two_layer_spine_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$
7 //LIC//
8 //LIC// $LastChangedDate$
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 #ifndef OOMPH_TWO_LAYER_SPINE_MESH_HEADER
31 #define OOMPH_TWO_LAYER_SPINE_MESH_HEADER
32 
33 
34 // The mesh
35 #include "../generic/spines.h"
37 
38 namespace oomph
39 {
40 
41 
42 //======================================================================
43 /// Two-layer spine mesh class derived from standard 2D mesh.
44 /// The mesh contains two layers of spinified fluid elements (of type ELEMENT;
45 /// e.g SpineElement<QCrouzeixRaviartElement<2>).
46 ///
47 /// This mesh paritions the elements into those above and below a
48 /// notional interface and relabels boundaries so that the mesh is as follows
49 /// 3
50 /// ---------------------------------------
51 /// | |
52 /// 4 | | 2
53 /// | 6 |
54 /// ---------------------------------------
55 /// | |
56 /// 5 | | 1
57 /// | |
58 /// ---------------------------------------
59 /// 0
60 /// Update information for the nodes in response to changes in spine length
61 /// is given, but additional equations must be specified in order to
62 /// completely specify the problem.
63 //======================================================================
64 template <class ELEMENT>
65 class TwoLayerSpineMesh : public RectangularQuadMesh<ELEMENT >,
66  public SpineMesh
67 {
68 
69 public:
70 
71  /// \short Constructor: Pass number of elements in x-direction, number of
72  /// elements in y-direction in bottom and top layer, respectively,
73  /// axial length and height of top and bottom layers and pointer
74  /// to timestepper (defaults to Steady timestepper)
75  TwoLayerSpineMesh(const unsigned &nx,
76  const unsigned &ny1,
77  const unsigned &ny2,
78  const double &lx,
79  const double &h1,
80  const double &h2,
81  TimeStepper* time_stepper_pt=
83 
84 
85  /// \short Constructor: Pass number of elements in x-direction, number of
86  /// elements in y-direction in bottom and top layer, respectively,
87  /// axial length and height of top and bottom layers, a boolean
88  /// flag to make the mesh periodic in the x-direction, and pointer
89  /// to timestepper (defaults to Steady timestepper)
90  TwoLayerSpineMesh(const unsigned &nx,
91  const unsigned &ny1,
92  const unsigned &ny2,
93  const double &lx,
94  const double &h1,
95  const double &h2,
96  const bool& periodic_in_x,
97  TimeStepper* time_stepper_pt=
99 
100 
101  /// \short Constructor: Pass number of elements in x-direction, number of
102  /// elements in y-direction in bottom and top layer, respectively,
103  /// axial length and height of top and bottom layers, a boolean
104  /// flag to make the mesh periodic in the x-direction, a boolean flag to
105  /// specify whether or not to call the "build_two_layer_mesh" function,
106  /// and pointer to timestepper (defaults to Steady timestepper)
107  TwoLayerSpineMesh(const unsigned &nx,
108  const unsigned &ny1,
109  const unsigned &ny2,
110  const double &lx,
111  const double &h1,
112  const double &h2,
113  const bool& periodic_in_x,
114  const bool& build_mesh,
115  TimeStepper* time_stepper_pt=
117 
118  ///Access functions for pointers to elements in upper layer
119  FiniteElement* &upper_layer_element_pt(const unsigned long &i)
120  {return Upper_layer_element_pt[i];}
121 
122  ///Access functions for pointers to elements in bottom layer
123  FiniteElement* &lower_layer_element_pt(const unsigned long &i)
124  {return Lower_layer_element_pt[i];}
125 
126  ///Number of elements in upper layer
127  unsigned long nupper() const {return Upper_layer_element_pt.size();}
128 
129  ///Number of elements in top layer
130  unsigned long nlower() const {return Lower_layer_element_pt.size();}
131 
132  ///Access functions for pointers to elements in upper layer
135 
136  ///Access functions for pointers to elements in bottom layer
139 
140  ///Number of elements in upper layer
141  unsigned long ninterface_upper() const
142  {return Interface_upper_boundary_element_pt.size();}
143 
144  ///Number of elements in top layer
145  unsigned long ninterface_lower() const
146  {return Interface_lower_boundary_element_pt.size();}
147 
148  ///\short Index of the face of the elements next to the interface
149  ///in the upper region (always -2)
151  {return -2;}
152 
153  ///\short Index of the face of the elements next to the interface in
154  /// the lower region (always 2)
156  {return 2;}
157 
158  /// \short General node update function implements pure virtual function
159  /// defined in SpineMesh base class and performs specific update
160  /// actions, depending on the node update fct id stored for each node.
161  void spine_node_update(SpineNode* spine_node_pt)
162  {
163  unsigned id=spine_node_pt->node_update_fct_id();
164  switch(id)
165  {
166  case 0:
167  spine_node_update_lower(spine_node_pt);
168  break;
169 
170  case 1:
171  spine_node_update_upper(spine_node_pt);
172  break;
173 
174  default:
175  std::ostringstream error_message;
176  error_message << "Unknown id passed to spine_node_update " << id
177  << std::endl;
178  throw OomphLibError(error_message.str(),
179  OOMPH_CURRENT_FUNCTION,
180  OOMPH_EXCEPTION_LOCATION);
181  }
182  }
183 
184 
185 
186 protected:
187 
188  /// Number of elements in lower layer
189  unsigned Ny1;
190 
191  /// Number of elements in upper layer
192  unsigned Ny2;
193 
194  /// \short Height of the lower layer
195  double H1;
196 
197  /// \short Height of the upper layer
198  double H2;
199 
200  /// Vector of pointers to element in the upper layer
202 
203  /// Vector of pointers to element in the lower layer
205 
206  /// \short Vector of pointers to the elements adjacent to the interface
207  /// on the lower layer
209 
210  /// \short Vector of pointers to the element adjacent to the interface
211  /// on the upper layer
213 
214 
215  /// \short The spacing function for the x co-ordinates with two
216  /// regions.
217  double x_spacing_function(unsigned xelement, unsigned xnode,
218  unsigned yelement, unsigned ynode);
219 
220  /// \short The spacing function for the y co-ordinates with three
221  /// regions in each fluid.
222  double y_spacing_function(unsigned xelement, unsigned xnode,
223  unsigned yelement, unsigned ynode);
224 
225  /// \short Update function for the lower part of the domain
226  void spine_node_update_lower(SpineNode *spine_node_pt)
227  {
228  //Get fraction along the spine
229  double W = spine_node_pt->fraction();
230  //Get spine height
231  double H = spine_node_pt->h();
232  //Set the value of y
233  spine_node_pt->x(1) = this->Ymin + W*H;
234  }
235 
236 
237  /// \short Update function for the upper part of the domain
238  void spine_node_update_upper(SpineNode *spine_node_pt)
239  {
240  //Get fraction alon the spine
241  double W = spine_node_pt->fraction();
242 
243  //Get spine height
244  double H = spine_node_pt->h();
245 
246  //Set the value of y
247  spine_node_pt->x(1) = (this->Ymin+H) + W *(this->Ymax - (this->Ymin+H) );
248  }
249 
250  /// \short Helper function to actually build the two-layer spine mesh
251  /// (called from various constructors)
252  virtual void build_two_layer_mesh(TimeStepper* time_stepper_pt);
253 
254 };
255 
256 }
257 
258 #endif
259 
Vector< FiniteElement * > Lower_layer_element_pt
Vector of pointers to element in the upper layer.
const unsigned & nx() const
Return number of elements in x direction.
int interface_lower_face_index_at_boundary(const unsigned &e)
Index of the face of the elements next to the interface in the lower region (always 2) ...
FiniteElement *& interface_lower_boundary_element_pt(const unsigned long &i)
Access functions for pointers to elements in bottom layer.
unsigned long nlower() const
Number of elements in top layer.
static Steady< 0 > Default_TimeStepper
Default Steady Timestepper, to be used in default arguments to Mesh constructors. ...
Definition: mesh.h:85
void spine_node_update(SpineNode *spine_node_pt)
General node update function implements pure virtual function defined in SpineMesh base class and per...
virtual void build_two_layer_mesh(TimeStepper *time_stepper_pt)
Helper function to actually build the two-layer spine mesh (called from various constructors) ...
cstr elem_len * i
Definition: cfortran.h:607
double & fraction()
Set reference to fraction along spine.
Definition: spines.h:350
A general Finite Element class.
Definition: elements.h:1274
double y_spacing_function(unsigned xelement, unsigned xnode, unsigned yelement, unsigned ynode)
The spacing function for the y co-ordinates with three regions in each fluid.
unsigned & node_update_fct_id()
Access function to ID of node update function (within specific mesh)
Definition: spines.h:353
FiniteElement *& interface_upper_boundary_element_pt(const unsigned long &i)
Access functions for pointers to elements in upper layer.
FiniteElement *& upper_layer_element_pt(const unsigned long &i)
Access functions for pointers to elements in upper layer.
unsigned long ninterface_lower() const
Number of elements in top layer.
e
Definition: cfortran.h:575
unsigned long nupper() const
Number of elements in upper layer.
TwoLayerSpineMesh(const unsigned &nx, const unsigned &ny1, const unsigned &ny2, const double &lx, const double &h1, const double &h2, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor: Pass number of elements in x-direction, number of elements in y-direction in bottom and ...
FiniteElement *& lower_layer_element_pt(const unsigned long &i)
Access functions for pointers to elements in bottom layer.
double & x(const unsigned &i)
Return the i-th nodal coordinate.
Definition: nodes.h:995
int interface_upper_face_index_at_boundary(const unsigned &e)
Index of the face of the elements next to the interface in the upper region (always -2) ...
void spine_node_update_upper(SpineNode *spine_node_pt)
Update function for the upper part of the domain.
unsigned Ny2
Number of elements in upper layer.
unsigned Ny1
Number of elements in lower layer.
Vector< FiniteElement * > Interface_lower_boundary_element_pt
Vector of pointers to the elements adjacent to the interface on the lower layer.
Vector< FiniteElement * > Upper_layer_element_pt
Vector of pointers to element in the lower layer.
double H1
Height of the lower layer.
double H2
Height of the upper layer.
unsigned long ninterface_upper() const
Number of elements in upper layer.
void build_mesh(TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Generic mesh construction function: contains all the hard work.
Vector< FiniteElement * > Interface_upper_boundary_element_pt
Vector of pointers to the element adjacent to the interface on the upper layer.
double & h()
Access function to spine height.
Definition: spines.h:363
double Ymax
Maximum value of y coordinate.
double x_spacing_function(unsigned xelement, unsigned xnode, unsigned yelement, unsigned ynode)
The spacing function for the x co-ordinates with two regions.
void spine_node_update_lower(SpineNode *spine_node_pt)
Update function for the lower part of the domain.
Base class for time-stepping schemes. Timestepper provides an approximation of the temporal derivativ...
Definition: timesteppers.h:219
double Ymin
Minimum value of y coordinate.