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// Copyright (C) 2006-2022 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 #ifndef OOMPH_CHANNEL_SPINE_MESH_HEADER
27 #define OOMPH_CHANNEL_SPINE_MESH_HEADER
28 
29 // oomph-lib includes
30 #include "../generic/spines.h"
32 
33 namespace oomph
34 {
35  //======================================================================
40  //======================================================================
41  template<class ELEMENT>
42  class ChannelSpineMesh : public RectangularQuadMesh<ELEMENT>, public SpineMesh
43  {
44  public:
50  ChannelSpineMesh(const unsigned& nx0,
51  const unsigned& nx1,
52  const unsigned& nx2,
53  const unsigned& ny,
54  const double& lx0,
55  const double& lx1,
56  const double& lx2,
57  const double& h,
59  TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper);
60 
67  ChannelSpineMesh(const unsigned& nx0,
68  const unsigned& nx1,
69  const unsigned& nx2,
70  const unsigned& ny,
71  const double& lx0,
72  const double& lx1,
73  const double& lx2,
74  const double& h,
76  const bool& periodic_in_x,
77  TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper);
78 
81  FiniteElement*& left_element_pt(const unsigned long& i)
82  {
83  return Left_element_pt[i];
84  }
85 
88  FiniteElement*& centre_element_pt(const unsigned long& i)
89  {
90  return Centre_element_pt[i];
91  }
92 
95  FiniteElement*& right_element_pt(const unsigned long& i)
96  {
97  return Right_element_pt[i];
98  }
99 
101  unsigned long nleft() const
102  {
103  return Left_element_pt.size();
104  }
105 
107  unsigned long ncentre() const
108  {
109  return Centre_element_pt.size();
110  }
111 
113  unsigned long nright() const
114  {
115  return Right_element_pt.size();
116  }
117 
119  unsigned long nbulk() const
120  {
121  unsigned long Nbulk = Left_element_pt.size() + Centre_element_pt.size() +
122  Right_element_pt.size();
123  return Nbulk;
124  }
125 
128  void element_reorder();
129 
133  virtual void spine_node_update(SpineNode* spine_node_pt)
134  {
135  // Get spine node's fraction along the spine
136  double W = spine_node_pt->fraction();
137 
138  // Get local coordinates
139  Vector<double> s_wall(1);
140  s_wall[0] = spine_node_pt->spine_pt()->geom_parameter(0);
141 
142  // Get position vector to wall
143  Vector<double> position(2);
144  spine_node_pt->spine_pt()->geom_object_pt(0)->position(s_wall, position);
145 
146  // Set the value of y
147  spine_node_pt->x(1) = this->Ymin + W * position[1];
148  }
149 
156  virtual double x_spacing_function(unsigned xelement,
157  unsigned xnode,
158  unsigned yelement,
159  unsigned ynode)
160  {
161  // Calculate the values of equal increments in nodal values in left region
162  double xstep1 = Lx0 / ((this->Np - 1) * Nx0);
163  // Calculate the values of equal increments in nodal values in centre
164  // region
165  double xstep2 = Lx1 / ((this->Np - 1) * Nx1);
166  // Calculate the values of equal increments in nodal values in right
167  // region
168  double xstep3 = Lx2 / ((this->Np - 1) * Nx2);
169 
170  // left region
171  if (xelement < Nx0)
172  {
173  // Return the appropriate value
174  return (this->Xmin + xstep1 * ((this->Np - 1) * xelement + xnode));
175  }
176  // centre region
177  else if (xelement < Nx0 + Nx1)
178  {
179  // Return the appropriate value
180  return (Lx0 + xstep2 * ((this->Np - 1) * (xelement - Nx0) + xnode));
181  }
182  // right region
183  else if (xelement < Nx0 + Nx1 + Nx2)
184  {
185  // Return the appropriate value
186  return (Lx0 + Lx1 +
187  xstep3 * ((this->Np - 1) * (xelement - Nx0 - Nx1) + xnode));
188  }
189  else
190  {
191  throw OomphLibError("Should not have got here",
194  }
195  // Dummy return to keep compiler from barking
196  return 0.0;
197  }
198 
200  Spine*& left_spine_pt(const unsigned long& i)
201  {
202 #ifdef PARNOID
203  if (i > Nleft_spine)
204  {
205  throw OomphLibError("Arguemnt out of range",
208  }
209 #endif
210  return Spine_pt[i];
211  }
212 
214  Spine*& centre_spine_pt(const unsigned long& i)
215  {
216  if (i > Ncentre_spine)
217  {
218  throw OomphLibError("Arguemnt out of range",
221  }
222  else
223  {
224  return Spine_pt[Nleft_spine + i];
225  }
226  }
227 
229  Spine*& right_spine_pt(const unsigned long& i)
230  {
231  if (i > Nright_spine)
232  {
233  throw OomphLibError("Arguemnt out of range",
236  }
237  else
238  {
239  return Spine_pt[Nleft_spine + Ncentre_spine - 1 + i];
240  }
241  }
242 
244  unsigned nleft_spine()
245  {
246  return Nleft_spine;
247  }
248 
250  unsigned ncentre_spine()
251  {
252  return Ncentre_spine;
253  }
254 
256  unsigned nright_spine()
257  {
258  return Nright_spine;
259  }
260 
263  {
264  return Wall_pt;
265  }
266 
269  {
270  return Straight_wall_pt;
271  }
272 
273  protected:
276 
279 
282 
285  virtual void build_channel_spine_mesh(TimeStepper* time_stepper_pt);
286 
288  unsigned Nx0;
289 
291  unsigned Nx1;
292 
294  unsigned Nx2;
295 
297  double Lx0;
298 
300  double Lx1;
301 
303  double Lx2;
304 
306  unsigned Nleft_spine;
307 
309  unsigned Ncentre_spine;
310 
312  unsigned Nright_spine;
313 
316 
319  };
320 
321 } // namespace oomph
322 
323 #endif
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Definition: channel_spine_mesh.template.h:43
Vector< FiniteElement * > Centre_element_pt
Vector of pointers to element in the centre region.
Definition: channel_spine_mesh.template.h:278
virtual void build_channel_spine_mesh(TimeStepper *time_stepper_pt)
Definition: channel_spine_mesh.template.cc:153
virtual double x_spacing_function(unsigned xelement, unsigned xnode, unsigned yelement, unsigned ynode)
Definition: channel_spine_mesh.template.h:156
unsigned Nx0
Number of elements in the left region.
Definition: channel_spine_mesh.template.h:288
FiniteElement *& centre_element_pt(const unsigned long &i)
Definition: channel_spine_mesh.template.h:88
GeomObject * Straight_wall_pt
GeomObject for the straight upper wall.
Definition: channel_spine_mesh.template.h:318
double Lx1
Length of centre region.
Definition: channel_spine_mesh.template.h:300
double Lx0
Length of left region.
Definition: channel_spine_mesh.template.h:297
unsigned long ncentre() const
Number of elements in centre region.
Definition: channel_spine_mesh.template.h:107
unsigned Nx2
Number of elements in the right region.
Definition: channel_spine_mesh.template.h:294
unsigned nright_spine()
Access function for the number of spines in the right region.
Definition: channel_spine_mesh.template.h:256
double Lx2
Length of right region.
Definition: channel_spine_mesh.template.h:303
GeomObject * straight_wall_pt()
Access function to the GeomObject for the straight upper wall.
Definition: channel_spine_mesh.template.h:268
unsigned long nright() const
Number of elements in right region.
Definition: channel_spine_mesh.template.h:113
unsigned Nright_spine
Number of spines in right region.
Definition: channel_spine_mesh.template.h:312
unsigned Nleft_spine
Number of spines in left region.
Definition: channel_spine_mesh.template.h:306
unsigned Nx1
Number of elements in the centre region.
Definition: channel_spine_mesh.template.h:291
Spine *& centre_spine_pt(const unsigned long &i)
Access function for spines in centre region.
Definition: channel_spine_mesh.template.h:214
unsigned long nleft() const
Number of elements in left region.
Definition: channel_spine_mesh.template.h:101
GeomObject * wall_pt()
Access function to the GeomObject for upper wall.
Definition: channel_spine_mesh.template.h:262
Spine *& right_spine_pt(const unsigned long &i)
Access function for spines in right region.
Definition: channel_spine_mesh.template.h:229
FiniteElement *& left_element_pt(const unsigned long &i)
Definition: channel_spine_mesh.template.h:81
unsigned ncentre_spine()
Access function for the number of spines in the centre region.
Definition: channel_spine_mesh.template.h:250
unsigned long nbulk() const
Number of elements in bulk.
Definition: channel_spine_mesh.template.h:119
FiniteElement *& right_element_pt(const unsigned long &i)
Definition: channel_spine_mesh.template.h:95
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)
Definition: channel_spine_mesh.template.cc:48
Vector< FiniteElement * > Right_element_pt
Vector of pointers to element in the right region.
Definition: channel_spine_mesh.template.h:281
Vector< FiniteElement * > Left_element_pt
Vector of pointers to element in the left region.
Definition: channel_spine_mesh.template.h:275
void element_reorder()
Definition: channel_spine_mesh.template.cc:694
Spine *& left_spine_pt(const unsigned long &i)
Access function for spines in left region.
Definition: channel_spine_mesh.template.h:200
GeomObject * Wall_pt
GeomObject for upper wall.
Definition: channel_spine_mesh.template.h:315
virtual void spine_node_update(SpineNode *spine_node_pt)
Definition: channel_spine_mesh.template.h:133
unsigned nleft_spine()
Access function for the number of spines in the left region.
Definition: channel_spine_mesh.template.h:244
unsigned Ncentre_spine
Number of spines in centre region.
Definition: channel_spine_mesh.template.h:309
Definition: elements.h:1313
Definition: geom_objects.h:101
virtual void position(const Vector< double > &zeta, Vector< double > &r) const =0
Parametrised position on object at current time: r(zeta).
static Steady< 0 > Default_TimeStepper
The Steady Timestepper.
Definition: mesh.h:75
double & x(const unsigned &i)
Return the i-th nodal coordinate.
Definition: nodes.h:1060
Definition: oomph_definitions.h:222
Definition: rectangular_quadmesh.template.h:59
const unsigned & ny() const
Return number of elements in y direction.
Definition: rectangular_quadmesh.template.h:231
unsigned Np
Np: number of (linear) points in the element.
Definition: rectangular_quadmesh.template.h:67
double Ymin
Minimum value of y coordinate.
Definition: rectangular_quadmesh.template.h:75
double Xmin
Minimum value of x coordinate.
Definition: rectangular_quadmesh.template.h:70
Definition: spines.h:613
Vector< Spine * > Spine_pt
A Spine mesh contains a Vector of pointers to spines.
Definition: spines.h:616
Definition: spines.h:328
Spine *& spine_pt()
Access function to spine.
Definition: spines.h:372
double & fraction()
Set reference to fraction along spine.
Definition: spines.h:378
Definition: spines.h:64
GeomObject *& geom_object_pt(const unsigned &i)
Definition: spines.h:244
double & geom_parameter(const unsigned &i)
Definition: spines.h:287
Definition: timesteppers.h:231
@ W
Definition: quadtree.h:63
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86