6 env = cf.Core.environment()
9 env.assertion_throws =
False
10 env.assertion_backtrace =
False
11 env.exception_backtrace =
False
12 env.regist_signal_handlers =
False
16 model = root.create_component(
'NavierStokes',
'cf3.solver.ModelUnsteady')
17 domain = model.create_domain()
18 physics = model.create_physics(
'cf3.UFEM.NavierStokesPhysics')
19 solver = model.create_solver(
'cf3.UFEM.Solver')
22 ns_solver = solver.add_unsteady_solver(
'cf3.UFEM.NavierStokes')
24 ic_visc = solver.InitialConditions.create_initial_condition(builder_name =
'cf3.UFEM.InitialConditionFunction', field_tag =
'navier_stokes_viscosity')
25 ic_visc.variable_name =
'EffectiveViscosity'
28 blocks = domain.create_component(
'blocks',
'cf3.mesh.BlockMesh.BlockArrays')
29 points = blocks.create_points(dimensions = 2, nb_points = 6)
33 points[3] = [10., 0.5]
37 block_nodes = blocks.create_blocks(2)
38 block_nodes[0] = [0, 1, 3, 2]
39 block_nodes[1] = [2, 3, 5, 4]
41 block_subdivs = blocks.create_block_subdivisions()
42 block_subdivs[0] = [40, 20]
43 block_subdivs[1] = [40, 20]
45 gradings = blocks.create_block_gradings()
46 gradings[0] = [1., 1., 1., 1.]
47 gradings[1] = [1., 1., 1., 1.]
49 left_patch = blocks.create_patch_nb_faces(name =
'left', nb_faces = 2)
50 left_patch[0] = [2, 0]
51 left_patch[1] = [4, 2]
53 bottom_patch = blocks.create_patch_nb_faces(name =
'bottom', nb_faces = 1)
54 bottom_patch[0] = [0, 1]
56 top_patch = blocks.create_patch_nb_faces(name =
'top', nb_faces = 1)
59 right_patch = blocks.create_patch_nb_faces(name =
'right', nb_faces = 2)
60 right_patch[0] = [1, 3]
61 right_patch[1] = [3, 5]
63 blocks.partition_blocks(nb_partitions = cf.Core.nb_procs(), direction = 0)
65 mesh = domain.create_component(
'Mesh',
'cf3.mesh.Mesh')
66 blocks.create_mesh(mesh.uri())
68 ns_solver.regions = [mesh.topology.uri()]
72 solver.create_fields()
75 solver.InitialConditions.navier_stokes_solution.Velocity = u_in
76 ic_visc.value = [
'10. + 2*sin(2/pi*x)']
77 ic_visc.regions = [mesh.topology.uri()]
79 domain.write_mesh(cf.URI(
'laminar-channel-2d_output-init.pvtu'))
82 physics.options().set(
'density', 1000.)
83 physics.options().set(
'dynamic_viscosity', 10.)
86 bc = ns_solver.BoundaryConditions
87 bc.add_constant_bc(region_name =
'left', variable_name =
'Velocity').value = u_in
88 bc.add_constant_bc(region_name =
'bottom', variable_name =
'Velocity').value = [0., 0.]
89 bc.add_constant_bc(region_name =
'top', variable_name =
'Velocity').value = [0., 0.]
90 bc.add_constant_bc(region_name =
'right', variable_name =
'Pressure').value = 0.
92 pressure_integral = solver.add_unsteady_solver(
'cf3.UFEM.SurfaceIntegral')
93 pressure_integral.set_field(variable_name =
'Pressure', field_tag =
'navier_stokes_solution')
94 pressure_integral.regions = [mesh.topology.access_component(
'bottom').
uri()]
95 pressure_integral.history = solver.create_component(
'ForceHistory',
'cf3.solver.History')
96 pressure_integral.history.file = cf.URI(
'force-implicit.tsv')
97 pressure_integral.history.dimension = 2
100 time = model.create_time()
101 time.options().set(
'time_step', 0.1)
108 current_end_time = 0.
111 writer = root.create_component(
'Writer',
'cf3.mesh.gmsh.Writer')
112 writer.fields = [mesh.geometry.navier_stokes_solution.uri()]
113 writer.enable_overlap =
True
116 while current_end_time < final_end_time:
117 current_end_time += save_interval
118 time.options().set(
'end_time', current_end_time)
120 writer.file = cf.URI(
'laminar-channel-2d_output-' +str(iteration) +
'.msh')
122 domain.write_mesh(cf.URI(
'laminar-channel-2d_output-' +str(iteration) +
'.pvtu'))
125 solver.options().set(
'disabled_actions', [
'InitialConditions'])
128 model.print_timing_tree()
common::URI uri(ComponentWrapper &self)