2 import xml.etree.ElementTree
as ET
6 cf.env.assertion_throws =
False
7 cf.env.assertion_backtrace =
False
8 cf.env.exception_backtrace =
False
9 cf.env.exception_outputs =
False
10 cf.env.regist_signal_handlers =
False
15 measurement = ET.Element(
'DartMeasurement', name =
'Problem size', type =
'numeric/integer')
16 measurement.text = str(n)
17 print ET.tostring(measurement)
22 domain = model.create_domain()
24 physics = model.create_physics(
'cf3.UFEM.NavierStokesPhysics')
26 physics.dynamic_viscosity = 1.
28 solver = model.create_solver(
'cf3.UFEM.Solver')
29 ns_solver = solver.add_unsteady_solver(
'cf3.UFEM.demo.NavierStokesChorin')
32 mesh = domain.create_component(
'Mesh',
'cf3.mesh.Mesh')
33 mesh_generator = domain.create_component(
"MeshGenerator",
"cf3.mesh.SimpleMeshGenerator")
34 mesh_generator.mesh = mesh.uri()
35 mesh_generator.nb_cells = [n,n]
36 mesh_generator.lengths = [10.,2.]
37 mesh_generator.offsets = [0.,0.]
38 mesh_generator.execute()
41 triangulator = domain.create_component(
'triangulator',
'cf3.mesh.MeshTriangulator')
42 triangulator.mesh = mesh
43 triangulator.execute()
46 ns_solver.regions = [mesh.topology.uri()]
49 ic_u = solver.InitialConditions.create_initial_condition(builder_name =
'cf3.UFEM.InitialConditionFunction', field_tag =
'navier_stokes_u_solution')
50 ic_u.variable_name =
'Velocity'
51 ic_u.options.field_space_name =
'cf3.mesh.LagrangeP2'
52 ic_u.value = [
'0',
'0']
53 ic_u.regions = ns_solver.regions
55 ic_p = solver.InitialConditions.create_initial_condition(builder_name =
'cf3.UFEM.InitialConditionFunction', field_tag =
'navier_stokes_p_solution')
56 ic_p.variable_name =
'Pressure'
57 ic_p.value = [
'20-2*x']
58 ic_p.regions = ns_solver.regions
61 ns_solver.VelocityBC.regions = ns_solver.regions
62 ns_solver.PressureBC.regions = ns_solver.regions
64 bc_wall = ns_solver.VelocityBC.create_bc_action(region_name =
'top', builder_name =
'cf3.UFEM.BCDirichletFunction')
65 bc_wall.solving_for_difference =
False
66 bc_wall.variable_name =
'Velocity'
67 bc_wall.field_tag =
'navier_stokes_u_solution'
68 bc_wall.space =
'cf3.mesh.LagrangeP2'
69 bc_wall.value = [
'0',
'0']
70 bc_wall.regions = [mesh.topology.top.uri(), mesh.topology.bottom.uri()]
72 bc_p_out = ns_solver.PressureBC.create_bc_action(region_name =
'right', builder_name =
'cf3.UFEM.BCDirichletFunction')
73 bc_p_out.solving_for_difference =
False
74 bc_p_out.variable_name =
'Pressure'
75 bc_p_out.field_tag =
'navier_stokes_p_solution'
76 bc_p_out.value = [
'0']
77 bc_p_in = ns_solver.PressureBC.create_bc_action(region_name =
'left', builder_name =
'cf3.UFEM.BCDirichletFunction')
78 bc_p_in.solving_for_difference =
False
79 bc_p_in.variable_name =
'Pressure'
80 bc_p_in.field_tag =
'navier_stokes_p_solution'
81 bc_p_in.value = [
'20']
84 solver.create_fields()
86 lss = ns_solver.children.AuxiliaryLSS.create_lss()
87 lss.SolutionStrategy.Parameters.preconditioner_type =
'ML'
88 lss.SolutionStrategy.Parameters.PreconditionerTypes.ML.MLSettings.default_values =
'SA'
89 lss.SolutionStrategy.Parameters.PreconditionerTypes.ML.MLSettings.aggregation_type =
'MIS'
90 lss.SolutionStrategy.Parameters.PreconditionerTypes.ML.MLSettings.smoother_type =
'symmetric block Gauss-Seidel'
91 lss.SolutionStrategy.Parameters.PreconditionerTypes.ML.MLSettings.smoother_sweeps = 2
92 lss.SolutionStrategy.Parameters.PreconditionerTypes.ML.MLSettings.smoother_pre_or_post =
'both'
95 time = model.create_time()
97 time.end_time = 10.*time.time_step
103 model.print_timing_tree()
106 domain.write_mesh(cf.URI(
'chorin.msh'))
boost::python::object create_component(ComponentWrapper &self, const std::string &name, const std::string &builder_name)