brick_from_tet_mesh.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-2025 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// Config header
30#ifdef HAVE_CONFIG_H
31#include <oomph-lib-config.h>
32#endif
33
34#ifdef OOMPH_HAS_MPI
35// mpi headers
36#include "mpi.h"
37#endif
38
39#include <iterator>
40#include <algorithm>
41
42#include "generic/mesh.h"
43#include "generic/tet_mesh.h"
44#include "generic/brick_mesh.h"
46#include "generic/Telements.h"
47#include "xda_tet_mesh.h"
48#include "tetgen_mesh.h"
49
50namespace oomph
51{
52 //=====================================================================
53 /// Brick mesh built by brickifying an existing tet mesh -- each
54 /// tet gets split into four bricks. Can only be built with
55 /// quadratic (27 node) elements.
56 //=====================================================================
57 template<class ELEMENT>
58 class BrickFromTetMesh : public virtual BrickMeshBase
59 {
60 public:
61 /// Constructor: Pass xda file name.
63 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
64 {
65 // Mesh can only be built with 3D Qelements.
66 MeshChecker::assert_geometric_element<QElementGeometricBase, ELEMENT>(3,
67 3);
68
69 // Build temporary tet mesh
71 new XdaTetMesh<TElement<3, 3>>(xda_file_name, time_stepper_pt);
72
73 // Actually build the mesh
74 build_mesh(tmp_mesh_pt, time_stepper_pt);
75
76 // Now kill the temporary mesh
77 delete tmp_mesh_pt;
78 }
79
80 /// Constructor: Pass the files required for the tetgen mesh.
81 BrickFromTetMesh(const std::string& node_file_name,
82 const std::string& element_file_name,
83 const std::string& face_file_name,
84 const bool& split_corner_elements,
85 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper,
86 const bool& use_attributes = false)
87 {
88 // Mesh can only be built with 3D Qelements.
89 MeshChecker::assert_geometric_element<QElementGeometricBase, ELEMENT>(3,
90 3);
91
92 // Build temporary tet mesh
98 time_stepper_pt,
100
101 // Actually build the mesh
102 build_mesh(tmp_mesh_pt, time_stepper_pt);
103
104 // Now kill the temporary mesh
105 delete tmp_mesh_pt;
106 }
107
108
109 /// Constructor: Pass xda file name. This returns a pointer to the
110 /// internally built XdaTetMesh for external use. Note that YOU
111 /// are responsible for deleting this mesh.
114 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
115 {
116 // Mesh can only be built with 3D Qelements.
117 MeshChecker::assert_geometric_element<QElementGeometricBase, ELEMENT>(3,
118 3);
119
120 // Build temporary tet mesh
122 new XdaTetMesh<TElement<3, 3>>(xda_file_name, time_stepper_pt);
123
124 // Actually build the brick mesh
125 build_mesh(xda_tet_mesh_pt, time_stepper_pt);
126
127 // Note that we're keeping the tet mesh alive for external use...
128 }
129
130 /// Access functions to the Vector of oomph-lib boundary ids
131 /// that make up boundary b in the original xda enumeration
136
137 private:
138 /// Build fct: Pass pointer to existing tet mesh.
140 TimeStepper* time_stepper_pt);
141
142 /// Build fct: Pass pointer to existing tet mesh.
144 TimeStepper* time_stepper_pt);
145
146 /// Vector of vectors containing the boundary IDs of
147 /// the overall boundary specified in the xda file.
149 };
150
151
152 ///////////////////////////////////////////////////////////////////////
153 ///////////////////////////////////////////////////////////////////////
154 ///////////////////////////////////////////////////////////////////////
155
156 //=====================================================================
157 /// Solid brick mesh built by brickifying an existing tet mesh -- each
158 /// tet gets split into four bricks. Can only be built with
159 /// quadratic (27 node) elements.
160 //=====================================================================
161 template<class ELEMENT>
162 class SolidBrickFromTetMesh : public virtual BrickFromTetMesh<ELEMENT>,
163 public SolidMesh
164 {
165 public:
166 /// Constructor: Pass xda file name.
168 const std::string xda_file_name,
169 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
170 : BrickFromTetMesh<ELEMENT>(xda_file_name, time_stepper_pt)
171 {
172 // Make the current configuration the undeformed one by
173 // setting the nodal Lagrangian coordinates to their current
174 // Eulerian ones
176 }
177
178
179 /// Constructor: Pass xda file name. This returns a pointer to the
180 /// internally built XdaTetMesh for external use. Note that YOU
181 /// are responsible for deleting this mesh.
183 const std::string xda_file_name,
185 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
186 : BrickFromTetMesh<ELEMENT>(
187 xda_file_name, xda_tet_mesh_pt, time_stepper_pt)
188 {
189 // Make the current configuration the undeformed one by
190 // setting the nodal Lagrangian coordinates to their current
191 // Eulerian ones
193 }
194 };
195
196
197 ///////////////////////////////////////////////////////////////////////
198 ///////////////////////////////////////////////////////////////////////
199 ///////////////////////////////////////////////////////////////////////
200
201 //=====================================================================
202 /// Refineable brick mesh built by brickifying an existing tet mesh -- each
203 /// tet gets split into four bricks. Can only be built with
204 /// quadratic (27 node) elements.
205 //=====================================================================
206 template<class ELEMENT>
207 class RefineableBrickFromTetMesh : public virtual BrickFromTetMesh<ELEMENT>,
208 public virtual RefineableBrickMesh<ELEMENT>
209 {
210 public:
211 /// Constructor: Pass xda file name.
213 const std::string xda_file_name,
214 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
215 : BrickFromTetMesh<ELEMENT>(xda_file_name, time_stepper_pt)
216 {
217 // Nodal positions etc. were created in constructor for
218 // nonrefineable mesh. Only need to setup quadtree forest
219 this->setup_octree_forest();
220 }
221
222
223 /// Constructor: Pass xda file name. This returns a pointer to the
224 /// internally built XdaTetMesh for external use. Note that YOU
225 /// are responsible for deleting this mesh.
227 const std::string xda_file_name,
229 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
230 : BrickFromTetMesh<ELEMENT>(
231 xda_file_name, xda_tet_mesh_pt, time_stepper_pt)
232 {
233 // Nodal positions etc. were created in constructor for
234 // RectangularMesh<...>. Only need to setup quadtree forest
235 this->setup_octree_forest();
236 }
237 };
238
239
240 ///////////////////////////////////////////////////////////////////////
241 ///////////////////////////////////////////////////////////////////////
242 ///////////////////////////////////////////////////////////////////////
243
244 //=====================================================================
245 /// Refineable solid brick mesh built by brickifying an existing tet
246 /// mesh -- each tet gets split into four bricks. Can only be built with
247 /// quadratic (27 node) elements.
248 //=====================================================================
249 template<class ELEMENT>
251 : public virtual BrickFromTetMesh<ELEMENT>,
252 public virtual RefineableBrickMesh<ELEMENT>,
253 public SolidMesh
254
255 {
256 public:
257 /// Constructor: Pass xda file name.
259 const std::string xda_file_name,
260 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
261 : BrickFromTetMesh<ELEMENT>(xda_file_name, time_stepper_pt)
262 {
263 // Make the current configuration the undeformed one by
264 // setting the nodal Lagrangian coordinates to their current
265 // Eulerian ones
267
268 // Nodal positions etc. were created in constructor for
269 // nonrefineable mesh. Only need to setup quadtree forest
270 this->setup_octree_forest();
271 }
272
273
274 /// Constructor: Pass xda file name. This returns a pointer to the
275 /// internally built XdaTetMesh for external use. Note that YOU
276 /// are responsible for deleting this mesh.
278 const std::string xda_file_name,
280 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
281 : BrickFromTetMesh<ELEMENT>(
282 xda_file_name, xda_tet_mesh_pt, time_stepper_pt)
283 {
284 // Make the current configuration the undeformed one by
285 // setting the nodal Lagrangian coordinates to their current
286 // Eulerian ones
288
289 // Nodal positions etc. were created in constructor for
290 // RectangularMesh<...>. Only need to setup quadtree forest
291 this->setup_octree_forest();
292 }
293 };
294
295} // namespace oomph
296
298#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.
Base class for brick meshes (meshes made of 3D brick elements).
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
Refineable brick mesh built by brickifying an existing tet mesh – each tet gets split into four brick...
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...
Refineable solid brick mesh built by brickifying an existing tet mesh – each tet gets split into four...
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.
Solid brick mesh built by brickifying an existing tet mesh – each tet gets split into four bricks....
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:2570
void set_lagrangian_nodal_coordinates()
Make the current configuration the undeformed one by setting the nodal Lagrangian coordinates to thei...
Definition mesh.cc:9564
TAdvectionDiffusionReactionElement<NREAGENT,DIM,NNODE_1D> elements are isoparametric triangular DIM-d...
Unstructured tet mesh based on output from Tetgen: http://wias-berlin.de/software/tetgen/.
Definition tetgen_mesh.h:51
Base class for time-stepping schemes. Timestepper provides an approximation of the temporal derivativ...
Tet mesh made of quadratic (ten node) tets built from xda input file.
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).