rectangle_with_moving_cylinder_mesh.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-2025 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
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)
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
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 /// Destructor: Empty; macro elements are deleted in base class destructor
117
118
119 /// Helper function that, given the Lagrangian coordinate, xi,
120 /// (associated with a point on the cylinder), returns the corresponding
121 /// point on the outer boundary of the annular region (where the inner
122 /// boundary is prescribed by the boundary of the cylinder)
123 void project_point_on_cylinder_to_annular_boundary(const unsigned& time,
124 const Vector<double>& xi,
126
127 /// Helper function that, given the Lagrangian coordinate, xi,
128 /// (associated with a point on the cylinder), returns the corresponding
129 /// point on the outer boundary of the annular region (where the inner
130 /// boundary is prescribed by the boundary of the cylinder)
131 void project_point_on_cylinder_to_annular_boundary(const double& time,
132 const Vector<double>& xi,
134
135
136 /// Helper function to interpolate linearly between the
137 /// "right" and "left" points; \f$ s \in [-1,1] \f$
139 const Vector<double>& right,
140 const double& s,
142 {
143 // Loop over the coordinates
144 for (unsigned i = 0; i < 2; i++)
145 {
146 // Get the linear interpolation of the two points
147 f[i] = left[i] + (right[i] - left[i]) * 0.5 * (s + 1.0);
148 }
149 } // End of linear_interpolate
150
151
152 /// Parametrisation of macro element boundaries: f(s) is the position
153 /// vector to macro-element m's boundary in the specified direction
154 /// [N/S/E/W] at the specified discrete time level (time=0: present; time>0:
155 /// previous)
156 void macro_element_boundary(const double& time,
157 const unsigned& m,
158 const unsigned& direction,
159 const Vector<double>& s,
160 Vector<double>& f);
161
162 /// Parametrisation of macro element boundaries: f(s) is the position
163 /// vector to macro-element m's boundary in the specified direction
164 /// [N/S/E/W] at the specified discrete time level (time=0: present; time>0:
165 /// previous)
166 void macro_element_boundary(const unsigned& time,
167 const unsigned& m,
168 const unsigned& direction,
169 const Vector<double>& s,
170 Vector<double>& f);
171
172 private:
173 /// Lower left corner of rectangle
175
176 /// Lower right corner of rectangle
178
179 /// Where the "radial" line from circle meets lower boundary on left
181
182 /// Where the "radial" line from circle meets lower boundary on right
184
185 /// Upper left corner of rectangle
187
188 /// Upper right corner of rectangle
190
191 /// Where the "radial" line from circle meets upper boundary on left
193
194 /// Where the "radial" line from circle meets upper boundary on right
196
197 /// Pointer to geometric object that represents the central cylinder
199
200 /// The radius of the outer boundary of the annular region
201 /// whose inner boundary is described by Cylinder_pt and outer
202 /// boundary is a circle with radius lying between half the length
203 /// of the bounding box and the radius cylinder
205 };
206
207 ////////////////////////////////////////////////////////////////////////
208 ////////////////////////////////////////////////////////////////////////
209 ////////////////////////////////////////////////////////////////////////
210
211 //=============================================================================
212 /// Domain-based mesh for rectangular mesh with circular hole
213 //=============================================================================
214 template<class ELEMENT>
216 {
217 public:
218 /// Constructor: Pass pointer to geometric object that
219 /// represents the cylinder, the length and height of the domain.
220 /// The GeomObject must be parametrised such that
221 /// \f$\zeta \in [0,2\pi]\f$ sweeps around the circumference
222 /// in anticlockwise direction. Timestepper defaults to Steady
223 /// default timestepper.
225 GeomObject* cylinder_pt,
226 const double& annular_region_radius,
227 const double& length,
228 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper);
229
230 /// Destructor: We made the Domain object so we have a responsibility
231 /// for deleting it!
233 {
234 // If it's a non-null pointer (don't know why it shouldn't be but
235 // still...)
236 if (Domain_pt != 0)
237 {
238 // Delete the domain pointer
239 delete Domain_pt;
240
241 // Make it a null pointer
242 Domain_pt = 0;
243 }
244 } // End of ~RectangleWithHoleAndAnnularRegionMesh
245
246 /// Access function to the domain
248 {
249 // Return a pointer to the Domain object defining the domain
250 return Domain_pt;
251 }
252
253 protected:
254 /// Pointer to the domain
256 };
257
258 ////////////////////////////////////////////////////////////////////////
259 ////////////////////////////////////////////////////////////////////////
260 ////////////////////////////////////////////////////////////////////////
261
262 //=============================================================================
263 /// Refineable version of RectangleWithHoleAndAnnularRegionMesh. Applies one
264 /// uniform refinement immediately to avoid problems with the automatic
265 /// applications of boundary conditions in subsequent refinements
266 //=============================================================================
267 template<class ELEMENT>
270 public RefineableQuadMesh<ELEMENT>
271 {
272 public:
273 /// Constructor. Pass pointer to geometric object that
274 /// represents the cylinder, the length and height of the domain.
275 /// The GeomObject must be parametrised such that
276 /// \f$\zeta \in [0,2\pi]\f$ sweeps around the circumference
277 /// in anticlockwise direction. Timestepper defaults to Steady
278 /// default timestepper.
280 GeomObject* cylinder_pt,
281 const double& annular_region_radius,
282 const double& length,
283 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
285 cylinder_pt, annular_region_radius, length, time_stepper_pt)
286 {
287 // Nodal positions etc. were created in constructor for
288 // Cylinder...<...>. Need to set up adaptive information.
289
290 // Get the size of the container
291 unsigned n_macro_element = this->Domain_pt->nmacro_element();
292
293 // Loop over all elements and set macro element pointer
294 for (unsigned e = 0; e < n_macro_element; e++)
295 {
296 dynamic_cast<ELEMENT*>(this->element_pt(e))
297 ->set_macro_elem_pt(this->Domain_pt->macro_element_pt(e));
298 }
299
300 // Setup boundary element lookup schemes
302
303 // Setup quadtree forest for mesh refinement
304 this->setup_quadtree_forest();
305 } // End of RefineableRectangleWithHoleAndAnnularRegionMesh
306
307 /// Destructor: Empty
309 };
310
311 ////////////////////////////////////////////////////////////////////////
312 ////////////////////////////////////////////////////////////////////////
313 ////////////////////////////////////////////////////////////////////////
314
315 //=============================================================================
316 /// My Mesh
317 //=============================================================================
318 template<class ELEMENT>
320 : public virtual RefineableQuadMesh<ELEMENT>
321 {
322 public:
323 /// Constructor. Pass pointer to geometric object that represents the
324 /// cylinder; hierher the length and height of the domain. The GeomObject
325 /// must be parametrised such that \f$\zeta \in [0,2\pi]\f$ sweeps around
326 /// the circumference in anticlockwise direction. Timestepper defaults to
327 /// Steady default timestepper.
329 GeomObject* cylinder_pt,
330 const double& annular_region_radius,
331 const double& length_of_central_box,
332 const double& x_left,
333 const double& x_right,
334 const double& height,
335 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper);
336
337 /// Destructor: Delete the part of the mesh which has a Domain
338 /// representation
340 {
341 // Delete the central mesh
342 delete Central_mesh_pt;
343
344 // Make it a null pointer
345 Central_mesh_pt = 0;
346 } // End of ~RefineableQuadMeshWithMovingCylinder
347
348 private:
349 /// Pointer to the part of the mesh which has a Domain
350 /// representation. We have to store it because we can't delete it in the
351 /// constructor as it would delete the Domain pointer which might be needed
352 /// after the whole mesh has been constructed (e.g. for the mesh extrusion
353 /// machinery)...
355
356 // Make the problem as coarse as possible
358 };
359} // End of namespace oomph
360
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
A geometric object is an object that provides a parametrised description of its shape via the functio...
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:279
const Vector< GeneralisedElement * > & element_pt() const
Return reference to the Vector of elements.
Definition mesh.h:464
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; .
Vector< double > Lower_right
Lower right corner of rectangle.
Vector< double > Upper_right
Upper right corner of rectangle.
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.
Vector< double > Lower_left
Lower left corner of rectangle.
Vector< double > Upper_left
Upper left corner of rectangle.
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...
Domain-based mesh for rectangular mesh with circular hole.
RectangleWithHoleAndAnnularRegionDomain * Domain_pt
Pointer to the domain.
RectangleWithHoleAndAnnularRegionDomain * domain_pt()
Access function to the domain.
~RectangleWithHoleAndAnnularRegionMesh()
Destructor: We made the Domain object so we have a responsibility for deleting it!
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...
Refineable version of RectangleWithHoleAndAnnularRegionMesh. Applies one uniform refinement immediate...
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 ...
TAdvectionDiffusionReactionElement<NREAGENT,DIM,NNODE_1D> elements are isoparametric triangular DIM-d...
Base class for time-stepping schemes. Timestepper provides an approximation of the temporal derivativ...
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).