channel_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: 1104 $
7 //LIC//
8 //LIC// $LastChangedDate: 2016-01-09 08:06:50 +0000 (Sat, 09 Jan 2016) $
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_CHANNEL_SPINE_MESH_HEADER
31 #define OOMPH_CHANNEL_SPINE_MESH_HEADER
32 
33 // oomph-lib includes
34 #include "../generic/spines.h"
36 
37 namespace oomph
38 {
39 
40 //======================================================================
41 /// Spine mesh class derived from standard 2D mesh.
42 /// The mesh contains a StraightLine GeomObject which defines the height
43 /// of the left and right regions (0,2) and another GeomObject is passed
44 /// to the constructor to define the height in the central region.
45 //======================================================================
46 template <class ELEMENT>
47 class ChannelSpineMesh : public RectangularQuadMesh<ELEMENT >, public SpineMesh
48 {
49 
50 public:
51 
52  /// \short Constructor: Pass number of elements in x-direction in regions
53  /// 0,1 and 2, number of elements in y-direction, length in x direction in
54  /// regions 0,1 and 2, height mesh, pointer to the GeomObject defining the
55  /// heightof the central region and pointer to timestepper (defaults to
56  /// Steady timestepper)
57  ChannelSpineMesh(const unsigned &nx0,
58  const unsigned &nx1,
59  const unsigned &nx2,
60  const unsigned &ny,
61  const double &lx0,
62  const double &lx1,
63  const double &lx2,
64  const double &h,
66  TimeStepper* time_stepper_pt=&Mesh::Default_TimeStepper);
67 
68  /// \short Constructor: Pass number of elements in x-direction in regions
69  /// 0,1 and 2, number of elements in y-direction, length in x direction in
70  /// regions 0,1 and 2, height mesh, pointer to the GeomObject defining the
71  /// heightof the central region, a boolean flag to indicate whether or not
72  /// the mesh is periodic and pointer to timestepper (defaults to Steady
73  /// timestepper)
74  ChannelSpineMesh(const unsigned &nx0,
75  const unsigned &nx1,
76  const unsigned &nx2,
77  const unsigned &ny,
78  const double &lx0,
79  const double &lx1,
80  const double &lx2,
81  const double &h,
82  GeomObject* wall_pt,
83  const bool& periodic_in_x,
84  TimeStepper* time_stepper_pt=&Mesh::Default_TimeStepper);
85 
86  /// \short Access functions for pointers to the \f$ i \f$ -th element in
87  /// the left region.
88  FiniteElement* &left_element_pt(const unsigned long &i)
89  {return Left_element_pt[i];}
90 
91  /// \short Access functions for pointers to the \f$ i \f$ -th element in
92  /// the centre region.
93  FiniteElement* &centre_element_pt(const unsigned long &i)
94  {return Centre_element_pt[i];}
95 
96  /// \short Access functions for pointers to the \f$ i \f$ -th element in
97  /// the right region.
98  FiniteElement* &right_element_pt(const unsigned long &i)
99  {return Right_element_pt[i];}
100 
101  /// Number of elements in left region
102  unsigned long nleft() const {return Left_element_pt.size();}
103 
104  /// Number of elements in centre region
105  unsigned long ncentre() const {return Centre_element_pt.size();}
106 
107  /// Number of elements in right region
108  unsigned long nright() const {return Right_element_pt.size();}
109 
110  /// Number of elements in bulk
111  unsigned long nbulk() const
112  {
113  unsigned long Nbulk=Left_element_pt.size()+
114  Centre_element_pt.size()+Right_element_pt.size();
115  return Nbulk;
116  }
117 
118  /// \short Reorder the elements so we loop over them vertically first
119  /// (advantageous in "wide" domains if a frontal solver is used).
120  void element_reorder();
121 
122  /// \short General node update function implements pure virtual function
123  /// defined in SpineMesh base class and performs specific node update
124  /// actions: along vertical spines
125  virtual void spine_node_update(SpineNode* spine_node_pt)
126  {
127  // Get spine node's fraction along the spine
128  double W = spine_node_pt->fraction();
129 
130  // Get local coordinates
131  Vector<double> s_wall(1);
132  s_wall[0] = spine_node_pt->spine_pt()->geom_parameter(0);
133 
134  // Get position vector to wall
135  Vector<double> position(2);
136  spine_node_pt->spine_pt()->geom_object_pt(0)->position(s_wall,position);
137 
138  //Set the value of y
139  spine_node_pt->x(1) = this->Ymin + W*position[1];
140  }
141 
142  /// \short Return the value of the x-coordinate at the node given by the
143  /// local node number (xnode, ynode) in the element (xelement,yelement).
144  /// The description is in a "psudeo" two-dimensional coordinate system,
145  /// so the range of xelement is [0,Nx-1], yelement is [0,Ny-1], and
146  /// that of xnode and ynode is [0,Np-1]. The default is to return
147  /// nodes that are equally spaced in the x coodinate.
148  virtual double x_spacing_function(unsigned xelement, unsigned xnode,
149  unsigned yelement, unsigned ynode)
150  {
151  // Calculate the values of equal increments in nodal values in left region
152  double xstep1 = Lx0/((this->Np-1)*Nx0);
153  // Calculate the values of equal increments in nodal values in centre region
154  double xstep2 = Lx1/((this->Np-1)*Nx1);
155  // Calculate the values of equal increments in nodal values in right region
156  double xstep3 = Lx2/((this->Np-1)*Nx2);
157 
158  // left region
159  if (xelement<Nx0)
160  {
161  //Return the appropriate value
162  return (this->Xmin + xstep1*((this->Np-1)*xelement + xnode));
163  }
164  // centre region
165  else if (xelement<Nx0+Nx1)
166  {
167  //Return the appropriate value
168  return (Lx0 + xstep2*((this->Np-1)*(xelement-Nx0) + xnode));
169  }
170  // right region
171  else if (xelement<Nx0+Nx1+Nx2)
172  {
173  //Return the appropriate value
174  return (Lx0+Lx1 + xstep3*((this->Np-1)*(xelement-Nx0-Nx1) + xnode));
175  }
176  else
177  {
178  throw OomphLibError("Should not have got here",
179  OOMPH_CURRENT_FUNCTION,
180  OOMPH_EXCEPTION_LOCATION);
181  }
182  // Dummy return to keep compiler from barking
183  return 0.0;
184  }
185 
186  /// Access function for spines in left region
187  Spine*& left_spine_pt(const unsigned long &i)
188  {
189 #ifdef PARNOID
190  if (i>Nleft_spine)
191  {
192  throw OomphLibError("Arguemnt out of range",
193  OOMPH_CURRENT_FUNCTION,
194  OOMPH_EXCEPTION_LOCATION);
195  }
196 #endif
197  return Spine_pt[i];
198  }
199 
200  /// Access function for spines in centre region
201  Spine*& centre_spine_pt(const unsigned long &i)
202  {
203  if (i>Ncentre_spine)
204  {
205  throw OomphLibError("Arguemnt out of range",
206  OOMPH_CURRENT_FUNCTION,
207  OOMPH_EXCEPTION_LOCATION);
208  }
209  else
210  {
211  return Spine_pt[Nleft_spine+i];
212  }
213  }
214 
215  /// Access function for spines in right region
216  Spine*& right_spine_pt(const unsigned long &i)
217  {
218  if (i>Nright_spine)
219  {
220  throw OomphLibError("Arguemnt out of range",
221  OOMPH_CURRENT_FUNCTION,
222  OOMPH_EXCEPTION_LOCATION);
223  }
224  else
225  {
227  }
228  }
229 
230  /// Access function for the number of spines in the left region
231  unsigned nleft_spine() {return Nleft_spine;}
232 
233  /// Access function for the number of spines in the centre region
234  unsigned ncentre_spine() {return Ncentre_spine;}
235 
236  /// Access function for the number of spines in the right region
237  unsigned nright_spine() {return Nright_spine;}
238 
239  /// Access function to the GeomObject for upper wall
240  GeomObject* wall_pt() { return Wall_pt; }
241 
242  /// Access function to the GeomObject for the straight upper wall
244 
245 protected:
246 
247  /// Vector of pointers to element in the left region
249 
250  /// Vector of pointers to element in the centre region
252 
253  /// Vector of pointers to element in the right region
255 
256  /// \short Helper function to actually build the channel-spine mesh
257  /// (called from various constructors)
258  virtual void build_channel_spine_mesh(TimeStepper* time_stepper_pt);
259 
260  /// Number of elements in the left region
261  unsigned Nx0;
262 
263  /// Number of elements in the centre region
264  unsigned Nx1;
265 
266  /// Number of elements in the right region
267  unsigned Nx2;
268 
269  /// Length of left region
270  double Lx0;
271 
272  /// Length of centre region
273  double Lx1;
274 
275  /// Length of right region
276  double Lx2;
277 
278  /// Number of spines in left region
279  unsigned Nleft_spine;
280 
281  /// Number of spines in centre region
282  unsigned Ncentre_spine;
283 
284  /// Number of spines in right region
285  unsigned Nright_spine;
286 
287  /// GeomObject for upper wall
289 
290  /// GeomObject for the straight upper wall
292 
293 };
294 
295 }
296 
297 #endif
GeomObject * straight_wall_pt()
Access function to the GeomObject for the straight upper wall.
unsigned Nx0
Number of elements in the left region.
Spine *& left_spine_pt(const unsigned long &i)
Access function for spines in left region.
static Steady< 0 > Default_TimeStepper
Default Steady Timestepper, to be used in default arguments to Mesh constructors. ...
Definition: mesh.h:85
void element_reorder()
Reorder the elements so we loop over them vertically first (advantageous in "wide" domains if a front...
FiniteElement *& right_element_pt(const unsigned long &i)
Access functions for pointers to the -th element in the right region.
cstr elem_len * i
Definition: cfortran.h:607
virtual void spine_node_update(SpineNode *spine_node_pt)
General node update function implements pure virtual function defined in SpineMesh base class and per...
double & fraction()
Set reference to fraction along spine.
Definition: spines.h:350
ChannelSpineMesh(const unsigned &nx0, const unsigned &nx1, const unsigned &nx2, const unsigned &ny, const double &lx0, const double &lx1, const double &lx2, const double &h, GeomObject *wall_pt, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor: Pass number of elements in x-direction in regions 0,1 and 2, number of elements in y-dir...
double & geom_parameter(const unsigned &i)
Return i-th geometric parameter that is involved in the node update operations for this Spine...
Definition: spines.h:267
A general Finite Element class.
Definition: elements.h:1271
FiniteElement *& centre_element_pt(const unsigned long &i)
Access functions for pointers to the -th element in the centre region.
FiniteElement *& left_element_pt(const unsigned long &i)
Access functions for pointers to the -th element in the left region.
virtual void position(const Vector< double > &zeta, Vector< double > &r) const =0
Parametrised position on object at current time: r(zeta).
virtual void build_channel_spine_mesh(TimeStepper *time_stepper_pt)
Helper function to actually build the channel-spine mesh (called from various constructors) ...
unsigned long nleft() const
Number of elements in left region.
unsigned long nright() const
Number of elements in right region.
double & x(const unsigned &i)
Return the i-th nodal coordinate.
Definition: nodes.h:995
double Lx1
Length of centre region.
unsigned nleft_spine()
Access function for the number of spines in the left region.
unsigned long ncentre() const
Number of elements in centre region.
unsigned Nx1
Number of elements in the centre region.
Vector< FiniteElement * > Centre_element_pt
Vector of pointers to element in the centre region.
unsigned Np
Np: number of (linear) points in the element.
unsigned Ncentre_spine
Number of spines in centre region.
Spine *& centre_spine_pt(const unsigned long &i)
Access function for spines in centre region.
virtual double x_spacing_function(unsigned xelement, unsigned xnode, unsigned yelement, unsigned ynode)
Return the value of the x-coordinate at the node given by the local node number (xnode, ynode) in the element (xelement,yelement). The description is in a "psudeo" two-dimensional coordinate system, so the range of xelement is [0,Nx-1], yelement is [0,Ny-1], and that of xnode and ynode is [0,Np-1]. The default is to return nodes that are equally spaced in the x coodinate.
GeomObject * wall_pt()
Access function to the GeomObject for upper wall.
unsigned Nx2
Number of elements in the right region.
GeomObject * Straight_wall_pt
GeomObject for the straight upper wall.
unsigned long nbulk() const
Number of elements in bulk.
double Lx2
Length of right region.
GeomObject *& geom_object_pt(const unsigned &i)
Return i-th geometric object that is involved in the node update operations for this Spine...
Definition: spines.h:237
unsigned Nleft_spine
Number of spines in left region.
double Xmin
Minimum value of x coordinate.
Spine *& spine_pt()
Access function to spine.
Definition: spines.h:347
double Lx0
Length of left region.
Vector< FiniteElement * > Right_element_pt
Vector of pointers to element in the right region.
unsigned ncentre_spine()
Access function for the number of spines in the centre region.
Vector< FiniteElement * > Left_element_pt
Vector of pointers to element in the left region.
Base class for time-stepping schemes. Timestepper provides an approximation of the temporal derivativ...
Definition: timesteppers.h:219
unsigned Nright_spine
Number of spines in right region.
const unsigned & ny() const
Return number of elements in y direction.
GeomObject * Wall_pt
GeomObject for upper wall.
double Ymin
Minimum value of y coordinate.
unsigned nright_spine()
Access function for the number of spines in the right region.
Vector< Spine * > Spine_pt
A Spine mesh contains a Vector of pointers to spines.
Definition: spines.h:570
Spine *& right_spine_pt(const unsigned long &i)
Access function for spines in right region.