COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
atest-ufem-particles-taylor-green-polydisperse.py
Go to the documentation of this file.
1 import sys
2 import coolfluid as cf
3 from math import pi
4 
5 env = cf.Core.environment()
6 
7 # Global configuration
8 env.assertion_throws = False
9 env.assertion_backtrace = False
10 env.exception_backtrace = False
11 env.regist_signal_handlers = False
12 env.log_level = 4
13 
14 nu = 1./5000.
15 
16 segs = 32
17 D = 0.5
18 Vs = 1./(4.*pi)
19 Ua = 0.
20 Va = 0.
21 
22 tau = 0.25
23 beta = 3.
24 
25 dt = 0.1
26 
27 numsteps = 1
28 write_interval = 5
29 
30 
31 def create_mesh(domain, segments):
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.]
37  points[3] = [0.5, 0.]
38  points[4] = [-0.5,0.5]
39  points[5] = [0.5, 0.5]
40 
41  block_nodes = blocks.create_blocks(2)
42  block_nodes[0] = [0, 1, 3, 2]
43  block_nodes[1] = [2, 3, 5, 4]
44 
45  block_subdivs = blocks.create_block_subdivisions()
46  block_subdivs[0] = [segments, segments/2]
47  block_subdivs[1] = [segments, segments/2]
48 
49  gradings = blocks.create_block_gradings()
50  #gradings[0] = [1., 1., 10., 10.]
51  #gradings[1] = [1., 1., 0.1, 0.1]
52  gradings[0] = [1., 1., 1., 1.]
53  gradings[1] = [1., 1., 1., 1.]
54 
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]
58 
59  bottom_patch = blocks.create_patch_nb_faces(name = 'bottom', nb_faces = 1)
60  bottom_patch[0] = [0, 1]
61 
62  top_patch = blocks.create_patch_nb_faces(name = 'top', nb_faces = 1)
63  top_patch[0] = [5, 4]
64 
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]
68 
69  blocks.partition_blocks(nb_partitions = cf.Core.nb_procs(), direction = 0)
70 
71  mesh = domain.create_component('Mesh', 'cf3.mesh.Mesh')
72 
73  blocks.create_mesh(mesh.uri())
74 
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()
80 
81  partitioner = domain.create_component('Partitioner', 'cf3.mesh.actions.PeriodicMeshPartitioner')
82  partitioner.mesh = mesh
83 
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.]
88 
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.]
93 
94  partitioner.execute()
95 
96  return mesh
97 
98 # Create the model and solvers
99 model = cf.Core.root().create_component('NavierStokes', 'cf3.solver.ModelUnsteady')
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
110 tg_solver.options.d = D
111 
112 polydisp = solver.add_unsteady_solver('cf3.UFEM.particles.Polydisperse')
113 polydisp.options.velocity_variable = 'FluidVelocityTG'
114 polydisp.options.velocity_tag = 'taylor_green'
115 
116 # Set up the physical constants
117 physics.density = 1.
118 physics.dynamic_viscosity = nu
119 
120 polydisp.initial_diameters = [1e-5, 1e-4,1e-3]
121 polydisp.initial_concentrations = [1.e20, 1.e20, 1.e20]
122 polydisp.nb_phases = 3
123 
124 # Create the mesh
125 mesh = create_mesh(domain, segs)
126 tg_solver.regions = [mesh.topology.interior.uri()]
127 polydisp.regions = [mesh.topology.interior.uri()]
128 
129 series_writer = solver.TimeLoop.create_component('TimeWriter', 'cf3.solver.actions.TimeSeriesWriter')
130 writer = series_writer.create_component('Writer', 'cf3.mesh.VTKXML.Writer')
131 writer.file = cf.URI('taylor-green-polydisperse-{iteration}.pvtu')
132 writer.mesh = mesh
133 series_writer.interval = write_interval
134 
135 solver.create_fields()
136 writer.fields = [mesh.geometry.taylor_green.uri(), mesh.geometry.particle_concentration_2.uri(), mesh.geometry.weighted_particle_volume_2.uri()]
137 
138 # Time setup
139 time = model.create_time()
140 time.time_step = dt
141 time.end_time = numsteps*dt
142 
143 model.simulate()
144 model.print_timing_tree()
145 
146 domain.write_mesh(cf.URI('taylor-green-polydisperse-end.pvtu'))
boost::python::object create_component(ComponentWrapper &self, const std::string &name, const std::string &builder_name)
Send comments to:
COOLFluiD Web Admin