8 env = cf.Core.environment()
11 env.assertion_throws =
False
12 env.assertion_backtrace =
False
13 env.exception_backtrace =
False
14 env.regist_signal_handlers =
False
18 model = root.create_component(
'NavierStokes',
'cf3.solver.ModelUnsteady')
19 domain = model.create_domain()
20 physics = model.create_physics(
'cf3.UFEM.NavierStokesPhysics')
21 solver = model.create_solver(
'cf3.UFEM.Solver')
24 ic = solver.create_initial_conditions()
27 scalaradv = solver.add_iteration_solver(
'cf3.UFEM.ScalarAdvection')
28 scalaradv.options().set(
'scalar_name',
'Temperature')
31 heatcond = solver.add_iteration_solver(
'cf3.UFEM.HeatConductionSteady')
34 nstokes = solver.add_unsteady_solver(
'cf3.UFEM.NavierStokes')
37 blocks = domain.create_component(
'blocks',
'cf3.mesh.BlockMesh.BlockArrays')
38 points = blocks.create_points(dimensions = 2, nb_points = 14)
51 points[10] = [-1, 0.2]
57 block_nodes = blocks.create_blocks(7)
58 block_nodes[0] = [0, 1, 3, 2]
59 block_nodes[1] = [2, 3, 5, 4]
61 block_nodes[2] = [1, 6, 7, 3]
62 block_nodes[3] = [3, 7, 8, 5]
63 block_nodes[4] = [9, 0, 2, 10]
64 block_nodes[5] = [10, 2, 4, 11]
66 block_nodes[6] = [12, 13, 1, 0]
68 block_subdivs = blocks.create_block_subdivisions()
69 block_subdivs[0] = [40, 20]
70 block_subdivs[1] = [40, 20]
72 block_subdivs[2] = [40, 20]
73 block_subdivs[3] = [40, 20]
74 block_subdivs[4] = [40, 20]
75 block_subdivs[5] = [40, 20]
76 block_subdivs[6] = [40, 20]
78 gradings = blocks.create_block_gradings()
79 gradings[0] = [1., 1., 5., 5.]
80 gradings[1] = [1., 1., 10., 10.]
81 gradings[2] = [1., 1., 5., 5.]
82 gradings[3] = [1., 1., 10., 10.]
83 gradings[4] = [1., 1., 5., 5.]
84 gradings[5] = [1., 1., 10., 10.]
85 gradings[6] = [1., 1., 1., 1.]
88 inlet_patch = blocks.create_patch_nb_faces(name =
'inlet', nb_faces = 2)
89 inlet_patch[0] = [10, 9]
90 inlet_patch[1] = [11, 10]
92 bottom_patch1 = blocks.create_patch_nb_faces(name =
'solid_bottom', nb_faces = 1)
93 bottom_patch1[0] = [12, 13]
95 bottom_patch1 = blocks.create_patch_nb_faces(name =
'solid_left', nb_faces = 1)
96 bottom_patch1[0] = [0, 12]
98 bottom_patch1 = blocks.create_patch_nb_faces(name =
'solid_right', nb_faces = 1)
99 bottom_patch1[0] = [13, 1]
101 bottom_patch2 = blocks.create_patch_nb_faces(name =
'bottom2', nb_faces = 1)
102 bottom_patch2[0] = [1, 6]
104 bottom_patch3 = blocks.create_patch_nb_faces(name =
'bottom3', nb_faces = 1)
105 bottom_patch3[0] = [9, 0]
107 outlet_patch = blocks.create_patch_nb_faces(name =
'outlet', nb_faces = 2)
108 outlet_patch[0] = [6, 7]
109 outlet_patch[1] = [7, 8]
111 top_patch = blocks.create_patch_nb_faces(name =
'top', nb_faces = 3)
112 top_patch[0] = [5, 4]
113 top_patch[1] = [8, 5]
114 top_patch[2] = [4, 11]
116 blocks.options().set(
'block_regions', [
'fluid',
'fluid',
'fluid',
'fluid',
'fluid',
'fluid',
'solid'])
118 mesh = domain.create_component(
'Mesh',
'cf3.mesh.Mesh')
119 blocks.create_mesh(mesh.uri())
122 variables = physics.get_child(
'VariableManager')
123 variables.get_child(
'scalar_advection_solution').options().set(
'Temperature_variable_name',
'Tadv')
124 variables.get_child(
'heat_conduction_solution').options().set(
'Temperature_variable_name',
'Tcond')
127 nstokes.options().set(
'regions', [mesh.access_component(
'topology/fluid').
uri()])
128 scalaradv.options().set(
'regions', [mesh.access_component(
'topology/fluid').
uri()])
129 heatcond.options().set(
'regions', [mesh.access_component(
'topology/solid').
uri()])
137 solver.InitialConditions.navier_stokes_solution.Velocity = u_in
138 solver.InitialConditions.heat_conduction_solution.Temperature = Twall
142 physics.dynamic_viscosity = 1.e-5
143 physics.reference_temperature = Twall
144 scalaradv.pr = 1./physics.dynamic_viscosity
147 bc = nstokes.get_child(
'BoundaryConditions')
148 bc.options().set(
'regions', [mesh.access_component(
'topology').
uri()])
149 bc.add_constant_bc(region_name =
'inlet', variable_name =
'Velocity').options().set(
'value', u_in)
150 bc.add_constant_bc(region_name =
'region_bnd_fluid_solid', variable_name =
'Velocity').options().set(
'value', u_wall)
151 bc.add_constant_bc(region_name =
'bottom2', variable_name =
'Velocity').options().set(
'value', u_wall)
152 bc.add_constant_component_bc(region_name =
'bottom3', variable_name =
'Velocity', component = 1).options().set(
'value', 0.)
153 bc.add_constant_bc(region_name =
'outlet', variable_name =
'Pressure').options().set(
'value', 1.)
154 bc.add_constant_bc(region_name =
'top', variable_name =
'Velocity').options().set(
'value', u_in)
157 bc = scalaradv.get_child(
'BoundaryConditions')
158 bc.options().set(
'regions', [mesh.access_component(
'topology').
uri()])
159 bc.add_constant_bc(region_name =
'inlet', variable_name =
'Temperature').options().set(
'value', Tin)
160 bc_wall_temp = bc.create_bc_action(region_name =
'region_bnd_fluid_solid', builder_name =
'cf3.UFEM.BCHoldValue')
161 bc_wall_temp.set_tags(from_field_tag =
'heat_conduction_solution', to_field_tag =
'scalar_advection_solution', from_variable =
'Temperature', to_variable =
'Temperature')
162 bc.add_constant_bc(region_name =
'bottom2', variable_name =
'Temperature').options().set(
'value', Tin)
163 bc.add_constant_bc(region_name =
'bottom3', variable_name =
'Temperature').options().set(
'value', Tin)
164 bc.add_constant_bc(region_name =
'top', variable_name =
'Temperature').options().set(
'value', Tin)
167 bc = heatcond.get_child(
'BoundaryConditions')
168 bc.options().set(
'regions', [mesh.access_component(
'topology').
uri()])
169 heat_coupling = bc.create_bc_action(region_name =
'region_bnd_fluid_solid', builder_name =
'cf3.UFEM.HeatCouplingFlux')
170 heat_coupling.options().set(
'gradient_region', mesh.access_component(
'topology/fluid'))
171 heat_coupling.options().set(
'temperature_field_tag',
'scalar_advection_solution')
172 bc.add_constant_bc(region_name =
'solid_bottom', variable_name =
'Temperature').options().set(
'value', Twall)
175 time = model.create_time()
176 time.options().set(
'time_step', 0.01)
180 final_end_time = 0.02
182 current_end_time = 0.
184 solver.TimeLoop.CouplingIteration.options.max_iter = 10
185 solver.create_fields()
188 probe0 = solver.add_probe(name =
'Probe', parent = scalaradv, dict = mesh.children[
'cf3.mesh.LagrangeP0'])
189 probe0.Log.variables = [
'TemperatureGradient[0]',
'TemperatureGradient[1]']
190 probe0.coordinate = [0.5, 0.5]
191 probe0.History.file = cf.URI(
'grad_t.tsv')
193 solver.InitialConditions.execute()
194 domain.write_mesh(cf.URI(
'atest-conjugate-heat-flatplate_output-initial.pvtu'))
195 while current_end_time < final_end_time:
196 current_end_time += save_interval
197 time.options().set(
'end_time', current_end_time)
199 domain.write_mesh(cf.URI(
'atest-cht-flatplate_10-iterations-' +str(iteration) +
'.pvtu'))
202 solver.options().set(
'disabled_actions', [
'InitialConditions'])
205 model.print_timing_tree()
common::URI uri(ComponentWrapper &self)