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