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
32 blocks = domain.create_component(
'blocks',
'cf3.mesh.BlockMesh.BlockArrays')
33 points = blocks.create_points(dimensions = 2, nb_points = 6)
34 points[0] = [-0.5, -0.5]
35 points[1] = [0.5, -0.5]
36 points[2] = [-0.5, 0.]
38 points[4] = [-0.5,0.5]
39 points[5] = [0.5, 0.5]
41 block_nodes = blocks.create_blocks(2)
42 block_nodes[0] = [0, 1, 3, 2]
43 block_nodes[1] = [2, 3, 5, 4]
45 block_subdivs = blocks.create_block_subdivisions()
46 block_subdivs[0] = [segments, segments/2]
47 block_subdivs[1] = [segments, segments/2]
49 gradings = blocks.create_block_gradings()
52 gradings[0] = [1., 1., 1., 1.]
53 gradings[1] = [1., 1., 1., 1.]
55 left_patch = blocks.create_patch_nb_faces(name =
'left', nb_faces = 2)
56 left_patch[0] = [2, 0]
57 left_patch[1] = [4, 2]
59 bottom_patch = blocks.create_patch_nb_faces(name =
'bottom', nb_faces = 1)
60 bottom_patch[0] = [0, 1]
62 top_patch = blocks.create_patch_nb_faces(name =
'top', nb_faces = 1)
65 right_patch = blocks.create_patch_nb_faces(name =
'right', nb_faces = 2)
66 right_patch[0] = [1, 3]
67 right_patch[1] = [3, 5]
69 blocks.partition_blocks(nb_partitions = cf.Core.nb_procs(), direction = 0)
71 mesh = domain.create_component(
'Mesh',
'cf3.mesh.Mesh')
73 blocks.create_mesh(mesh.uri())
75 create_point_region = domain.create_component(
'CreatePointRegion',
'cf3.mesh.actions.AddPointRegion')
76 create_point_region.coordinates = [0., 0.]
77 create_point_region.region_name =
'center'
78 create_point_region.mesh = mesh
79 create_point_region.execute()
81 partitioner = domain.create_component(
'Partitioner',
'cf3.mesh.actions.PeriodicMeshPartitioner')
82 partitioner.mesh = mesh
84 link_horizontal = partitioner.create_link_periodic_nodes()
85 link_horizontal.source_region = mesh.topology.right
86 link_horizontal.destination_region = mesh.topology.left
87 link_horizontal.translation_vector = [-1., 0.]
89 link_vertical = partitioner.create_link_periodic_nodes()
90 link_vertical.source_region = mesh.topology.top
91 link_vertical.destination_region = mesh.topology.bottom
92 link_vertical.translation_vector = [0., -1.]
100 domain = model.create_domain()
101 physics = model.create_physics(
'cf3.UFEM.NavierStokesPhysics')
102 physics.options.dimension = 2
103 solver = model.create_solver(
'cf3.UFEM.Solver')
104 tg_solver = solver.add_unsteady_solver(
'cf3.UFEM.particles.TaylorGreen')
105 tg_solver.options.ua = Ua
106 tg_solver.options.va = Va
107 tg_solver.options.tau = tau
108 tg_solver.options.beta = beta
109 tg_solver.options.vs = Vs
111 eq_euler = solver.add_unsteady_solver(
'cf3.UFEM.particles.EquilibriumEuler')
112 eq_euler.options.velocity_variable =
'FluidVelocityTG'
113 eq_euler.options.velocity_tag =
'taylor_green'
116 conv = solver.add_unsteady_solver(
'cf3.UFEM.particles.EquilibriumEulerConvergence')
119 particle_c = solver.add_unsteady_solver(
'cf3.UFEM.particles.ParticleConcentration')
120 particle_c.options.supg_type =
'metric'
124 particle_c.options.c0 = 2.
125 particle_c.options.d0 = 0.05
130 physics.dynamic_viscosity = nu
134 tg_solver.regions = [mesh.topology.interior.uri()]
135 eq_euler.regions = [mesh.topology.interior.uri()]
136 particle_c.regions = [mesh.topology.interior.uri()]
137 conv.regions = [mesh.topology.interior.uri()]
139 if eq_euler.name() ==
'EquilibriumEulerFEM':
141 lss.SolutionStrategy.Parameters.LinearSolverTypes.Belos.solver_type =
'Block CG'
142 lss.SolutionStrategy.Parameters.LinearSolverTypes.Belos.SolverTypes.BlockCG.convergence_tolerance = 1e-12
143 lss.SolutionStrategy.Parameters.LinearSolverTypes.Belos.SolverTypes.BlockCG.maximum_iterations = 300
145 particle_c.LSS.SolutionStrategy.Parameters.linear_solver_type =
'Amesos'
147 ic_c = solver.InitialConditions.create_initial_condition(builder_name =
'cf3.UFEM.InitialConditionConstant', field_tag =
'particle_concentration')
149 ic_c.regions = particle_c.regions
151 ic_tau = solver.InitialConditions.create_initial_condition(builder_name =
'cf3.UFEM.InitialConditionConstant', field_tag =
'ufem_particle_relaxation_time')
153 ic_tau.regions = eq_euler.regions
155 series_writer = solver.TimeLoop.create_component(
'TimeWriter',
'cf3.solver.actions.TimeSeriesWriter')
156 writer = series_writer.create_component(
'Writer',
'cf3.mesh.VTKXML.Writer')
157 writer.file = cf.URI(
'taylor-green-{iteration}.pvtu')
159 series_writer.interval = write_interval
161 solver.create_fields()
162 writer.fields = [mesh.geometry.taylor_green.uri(), mesh.geometry.ufem_particle_velocity.uri(), mesh.geometry.particle_concentration.uri()]
165 time = model.create_time()
167 time.end_time = numsteps*dt
170 model.print_timing_tree()
173 ufem_velocity = np.array(mesh.geometry.ufem_particle_velocity)
174 tg_particle_velocity = np.array(mesh.geometry.taylor_green)
175 err_array = np.abs(ufem_velocity-tg_particle_velocity[:,2:4])
176 print 'Maximum error:',np.max(err_array)
178 error_fd = mesh.geometry.create_field(name =
'error_field', variables =
'VelocityError[vector]')
179 for i
in range(len(error_fd)):
180 err_row = error_fd[i]
181 err_row[0] = err_array[i][0]
182 err_row[1] = err_array[i][1]
184 domain.write_mesh(cf.URI(
'taylor-green-end.pvtu'))
def create_mesh(domain, segments)
boost::python::object create_component(ComponentWrapper &self, const std::string &name, const std::string &builder_name)