Chi-Tech
doc_MeshGenerators.h
Go to the documentation of this file.
1
/**\defgroup doc_MeshGenerators Mesh Generators
2
\ingroup LuaMesh
3
*
4
We split a `MeshGenerator`'s execution into a
5
phase that generates an unpartitioned mesh and a phase that then converts
6
this mesh into partitioned `chi_mesh::MeshContinuum` (with both steps
7
customizable). The phase that creates the `MeshContinuum` object can be hooked
8
up to a partitioner that can also be designed to be pluggable.
9
10
## Example A
11
\code
12
nodes = {-1.0,-0.75,-0.5,-0.25,0.0,0.25,0.5,0.75,1.0}
13
meshgen1 = chi_mesh.OrthogonalMeshGenerator.Create({ node_sets = {nodes,nodes} })
14
chi_mesh.MeshGenerator.Execute(meshgen1)
15
16
chiMeshHandlerExportMeshToVTK("ZMeshTest")
17
\endcode
18
19
In this example we created a set of nodes (monotonically increasing in value)
20
for use with the
21
\ref chi_mesh__OrthogonalMeshGenerator. We supplied the same set twice meaning the generator
22
will build a 2D mesh.
23
24
We did not specify a partitioner and therefore the generator will use the
25
\ref chi__PETScGraphPartitioner with `type="parmetis"` by default. Using 8
26
processes, we can see the mesh and it's partitioning below.
27
28
\image html framework/chi_mesh/MeshGenerators/ExampleA.png width=500px
29
30
## Example B
31
\code
32
meshgen1 = chi_mesh.FromFileMeshGenerator.Create({ filename="TriangleMesh2x2.obj" })
33
chi_mesh.MeshGenerator.Execute(meshgen1)
34
35
chiMeshHandlerExportMeshToVTK("ZMeshTest")
36
\endcode
37
38
In this example we created a mesh by reading it from a file, using the
39
\ref chi_mesh__FromFileMeshGenerator. The types of file-types we can support is
40
ever growing. At the time of writing this we support the following formats:
41
- `.obj` Wavefront
42
- `.msh` gmesh,
43
- `.e` ExodusII,
44
- `.vtu` VTK Unstructured grid,
45
- `.pvtu` Pieced VTK Unstructured grid,
46
- `.case` Ensight Gold
47
48
Using 8 processes, we can see the mesh and it's partitioning below.
49
50
\image html framework/chi_mesh/MeshGenerators/ExampleB.png width=500px
51
52
## Example C
53
\code
54
meshgen1 = chi_mesh.ExtruderMeshGenerator.Create
55
({
56
inputs =
57
{
58
chi_mesh.FromFileMeshGenerator.Create({ filename=TriangleMesh2x2.obj" }),
59
},
60
layers = {{z=1.1, n=2}, -- First layer - 2 sub-layers
61
{z=2.1, n=3}}, -- Second layer - 3 sub-layers
62
})
63
chi_mesh.MeshGenerator.Execute(meshgen1)
64
65
chiMeshHandlerExportMeshToVTK("ZMeshTest")
66
\endcode
67
68
In this example we use an \ref chi_mesh__ExtruderMeshGenerator with another
69
mesh generator as an input to create an extruded mesh. Using 8 processes, we can
70
see the mesh and it's partitioning below.
71
72
\image html framework/chi_mesh/MeshGenerators/ExampleC.png width=500px
73
74
## Using different Partitioners
75
ChiTech now has a set of Graph Partitioners (i.e. based off `GraphPartitioner`)
76
that support different forms of partitioning, for example we have:
77
- \ref chi__LinearGraphPartitioner, a very basic partitioner used for
78
during the preparation of simulation meshes.
79
- \ref chi__PETScGraphPartitioner, a flexible partitioner that can use all the
80
partitioner options available in PETSc (defaults to using `"parmetis"`).
81
- \ref chi__KBAGraphPartitioner, the classical Neutron Transport KBA parallel
82
partitioning with an overlaid orthogonal layout.
83
84
An example of changing the partitioning to PETSc's `"average"` option is shown
85
below:
86
\code
87
meshgen1 = chi_mesh.ExtruderMeshGenerator.Create
88
({
89
inputs =
90
{
91
chi_mesh.FromFileMeshGenerator.Create
92
({
93
filename="resources/TestMeshes/TriangleMesh2x2.obj"
94
}),
95
},
96
layers = {{z=1.1, n=2}, {z=2.1, n=3}},
97
partitioner = chi.PETScGraphPartitioner.Create({type="average"})
98
})
99
chi_mesh.MeshGenerator.Execute(meshgen1)
100
101
chiMeshHandlerExportMeshToVTK("ZMeshTest")
102
\endcode
103
104
\image html framework/chi_mesh/MeshGenerators/ParExample1.png width=500px
105
106
Another example using the `KBAGraphPartitioner` is shown below
107
\code
108
meshgen1 = chi_mesh.ExtruderMeshGenerator.Create
109
({
110
inputs =
111
{
112
chi_mesh.FromFileMeshGenerator.Create
113
({
114
filename="resources/TestMeshes/TriangleMesh2x2.obj"
115
}),
116
},
117
layers = {{z=1.1, n=2}, {z=2.1, n=3}},
118
partitioner = chi.KBAGraphPartitioner.Create
119
({
120
nx = 2, ny=2, nz=2,
121
xcuts = {0.0}, ycuts = {0.0}, zcuts = {1.1}
122
})
123
})
124
chi_mesh.MeshGenerator.Execute(meshgen1)
125
126
chiMeshHandlerExportMeshToVTK("ZMeshTest")
127
\endcode
128
129
\image html framework/chi_mesh/MeshGenerators/ParExample2.png width=500px
130
131
132
## The special SplitFileMeshGenerator
133
134
For very large meshes the mesh generation process could both take very long and
135
require a lot of memory. The current mode of operation of the mesh generators is
136
that each process builds the mesh as an unpartitioned mesh then the mesh gets
137
converted to a partitioned mesh. Therefore, when a lot of processes are used,
138
there could be a large memory spike, large enough to be greater than what even
139
an HPC node has available. To partly address this problem we have the
140
\ref chi_mesh__SplitFileMeshGenerator. This generator will process multiple mesh inputs like
141
any other mesh generator but instead of building the mesh on each processor only
142
the home location builds the mesh. Thereafter the mesh is partitioned and each
143
processors' local-cells, ghost-cells, and relevant vertices are written to
144
separate binary files. The default folder, into which these files are written,
145
is named "SplitMesh" and the default file names for the meshes are
146
"split_mesh_x.cmesh", where the x represents the processors rank. Both the
147
folder name and file name prefixes (i.e. the "split_mesh" part) can be altered
148
via input parameters.
149
150
It is also possible to generate split meshes in serial by supplying the
151
`num_parts` parameter. Also, if a simulation uses the same mesh over and over
152
then the parameter `read_only` can be used to suppress the mesh being
153
created every single time.
154
155
### SplitFile Example A
156
157
\code
158
meshgen1 = chi_mesh.SplitFileMeshGenerator.Create
159
({
160
inputs =
161
{
162
chi_mesh.OrthogonalMeshGenerator.Create({ node_sets = {xmesh,ymesh,zmesh} })
163
},
164
})
165
166
chi_mesh.MeshGenerator.Execute(meshgen1)
167
\endcode
168
169
The examples below will create, in the current working directory, the folder
170
`SplitMesh` and within it `split_mesh_0.cmesh`, `split_mesh_1.cmesh`, etc.
171
172
### SplitFile Example B
173
174
\code
175
meshgen1 = chi_mesh.SplitFileMeshGenerator.Create
176
({
177
inputs = {
178
chi_mesh.OrthogonalMeshGenerator.Create({ node_sets = {xmesh,ymesh} }),
179
chi_mesh.ExtruderMeshGenerator.Create
180
({
181
layers = {{z=Lz, n=Nz}}
182
})
183
}
184
})
185
186
chi_mesh.MeshGenerator.Execute(meshgen1)
187
\endcode
188
189
This example is the same as the one above it, however, it uses the extruder
190
mesh generator in a chain.
191
192
\note Partitioning and the other parameters of \ref chi_mesh__SplitFileMeshGenerator are
193
identical to that of the base \ref chi_mesh__MeshGenerator.
194
195
*/
framework
mesh
MeshGenerator
doc
doc_MeshGenerators.h
Generated by
1.9.3