5 env = cf.Core.environment()
8 env.assertion_throws =
False
9 env.assertion_backtrace =
False
10 env.exception_backtrace =
False
11 env.regist_signal_handlers =
False
28 diams = [20.e-6, 40.e-6, 80.e-6]
29 volumes = [4./3.*pi*(d/2.)**3
for d
in diams]
31 c_reduced = [1, 1., 1.]
32 zeta = [v/ref_vol*c
for (v,c)
in zip(volumes,c_reduced)]
36 domain = model.create_domain()
37 physics = model.create_physics(
'cf3.UFEM.NavierStokesPhysics')
38 physics.options.dimension = 2
39 solver = model.create_solver(
'cf3.UFEM.Solver')
41 polydisp = solver.add_unsteady_solver(
'cf3.UFEM.particles.Polydisperse')
42 polydisp.options.velocity_variable =
'Velocity'
43 polydisp.options.velocity_tag =
'navier_stokes_u_solution'
44 polydisp.options.save_collision_rate =
True
45 polydisp.options.collision_kernel_type =
'DNSCollisionKernel'
48 physics.density = rho_f
49 physics.dynamic_viscosity = mu
51 polydisp.initial_diameters = diams
52 polydisp.reference_volume = ref_vol
53 polydisp.initial_concentrations = [x/polydisp.reference_volume
for x
in c_reduced]
54 polydisp.nb_phases = 3
57 mesh = domain.create_component(
'Mesh',
'cf3.mesh.Mesh')
67 blocks = domain.create_component(
'blocks',
'cf3.mesh.BlockMesh.BlockArrays')
68 points = blocks.create_points(dimensions = 2, nb_points = 4)
69 points[0] = [x_min, y_min]
70 points[1] = [x_max, y_min]
71 points[2] = [x_min, y_max]
72 points[3] = [x_max, y_max]
74 block_nodes = blocks.create_blocks(1)
75 block_nodes[0] = [0, 1, 3, 2]
77 block_subdivs = blocks.create_block_subdivisions()
78 block_subdivs[0] = [x_segs, y_segs]
80 gradings = blocks.create_block_gradings()
81 gradings[0] = [1., 1., 1., 1.]
83 left_patch = blocks.create_patch_nb_faces(name =
'left', nb_faces = 1)
84 left_patch[0] = [2, 0]
86 bottom_patch = blocks.create_patch_nb_faces(name =
'bottom', nb_faces = 1)
87 bottom_patch[0] = [0, 1]
89 top_patch = blocks.create_patch_nb_faces(name =
'top', nb_faces = 1)
92 right_patch = blocks.create_patch_nb_faces(name =
'right', nb_faces = 1)
93 right_patch[0] = [1, 3]
95 blocks.extrude_blocks(positions=[0.05], nb_segments=[z_segs], gradings=[1.])
96 blocks.create_mesh(mesh.uri())
98 partitioner = domain.create_component(
'Partitioner',
'cf3.mesh.actions.PeriodicMeshPartitioner')
99 partitioner.mesh = mesh
100 partitioner.load_balance =
False
102 link_horizontal = partitioner.create_link_periodic_nodes()
103 link_horizontal.source_region = mesh.topology.right
104 link_horizontal.destination_region = mesh.topology.left
105 link_horizontal.translation_vector = [-0.29, 0., 0.]
107 link_front_back = partitioner.create_link_periodic_nodes()
108 link_front_back.source_region = mesh.topology.back
109 link_front_back.destination_region = mesh.topology.front
110 link_front_back.translation_vector = [0., 0., -0.05]
112 partitioner.execute()
114 polydisp.regions = [mesh.topology.uri()]
118 series_writer = solver.TimeLoop.create_component(
'TimeWriter',
'cf3.solver.actions.TimeSeriesWriter')
119 writer = series_writer.create_component(
'Writer',
'cf3.mesh.VTKXML.Writer')
120 writer.file = cf.URI(
'polydisperse-burgers-{iteration}.pvtu')
122 series_writer.interval = write_interval
124 solver.create_fields()
125 writer.fields = [mesh.geometry.particle_concentration_1.uri(), mesh.geometry.weighted_particle_volume_1.uri()]
127 u_arr = [
'-((1 - exp(-(x^2 + y^2)/{r0}^2))*{omega0}*{r0}^2*y)/(2.*(x^2 + y^2))'.format(r0=r0,omega0=omega0),
'((1 - exp(-(x^2 + y^2)/{r0}^2))*{omega0}*{r0}^2*x)/(2.*(x^2 + y^2))'.format(r0=r0,omega0=omega0),
'0']
128 ic_u = solver.InitialConditions.create_initial_condition(builder_name =
'cf3.UFEM.InitialConditionFunction', field_tag =
'navier_stokes_u_solution')
129 ic_u.variable_name =
'Velocity'
130 ic_u.regions = [mesh.topology.uri()]
133 ic_lin_u = solver.InitialConditions.create_initial_condition(builder_name =
'cf3.UFEM.InitialConditionFunction', field_tag =
'linearized_velocity')
134 ic_lin_u.variable_name =
'AdvectionVelocity1'
135 ic_lin_u.regions = [mesh.topology.uri()]
136 ic_lin_u.value = u_arr
138 ic_g = solver.InitialConditions.create_initial_condition(builder_name =
'cf3.UFEM.InitialConditionConstant', field_tag =
'body_force')
139 ic_g.regions = [mesh.topology.uri()]
140 ic_g.Force = [0.,-g, 0.]
142 for i
in range(len(zeta)):
143 zeta_name =
'zeta_'+str(i)
145 print str(polydisp.BC.children[c_name].regions[0])
146 polydisp.BC.children[c_name].add_constant_bc(region_name =
'top', variable_name = c_name).value = c_reduced[i]
147 polydisp.BC.children[zeta_name].add_constant_bc(region_name =
'top', variable_name = zeta_name).value = zeta[i]
152 time = model.create_time()
154 time.end_time = numsteps*dt
159 domain.write_mesh(cf.URI(
'polydisperse-burgers-end.pvtu'))
160 model.print_timing_tree()
boost::python::object create_component(ComponentWrapper &self, const std::string &name, const std::string &builder_name)