hermite_element_quad_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 // This header defines a class for hermite element quad mesh
27 
28 // Include guards
29 #ifndef OOMPH_HERMITE_ELEMENT_QUAD_MESH_HEADER
30 #define OOMPH_HERMITE_ELEMENT_QUAD_MESH_HEADER
31 
32 
33 // Config header generated by autoconfig
34 #ifdef HAVE_CONFIG_H
35 #include <oomph-lib-config.h>
36 #endif
37 
38 // oomph-lib headers
39 #include "../generic/hermite_elements.h"
40 #include "../generic/mesh.h"
42 
43 namespace oomph
44 {
45  //=============================================================================
50  //=============================================================================
51  template<class ELEMENT>
52  class HermiteQuadMesh : public Mesh
53  {
54  public:
59  typedef void (*MeshSpacingFnPtr)(const Vector<double>& m_uniform_spacing,
60  Vector<double>& m_non_uniform_spacing);
61 
62 
73  HermiteQuadMesh(const unsigned& nx,
74  const unsigned& ny,
76  const bool& periodic_in_x = false,
77  TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
78  {
79  // Mesh can only be built with 2D QHermiteElements.
80  MeshChecker::assert_geometric_element<QHermiteElementBase, ELEMENT>(2);
81 
82  // set number of elements in each coordinate direction
83  Nelement.resize(2);
84  Nelement[0] = nx;
85  Nelement[1] = ny;
86 
87  // set x periodicity
88  Xperiodic = periodic_in_x;
89 
90  // set the domain pointer
91  Domain_pt = domain;
92 
93  // set the node spacing function to zero
94  Node_spacing_fn = 0;
95 
96  // builds the mesh
97  build_mesh(time_stepper_pt);
98  }
99 
100 
114  HermiteQuadMesh(const unsigned& nx,
115  const unsigned& ny,
117  const MeshSpacingFnPtr spacing_fn,
118  const bool& periodic_in_x = false,
119  TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
120  {
121  // Mesh can only be built with 2D QHermiteElements.
122  MeshChecker::assert_geometric_element<QHermiteElementBase, ELEMENT>(2);
123 
124  // set number of elements in each coordinate direction
125  Nelement.resize(2);
126  Nelement[0] = nx;
127  Nelement[1] = ny;
128 
129  // set x periodicity
130  Xperiodic = periodic_in_x;
131 
132  // set the domain pointer
133  Domain_pt = domain;
134 
135  // set the node spacing function to zero
136  Node_spacing_fn = spacing_fn;
137 
139  build_mesh(time_stepper_pt);
140  }
141 
142 
145 
146 
148  unsigned& nelement_in_dim(const unsigned& d)
149  {
150  return Nelement[d];
151  }
152 
153 
154  private:
157  void macro_coordinate_position(const unsigned& node_num_x,
158  const unsigned& node_num_y,
159  Vector<double>& macro_element_position)
160  {
161  // compute macro element position in uniformly spaced mesh
162  macro_element_position[0] = 2 * node_num_x / double(Nelement[0]) - 1;
163  macro_element_position[1] = 2 * node_num_y / double(Nelement[1]) - 1;
164 
165  // if a non unform spacing function is provided
166  if (Node_spacing_fn != 0)
167  {
168  Vector<double> temp(macro_element_position);
169  (*Node_spacing_fn)(temp, macro_element_position);
170  }
171  }
172 
173 
177  void set_position_of_node(const unsigned& node_num_x,
178  const unsigned& node_num_y,
179  Node* node_pt);
180 
181 
187  void set_position_of_boundary_node(const unsigned& node_num_x,
188  const unsigned& node_num_y,
190 
191 
199  void generalised_macro_element_position_of_node(const unsigned& node_num_x,
200  const unsigned& node_num_y,
201  DenseMatrix<double>& m_gen);
202 
203 
205  virtual void build_mesh(TimeStepper* time_stepper_pt);
206 
207 
216  {
217  std::ofstream outfile;
219  }
220 
221 
229  virtual void setup_boundary_element_info(std::ostream& outfile);
230 
231 
234 
237  bool Xperiodic;
238 
242 
245  };
246 } // namespace oomph
247 #endif
Definition: nodes.h:2242
Definition: hermite_element_quad_mesh.template.h:53
unsigned & nelement_in_dim(const unsigned &d)
Access function for number of elements in mesh in each dimension.
Definition: hermite_element_quad_mesh.template.h:148
Vector< unsigned > Nelement
number of elements in each coordinate direction
Definition: hermite_element_quad_mesh.template.h:233
void generalised_macro_element_position_of_node(const unsigned &node_num_x, const unsigned &node_num_y, DenseMatrix< double > &m_gen)
Definition: hermite_element_quad_mesh.template.cc:200
MeshSpacingFnPtr Node_spacing_fn
non uniform mesh spacing function pointer
Definition: hermite_element_quad_mesh.template.h:244
virtual void setup_boundary_element_info()
Definition: hermite_element_quad_mesh.template.h:215
void set_position_of_boundary_node(const unsigned &node_num_x, const unsigned &node_num_y, BoundaryNode< Node > *node_pt)
Definition: hermite_element_quad_mesh.template.cc:116
void macro_coordinate_position(const unsigned &node_num_x, const unsigned &node_num_y, Vector< double > &macro_element_position)
Definition: hermite_element_quad_mesh.template.h:157
~HermiteQuadMesh()
Destructor - does nothing - handled in mesh base class.
Definition: hermite_element_quad_mesh.template.h:144
void set_position_of_node(const unsigned &node_num_x, const unsigned &node_num_y, Node *node_pt)
Definition: hermite_element_quad_mesh.template.cc:48
void(* MeshSpacingFnPtr)(const Vector< double > &m_uniform_spacing, Vector< double > &m_non_uniform_spacing)
Definition: hermite_element_quad_mesh.template.h:59
HermiteQuadMesh(const unsigned &nx, const unsigned &ny, TopologicallyRectangularDomain *domain, const MeshSpacingFnPtr spacing_fn, const bool &periodic_in_x=false, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Definition: hermite_element_quad_mesh.template.h:114
HermiteQuadMesh(const unsigned &nx, const unsigned &ny, TopologicallyRectangularDomain *domain, const bool &periodic_in_x=false, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Definition: hermite_element_quad_mesh.template.h:73
bool Xperiodic
Definition: hermite_element_quad_mesh.template.h:237
TopologicallyRectangularDomain * Domain_pt
Definition: hermite_element_quad_mesh.template.h:241
virtual void build_mesh(TimeStepper *time_stepper_pt)
Generic mesh construction function to build the mesh.
Definition: hermite_element_quad_mesh.template.cc:603
Definition: mesh.h:67
static Steady< 0 > Default_TimeStepper
The Steady Timestepper.
Definition: mesh.h:75
Node *& node_pt(const unsigned long &n)
Return pointer to global node n.
Definition: mesh.h:436
Definition: nodes.h:906
Definition: timesteppers.h:231
Definition: topologically_rectangular_domain.h:51
const unsigned nx
Definition: ConstraintElementsUnitTest.cpp:30
const unsigned ny
Definition: ConstraintElementsUnitTest.cpp:31
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
SteadyAxisymAdvectionDiffusion problem on rectangular domain
Definition: steady_axisym_advection_diffusion.cc:151