COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-mesh-wall-distance.py
Go to the documentation of this file.
1 import sys
2 import coolfluid as cf
3 
4 env = cf.Core.environment()
5 env.log_level = 4
6 env.only_cpu0_writes = True
7 
8 root = cf.Core.root()
9 domain = root.create_component('Domain', 'cf3.mesh.Domain')
10 
11 # 2D case
12 mesh = domain.create_component('mesh','cf3.mesh.Mesh')
13 
14 blocks = root.create_component('model', 'cf3.mesh.BlockMesh.BlockArrays')
15 points = blocks.create_points(dimensions = 2, nb_points = 9)
16 points[0] = [0., 0.]
17 points[1] = [1., 0.]
18 points[2] = [1., 1.]
19 points[3] = [0., 1.]
20 points[4] = [0.5, 0.5]
21 points[5] = [0.5, 1.]
22 points[6] = [1., 0.5]
23 points[7] = [0.5, 0.]
24 points[8] = [0., 0.5]
25 block_nodes = blocks.create_blocks(3)
26 block_nodes[0] = [0, 7, 4, 8]
27 block_nodes[1] = [8, 4, 5, 3]
28 block_nodes[2] = [4, 6, 2, 5]
29 block_subdivs = blocks.create_block_subdivisions()
30 block_subdivs[0] = [10,10]
31 block_subdivs[1] = [10,10]
32 block_subdivs[2] = [10,10]
33 gradings = blocks.create_block_gradings()
34 gradings[0] = [1., 1., 1., 1.]
35 gradings[1] = [1., 1., 1., 1.]
36 gradings[2] = [1., 1., 1., 1.]
37 blocks.create_patch_nb_faces(name = 'bottom', nb_faces = 1)[0] = [0, 7]
38 blocks.create_patch_nb_faces(name = 'right', nb_faces = 1)[0] = [6, 2]
39 top = blocks.create_patch_nb_faces(name = 'top', nb_faces = 2)
40 top[0] = [2, 5]
41 top[1] = [5, 3]
42 left = blocks.create_patch_nb_faces(name = 'left', nb_faces = 2)
43 left[0] = [3, 8]
44 left[1] = [8, 0]
45 step = blocks.create_patch_nb_faces(name = 'step', nb_faces = 2)
46 step[0] = [7, 4]
47 step[1] = [4, 6]
48 blocks.partition_blocks(nb_partitions = 2, direction = 0)
49 blocks.partition_blocks(nb_partitions = 2, direction = 1)
50 blocks.create_mesh(mesh.uri())
51 
52 make_boundary_global = root.create_component('MakeBoundaryGlobal', 'cf3.mesh.actions.MakeBoundaryGlobal')
53 make_boundary_global.mesh = mesh
54 make_boundary_global.execute()
55 
56 wall_distance = root.create_component('WallDistance', 'cf3.mesh.actions.WallDistance')
57 wall_distance.mesh = mesh
58 wall_distance.regions = [mesh.topology.step]
59 wall_distance.execute()
60 
61 domain.write_mesh(cf.URI('wall-distance-2dstep.pvtu'))
62 
63 mesh.delete_component()
64 
65 # 3D, triangle surface elements
66 mesh = domain.load_mesh(file = cf.URI(sys.argv[1]), name = 'mesh')
67 make_boundary_global.mesh = mesh
68 make_boundary_global.execute()
69 wall_distance.mesh = mesh
70 wall_distance.regions = [mesh.topology.inner]
71 wall_distance.execute()
72 domain.write_mesh(cf.URI('wall-distance-sphere.pvtu'))
73 
74 mesh.delete_component()
75 
76 # 3D, quad surface elements
77 mesh = domain.create_component('mesh','cf3.mesh.Mesh')
78 
79 blocks = root.create_component('model', 'cf3.mesh.BlockMesh.BlockArrays')
80 points = blocks.create_points(dimensions = 2, nb_points = 9)
81 points[0] = [0., 0.]
82 points[1] = [1., 0.]
83 points[2] = [1., 1.]
84 points[3] = [0., 1.]
85 points[4] = [0.5, 0.5]
86 points[5] = [0.5, 1.]
87 points[6] = [1., 0.5]
88 points[7] = [0.5, 0.]
89 points[8] = [0., 0.5]
90 block_nodes = blocks.create_blocks(3)
91 block_nodes[0] = [0, 7, 4, 8]
92 block_nodes[1] = [8, 4, 5, 3]
93 block_nodes[2] = [4, 6, 2, 5]
94 block_subdivs = blocks.create_block_subdivisions()
95 block_subdivs[0] = [10,10]
96 block_subdivs[1] = [10,10]
97 block_subdivs[2] = [10,10]
98 gradings = blocks.create_block_gradings()
99 gradings[0] = [1., 1., 1., 1.]
100 gradings[1] = [1., 1., 1., 1.]
101 gradings[2] = [1., 1., 1., 1.]
102 blocks.create_patch_nb_faces(name = 'bottom', nb_faces = 1)[0] = [0, 7]
103 blocks.create_patch_nb_faces(name = 'right', nb_faces = 1)[0] = [6, 2]
104 top = blocks.create_patch_nb_faces(name = 'top', nb_faces = 2)
105 top[0] = [2, 5]
106 top[1] = [5, 3]
107 left = blocks.create_patch_nb_faces(name = 'left', nb_faces = 2)
108 left[0] = [3, 8]
109 left[1] = [8, 0]
110 step = blocks.create_patch_nb_faces(name = 'step', nb_faces = 2)
111 step[0] = [7, 4]
112 step[1] = [4, 6]
113 blocks.extrude_blocks(positions=[1.], nb_segments=[10], gradings=[1.])
114 blocks.partition_blocks(nb_partitions = 2, direction = 0)
115 blocks.partition_blocks(nb_partitions = 2, direction = 1)
116 blocks.create_mesh(mesh.uri())
117 
118 make_boundary_global.mesh = mesh
119 make_boundary_global.execute()
120 wall_distance.mesh = mesh
121 wall_distance.regions = [mesh.topology.step, mesh.topology.back]
122 wall_distance.execute()
123 domain.write_mesh(cf.URI('wall-distance-3dstep.pvtu'))
Send comments to:
COOLFluiD Web Admin