COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
atest-blockmesh-multiregion.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 z_parts = 2
17 
18 # Meshing parameters
19 step_length = 10.e-3
20 step_height = 4.9e-3
21 channel_height = 5.2e-3
22 channel_length = 150.e-3
23 
24 top_grading = 0.2
25 bottom_grading = 0.2
26 step_x_grading = 0.8
27 channel_x_grading = 1.5
28 
29 step_x_segs = 20
30 step_y_segs = 11
31 channel_x_segs = 180
32 channel_y_segs = 9
33 
34 blocks = root.create_component('model', 'cf3.mesh.BlockMesh.BlockArrays')
35 
36 points = blocks.create_points(dimensions = 2, nb_points = 13)
37 points[0] = [-step_length, 0. ]
38 points[1] = [-step_length, channel_height/2.]
39 points[2] = [-step_length, channel_height ]
40 points[3] = [0., -step_height ]
41 points[4] = [0., -step_height/2. ]
42 points[5] = [0., 0. ]
43 points[6] = [0., channel_height/2.]
44 points[7] = [0., channel_height ]
45 points[8] = [channel_length, -step_height ]
46 points[9] = [channel_length, -step_height/2. ]
47 points[10] = [channel_length, 0. ]
48 points[11] = [channel_length, channel_height/2.]
49 points[12] = [channel_length, channel_height ]
50 
51 block_nodes = blocks.create_blocks(6)
52 block_nodes[0] = [0, 5, 6, 1]
53 block_nodes[1] = [1, 6, 7, 2]
54 block_nodes[2] = [3, 8, 9, 4]
55 block_nodes[3] = [4, 9, 10, 5]
56 block_nodes[4] = [5, 10, 11, 6]
57 block_nodes[5] = [6, 11, 12, 7]
58 
59 # y-segments, ordered top-to-bottom
60 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.))]
61 block_subdivs = blocks.create_block_subdivisions()
62 block_subdivs[0] = [step_x_segs, y_segs[1]]
63 block_subdivs[1] = [step_x_segs, y_segs[0]]
64 block_subdivs[2] = [channel_x_segs, y_segs[3]]
65 block_subdivs[3] = [channel_x_segs, y_segs[2]]
66 block_subdivs[4] = [channel_x_segs, y_segs[1]]
67 block_subdivs[5] = [channel_x_segs, y_segs[0]]
68 
69 gradings = blocks.create_block_gradings()
70 gradings[0] = [step_x_grading, step_x_grading, 1./top_grading, 1./top_grading]
71 gradings[1] = [step_x_grading, step_x_grading, top_grading, top_grading]
72 gradings[2] = [channel_x_grading, channel_x_grading, 1./bottom_grading, 1./bottom_grading]
73 gradings[3] = [channel_x_grading, channel_x_grading, bottom_grading, bottom_grading]
74 gradings[4] = [channel_x_grading, channel_x_grading, 1./top_grading, 1./top_grading]
75 gradings[5] = [channel_x_grading, channel_x_grading, top_grading, top_grading]
76 
77 inlet_patch = blocks.create_patch_nb_faces(name = 'inlet', nb_faces = 2)
78 inlet_patch[0] = [1, 0]
79 inlet_patch[1] = [2, 1]
80 
81 step_top = blocks.create_patch_nb_faces(name = 'step_top', nb_faces = 1)
82 step_top[0] = [0, 5]
83 
84 step_front = blocks.create_patch_nb_faces(name = 'step_front', nb_faces = 2)
85 step_front[0] = [4, 3]
86 step_front[1] = [5, 4]
87 
88 top_patch = blocks.create_patch_nb_faces(name = 'top', nb_faces = 2)
89 top_patch[0] = [12, 7]
90 top_patch[1] = [7, 2]
91 
92 bottom_patch = blocks.create_patch_nb_faces(name = 'bottom', nb_faces = 1)
93 bottom_patch[0] = [3, 8]
94 
95 outlet_patch = blocks.create_patch_nb_faces(name = 'outlet', nb_faces = 4)
96 outlet_patch[0] = [8, 9]
97 outlet_patch[1] = [9, 10]
98 outlet_patch[2] = [10, 11]
99 outlet_patch[3] = [11, 12]
100 
101 blocks.options().set('block_regions', ['fluid_top', 'fluid_top', 'fluid_bottom', 'fluid_bottom', 'fluid_top', 'fluid_top'])
102 
103 # Generate a channel mesh
104 mesh = root.create_component('Mesh', 'cf3.mesh.Mesh')
105 blocks.create_mesh(mesh.uri())
106 mesh.write_mesh(file=cf.URI('backstep-multiregion.msh'))
107 mesh.print_tree()
Send comments to:
COOLFluiD Web Admin