hermite_element_quad_mesh.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-2025 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// Config header
33#ifdef HAVE_CONFIG_H
34#include <oomph-lib-config.h>
35#endif
36
37// oomph-lib headers
39#include "generic/mesh.h"
40
41// Include the domain header
43
44namespace oomph
45{
46 //=============================================================================
47 /// A two dimensional Hermite bicubic element quadrilateral mesh for
48 /// a topologically rectangular domain. The geometry of the problem must be
49 /// prescribed using the TopologicallyRectangularDomain. Non uniform node
50 /// spacing can be prescribed using a function pointer.
51 //=============================================================================
52 template<class ELEMENT>
53 class HermiteQuadMesh : public Mesh
54 {
55 public:
56 /// Mesh Spacing Function Pointer - an optional function pointer
57 /// to prescibe the node spacing in a non-uniformly spaced mesh - takes the
58 /// position of a node (in macro element coordinates) in the uniformly
59 /// spaced mesh and return the position in the non-uniformly spaced mesh
62
63
64 /// Mesh Constructor (for a uniformly spaced mesh). Takes the
65 /// following arguments : nx : number of elements in x
66 /// direction;
67 /// ny : number of elements in y direction;
68 /// domain : topologically rectangular domain;
69 /// periodic_in_x : flag specifying if the mesh is periodic
70 /// in
71 /// the x direction (default = false);
72 /// time_stepper_pt : pointer to the time stepper (default = no
73 /// timestepper);
74 HermiteQuadMesh(const unsigned& nx,
75 const unsigned& ny,
77 const bool& periodic_in_x = false,
78 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
79 {
80 // Mesh can only be built with 2D QHermiteElements.
81 MeshChecker::assert_geometric_element<QHermiteElementBase, ELEMENT>(2);
82
83 // set number of elements in each coordinate direction
84 Nelement.resize(2);
85 Nelement[0] = nx;
86 Nelement[1] = ny;
87
88 // set x periodicity
90
91 // set the domain pointer
93
94 // set the node spacing function to zero
96
97 // builds the mesh
98 build_mesh(time_stepper_pt);
99 }
100
101
102 /// Mesh Constructor (for a non-uniformly spaced mesh). Takes the
103 /// following arguments : nx : number of elements in x
104 /// direction;
105 /// ny : number of elements in y
106 /// direction; domain : topologically
107 /// rectangular domain; spacing_fn : spacing
108 /// function prescribing a
109 /// non-uniformly spaced mesh
110 /// periodic_in_x : flag specifying if the mesh is
111 /// periodic in the x direction
112 /// (default = false);
113 /// time_stepper_pt : pointer to the time stepper
114 /// (default = notimestepper);
115 HermiteQuadMesh(const unsigned& nx,
116 const unsigned& ny,
119 const bool& periodic_in_x = false,
120 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
121 {
122 // Mesh can only be built with 2D QHermiteElements.
123 MeshChecker::assert_geometric_element<QHermiteElementBase, ELEMENT>(2);
124
125 // set number of elements in each coordinate direction
126 Nelement.resize(2);
127 Nelement[0] = nx;
128 Nelement[1] = ny;
129
130 // set x periodicity
132
133 // set the domain pointer
135
136 // set the node spacing function to zero
138
139 /// build the mesh
140 build_mesh(time_stepper_pt);
141 }
142
143 /// Destructor - does nothing - handled in mesh base class
145
146 /// Access function for number of elements in mesh in each dimension
147 unsigned& nelement_in_dim(const unsigned& d)
148 {
149 return Nelement[d];
150 }
151
152 private:
153 /// returns the macro element position of the node that is the x-th
154 /// node along from the LHS and the y-th node up from the lower edge
156 const unsigned& node_num_y,
158 {
159 // compute macro element position in uniformly spaced mesh
162
163 // if a non unform spacing function is provided
164 if (Node_spacing_fn != 0)
165 {
167 (*Node_spacing_fn)(temp, macro_element_position);
168 }
169 }
170
171
172 /// sets the generalised position of the node (i.e. - x_i, dx_i/ds_0,
173 /// dx_i/ds_1 & d2x_i/ds_0ds_1 for i = 1,2). Takes the x,y coordinates of
174 /// the node from which its position can be determined.
175 void set_position_of_node(const unsigned& node_num_x,
176 const unsigned& node_num_y,
177 Node* node_pt);
178
179
180 /// 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
182 /// the node from which its position can be determined. Also sets
183 /// coordinates on boundary vector for the node to be the generalised
184 /// position of the node in macro element coordinates
185 void set_position_of_boundary_node(const unsigned& node_num_x,
186 const unsigned& node_num_y,
188
189
190 /// computes the generalised position of the node at position
191 /// (node_num_x, node_num_y) in the macro element coordinate scheme.
192 /// index 0 of m_gen : 0 - m_i
193 /// 1 - dm_i/ds_0
194 /// 2 - dm_i/ds_1
195 /// 3 - d2m_i/ds_0ds_1 (where i is index 1 of
196 /// m_gen)
198 const unsigned& node_num_y,
200
201
202 /// Generic mesh construction function to build the mesh
203 virtual void build_mesh(TimeStepper* time_stepper_pt);
204
205 /// Setup lookup schemes which establish whic elements are located
206 /// next to mesh's boundaries (wrapper to suppress doc).
207 /// Specific version for HermiteQuadMesh to ensure that the order of the
208 /// elements in Boundary_element_pt matches the actual order along the
209 /// boundary. This is required when hijacking the BiharmonicElement to apply
210 /// the BiharmonicFluidBoundaryElement in
211 /// BiharmonicFluidProblem::impose_traction_free_edge(...)
213 {
214 std::ofstream outfile;
216 }
217
218
219 /// Setup lookup schemes which establish which elements are located
220 /// next to which boundaries (Doc to outfile if it's open).
221 /// Specific version for HermiteQuadMesh to ensure that the order of the
222 /// elements in Boundary_element_pt matches the actual order along the
223 /// boundary. This is required when hijacking the BiharmonicElement to apply
224 /// the BiharmonicFluidBoundaryElement in
225 /// BiharmonicFluidProblem::impose_traction_free_edge(...)
226 virtual void setup_boundary_element_info(std::ostream& outfile);
227
228
229 /// number of elements in each coordinate direction
231
232 /// boolean variable to determine whether the mesh is periodic in the
233 /// x-direction
235
236 /// Pointer to the topologically rectangular domain which prescribes
237 /// the problem domain
239
240 /// non uniform mesh spacing function pointer
242 };
243} // namespace oomph
245#endif
A two dimensional Hermite bicubic element quadrilateral mesh for a topologically rectangular domain....
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
unsigned & nelement_in_dim(const unsigned &d)
Access function for number of elements in mesh in each dimension.
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:440
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
Definition nodes.h:906
TAdvectionDiffusionReactionElement<NREAGENT,DIM,NNODE_1D> elements are isoparametric triangular DIM-d...
Base class for time-stepping schemes. Timestepper provides an approximation of the temporal derivativ...
Topologically Rectangular Domain - a domain dexcribing a topologically rectangular problem - primaril...
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).