brick_from_tet_mesh.template.h
Go to the documentation of this file.
1// LIC// ====================================================================
2// LIC// This file forms part of oomph-lib, the object-oriented,
3// LIC// multi-physics finite-element library, available
4// LIC// at http://www.oomph-lib.org.
5// LIC//
6// LIC// Copyright (C) 2006-2022 Matthias Heil and Andrew Hazel
7// LIC//
8// LIC// This library is free software; you can redistribute it and/or
9// LIC// modify it under the terms of the GNU Lesser General Public
10// LIC// License as published by the Free Software Foundation; either
11// LIC// version 2.1 of the License, or (at your option) any later version.
12// LIC//
13// LIC// This library is distributed in the hope that it will be useful,
14// LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16// LIC// Lesser General Public License for more details.
17// LIC//
18// LIC// You should have received a copy of the GNU Lesser General Public
19// LIC// License along with this library; if not, write to the Free Software
20// LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21// LIC// 02110-1301 USA.
22// LIC//
23// LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
24// LIC//
25// LIC//====================================================================
26#ifndef OOMPH_BRICK_FROM_TET_MESH_HEADER
27#define OOMPH_BRICK_FROM_TET_MESH_HEADER
28
29
30// Config header generated by autoconfig
31#ifdef HAVE_CONFIG_H
32#include <oomph-lib-config.h>
33#endif
34
35
36#ifdef OOMPH_HAS_MPI
37// mpi headers
38#include "mpi.h"
39#endif
40
41#include <iterator>
42#include <algorithm>
43
44#include "../generic/mesh.h"
45#include "../generic/tet_mesh.h"
46#include "../generic/brick_mesh.h"
47#include "../generic/refineable_brick_mesh.h"
48#include "../generic/Telements.h"
51
52namespace oomph
53{
54 //=====================================================================
55 /// Brick mesh built by brickifying an existing tet mesh -- each
56 /// tet gets split into four bricks. Can only be built with
57 /// quadratic (27 node) elements.
58 //=====================================================================
59 template<class ELEMENT>
60 class BrickFromTetMesh : public virtual BrickMeshBase
61 {
62 public:
63 /// Constructor: Pass xda file name.
64 BrickFromTetMesh(const std::string xda_file_name,
65 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
66 {
67 // Mesh can only be built with 3D Qelements.
68 MeshChecker::assert_geometric_element<QElementGeometricBase, ELEMENT>(3,
69 3);
70
71 // Build temporary tet mesh
72 XdaTetMesh<TElement<3, 3>>* tmp_mesh_pt =
73 new XdaTetMesh<TElement<3, 3>>(xda_file_name, time_stepper_pt);
74
75 // Actually build the mesh
76 build_mesh(tmp_mesh_pt, time_stepper_pt);
77
78 // Now kill the temporary mesh
79 delete tmp_mesh_pt;
80 }
81
82 /// Constructor: Pass the files required for the tetgen mesh.
83 BrickFromTetMesh(const std::string& node_file_name,
84 const std::string& element_file_name,
85 const std::string& face_file_name,
86 const bool& split_corner_elements,
87 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper,
88 const bool& use_attributes = false)
89 {
90 // Mesh can only be built with 3D Qelements.
91 MeshChecker::assert_geometric_element<QElementGeometricBase, ELEMENT>(3,
92 3);
93
94 // Build temporary tet mesh
95 TetgenMesh<TElement<3, 3>>* tmp_mesh_pt =
96 new TetgenMesh<TElement<3, 3>>(node_file_name,
97 element_file_name,
98 face_file_name,
99 split_corner_elements,
100 time_stepper_pt,
101 use_attributes);
102
103 // Actually build the mesh
104 build_mesh(tmp_mesh_pt, time_stepper_pt);
105
106 // Now kill the temporary mesh
107 delete tmp_mesh_pt;
108 }
109
110
111 /// Constructor: Pass xda file name. This returns a pointer to the
112 /// internally built XdaTetMesh for external use. Note that YOU
113 /// are responsible for deleting this mesh.
114 BrickFromTetMesh(const std::string xda_file_name,
115 XdaTetMesh<TElement<3, 3>>*& xda_tet_mesh_pt,
116 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
117 {
118 // Mesh can only be built with 3D Qelements.
119 MeshChecker::assert_geometric_element<QElementGeometricBase, ELEMENT>(3,
120 3);
121
122 // Build temporary tet mesh
123 xda_tet_mesh_pt =
124 new XdaTetMesh<TElement<3, 3>>(xda_file_name, time_stepper_pt);
125
126 // Actually build the brick mesh
127 build_mesh(xda_tet_mesh_pt, time_stepper_pt);
128
129 // Note that we're keeping the tet mesh alive for external use...
130 }
131
132 /// Access functions to the Vector of oomph-lib boundary ids
133 /// that make up boundary b in the original xda enumeration
134 Vector<unsigned> oomph_lib_boundary_ids(const unsigned& xda_boundary_id)
135 {
136 return Boundary_id[xda_boundary_id];
137 }
138
139
140 private:
141 /// Build fct: Pass pointer to existing tet mesh.
142 void build_mesh(XdaTetMesh<TElement<3, 3>>* tet_mesh_pt,
143 TimeStepper* time_stepper_pt);
144
145 /// Build fct: Pass pointer to existing tet mesh.
146 void build_mesh(TetgenMesh<TElement<3, 3>>* tet_mesh_pt,
147 TimeStepper* time_stepper_pt);
148
149 /// Vector of vectors containing the boundary IDs of
150 /// the overall boundary specified in the xda file.
152 };
153
154
155 /// ////////////////////////////////////////////////////////////////////
156 /// ////////////////////////////////////////////////////////////////////
157 /// ////////////////////////////////////////////////////////////////////
158
159
160 //=====================================================================
161 /// Solid brick mesh built by brickifying an existing tet mesh -- each
162 /// tet gets split into four bricks. Can only be built with
163 /// quadratic (27 node) elements.
164 //=====================================================================
165 template<class ELEMENT>
166 class SolidBrickFromTetMesh : public virtual BrickFromTetMesh<ELEMENT>,
167 public SolidMesh
168 {
169 public:
170 /// Constructor: Pass xda file name.
172 const std::string xda_file_name,
173 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
174 : BrickFromTetMesh<ELEMENT>(xda_file_name, time_stepper_pt)
175 {
176 // Make the current configuration the undeformed one by
177 // setting the nodal Lagrangian coordinates to their current
178 // Eulerian ones
180 }
181
182
183 /// Constructor: Pass xda file name. This returns a pointer to the
184 /// internally built XdaTetMesh for external use. Note that YOU
185 /// are responsible for deleting this mesh.
187 const std::string xda_file_name,
188 XdaTetMesh<TElement<3, 3>>*& xda_tet_mesh_pt,
189 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
190 : BrickFromTetMesh<ELEMENT>(
191 xda_file_name, xda_tet_mesh_pt, time_stepper_pt)
192 {
193 // Make the current configuration the undeformed one by
194 // setting the nodal Lagrangian coordinates to their current
195 // Eulerian ones
197 }
198 };
199
200
201 /// ////////////////////////////////////////////////////////////////////
202 /// ////////////////////////////////////////////////////////////////////
203 /// ////////////////////////////////////////////////////////////////////
204
205
206 //=====================================================================
207 /// Refineable brick mesh built by brickifying an existing tet mesh -- each
208 /// tet gets split into four bricks. Can only be built with
209 /// quadratic (27 node) elements.
210 //=====================================================================
211 template<class ELEMENT>
212 class RefineableBrickFromTetMesh : public virtual BrickFromTetMesh<ELEMENT>,
213 public virtual RefineableBrickMesh<ELEMENT>
214 {
215 public:
216 /// Constructor: Pass xda file name.
218 const std::string xda_file_name,
219 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
220 : BrickFromTetMesh<ELEMENT>(xda_file_name, time_stepper_pt)
221 {
222 // Nodal positions etc. were created in constructor for
223 // nonrefineable mesh. Only need to setup quadtree forest
224 this->setup_octree_forest();
225 }
226
227
228 /// Constructor: Pass xda file name. This returns a pointer to the
229 /// internally built XdaTetMesh for external use. Note that YOU
230 /// are responsible for deleting this mesh.
232 const std::string xda_file_name,
233 XdaTetMesh<TElement<3, 3>>*& xda_tet_mesh_pt,
234 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
235 : BrickFromTetMesh<ELEMENT>(
236 xda_file_name, xda_tet_mesh_pt, time_stepper_pt)
237 {
238 // Nodal positions etc. were created in constructor for
239 // RectangularMesh<...>. Only need to setup quadtree forest
240 this->setup_octree_forest();
241 }
242 };
243
244
245 /// ////////////////////////////////////////////////////////////////////
246 /// ////////////////////////////////////////////////////////////////////
247 /// ////////////////////////////////////////////////////////////////////
248
249
250 //=====================================================================
251 /// Refineable solid brick mesh built by brickifying an existing tet
252 /// mesh -- each tet gets split into four bricks. Can only be built with
253 /// quadratic (27 node) elements.
254 //=====================================================================
255 template<class ELEMENT>
257 : public virtual BrickFromTetMesh<ELEMENT>,
258 public virtual RefineableBrickMesh<ELEMENT>,
259 public SolidMesh
260
261 {
262 public:
263 /// Constructor: Pass xda file name.
265 const std::string xda_file_name,
266 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
267 : BrickFromTetMesh<ELEMENT>(xda_file_name, time_stepper_pt)
268 {
269 // Make the current configuration the undeformed one by
270 // setting the nodal Lagrangian coordinates to their current
271 // Eulerian ones
273
274 // Nodal positions etc. were created in constructor for
275 // nonrefineable mesh. Only need to setup quadtree forest
276 this->setup_octree_forest();
277 }
278
279
280 /// Constructor: Pass xda file name. This returns a pointer to the
281 /// internally built XdaTetMesh for external use. Note that YOU
282 /// are responsible for deleting this mesh.
284 const std::string xda_file_name,
285 XdaTetMesh<TElement<3, 3>>*& xda_tet_mesh_pt,
286 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
287 : BrickFromTetMesh<ELEMENT>(
288 xda_file_name, xda_tet_mesh_pt, time_stepper_pt)
289 {
290 // Make the current configuration the undeformed one by
291 // setting the nodal Lagrangian coordinates to their current
292 // Eulerian ones
294
295 // Nodal positions etc. were created in constructor for
296 // RectangularMesh<...>. Only need to setup quadtree forest
297 this->setup_octree_forest();
298 }
299 };
300
301} // namespace oomph
302
303#endif
Brick mesh built by brickifying an existing tet mesh – each tet gets split into four bricks....
Vector< Vector< unsigned > > Boundary_id
Vector of vectors containing the boundary IDs of the overall boundary specified in the xda file.
BrickFromTetMesh(const std::string xda_file_name, XdaTetMesh< TElement< 3, 3 > > *&xda_tet_mesh_pt, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor: Pass xda file name. This returns a pointer to the internally built XdaTetMesh for extern...
void build_mesh(XdaTetMesh< TElement< 3, 3 > > *tet_mesh_pt, TimeStepper *time_stepper_pt)
Build fct: Pass pointer to existing tet mesh.
Vector< unsigned > oomph_lib_boundary_ids(const unsigned &xda_boundary_id)
Access functions to the Vector of oomph-lib boundary ids that make up boundary b in the original xda ...
BrickFromTetMesh(const std::string xda_file_name, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor: Pass xda file name.
BrickFromTetMesh(const std::string &node_file_name, const std::string &element_file_name, const std::string &face_file_name, const bool &split_corner_elements, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper, const bool &use_attributes=false)
Constructor: Pass the files required for the tetgen mesh.
//////////////////////////////////////////////////////////////////////// ////////////////////////////...
Definition: brick_mesh.h:178
static Steady< 0 > Default_TimeStepper
Default Steady Timestepper, to be used in default arguments to Mesh constructors.
Definition: mesh.h:75
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
RefineableBrickFromTetMesh(const std::string xda_file_name, XdaTetMesh< TElement< 3, 3 > > *&xda_tet_mesh_pt, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor: Pass xda file name. This returns a pointer to the internally built XdaTetMesh for extern...
RefineableBrickFromTetMesh(const std::string xda_file_name, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor: Pass xda file name.
Intermediate mesh class that implements the mesh adaptation functions specified in the TreeBasedRefin...
void setup_octree_forest()
Do what it says...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
RefineableSolidBrickFromTetMesh(const std::string xda_file_name, XdaTetMesh< TElement< 3, 3 > > *&xda_tet_mesh_pt, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor: Pass xda file name. This returns a pointer to the internally built XdaTetMesh for extern...
RefineableSolidBrickFromTetMesh(const std::string xda_file_name, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor: Pass xda file name.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
SolidBrickFromTetMesh(const std::string xda_file_name, XdaTetMesh< TElement< 3, 3 > > *&xda_tet_mesh_pt, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor: Pass xda file name. This returns a pointer to the internally built XdaTetMesh for extern...
SolidBrickFromTetMesh(const std::string xda_file_name, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor: Pass xda file name.
General SolidMesh class.
Definition: mesh.h:2562
void set_lagrangian_nodal_coordinates()
Make the current configuration the undeformed one by setting the nodal Lagrangian coordinates to thei...
Definition: mesh.cc:9564
General TElement class.
Definition: Telements.h:1208
Unstructured tet mesh based on output from Tetgen: http://wias-berlin.de/software/tetgen/.
////////////////////////////////////////////////////////////////////// //////////////////////////////...
Definition: timesteppers.h:231
A slight extension to the standard template vector class so that we can include "graceful" array rang...
Definition: Vector.h:58
Tet mesh made of quadratic (ten node) tets built from xda input file.
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...