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-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 // 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  //=============================================================================
46  /// A two dimensional Hermite bicubic element quadrilateral mesh for
47  /// a topologically rectangular domain. The geometry of the problem must be
48  /// prescribed using the TopologicallyRectangularDomain. Non uniform node
49  /// spacing can be prescribed using a function pointer.
50  //=============================================================================
51  template<class ELEMENT>
52  class HermiteQuadMesh : public Mesh
53  {
54  public:
55  /// Mesh Spacing Function Pointer - an optional function pointer
56  /// to prescibe the node spacing in a non-uniformly spaced mesh - takes the
57  /// position of a node (in macro element coordinates) in the uniformly
58  /// spaced mesh and return the position in the non-uniformly spaced mesh
59  typedef void (*MeshSpacingFnPtr)(const Vector<double>& m_uniform_spacing,
60  Vector<double>& m_non_uniform_spacing);
61 
62 
63  /// Mesh Constructor (for a uniformly spaced mesh). Takes the
64  /// following arguments : nx : number of elements in x
65  /// direction;
66  /// ny : number of elements in y direction;
67  /// domain : topologically rectangular domain;
68  /// periodic_in_x : flag specifying if the mesh is periodic
69  /// in
70  /// the x direction (default = false);
71  /// time_stepper_pt : pointer to the time stepper (default = no
72  /// timestepper);
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 
101  /// Mesh Constructor (for a non-uniformly spaced mesh). Takes the
102  /// following arguments : nx : number of elements in x
103  /// direction;
104  /// ny : number of elements in y
105  /// direction; domain : topologically
106  /// rectangular domain; spacing_fn : spacing
107  /// function prescribing a
108  /// non-uniformly spaced mesh
109  /// periodic_in_x : flag specifying if the mesh is
110  /// periodic in the x direction
111  /// (default = false);
112  /// time_stepper_pt : pointer to the time stepper
113  /// (default = notimestepper);
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 
138  /// build the mesh
139  build_mesh(time_stepper_pt);
140  }
141 
142 
143  /// Destructor - does nothing - handled in mesh base class
145 
146 
147  /// Access function for number of elements in mesh in each dimension
148  unsigned& nelement_in_dim(const unsigned& d)
149  {
150  return Nelement[d];
151  }
152 
153 
154  private:
155  /// returns the macro element position of the node that is the x-th
156  /// node along from the LHS and the y-th node up from the lower edge
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 
174  /// sets the generalised position of the node (i.e. - x_i, dx_i/ds_0,
175  /// dx_i/ds_1 & d2x_i/ds_0ds_1 for i = 1,2). Takes the x,y coordinates of
176  /// the node from which its position can be determined.
177  void set_position_of_node(const unsigned& node_num_x,
178  const unsigned& node_num_y,
179  Node* node_pt);
180 
181 
182  /// sets the generalised position of the node (i.e. - x_i, dx_i/ds_0,
183  /// dx_i/ds_1 & d2x_i/ds_0ds_1 for i = 1,2). Takes the x,y coordinates of
184  /// the node from which its position can be determined. Also sets
185  /// coordinates on boundary vector for the node to be the generalised
186  /// position of the node in macro element coordinates
187  void set_position_of_boundary_node(const unsigned& node_num_x,
188  const unsigned& node_num_y,
190 
191 
192  /// computes the generalised position of the node at position
193  /// (node_num_x, node_num_y) in the macro element coordinate scheme.
194  /// index 0 of m_gen : 0 - m_i
195  /// 1 - dm_i/ds_0
196  /// 2 - dm_i/ds_1
197  /// 3 - d2m_i/ds_0ds_1 (where i is index 1 of
198  /// m_gen)
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 
204  /// Generic mesh construction function to build the mesh
205  virtual void build_mesh(TimeStepper* time_stepper_pt);
206 
207 
208  /// Setup lookup schemes which establish whic elements are located
209  /// next to mesh's boundaries (wrapper to suppress doc).
210  /// Specific version for HermiteQuadMesh to ensure that the order of the
211  /// elements in Boundary_element_pt matches the actual order along the
212  /// boundary. This is required when hijacking the BiharmonicElement to apply
213  /// the BiharmonicFluidBoundaryElement in
214  /// BiharmonicFluidProblem::impose_traction_free_edge(...)
216  {
217  std::ofstream outfile;
219  }
220 
221 
222  /// Setup lookup schemes which establish which elements are located
223  /// next to which boundaries (Doc to outfile if it's open).
224  /// Specific version for HermiteQuadMesh to ensure that the order of the
225  /// elements in Boundary_element_pt matches the actual order along the
226  /// boundary. This is required when hijacking the BiharmonicElement to apply
227  /// the BiharmonicFluidBoundaryElement in
228  /// BiharmonicFluidProblem::impose_traction_free_edge(...)
229  virtual void setup_boundary_element_info(std::ostream& outfile);
230 
231 
232  /// number of elements in each coordinate direction
234 
235  /// boolean variable to determine whether the mesh is periodic in the
236  /// x-direction
237  bool Xperiodic;
238 
239  /// Pointer to the topologically rectangular domain which prescribes
240  /// the problem domain
242 
243  /// non uniform mesh spacing function pointer
245  };
246 } // namespace oomph
247 #endif
A template Class for BoundaryNodes; that is Nodes that MAY live on the boundary of a Mesh....
Definition: nodes.h:2242
A two dimensional Hermite bicubic element quadrilateral mesh for a topologically rectangular domain....
unsigned & nelement_in_dim(const unsigned &d)
Access function for number of elements in mesh in each dimension.
Vector< unsigned > Nelement
number of elements in each coordinate direction
void generalised_macro_element_position_of_node(const unsigned &node_num_x, const unsigned &node_num_y, DenseMatrix< double > &m_gen)
computes the generalised position of the node at position (node_num_x, node_num_y) in the macro eleme...
MeshSpacingFnPtr Node_spacing_fn
non uniform mesh spacing function pointer
virtual void setup_boundary_element_info()
Setup lookup schemes which establish whic elements are located next to mesh's boundaries (wrapper to ...
void set_position_of_boundary_node(const unsigned &node_num_x, const unsigned &node_num_y, BoundaryNode< Node > *node_pt)
sets the generalised position of the node (i.e. - x_i, dx_i/ds_0, dx_i/ds_1 & d2x_i/ds_0ds_1 for i = ...
void macro_coordinate_position(const unsigned &node_num_x, const unsigned &node_num_y, Vector< double > &macro_element_position)
returns the macro element position of the node that is the x-th node along from the LHS and the y-th ...
~HermiteQuadMesh()
Destructor - does nothing - handled in mesh base class.
void set_position_of_node(const unsigned &node_num_x, const unsigned &node_num_y, Node *node_pt)
sets the generalised position of the node (i.e. - x_i, dx_i/ds_0, dx_i/ds_1 & d2x_i/ds_0ds_1 for i = ...
void(* MeshSpacingFnPtr)(const Vector< double > &m_uniform_spacing, Vector< double > &m_non_uniform_spacing)
Mesh Spacing Function Pointer - an optional function pointer to prescibe the node spacing in a non-un...
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)
Mesh Constructor (for a non-uniformly spaced mesh). Takes the following arguments : nx : number of el...
HermiteQuadMesh(const unsigned &nx, const unsigned &ny, TopologicallyRectangularDomain *domain, const bool &periodic_in_x=false, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Mesh Constructor (for a uniformly spaced mesh). Takes the following arguments : nx : number of elemen...
bool Xperiodic
boolean variable to determine whether the mesh is periodic in the x-direction
TopologicallyRectangularDomain * Domain_pt
Pointer to the topologically rectangular domain which prescribes the problem domain.
virtual void build_mesh(TimeStepper *time_stepper_pt)
Generic mesh construction function to build the mesh.
A general mesh class.
Definition: mesh.h:67
static Steady< 0 > Default_TimeStepper
Default Steady Timestepper, to be used in default arguments to Mesh constructors.
Definition: mesh.h:75
Node *& node_pt(const unsigned long &n)
Return pointer to global node n.
Definition: mesh.h:436
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
Definition: nodes.h:906
////////////////////////////////////////////////////////////////////// //////////////////////////////...
Definition: timesteppers.h:231
Topologically Rectangular Domain - a domain dexcribing a topologically rectangular problem - primaril...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...