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// Version 1.0; svn revision $LastChangedRevision: 1097 $
7 //LIC//
8 //LIC// $LastChangedDate: 2015-12-17 11:53:17 +0000 (Thu, 17 Dec 2015) $
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 //This header defines a class for hermite element quad mesh
31 
32 //Include guards
33 #ifndef OOMPH_HERMITE_ELEMENT_QUAD_MESH_HEADER
34 #define OOMPH_HERMITE_ELEMENT_QUAD_MESH_HEADER
35 
36 
37 // Config header generated by autoconfig
38 #ifdef HAVE_CONFIG_H
39  #include <oomph-lib-config.h>
40 #endif
41 
42 //oomph-lib headers
43 #include "../generic/hermite_elements.h"
44 #include "../generic/mesh.h"
46 
47 namespace oomph
48 {
49 
50 
51 
52 //=============================================================================
53 /// \short A two dimensional Hermite bicubic element quadrilateral mesh for
54 /// a topologically rectangular domain. The geometry of the problem must be
55 /// prescribed using the TopologicallyRectangularDomain. Non uniform node
56 /// spacing can be prescribed using a function pointer.
57 //=============================================================================
58 template <class ELEMENT> class HermiteQuadMesh :
59  public Mesh
60 {
61 
62 public:
63 
64 
65  /// \short Mesh Spacing Function Pointer - an optional function pointer
66  /// to prescibe the node spacing in a non-uniformly spaced mesh - takes the
67  /// position of a node (in macro element coordinates) in the uniformly spaced
68  /// mesh and return the position in the non-uniformly spaced mesh
69  typedef void (*MeshSpacingFnPtr)(const Vector<double>& m_uniform_spacing,
70  Vector<double>& m_non_uniform_spacing);
71 
72 
73  /// \short Mesh Constructor (for a uniformly spaced mesh). Takes the following
74  /// arguments : nx : number of elements in x direction;
75  /// ny : number of elements in y direction;
76  /// domain : topologically rectangular domain;
77  /// periodic_in_x : flag specifying if the mesh is periodic in
78  /// the x direction (default = false);
79  /// time_stepper_pt : pointer to the time stepper (default = no
80  /// timestepper);
81  HermiteQuadMesh(const unsigned &nx, const unsigned &ny,
83  const bool &periodic_in_x = false,
84  TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
85  {
86 
87  // Mesh can only be built with 2D QHermiteElements.
88  MeshChecker::assert_geometric_element<QHermiteElementBase,ELEMENT>(2);
89 
90  // set number of elements in each coordinate direction
91  Nelement.resize(2);
92  Nelement[0] = nx;
93  Nelement[1] = ny;
94 
95  // set x periodicity
96  Xperiodic = periodic_in_x;
97 
98  // set the domain pointer
99  Domain_pt = domain;
100 
101  // set the node spacing function to zero
102  Node_spacing_fn = 0;
103 
104  // builds the mesh
105  build_mesh(time_stepper_pt);
106  }
107 
108 
109  /// \short Mesh Constructor (for a non-uniformly spaced mesh). Takes the
110  /// following arguments : nx : number of elements in x direction;
111  /// ny : number of elements in y direction;
112  /// domain : topologically rectangular domain;
113  /// spacing_fn : spacing function prescribing a
114  /// non-uniformly spaced mesh
115  /// periodic_in_x : flag specifying if the mesh is
116  /// periodic in the x direction
117  /// (default = false);
118  /// time_stepper_pt : pointer to the time stepper
119  /// (default = notimestepper);
120  HermiteQuadMesh(const unsigned &nx, const unsigned &ny,
122  const MeshSpacingFnPtr spacing_fn,
123  const bool &periodic_in_x = false,
124  TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
125  {
126  // Mesh can only be built with 2D QHermiteElements.
127  MeshChecker::assert_geometric_element<QHermiteElementBase,ELEMENT>(2);
128 
129  // set number of elements in each coordinate direction
130  Nelement.resize(2);
131  Nelement[0] = nx;
132  Nelement[1] = ny;
133 
134  // set x periodicity
135  Xperiodic = periodic_in_x;
136 
137  // set the domain pointer
138  Domain_pt = domain;
139 
140  // set the node spacing function to zero
141  Node_spacing_fn = spacing_fn;
142 
143  /// build the mesh
144  build_mesh(time_stepper_pt);
145  }
146 
147 
148  /// Destructor - does nothing - handled in mesh base class
150 
151 
152  /// Access function for number of elements in mesh in each dimension
153  unsigned& nelement_in_dim(const unsigned& d)
154  {
155  return Nelement[d];
156  }
157 
158 
159 private :
160 
161  /// \short returns the macro element position of the node that is the x-th
162  /// node along from the LHS and the y-th node up from the lower edge
163  void macro_coordinate_position(const unsigned& node_num_x,
164  const unsigned& node_num_y,
165  Vector<double>& macro_element_position)
166  {
167  // compute macro element position in uniformly spaced mesh
168  macro_element_position[0] = 2*node_num_x/double(Nelement[0])-1;
169  macro_element_position[1] = 2*node_num_y/double(Nelement[1])-1;
170 
171  // if a non unform spacing function is provided
172  if (Node_spacing_fn != 0)
173  {
174  Vector<double> temp(macro_element_position);
175  (*Node_spacing_fn)(temp,macro_element_position);
176  }
177  }
178 
179 
180  /// \short sets the generalised position of the node (i.e. - x_i, dx_i/ds_0,
181  /// dx_i/ds_1 & d2x_i/ds_0ds_1 for i = 1,2). Takes the x,y coordinates of the
182  /// node from which its position can be determined.
183  void set_position_of_node(const unsigned& node_num_x,
184  const unsigned& node_num_y, Node* node_pt);
185 
186 
187  /// \short sets the generalised position of the node (i.e. - x_i, dx_i/ds_0,
188  /// dx_i/ds_1 & d2x_i/ds_0ds_1 for i = 1,2). Takes the x,y coordinates of the
189  /// node from which its position can be determined. Also sets coordinates
190  /// on boundary vector for the node to be the generalised position of the node
191  /// in macro element coordinates
192  void set_position_of_boundary_node(const unsigned& node_num_x,
193  const unsigned& node_num_y,
195 
196 
197  /// \short computes the generalised position of the node at position
198  /// (node_num_x, node_num_y) in the macro element coordinate scheme.
199  /// index 0 of m_gen : 0 - m_i
200  /// 1 - dm_i/ds_0
201  /// 2 - dm_i/ds_1
202  /// 3 - d2m_i/ds_0ds_1 (where i is index 1 of m_gen)
203  void generalised_macro_element_position_of_node(const unsigned& node_num_x,
204  const unsigned& node_num_y,
205  DenseMatrix<double>& m_gen);
206 
207 
208  /// \short Generic mesh construction function to build the mesh
209  virtual void build_mesh(TimeStepper* time_stepper_pt);
210 
211 
212  /// Setup lookup schemes which establish whic elements are located
213  /// next to mesh's boundaries (wrapper to suppress doc).
214  /// Specific version for HermiteQuadMesh to ensure that the order of the
215  /// elements in Boundary_element_pt matches the actual order along the
216  /// boundary. This is required when hijacking the BiharmonicElement to apply
217  /// the BiharmonicFluidBoundaryElement in
218  /// BiharmonicFluidProblem::impose_traction_free_edge(...)
220  {
221  std::ofstream outfile;
223  }
224 
225 
226  /// \short Setup lookup schemes which establish which elements are located
227  /// next to which boundaries (Doc to outfile if it's open).
228  /// Specific version for HermiteQuadMesh to ensure that the order of the
229  /// elements in Boundary_element_pt matches the actual order along the
230  /// boundary. This is required when hijacking the BiharmonicElement to apply
231  /// the BiharmonicFluidBoundaryElement in
232  /// BiharmonicFluidProblem::impose_traction_free_edge(...)
233  virtual void setup_boundary_element_info(std::ostream &outfile);
234 
235 
236  /// \short number of elements in each coordinate direction
238 
239  /// \short boolean variable to determine whether the mesh is periodic in the
240  /// x-direction
241  bool Xperiodic;
242 
243  /// \short Pointer to the topologically rectangular domain which prescribes
244  /// the problem domain
246 
247  /// non uniform mesh spacing function pointer
249 };
250 }
251 #endif
static Steady< 0 > Default_TimeStepper
Default Steady Timestepper, to be used in default arguments to Mesh constructors. ...
Definition: mesh.h:85
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 = ...
A two dimensional Hermite bicubic element quadrilateral mesh for a topologically rectangular domain...
~HermiteQuadMesh()
Destructor - does nothing - handled in mesh base class.
virtual void build_mesh(TimeStepper *time_stepper_pt)
Generic mesh construction function to build the mesh.
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
Definition: nodes.h:852
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...
MeshSpacingFnPtr Node_spacing_fn
non uniform mesh spacing function pointer
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 ...
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 = ...
A template Class for BoundaryNodes; that is Nodes that MAY live on the boundary of a Mesh...
Definition: nodes.h:67
TopologicallyRectangularDomain * Domain_pt
Pointer to the topologically rectangular domain which prescribes the problem domain.
unsigned & nelement_in_dim(const unsigned &d)
Access function for number of elements in mesh in each dimension.
Topologically Rectangular Domain - a domain dexcribing a topologically rectangular problem - primaril...
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...
Node *& node_pt(const unsigned long &n)
Return pointer to global node n.
Definition: mesh.h:456
bool Xperiodic
boolean variable to determine whether the mesh is periodic in the x-direction
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...
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...
Vector< unsigned > Nelement
number of elements in each coordinate direction
Base class for time-stepping schemes. Timestepper provides an approximation of the temporal derivativ...
Definition: timesteppers.h:219
A general mesh class.
Definition: mesh.h:74