two_layer_perturbed_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_TWO_LAYER_PERTURBED_SPINE_MESH_HEADER
27 #define OOMPH_TWO_LAYER_PERTURBED_SPINE_MESH_HEADER
28 
29 // The mesh
30 #include "perturbed_spines.h"
31 #include "meshes.h"
32 #include "generic.h"
33 
34 namespace oomph
35 {
36 
37 
38 //======================================================================
45 //======================================================================
46 template <class ELEMENT>
48  : public RectangularQuadMesh<ELEMENT>, public PerturbedSpineMesh
49 {
50 
51 public:
52 
62  TwoLayerPerturbedSpineMesh(const unsigned &nx,
63  const unsigned &ny1,
64  const unsigned &ny2,
65  const double &lx,
66  const double &h1,
67  const double &h2,
68  SpineMesh* &base_mesh_pt,
69  TimeStepper* time_stepper_pt=
71 
82  TwoLayerPerturbedSpineMesh(const unsigned &nx,
83  const unsigned &ny1,
84  const unsigned &ny2,
85  const double &lx,
86  const double &h1,
87  const double &h2,
88  const bool& periodic_in_x,
89  SpineMesh* &base_mesh_pt,
90  TimeStepper* time_stepper_pt=
92 
105  TwoLayerPerturbedSpineMesh(const unsigned &nx,
106  const unsigned &ny1,
107  const unsigned &ny2,
108  const double &lx,
109  const double &h1,
110  const double &h2,
111  const bool& periodic_in_x,
112  const bool& build_mesh,
113  SpineMesh* &base_mesh_pt,
114  TimeStepper* time_stepper_pt=
116 
117 
120  void element_reorder();
121 
123  FiniteElement* &upper_layer_element_pt(const unsigned long &i)
124  { return Upper_layer_element_pt[i]; }
125 
127  FiniteElement* &lower_layer_element_pt(const unsigned long &i)
128  { return Lower_layer_element_pt[i]; }
129 
131  unsigned long nupper() const { return Upper_layer_element_pt.size(); }
132 
134  unsigned long nlower() const { return Lower_layer_element_pt.size(); }
135 
145  {
146  unsigned id=spine_node_pt->node_update_fct_id();
147  switch(id)
148  {
149  case 0:
150  spine_node_update_lower(spine_node_pt);
151  break;
152 
153  case 1:
154  spine_node_update_upper(spine_node_pt);
155  break;
156 
157  default:
158  std::ostringstream error_message;
159  error_message << "Unknown id passed to perturbed_spine_node_update " << id
160  << std::endl;
161  throw OomphLibError(error_message.str(),
162  "TwoLayerPerturbedSpineMesh::perturbed_spine_node_update()",
164  }
165  }
166 
168  const unsigned& ny1() const { return Ny1; }
169 
171  const unsigned& ny2() const { return Ny2; }
172 
177  const unsigned& cosine_index,
178  const unsigned& sine_index)
179  {
180  YC_index = cosine_index;
181  YS_index = sine_index;
182  }
183 
184  protected:
185 
187  unsigned Ny1;
188 
190  unsigned Ny2;
191 
193  double H1;
194 
196  double H2;
197 
199  // Note: this has got to be a mesh that inherits from the SpineMesh
200  // base class. We store this so that the build_two_layer_mesh function
201  // can pass pointers to the corresponding base spines to each of the
202  // perturbed spines as it builds them
204 
209  int YC_index;
210 
215  int YS_index;
216 
219 
222 
225  double x_spacing_function(unsigned xelement, unsigned xnode,
226  unsigned yelement, unsigned ynode);
227 
230  double y_spacing_function(unsigned xelement, unsigned xnode,
231  unsigned yelement, unsigned ynode);
232 
235  {
236  // Get fraction along the spine
237  const double w = spine_node_pt->fraction();
238 
239  // Get base spine height
240  const double h =
241  spine_node_pt->perturbed_spine_pt()->base_spine_pt()->height();
242 
243  // Set the nodal y-position
244  spine_node_pt->x(1) = this->Ymin + w*h;
245 
246  // Get perturbed spine height (cosine and sine parts)
247  const double HC = spine_node_pt->perturbed_spine_pt()->height(0);
248  const double HS = spine_node_pt->perturbed_spine_pt()->height(1);
249 
250  // Set the perturbation (cosine and sine parts) to the nodal
251  // y-position. Note that YC_index and YS_index are the indices at
252  // which the perturbations to the nodal y-position are stored in
253  // the bulk elements
254  if(YC_index>=0)
255  {
256  spine_node_pt->set_value(YC_index,w*HC);
257  }
258  else
259  {
260  std::ostringstream error_message;
261  error_message << "The cosine part of the perturbation to the nodal\n"
262  << "y-position has not been set up." << std::endl;
263  throw OomphLibError(
264  error_message.str(),
265  "TwoLayerPerturbedSpineMesh::spine_node_update_lower(...)",
267  }
268  if(YS_index>=0)
269  {
270  spine_node_pt->set_value(YS_index,w*HS);
271  }
272  else
273  {
274  std::ostringstream error_message;
275  error_message << "The sine part of the perturbation to the nodal\n"
276  << "y-position has not been set up." << std::endl;
277  throw OomphLibError(
278  error_message.str(),
279  "TwoLayerPerturbedSpineMesh::spine_node_update_lower(...)",
281  }
282  }
283 
286  {
287  // Get fraction along the spine
288  const double w = spine_node_pt->fraction();
289 
290  // Get base spine height
291  const double h =
292  spine_node_pt->perturbed_spine_pt()->base_spine_pt()->height();
293 
294  // Set the nodal y-position
295  spine_node_pt->x(1) = (this->Ymin + h) + w*(this->Ymax - (this->Ymin+h));
296 
297  // Get perturbed spine height (cosine and sine parts)
298  const double HC = spine_node_pt->perturbed_spine_pt()->height(0);
299  const double HS = spine_node_pt->perturbed_spine_pt()->height(1);
300 
301  // Set the perturbation (cosine and sine parts) to the nodal
302  // y-position. Note that YC_index and YS_index are the indices at
303  // which the perturbations to the nodal y-position are stored in
304  // the bulk elements
305  if(YC_index>=0)
306  {
307  // To see analysis of why this is okay, see the pdf file
308  // "perturbed_node_update_procedure.pdf" (emailed to myself)
309  spine_node_pt->set_value(YC_index,HC*(1.0-w));
310  }
311  else
312  {
313  std::ostringstream error_message;
314  error_message << "The cosine part of the perturbation to the nodal\n"
315  << "y-position has not been set up." << std::endl;
316  throw OomphLibError(
317  error_message.str(),
318  "TwoLayerPerturbedSpineMesh::spine_node_update_upper(...)",
320  }
321  if(YS_index>=0)
322  {
323  // To see analysis of why this is okay, see the pdf file
324  // "perturbed_node_update_procedure.pdf" (emailed to myself)
325  spine_node_pt->set_value(YS_index,HS*(1.0-w));
326  }
327  else
328  {
329  std::ostringstream error_message;
330  error_message << "The sine part of the perturbation to the nodal\n"
331  << "y-position has not been set up." << std::endl;
332  throw OomphLibError(
333  error_message.str(),
334  "TwoLayerPerturbedSpineMesh::spine_node_update_upper(...)",
336  }
337  }
338 
341  virtual void build_two_layer_mesh(TimeStepper* time_stepper_pt);
342 
343  private:
344 
349 };
350 
351 
352 }
353 
354 #endif
int i
Definition: BiCGSTAB_step_by_step.cpp:9
RowVector3d w
Definition: Matrix_resize_int.cpp:3
void set_value(const unsigned &i, const double &value_)
Definition: nodes.h:271
Definition: elements.h:1313
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: perturbed_spines.h:553
Class for nodes that ‘live’ on perturbed spines.
Definition: perturbed_spines.h:276
unsigned & node_update_fct_id()
Access function to ID of node update function (within specific mesh)
Definition: perturbed_spines.h:320
double & fraction()
Set reference to fraction along spine.
Definition: perturbed_spines.h:317
PerturbedSpine *& perturbed_spine_pt()
Access function to perturbed spine.
Definition: perturbed_spines.h:314
Spine *& base_spine_pt()
Access function to pointer to base spine.
Definition: perturbed_spines.h:98
double & height(const unsigned &i)
Access function to i-th component of spine "height".
Definition: perturbed_spines.h:101
Definition: rectangular_quadmesh.template.h:59
double Ymax
Maximum value of y coordinate.
Definition: rectangular_quadmesh.template.h:77
const unsigned & nx() const
Return number of elements in x direction.
Definition: rectangular_quadmesh.template.h:224
double Ymin
Minimum value of y coordinate.
Definition: rectangular_quadmesh.template.h:75
void build_mesh(TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Generic mesh construction function: contains all the hard work.
Definition: rectangular_quadmesh.template.cc:43
Definition: spines.h:613
double & height()
Access function to spine height.
Definition: spines.h:150
Definition: timesteppers.h:231
Definition: two_layer_perturbed_spine_mesh.template.h:49
unsigned long nlower() const
Number of elements in top layer.
Definition: two_layer_perturbed_spine_mesh.template.h:134
void spine_node_update_upper(PerturbedSpineNode *spine_node_pt)
Update function for the upper part of the domain.
Definition: two_layer_perturbed_spine_mesh.template.h:285
virtual void build_two_layer_mesh(TimeStepper *time_stepper_pt)
Definition: two_layer_perturbed_spine_mesh.template.cc:296
TwoLayerPerturbedSpineMesh(const unsigned &nx, const unsigned &ny1, const unsigned &ny2, const double &lx, const double &h1, const double &h2, SpineMesh *&base_mesh_pt, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Definition: two_layer_perturbed_spine_mesh.template.cc:65
unsigned Ny1
Number of elements in lower layer.
Definition: two_layer_perturbed_spine_mesh.template.h:187
const unsigned & ny2() const
Access function for number of elements in upper layer.
Definition: two_layer_perturbed_spine_mesh.template.h:171
int YC_index
Definition: two_layer_perturbed_spine_mesh.template.h:209
const unsigned & ny1() const
Access function for number of elements in lower layer.
Definition: two_layer_perturbed_spine_mesh.template.h:168
double y_spacing_function(unsigned xelement, unsigned xnode, unsigned yelement, unsigned ynode)
Definition: two_layer_perturbed_spine_mesh.template.cc:250
void spine_node_update_lower(PerturbedSpineNode *spine_node_pt)
Update function for the lower part of the domain.
Definition: two_layer_perturbed_spine_mesh.template.h:234
int YS_index
Definition: two_layer_perturbed_spine_mesh.template.h:215
Vector< FiniteElement * > Lower_layer_element_pt
Vector of pointers to element in the lower layer.
Definition: two_layer_perturbed_spine_mesh.template.h:218
const void set_perturbation_to_nodal_positions_indices(const unsigned &cosine_index, const unsigned &sine_index)
Definition: two_layer_perturbed_spine_mesh.template.h:176
FiniteElement *& upper_layer_element_pt(const unsigned long &i)
Access functions for pointers to elements in upper layer.
Definition: two_layer_perturbed_spine_mesh.template.h:123
double x_spacing_function(unsigned xelement, unsigned xnode, unsigned yelement, unsigned ynode)
Definition: two_layer_perturbed_spine_mesh.template.cc:233
SpineMesh * Base_mesh_pt
Pointer to corresponding mesh of base state problem.
Definition: two_layer_perturbed_spine_mesh.template.h:203
Vector< FiniteElement * > Upper_layer_element_pt
Vector of pointers to element in the upper layer.
Definition: two_layer_perturbed_spine_mesh.template.h:221
FiniteElement *& lower_layer_element_pt(const unsigned long &i)
Access functions for pointers to elements in lower layer.
Definition: two_layer_perturbed_spine_mesh.template.h:127
unsigned Ny2
Number of elements in upper layer.
Definition: two_layer_perturbed_spine_mesh.template.h:190
void element_reorder()
Definition: two_layer_perturbed_spine_mesh.template.cc:544
static int Perturbation_to_nodal_position_indices_not_set_up
Definition: two_layer_perturbed_spine_mesh.template.h:348
double H1
Height of the lower layer.
Definition: two_layer_perturbed_spine_mesh.template.h:193
void perturbed_spine_node_update(PerturbedSpineNode *spine_node_pt)
Definition: two_layer_perturbed_spine_mesh.template.h:144
double H2
Height of the upper layer.
Definition: two_layer_perturbed_spine_mesh.template.h:196
unsigned long nupper() const
Number of elements in upper layer.
Definition: two_layer_perturbed_spine_mesh.template.h:131
const double lx
Definition: ConstraintElementsUnitTest.cpp:33
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61