COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
atest-blockmesh-backstep2d-zoltan.py
Go to the documentation of this file.
1 import math
2 import sys
3 import string
4 import coolfluid as cf
5 
6 # Some shortcuts
7 root = cf.Core.root()
8 env = cf.Core.environment()
9 
10 # Global configuration
11 env.options().set('log_level', 4)
12 
13 # simulation parameters
14 x_parts = 4
15 y_parts = 2
16 
17 # Meshing parameters
18 step_length = 10.e-3
19 step_height = 4.9e-3
20 channel_height = 5.2e-3
21 channel_length = 150.e-3
22 
23 top_grading = 0.2
24 bottom_grading = 0.2
25 step_x_grading = 0.8
26 channel_x_grading = 1.5
27 
28 step_x_segs = 20
29 step_y_segs = 11
30 channel_x_segs = 180
31 channel_y_segs = 9
32 
33 domain = root.create_component('Domain', 'cf3.mesh.Domain')
34 
35 blocks = domain.create_component('model', 'cf3.mesh.BlockMesh.BlockArrays')
36 
37 points = blocks.create_points(dimensions = 2, nb_points = 13)
38 points[0] = [-step_length, 0. ]
39 points[1] = [-step_length, channel_height/2.]
40 points[2] = [-step_length, channel_height ]
41 points[3] = [0., -step_height ]
42 points[4] = [0., -step_height/2. ]
43 points[5] = [0., 0. ]
44 points[6] = [0., channel_height/2.]
45 points[7] = [0., channel_height ]
46 points[8] = [channel_length, -step_height ]
47 points[9] = [channel_length, -step_height/2. ]
48 points[10] = [channel_length, 0. ]
49 points[11] = [channel_length, channel_height/2.]
50 points[12] = [channel_length, channel_height ]
51 
52 block_nodes = blocks.create_blocks(6)
53 block_nodes[0] = [0, 5, 6, 1]
54 block_nodes[1] = [1, 6, 7, 2]
55 block_nodes[2] = [3, 8, 9, 4]
56 block_nodes[3] = [4, 9, 10, 5]
57 block_nodes[4] = [5, 10, 11, 6]
58 block_nodes[5] = [6, 11, 12, 7]
59 
60 # y-segments, ordered top-to-bottom
61 y_segs = [int(math.ceil(step_y_segs/2.)), int(math.floor(step_y_segs/2.)), int(math.floor(channel_y_segs/2.)), int(math.ceil(channel_y_segs/2.))]
62 block_subdivs = blocks.create_block_subdivisions()
63 block_subdivs[0] = [step_x_segs, y_segs[1]]
64 block_subdivs[1] = [step_x_segs, y_segs[0]]
65 block_subdivs[2] = [channel_x_segs, y_segs[3]]
66 block_subdivs[3] = [channel_x_segs, y_segs[2]]
67 block_subdivs[4] = [channel_x_segs, y_segs[1]]
68 block_subdivs[5] = [channel_x_segs, y_segs[0]]
69 
70 gradings = blocks.create_block_gradings()
71 gradings[0] = [step_x_grading, step_x_grading, 1./top_grading, 1./top_grading]
72 gradings[1] = [step_x_grading, step_x_grading, top_grading, top_grading]
73 gradings[2] = [channel_x_grading, channel_x_grading, 1./bottom_grading, 1./bottom_grading]
74 gradings[3] = [channel_x_grading, channel_x_grading, bottom_grading, bottom_grading]
75 gradings[4] = [channel_x_grading, channel_x_grading, 1./top_grading, 1./top_grading]
76 gradings[5] = [channel_x_grading, channel_x_grading, top_grading, top_grading]
77 
78 inlet_patch = blocks.create_patch_nb_faces(name = 'inlet', nb_faces = 2)
79 inlet_patch[0] = [1, 0]
80 inlet_patch[1] = [2, 1]
81 
82 step_top = blocks.create_patch_nb_faces(name = 'step_top', nb_faces = 1)
83 step_top[0] = [0, 5]
84 
85 step_front = blocks.create_patch_nb_faces(name = 'step_front', nb_faces = 2)
86 step_front[0] = [4, 3]
87 step_front[1] = [5, 4]
88 
89 top_patch = blocks.create_patch_nb_faces(name = 'top', nb_faces = 2)
90 top_patch[0] = [12, 7]
91 top_patch[1] = [7, 2]
92 
93 bottom_patch = blocks.create_patch_nb_faces(name = 'bottom', nb_faces = 1)
94 bottom_patch[0] = [3, 8]
95 
96 outlet_patch = blocks.create_patch_nb_faces(name = 'outlet', nb_faces = 4)
97 outlet_patch[0] = [8, 9]
98 outlet_patch[1] = [9, 10]
99 outlet_patch[2] = [10, 11]
100 outlet_patch[3] = [11, 12]
101 
102 blocks.options.overlap = 0
103 
104 # Generate a channel mesh
105 mesh = domain.create_component('Mesh', 'cf3.mesh.Mesh')
106 blocks.partition_blocks(nb_partitions = x_parts, direction = 0)
107 blocks.partition_blocks(nb_partitions = y_parts, direction = 1)
108 blocks.create_mesh(mesh.uri())
109 
110 make_par_data = domain.create_component('MakeParData', 'cf3.solver.actions.ParallelDataToFields')
111 make_par_data.mesh = mesh
112 make_par_data.execute()
113 
114 domain.write_mesh(cf.URI('backstep2d-blockmesh.pvtu'))
115 
116 load_balancer = domain.create_component('LoadBalancer', 'cf3.mesh.actions.LoadBalance')
117 load_balancer.mesh = mesh
118 load_balancer.execute()
119 
120 make_par_data.execute()
121 domain.write_mesh(cf.URI('backstep2d-zoltan.pvtu'))
Send comments to:
COOLFluiD Web Admin