extruded_cube_mesh_from_quad_mesh_with_macro_elements.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-2023 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 // Header file for ExtrudedCubeMeshFromQuadMesh class
27 #ifndef OOMPH_EXTRUDED_CUBE_MESH_FROM_QUAD_MESH_WITH_MACRO_ELEMENTS_HEADER
28 #define OOMPH_EXTRUDED_CUBE_MESH_FROM_QUAD_MESH_WITH_MACRO_ELEMENTS_HEADER
29 
30 // Config header generated by autoconfig
31 #ifdef HAVE_CONFIG_H
32 #include <oomph-lib-config.h>
33 #endif
34 
35 // Oomph-lib headers
36 #include "../generic/mesh.h"
37 #include "../generic/quad_mesh.h"
38 #include "../generic/brick_mesh.h"
39 #include "../generic/refineable_brick_mesh.h"
40 #include "../generic/extruded_domain.h"
41 #include "../generic/extruded_macro_element.h"
42 
43 /// //////////////////////////////////////////////////////////////////////
44 /// //////////////////////////////////////////////////////////////////////
45 /// //////////////////////////////////////////////////////////////////////
46 
47 namespace oomph
48 {
49  //===============================================================
50  // Namespace for the mesh extrusion machinery
51  //===============================================================
52  namespace MeshExtrusionHelpers
53  {
54  /// Class to contain any helpers for the mesh extrusion. At
55  /// the moment this only used to decide on whether or not to
56  /// doc the mesh setup time
58  {
59  public:
60  /// Constructor (empty)
62 
63 
64  /// Return the value of the Doc_mesh_setup_time flag
66  {
67  // Return the boolean flag
68  return Doc_mesh_setup_time;
69  } // End of doc_mesh_setup_time
70 
71 
72  /// Enable doc-ing of the mesh setup
74  {
75  // Enable the appropriate boolean flag
76  Doc_mesh_setup_time = true;
77  } // End of enable_doc_mesh_setup_time
78 
79 
80  /// Disable doc-ing of the mesh setup
82  {
83  // Disable the appropriate boolean flag
84  Doc_mesh_setup_time = false;
85  } // End of disable_doc_mesh_setup_time
86 
87  private:
88  /// Boolean to indicate whether or not to doc the progress
91  } // namespace MeshExtrusionHelpers
92 
93  //=======================================================================
94  /// Mesh class that takes a 2D mesh consisting of quadrilateral
95  /// elements and "extrudes" it in the z-direction.
96  //=======================================================================
97  template<class ELEMENT>
99  {
100  public:
101  /// Constructor: Pass a mesh consisting of quad elements,
102  /// specify the number of elements in the z direction, and the
103  /// corresponding length in this direction. Assumes that the back
104  /// lower left corner is located at (0,0,0). Timestepper defaults
105  /// to the Steady timestepper.
107  QuadMeshBase* quad_mesh_pt,
108  const unsigned& nz,
109  const double& lz,
110  TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
111  : Nz(nz), Zmin(0.0), Zmax(lz)
112  {
113  // Call the generic build function
114  build_mesh(quad_mesh_pt, time_stepper_pt);
115  }
116 
117 
118  /// Constructor: Pass a mesh consisting of quad elements,
119  /// specify the number of elements in the z direction, and the
120  /// corresponding minimum and maximum z-value of the mesh. Again,
121  /// timestepper defaults to Steady.
123  QuadMeshBase* quad_mesh_pt,
124  const unsigned& nz,
125  const double& zmin,
126  const double& zmax,
127  TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
128  : Nz(nz), Zmin(zmin), Zmax(zmax)
129  {
130  // Call the generic mesh constructor
131  build_mesh(quad_mesh_pt, time_stepper_pt);
132  }
133 
134 
135  /// Destructor: If the underlying spatial domain was made up of
136  /// any macro elements then we will have created an extruded domain
137  /// which in turn creates extruded macro elements. As we're responsible
138  /// for creating the domain, we need to kill it and it'll kill the
139  /// extruded macro elements...
141  {
142  // Are there any extruded domains?
143  if (Extruded_domain_pt.size() > 0)
144  {
145  // How many extruded domains did we create?
146  unsigned n_extruded_domain = Extruded_domain_pt.size();
147 
148  // Loop over the extruded domains
149  for (unsigned i = 0; i < n_extruded_domain; i++)
150  {
151  // Delete the i-th extruded domain
152  delete Extruded_domain_pt[i];
153 
154  // Make it a null pointer
155  Extruded_domain_pt[i] = 0;
156  }
157  } // if (Extruded_domain_pt.size()>0)
158  } // End of ExtrudedCubeMeshFromQuadMesh
159 
160 
161  /// Return the value of the z-coordinate at the node given by the
162  /// local node number, znode.
163  virtual double z_spacing_function(const unsigned& z_element,
164  const unsigned& z_node) const
165  {
166  // Calculate the values of equal increments in nodal values
167  double z_step = (Zmax - Zmin) / ((N_node_1d - 1) * Nz);
168 
169  // Return the appropriate value
170  return (Zmin + z_step * ((N_node_1d - 1) * z_element + z_node));
171  } // End of z_spacing_function
172 
173 
174  /// Get all the boundary information of an element using the
175  /// input (quad_mesh_pt) mesh. If the element lies on a boundary then
176  /// the user will be given the corresponding boundary index and the
177  /// index of the face of quad_el_pt attached to the boundary. If the
178  /// element does NOT lie on any boundaries, this function simply
179  /// returns a vector of size zero.
181  QuadMeshBase* quad_mesh_pt, FiniteElement* quad_el_pt);
182 
183  /// Access function for number of elements in z-direction (const version)
184  const unsigned& nz() const
185  {
186  // Return the value of the appropriate private variable
187  return Nz;
188  } // End of nz
189 
190  protected:
191  /// The number of nodes in each direction
192  unsigned N_node_1d;
193 
194  /// Number of elements in the z-direction
195  unsigned Nz;
196 
197  /// Minimum value of z coordinate
198  double Zmin;
199 
200  /// Maximum value of z coordinate
201  double Zmax;
202 
203  /// Vector of pointers to extruded domain objects
205 
206  /// Generic mesh construction function: contains all the hard work
207  void build_mesh(QuadMeshBase* quad_mesh_pt,
208  TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper);
209  };
210 
211  /// /////////////////////////////////////////////////////////////////////////
212  /// /////////////////////////////////////////////////////////////////////////
213  /// /////////////////////////////////////////////////////////////////////////
214 
215  //=======================================================================
216  /// Mesh class that takes a 2D mesh, "extrudes" it in the z-direction and
217  /// also makes the resulting mesh refineable.
218  //=======================================================================
219  template<class ELEMENT>
221  : public virtual ExtrudedCubeMeshFromQuadMesh<ELEMENT>,
222  public virtual RefineableBrickMesh<ELEMENT>
223  {
224  public:
225  /// Constructor: Pass a mesh consisting of quad elements,
226  /// specify the number of elements in the z direction, and the
227  /// corresponding length in this direction. Assumes that the back
228  /// lower left corner is located at (0,0,0). Timestepper defaults
229  /// to the Steady timestepper.
231  QuadMeshBase* quad_mesh_pt,
232  const unsigned& nz,
233  const double& lz,
234  TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
235  : ExtrudedCubeMeshFromQuadMesh<ELEMENT>(
236  quad_mesh_pt, nz, lz, time_stepper_pt)
237  {
238  // Nodal positions etc. were created in constructor for
239  // base class Only need to setup octree forest
240  this->setup_octree_forest();
241  }
242 
243 
244  /// Constructor: Pass a mesh consisting of quad elements,
245  /// specify the number of elements in the z direction, and the
246  /// corresponding minimum and maximum z-value of the mesh. Again,
247  /// timestepper defaults to Steady.
249  QuadMeshBase* quad_mesh_pt,
250  const unsigned& nz,
251  const double& zmin,
252  const double& zmax,
253  TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
254  : ExtrudedCubeMeshFromQuadMesh<ELEMENT>(
255  quad_mesh_pt, nz, zmin, zmax, time_stepper_pt)
256  {
257  // Nodal positions etc. were created in constructor for
258  // base class Only need to setup octree forest
259  this->setup_octree_forest();
260  }
261  };
262 
263 } // End of namespace oomph
264 
265 #endif
cstr elem_len * i
Definition: cfortran.h:603
//////////////////////////////////////////////////////////////////////// ////////////////////////////...
Definition: brick_mesh.h:178
Mesh class that takes a 2D mesh consisting of quadrilateral elements and "extrudes" it in the z-direc...
void build_mesh(QuadMeshBase *quad_mesh_pt, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Generic mesh construction function: contains all the hard work.
virtual double z_spacing_function(const unsigned &z_element, const unsigned &z_node) const
Return the value of the z-coordinate at the node given by the local node number, znode.
Vector< ExtrudedDomain * > Extruded_domain_pt
Vector of pointers to extruded domain objects.
ExtrudedCubeMeshFromQuadMesh(QuadMeshBase *quad_mesh_pt, const unsigned &nz, const double &zmin, const double &zmax, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor: Pass a mesh consisting of quad elements, specify the number of elements in the z directi...
Vector< std::pair< unsigned, int > > get_element_boundary_information(QuadMeshBase *quad_mesh_pt, FiniteElement *quad_el_pt)
Get all the boundary information of an element using the input (quad_mesh_pt) mesh....
~ExtrudedCubeMeshFromQuadMesh()
Destructor: If the underlying spatial domain was made up of any macro elements then we will have crea...
const unsigned & nz() const
Access function for number of elements in z-direction (const version)
ExtrudedCubeMeshFromQuadMesh(QuadMeshBase *quad_mesh_pt, const unsigned &nz, const double &lz, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor: Pass a mesh consisting of quad elements, specify the number of elements in the z directi...
A general Finite Element class.
Definition: elements.h:1313
Class to contain any helpers for the mesh extrusion. At the moment this only used to decide on whethe...
bool Doc_mesh_setup_time
Boolean to indicate whether or not to doc the progress.
static Steady< 0 > Default_TimeStepper
Default Steady Timestepper, to be used in default arguments to Mesh constructors.
Definition: mesh.h:75
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
Definition: quad_mesh.h:57
Intermediate mesh class that implements the mesh adaptation functions specified in the TreeBasedRefin...
void setup_octree_forest()
Do what it says...
///////////////////////////////////////////////////////////////////////// ///////////////////////////...
RefineableExtrudedCubeMeshFromQuadMesh(QuadMeshBase *quad_mesh_pt, const unsigned &nz, const double &zmin, const double &zmax, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor: Pass a mesh consisting of quad elements, specify the number of elements in the z directi...
RefineableExtrudedCubeMeshFromQuadMesh(QuadMeshBase *quad_mesh_pt, const unsigned &nz, const double &lz, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor: Pass a mesh consisting of quad elements, specify the number of elements in the z directi...
////////////////////////////////////////////////////////////////////// //////////////////////////////...
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
class oomph::MeshExtrusionHelpers::ExtrusionHelper Mesh_extrusion_helper
//////////////////////////////////////////////////////////////////// ////////////////////////////////...