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