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
14 matrix_builder =
'cf3.math.LSS.EmptyLSSMatrix'
17 measurement = ET.Element(
'DartMeasurement', name =
'Problem size', type =
'numeric/integer')
18 measurement.text = str(n)
19 print ET.tostring(measurement)
24 domain = model.create_domain()
26 physics = model.create_physics(
'cf3.UFEM.NavierStokesPhysics')
28 physics.dynamic_viscosity = 1.
30 solver = model.create_solver(
'cf3.UFEM.Solver')
31 ns_solver = solver.add_unsteady_solver(
'cf3.UFEM.demo.NavierStokesChorin')
32 ns_solver.children.AuxiliaryLSS.matrix_builder = matrix_builder
33 ns_solver.children.PressureLSS.matrix_builder = matrix_builder
34 ns_solver.children.CorrectionLSS.matrix_builder = matrix_builder
37 mesh = domain.create_component(
'Mesh',
'cf3.mesh.Mesh')
38 mesh_generator = domain.create_component(
"MeshGenerator",
"cf3.mesh.SimpleMeshGenerator")
39 mesh_generator.mesh = mesh.uri()
40 mesh_generator.nb_cells = [n,n]
41 mesh_generator.lengths = [10.,2.]
42 mesh_generator.offsets = [0.,0.]
43 mesh_generator.execute()
46 triangulator = domain.create_component(
'triangulator',
'cf3.mesh.MeshTriangulator')
47 triangulator.mesh = mesh
48 triangulator.execute()
51 ns_solver.regions = [mesh.topology.uri()]
54 ic_u = solver.InitialConditions.create_initial_condition(builder_name =
'cf3.UFEM.InitialConditionFunction', field_tag =
'navier_stokes_u_solution')
55 ic_u.variable_name =
'Velocity'
56 ic_u.options.field_space_name =
'cf3.mesh.LagrangeP2'
57 ic_u.value = [
'0',
'0']
58 ic_u.regions = ns_solver.regions
60 ic_p = solver.InitialConditions.create_initial_condition(builder_name =
'cf3.UFEM.InitialConditionFunction', field_tag =
'navier_stokes_p_solution')
61 ic_p.variable_name =
'Pressure'
62 ic_p.value = [
'20-2*x']
63 ic_p.regions = ns_solver.regions
66 ns_solver.VelocityBC.regions = ns_solver.regions
67 ns_solver.PressureBC.regions = ns_solver.regions
69 bc_wall = ns_solver.VelocityBC.create_bc_action(region_name =
'top', builder_name =
'cf3.UFEM.BCDirichletFunction')
70 bc_wall.solving_for_difference =
False
71 bc_wall.variable_name =
'Velocity'
72 bc_wall.field_tag =
'navier_stokes_u_solution'
73 bc_wall.space =
'cf3.mesh.LagrangeP2'
74 bc_wall.value = [
'0',
'0']
75 bc_wall.regions = [mesh.topology.top.uri(), mesh.topology.bottom.uri()]
77 bc_p_out = ns_solver.PressureBC.create_bc_action(region_name =
'right', builder_name =
'cf3.UFEM.BCDirichletFunction')
78 bc_p_out.solving_for_difference =
False
79 bc_p_out.variable_name =
'Pressure'
80 bc_p_out.field_tag =
'navier_stokes_p_solution'
81 bc_p_out.value = [
'0']
82 bc_p_in = ns_solver.PressureBC.create_bc_action(region_name =
'left', builder_name =
'cf3.UFEM.BCDirichletFunction')
83 bc_p_in.solving_for_difference =
False
84 bc_p_in.variable_name =
'Pressure'
85 bc_p_in.field_tag =
'navier_stokes_p_solution'
86 bc_p_in.value = [
'20']
89 solver.create_fields()
91 lss = ns_solver.children.AuxiliaryLSS.create_lss()
92 lss.SolutionStrategy.Parameters.preconditioner_type =
'ML'
93 lss.SolutionStrategy.Parameters.PreconditionerTypes.ML.MLSettings.default_values =
'SA'
94 lss.SolutionStrategy.Parameters.PreconditionerTypes.ML.MLSettings.aggregation_type =
'MIS'
95 lss.SolutionStrategy.Parameters.PreconditionerTypes.ML.MLSettings.smoother_type =
'symmetric block Gauss-Seidel'
96 lss.SolutionStrategy.Parameters.PreconditionerTypes.ML.MLSettings.smoother_sweeps = 2
97 lss.SolutionStrategy.Parameters.PreconditionerTypes.ML.MLSettings.smoother_pre_or_post =
'both'
100 time = model.create_time()
102 time.end_time = 1.*time.time_step
104 ns_solver.children.AuxiliaryLSS.options.disabled_actions = [
'SolveLSS']
105 ns_solver.children.PressureLSS.options.disabled_actions = [
'SolveLSS']
106 ns_solver.children.CorrectionLSS.options.disabled_actions = [
'SolveLSS']
113 ns_solver.children.AuxiliaryLSS.children.MatrixAssembly.execute()
114 ns_solver.children.AuxiliaryLSS.children.RHSAssembly.execute()
115 ns_solver.children.PressureLSS.children.MatrixAssembly.execute()
116 ns_solver.children.PressureLSS.children.RHSAssembly.execute()
117 ns_solver.children.CorrectionLSS.children.MatrixAssembly.execute()
118 ns_solver.children.CorrectionLSS.children.RHSAssembly.execute()
121 model.print_timing_tree()
124 domain.write_mesh(cf.URI(
'chorin.msh'))
boost::python::object create_component(ComponentWrapper &self, const std::string &name, const std::string &builder_name)