rectangle_with_moving_cylinder_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// Header file for SpaceTimeNavierStokesMixedOrder elements
27#ifndef OOMPH_RECTANGLE_WITH_MOVING_CYLINDER_MESH_HEADER
28#define OOMPH_RECTANGLE_WITH_MOVING_CYLINDER_MESH_HEADER
29
30// Config header generated by autoconfig
31#ifdef HAVE_CONFIG_H
32#include <oomph-lib-config.h>
33#endif
34
35#include "../generic/domain.h"
36#include "../generic/geom_objects.h"
37#include "../generic/refineable_quad_mesh.h"
38
39// Refineable quad mesh headers
41
42// Namespace extension
43namespace oomph
44{
45 //=============================================================================
46 /// Rectangular domain with circular whole
47 /// DRAIG: This looks like a redefinition of the
48 /// RectangleWithHoleAndAnnularRegionDomain in src/meshes but it creates 8
49 /// macro-elements instead of 4 macro-elements and creates an annular region
50 /// around the cylinder. It's probably a good idea to rename this class to
51 /// avoid ambiguity and a name clash...
52 //=============================================================================
54 {
55 public:
56 /// Constructor. Pass pointer to geometric object that
57 /// represents the cylinder, the length of the (square) domain.
58 /// The GeomObject must be parametrised such that
59 /// \f$\zeta \in [0,2\pi]\f$ sweeps around the circumference
60 /// in anticlockwise direction.
62 const double& annular_region_radius,
63 const double& length)
64 : Cylinder_pt(cylinder_pt), Annular_region_radius(annular_region_radius)
65 {
66 // Vertices of rectangle
67 Lower_left.resize(2);
68 Lower_left[0] = -0.5 * length;
69 Lower_left[1] = -0.5 * length;
70
71 Upper_left.resize(2);
72 Upper_left[0] = -0.5 * length;
73 Upper_left[1] = 0.5 * length;
74
75 Lower_right.resize(2);
76 Lower_right[0] = 0.5 * length;
77 Lower_right[1] = -0.5 * length;
78
79 Upper_right.resize(2);
80 Upper_right[0] = 0.5 * length;
81 Upper_right[1] = 0.5 * length;
82
83 // Coordinates of points where the "radial" lines from central
84 // cylinder meet the upper and lower boundaries
85 Lower_mid_left.resize(2);
86 Lower_mid_left[0] = -0.5 * length;
87 Lower_mid_left[1] = -0.5 * length;
88
89 Upper_mid_left.resize(2);
90 Upper_mid_left[0] = -0.5 * length;
91 Upper_mid_left[1] = 0.5 * length;
92
93 Lower_mid_right.resize(2);
94 Lower_mid_right[0] = 0.5 * length;
95 Lower_mid_right[1] = -0.5 * length;
96
97 Upper_mid_right.resize(2);
98 Upper_mid_right[0] = 0.5 * length;
99 Upper_mid_right[1] = 0.5 * length;
100
101 // The number of macro elements
102 unsigned n_macro_element = 8;
103
104 // There are four macro elements
105 Macro_element_pt.resize(n_macro_element);
106
107 // Build the 2D macro elements
108 for (unsigned i = 0; i < n_macro_element; i++)
109 {
110 // Create the i-th macro element
111 Macro_element_pt[i] = new QMacroElement<2>(this, i);
112 }
113 } // End of RectangleWithHoleAndAnnularRegionDomain
114
115
116 /// Destructor: Empty; macro elements are deleted in base class destructor
118
119
120 /// Helper function that, given the Lagrangian coordinate, xi,
121 /// (associated with a point on the cylinder), returns the corresponding
122 /// point on the outer boundary of the annular region (where the inner
123 /// boundary is prescribed by the boundary of the cylinder)
124 void project_point_on_cylinder_to_annular_boundary(const unsigned& time,
125 const Vector<double>& xi,
126 Vector<double>& r);
127
128 /// Helper function that, given the Lagrangian coordinate, xi,
129 /// (associated with a point on the cylinder), returns the corresponding
130 /// point on the outer boundary of the annular region (where the inner
131 /// boundary is prescribed by the boundary of the cylinder)
132 void project_point_on_cylinder_to_annular_boundary(const double& time,
133 const Vector<double>& xi,
134 Vector<double>& r);
135
136
137 /// Helper function to interpolate linearly between the
138 /// "right" and "left" points; \f$ s \in [-1,1] \f$
140 const Vector<double>& right,
141 const double& s,
143 {
144 // Loop over the coordinates
145 for (unsigned i = 0; i < 2; i++)
146 {
147 // Get the linear interpolation of the two points
148 f[i] = left[i] + (right[i] - left[i]) * 0.5 * (s + 1.0);
149 }
150 } // End of linear_interpolate
151
152
153 /// Parametrisation of macro element boundaries: f(s) is the position
154 /// vector to macro-element m's boundary in the specified direction
155 /// [N/S/E/W] at the specified discrete time level (time=0: present; time>0:
156 /// previous)
157 void macro_element_boundary(const double& time,
158 const unsigned& m,
159 const unsigned& direction,
160 const Vector<double>& s,
161 Vector<double>& f);
162
163 /// Parametrisation of macro element boundaries: f(s) is the position
164 /// vector to macro-element m's boundary in the specified direction
165 /// [N/S/E/W] at the specified discrete time level (time=0: present; time>0:
166 /// previous)
167 void macro_element_boundary(const unsigned& time,
168 const unsigned& m,
169 const unsigned& direction,
170 const Vector<double>& s,
171 Vector<double>& f);
172
173 private:
174 /// Lower left corner of rectangle
176
177 /// Lower right corner of rectangle
179
180 /// Where the "radial" line from circle meets lower boundary on left
182
183 /// Where the "radial" line from circle meets lower boundary on right
185
186 /// Upper left corner of rectangle
188
189 /// Upper right corner of rectangle
191
192 /// Where the "radial" line from circle meets upper boundary on left
194
195 /// Where the "radial" line from circle meets upper boundary on right
197
198 /// Pointer to geometric object that represents the central cylinder
200
201 /// The radius of the outer boundary of the annular region
202 /// whose inner boundary is described by Cylinder_pt and outer
203 /// boundary is a circle with radius lying between half the length
204 /// of the bounding box and the radius cylinder
206 };
207
208 /// /////////////////////////////////////////////////////////////////////
209 /// /////////////////////////////////////////////////////////////////////
210 /// /////////////////////////////////////////////////////////////////////
211
212 //=============================================================================
213 /// Domain-based mesh for rectangular mesh with circular hole
214 //=============================================================================
215 template<class ELEMENT>
217 {
218 public:
219 /// Constructor: Pass pointer to geometric object that
220 /// represents the cylinder, the length and height of the domain.
221 /// The GeomObject must be parametrised such that
222 /// \f$\zeta \in [0,2\pi]\f$ sweeps around the circumference
223 /// in anticlockwise direction. Timestepper defaults to Steady
224 /// default timestepper.
226 GeomObject* cylinder_pt,
227 const double& annular_region_radius,
228 const double& length,
229 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper);
230
231 /// Destructor: We made the Domain object so we have a responsibility
232 /// for deleting it!
234 {
235 // If it's a non-null pointer (don't know why it shouldn't be but
236 // still...)
237 if (Domain_pt != 0)
238 {
239 // Delete the domain pointer
240 delete Domain_pt;
241
242 // Make it a null pointer
243 Domain_pt = 0;
244 }
245 } // End of ~RectangleWithHoleAndAnnularRegionMesh
246
247 /// Access function to the domain
249 {
250 // Return a pointer to the Domain object defining the domain
251 return Domain_pt;
252 }
253
254 protected:
255 /// Pointer to the domain
257 };
258
259 /// /////////////////////////////////////////////////////////////////////
260 /// /////////////////////////////////////////////////////////////////////
261 /// /////////////////////////////////////////////////////////////////////
262
263 //=============================================================================
264 /// Refineable version of RectangleWithHoleAndAnnularRegionMesh. Applies one
265 /// uniform refinement immediately to avoid problems with the automatic
266 /// applications of boundary conditions in subsequent refinements
267 //=============================================================================
268 template<class ELEMENT>
271 public RefineableQuadMesh<ELEMENT>
272 {
273 public:
274 /// Constructor. Pass pointer to geometric object that
275 /// represents the cylinder, the length and height of the domain.
276 /// The GeomObject must be parametrised such that
277 /// \f$\zeta \in [0,2\pi]\f$ sweeps around the circumference
278 /// in anticlockwise direction. Timestepper defaults to Steady
279 /// default timestepper.
281 GeomObject* cylinder_pt,
282 const double& annular_region_radius,
283 const double& length,
284 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
286 cylinder_pt, annular_region_radius, length, time_stepper_pt)
287 {
288 // Nodal positions etc. were created in constructor for
289 // Cylinder...<...>. Need to set up adaptive information.
290
291 // Get the size of the container
292 unsigned n_macro_element = this->Domain_pt->nmacro_element();
293
294 // Loop over all elements and set macro element pointer
295 for (unsigned e = 0; e < n_macro_element; e++)
296 {
297 dynamic_cast<ELEMENT*>(this->element_pt(e))
298 ->set_macro_elem_pt(this->Domain_pt->macro_element_pt(e));
299 }
300
301 // Setup boundary element lookup schemes
303
304 // Setup quadtree forest for mesh refinement
305 this->setup_quadtree_forest();
306 } // End of RefineableRectangleWithHoleAndAnnularRegionMesh
307
308 /// Destructor: Empty
310 };
311
312 /// /////////////////////////////////////////////////////////////////////
313 /// /////////////////////////////////////////////////////////////////////
314 /// /////////////////////////////////////////////////////////////////////
315
316 //=============================================================================
317 /// My Mesh
318 //=============================================================================
319 template<class ELEMENT>
321 : public virtual RefineableQuadMesh<ELEMENT>
322 {
323 public:
324 /// Constructor. Pass pointer to geometric object that represents the
325 /// cylinder; hierher the length and height of the domain. The GeomObject
326 /// must be parametrised such that \f$\zeta \in [0,2\pi]\f$ sweeps around
327 /// the circumference in anticlockwise direction. Timestepper defaults to
328 /// Steady default timestepper.
330 GeomObject* cylinder_pt,
331 const double& annular_region_radius,
332 const double& length_of_central_box,
333 const double& x_left,
334 const double& x_right,
335 const double& height,
336 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper);
337
338 /// Destructor: Delete the part of the mesh which has a Domain
339 /// representation
341 {
342 // Delete the central mesh
343 delete Central_mesh_pt;
344
345 // Make it a null pointer
346 Central_mesh_pt = 0;
347 } // End of ~RefineableQuadMeshWithMovingCylinder
348
349 private:
350 /// Pointer to the part of the mesh which has a Domain
351 /// representation. We have to store it because we can't delete it in the
352 /// constructor as it would delete the Domain pointer which might be needed
353 /// after the whole mesh has been constructed (e.g. for the mesh extrusion
354 /// machinery)...
356
357 // Make the problem as coarse as possible
359 };
360} // End of namespace oomph
361
362#endif
e
Definition: cfortran.h:571
static char t char * s
Definition: cfortran.h:568
cstr elem_len * i
Definition: cfortran.h:603
Base class for Domains with curvilinear and/or time-dependent boundaries. Domain boundaries are typic...
Definition: domain.h:67
Vector< MacroElement * > Macro_element_pt
Vector of pointers to macro elements.
Definition: domain.h:301
unsigned nmacro_element()
Number of macro elements in domain.
Definition: domain.h:123
MacroElement * macro_element_pt(const unsigned &i)
Access to i-th macro element.
Definition: domain.h:116
/////////////////////////////////////////////////////////////////////
Definition: geom_objects.h:101
A general mesh class.
Definition: mesh.h:67
static Steady< 0 > Default_TimeStepper
Default Steady Timestepper, to be used in default arguments to Mesh constructors.
Definition: mesh.h:75
virtual void setup_boundary_element_info()
Interface for function that is used to setup the boundary information (Empty virtual function – imple...
Definition: mesh.h:275
const Vector< GeneralisedElement * > & element_pt() const
Return reference to the Vector of elements.
Definition: mesh.h:460
QMacroElement specialised to 2 spatial dimensions.
Rectangular domain with circular whole DRAIG: This looks like a redefinition of the RectangleWithHole...
Vector< double > Upper_mid_left
Where the "radial" line from circle meets upper boundary on left.
void linear_interpolate(const Vector< double > &left, const Vector< double > &right, const double &s, Vector< double > &f)
Helper function to interpolate linearly between the "right" and "left" points; .
void macro_element_boundary(const double &time, const unsigned &m, const unsigned &direction, const Vector< double > &s, Vector< double > &f)
Parametrisation of macro element boundaries: f(s) is the position vector to macro-element m's boundar...
~RectangleWithHoleAndAnnularRegionDomain()
Destructor: Empty; macro elements are deleted in base class destructor.
GeomObject * Cylinder_pt
Pointer to geometric object that represents the central cylinder.
void project_point_on_cylinder_to_annular_boundary(const unsigned &time, const Vector< double > &xi, Vector< double > &r)
Helper function that, given the Lagrangian coordinate, xi, (associated with a point on the cylinder),...
Vector< double > Lower_mid_left
Where the "radial" line from circle meets lower boundary on left.
Vector< double > Lower_mid_right
Where the "radial" line from circle meets lower boundary on right.
double Annular_region_radius
The radius of the outer boundary of the annular region whose inner boundary is described by Cylinder_...
Vector< double > Upper_mid_right
Where the "radial" line from circle meets upper boundary on right.
RectangleWithHoleAndAnnularRegionDomain(GeomObject *cylinder_pt, const double &annular_region_radius, const double &length)
Constructor. Pass pointer to geometric object that represents the cylinder, the length of the (square...
///////////////////////////////////////////////////////////////////// ///////////////////////////////...
RectangleWithHoleAndAnnularRegionDomain * Domain_pt
Pointer to the domain.
RectangleWithHoleAndAnnularRegionDomain * domain_pt()
Access function to the domain.
RectangleWithHoleAndAnnularRegionMesh(GeomObject *cylinder_pt, const double &annular_region_radius, const double &length, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor: Pass pointer to geometric object that represents the cylinder, the length and height of ...
~RectangleWithHoleAndAnnularRegionMesh()
Destructor: We made the Domain object so we have a responsibility for deleting it!
///////////////////////////////////////////////////////////////////// ///////////////////////////////...
RefineableQuadMeshWithMovingCylinder(GeomObject *cylinder_pt, const double &annular_region_radius, const double &length_of_central_box, const double &x_left, const double &x_right, const double &height, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor. Pass pointer to geometric object that represents the cylinder; hierher the length and he...
RefineableRectangleWithHoleAndAnnularRegionMesh< ELEMENT > * Central_mesh_pt
Pointer to the part of the mesh which has a Domain representation. We have to store it because we can...
~RefineableQuadMeshWithMovingCylinder()
Destructor: Delete the part of the mesh which has a Domain representation.
Intermediate mesh class that implements the mesh adaptation functions specified in the TreeBasedRefin...
void setup_quadtree_forest()
Set up QuadTreeForest. Wipes any existing tree structure below the minimum refinement level and regar...
///////////////////////////////////////////////////////////////////// ///////////////////////////////...
RefineableRectangleWithHoleAndAnnularRegionMesh(GeomObject *cylinder_pt, const double &annular_region_radius, const double &length, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor. Pass pointer to geometric object that represents the cylinder, the length and height of ...
////////////////////////////////////////////////////////////////////// //////////////////////////////...
Definition: timesteppers.h:231
//////////////////////////////////////////////////////////////////// ////////////////////////////////...