Chi-Tech
MeshTutorial_04_Predef2d.h
Go to the documentation of this file.
1
/** \page MeshTutorial_04 Mesh Tutorial 4: Predefined 2D Mesh Setup
2
3
Consider an example of using a predeveloped mesh as shown in Figure 1 below.
4
5
\image html Meshing/SquareMesh2x2.png "Figure 1 - Mesh spanning from [-1,-1] to [1,1]" width=200px
6
7
8
The first step in this process is to create a chi_mesh::MeshHandler for all
9
subsequent meshing operations. This will also serve as a global subspace for
10
other meshing objects that will be added.
11
12
\code
13
chiMeshHandlerCreate()
14
\endcode
15
16
We next import a surface mesh (chi_mesh::SurfaceMesh) that will define our
17
problem. **Solvers will directly operate
18
on predefined meshes**.
19
20
\code
21
newSurfMesh = chiSurfaceMeshCreate();
22
chiSurfaceMeshImportFromOBJFile(newSurfMesh,"CHI_RESOURCES/TestObjects/SquareMesh2x2.obj")
23
\endcode
24
25
The next step is to break up the boundaries of this mesh into edges that we can
26
assign to boundaries. We first collect *loops* of edges, which are lists of
27
connected edges. We then split these loops by angle into further loops. Finally
28
we assign each fine-grained loop to a chi_mesh::LineMesh object that can be
29
added to a chi_mesh::Boundary type.
30
31
\code
32
line_mesh = {};
33
line_mesh_count = 0;
34
--
35
for k=1,loop_count do
36
split_loops,split_count = chiEdgeLoopSplitByAngle(loops,k-1);
37
for m=1,split_count do
38
line_mesh_count = line_mesh_count + 1;
39
line_mesh[line_mesh_count] = chiLineMeshCreateFromLoop(split_loops,m-1);
40
end
41
--
42
end
43
\endcode
44
45
Next we create a chi_mesh::Region object to which we are going to add boundaries.
46
We can add a boundary for each chi_mesh::LineMesh and each chi_mesh::SurfaceMesh.
47
48
\code
49
region1 = chiRegionCreate()
50
chiRegionAddSurfaceBoundary(region1,newSurfMesh);
51
for k=1,line_mesh_count do
52
chiRegionAddLineBoundary(region1,line_mesh[k]);
53
end
54
\endcode
55
56
We now have everything we need to do a Predefined 2D mesh operation. To do this
57
we create a chi_mesh::SurfaceMesher with the type *SURFACEMESHER_PREDEFINED* as
58
well as a chi_mesh::VolumeMesher with the type *VOLUMEMESHER_PREDEFINED2D*.
59
60
\code
61
chiSurfaceMesherCreate(SURFACEMESHER_PREDEFINED);
62
chiVolumeMesherCreate(VOLUMEMESHER_PREDEFINED2D);
63
--
64
chiSurfaceMesherExecute();
65
chiVolumeMesherExecute()
66
\endcode
67
68
The *SURFACEMESHER_PREDEFINED* is just a pass-through mesher, in contrast to the
69
*SURFACEMESHER_DELAUNAY* type which will re-mesh surfaces. The
70
*VOLUMEMESHER_PREDEFINED2D* similarly does not create new mesh elements but at
71
least this instantiates the notion of nodes and cells.
72
73
### Complete code segment
74
75
\code
76
chiMeshHandlerCreate()
77
--
78
newSurfMesh = chiSurfaceMeshCreate();
79
chiSurfaceMeshImportFromOBJFile(newSurfMesh,"CHI_RESOURCES/TestObjects/SquareMesh2x2.obj")
80
loops,loop_count = chiSurfaceMeshGetEdgeLoops(newSurfMesh)
81
--
82
--
83
line_mesh = {};
84
line_mesh_count = 0;
85
--
86
for k=1,loop_count do
87
split_loops,split_count = chiEdgeLoopSplitByAngle(loops,k-1);
88
for m=1,split_count do
89
line_mesh_count = line_mesh_count + 1;
90
line_mesh[line_mesh_count] = chiLineMeshCreateFromLoop(split_loops,m-1);
91
end
92
--
93
end
94
--
95
region1 = chiRegionCreate()
96
chiRegionAddSurfaceBoundary(region1,newSurfMesh);
97
for k=1,line_mesh_count do
98
chiRegionAddLineBoundary(region1,line_mesh[k]);
99
end
100
--
101
chiSurfaceMesherCreate(SURFACEMESHER_PREDEFINED);
102
chiVolumeMesherCreate(VOLUMEMESHER_PREDEFINED2D);
103
--
104
chiSurfaceMesherExecute();
105
chiVolumeMesherExecute()
106
\endcode
107
108
*/
doc
PAGES
MeshTutorials
MeshTutorial_04_Predef2d.h
Generated by
1.9.3