horizontal_single_layer_spine_mesh.template.cc
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: 1097 $
7 //LIC//
8 //LIC// $LastChangedDate: 2015-12-17 11:53:17 +0000 (Thu, 17 Dec 2015) $
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_HORIZONTAL_SINGLE_LAYER_SPINE_MESH_TEMPLATE_CC
31 #define OOMPH_HORIZONTAL_SINGLE_LAYER_SPINE_MESH_TEMPLATE_CC
32 
35 
36 
37 namespace oomph
38 {
39 
40 
41 //===========================================================================
42 /// Constructor for spine 2D mesh: Pass number of elements in x-direction,
43 /// number of elements in y-direction, axial length and height of layer,
44 /// and pointer to timestepper (defaults to Static timestepper).
45 ///
46 /// The mesh contains a layer of spinified fluid elements (of type ELEMENT;
47 /// e.g SpineElement<QCrouzeixRaviartElement<2>)
48 /// and information about how the internal nodes positions are affected
49 /// by changes in spine length. Additional equations that determine the
50 /// spine heights must be specified in order to use this mesh.
51 //===========================================================================
52 template<class ELEMENT>
54  const unsigned &nx, const unsigned &ny,
55  const double &lx, const double &h, TimeStepper* time_stepper_pt) :
56  RectangularQuadMesh<ELEMENT>(nx,ny,0.0,lx,0.0,h,false,false,
57  time_stepper_pt)
58 {
59  // Mesh can only be built with 2D Qelements.
60  MeshChecker::assert_geometric_element<QElementGeometricBase,ELEMENT>(2);
61 
62  //Mesh can only be built with spine elements
63  MeshChecker::assert_geometric_element<SpineFiniteElement,ELEMENT>(2);
64 
65  // We've called the "generic" constructor for the RectangularQuadMesh
66  // which doesn't do much...
67 
68  // Now build the mesh:
69  build_horizontal_single_layer_mesh(time_stepper_pt);
70 }
71 
72 //===========================================================================
73 /// Helper function that actually builds the single-layer spine mesh
74 /// based on the parameters set in the various constructors
75 //===========================================================================
76 template<class ELEMENT>
79  TimeStepper* time_stepper_pt)
80 {
81  // Build the underlying quad mesh:
83 
84  //Read out the number of elements in the x-direction
85  unsigned n_x = this->Nx;
86  unsigned n_y = this->Ny;
87 
88  //Allocate memory for the spines and fractions along spines
89  //---------------------------------------------------------
90 
91  //Read out number of linear points in the element
92  unsigned n_p = dynamic_cast<ELEMENT*>(finite_element_pt(0))->nnode_1d();
93  Spine_pt.reserve((n_p-1)*n_y+1);
94 
95  // FIRST SPINE
96  // -----------
97 
98  // Element 0
99  // Node 0
100  // Assign the new spine with unit length
101  Spine* new_spine_pt=new Spine(1.0);
102  Spine_pt.push_back(new_spine_pt);
103 
104 
105  // Get pointer to node
106  SpineNode* nod_pt=element_node_pt(0,0);
107  //Set the pointer to the spine
108  nod_pt->spine_pt() = new_spine_pt;
109  //Set the fraction
110  nod_pt->fraction() = 0.0;
111  // Pointer to the mesh that implements the update fct
112  nod_pt->spine_mesh_pt() = this;
113 
114  // Loop HORIZONTAL along the spine
115  // Loop over the elements
116  for(unsigned long i=0;i<n_x;i++)
117  {
118  //Loop over the HORIZONTAL nodes, apart from the first
119  for(unsigned l1=1;l1<n_p;l1++)
120  {
121  // Get pointer to node
122  //SpineNode* nod_pt=element_node_pt(i*n_y,l1*n_p);
123 
124  // Get pointer to node(without reoder)
125  SpineNode* nod_pt=element_node_pt(i,l1);
126  //Set the pointer to the spine
127  nod_pt->spine_pt()= new_spine_pt;
128  //Set the fraction
129  nod_pt->fraction()=(double(i)+double(l1)/double(n_p-1))/double(n_x);
130  // Pointer to the mesh that implements the update fct
131  nod_pt->spine_mesh_pt() = this;
132  }
133  }
134 
135 
136  // LOOP OVER OTHER SPINES
137  // ----------------------
138 
139  // Now loop over the elements VERTICALLY
140  for(unsigned long j=0;j<n_y;j++)
141  {
142  // Loop over the nodes in the elements horizontally, ignoring
143  // the first row
144 
145  // Last spine needs special treatment in x-periodic meshes:
146  unsigned n_pmax=n_p;
147 
148  for(unsigned l2=1;l2<n_pmax;l2++)
149  {
150  // Assign the new spine with unit height
151  new_spine_pt=new Spine(1.0);
152  Spine_pt.push_back(new_spine_pt);
153 
154  // Get the node
155  //SpineNode* nod_pt=element_node_pt(j,l2);
156 
157  // Get the node (without reorder)
158  SpineNode* nod_pt=element_node_pt(j*n_x,l2*n_p);
159  // Set the pointer to spine
160  nod_pt->spine_pt() = new_spine_pt;
161  //Set the fraction
162  nod_pt->fraction() = 0.0;
163  // Pointer to the mesh that implements the update fct
164  nod_pt->spine_mesh_pt() = this;
165 
166  // Loop HORIZONTALLY along the spine
167  // Loop over the elements
168  for(unsigned long i=0;i<n_x;i++)
169  {
170  // Loop over the HORIZONTAL nodes, apart from the first
171  for(unsigned l1=1;l1<n_p;l1++)
172  {
173  // Get the node
174  // SpineNode* nod_pt=element_node_pt(i*n_y+j,l1*n_p+l2);
175 
176  // Get the node (without reorder)
177  SpineNode* nod_pt=element_node_pt(j*n_x+i,l2*n_p+l1);
178  // Set the pointer to the spine
179  nod_pt->spine_pt() = new_spine_pt;
180  // Set the fraction
181  nod_pt->fraction()=(double(i)+double(l1)/double(n_p-1))/double(n_x);
182  // Pointer to the mesh that implements the update fct
183  nod_pt->spine_mesh_pt() = this;
184  }
185  }
186  }
187  }
188 
189 }
190 
191 
192 }
193 #endif
cstr elem_len * i
Definition: cfortran.h:607
virtual void build_horizontal_single_layer_mesh(TimeStepper *time_stepper_pt)
Helper function to actually build the single-layer spine mesh (called from various constructors) ...
double & fraction()
Set reference to fraction along spine.
Definition: spines.h:350
HorizontalSingleLayerSpineMesh(const unsigned &nx, const unsigned &ny, const double &lx, const double &h, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor: Pass number of elements in x-direction, number of elements in y-direction, axial length, height of layer, and pointer to timestepper (defaults to Steady timestepper)
void build_mesh(TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Generic mesh construction function: contains all the hard work.
Spine *& spine_pt()
Access function to spine.
Definition: spines.h:347
SpineMesh *& spine_mesh_pt()
Access function to Pointer to SpineMesh that this node is a part of and which implements the node upd...
Definition: spines.h:357
Base class for time-stepping schemes. Timestepper provides an approximation of the temporal derivativ...
Definition: timesteppers.h:219