domain.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_DOMAIN_HEADER
27#define OOMPH_DOMAIN_HEADER
28
29
30// Config header generated by autoconfig
31#ifdef HAVE_CONFIG_H
32#include <oomph-lib-config.h>
33#endif
34
35// oomph-lib headers
36#include "macro_element.h"
37
38namespace oomph
39{
40 class MacroElement;
41 class GeomObject;
42
43 class GeomReference;
44
45
46 //=================================================================
47 /// Base class for Domains with curvilinear and/or time-dependent
48 /// boundaries. Domain boundaries are typically represented by GeomObject s
49 /// and the Domain itself is decomposed into a number of MacroElement s
50 /// as shown in this 2D example:
51 /// \image html DomainWithMacroElementSketch.gif
52 /// Any instantiation of a specific Domain needs to implement the pure
53 /// virtual member function
54 /// \code Domain::macro_element_boundary(...) \endcode
55 /// which returns a Vector representation of each of the MacroElement s'
56 /// boundaries, parametrised by the coordinate(s) along this
57 /// boundary. For instance, in the above example,
58 /// the eastern boundary of MacroElement 1 is given by
59 /// the appropriate fraction of the curvilinear boundary;
60 /// its northern boundary (which coincides with the southern
61 /// boundary of MacroElement 2) is given by the straight line emanating
62 /// from the curvilinear boundary, etc. The MacroElement s obtain
63 /// their boundary positions via member function pointers to
64 /// \c Domain::macro_element_boundary(...).
65 //=================================================================
66 class Domain
67 {
68 public:
69 /// Constructor
71 {
72 // Make sure all containers are empty (a bit paranoid, I know...)
73 Macro_element_pt.resize(0);
74 }
75
76 /// Broken copy constructor
77 Domain(const Domain&) = delete;
78
79 /// Broken assignment operator
80 void operator=(const Domain&) = delete;
81
82 /// Destructor: Strictly speaking, whoever creates an object
83 /// dynamically should be responsible for the cleanup of said object
84 /// but it makes sense here for the Domain to generically kill any
85 /// MacroElements left over in the MacroElement container (if it hasn't
86 /// already been done in the derived class) to avoid memory leaks.
87 virtual ~Domain()
88 {
89 // How many macro elements are there?
90 unsigned n_macro_element = Macro_element_pt.size();
91
92 // Loop over the macro elements
93 for (unsigned i = 0; i < n_macro_element; i++)
94 {
95 // They might have already deleted (some or all of) the macro elements
96 // so skip them if they've already been made null pointers
97 if (Macro_element_pt[i] != 0)
98 {
99 // Delete the i-th macro element
100 delete Macro_element_pt[i];
101
102 // Make it a null pointer
103 Macro_element_pt[i] = 0;
104 }
105 } // for (unsigned i=0;i<n_macro_element;i++)
106
107 // Now clear the storage. NOTE: We can't just call this function
108 // as this would only delete the pointers to the macro elements,
109 // not the macro elements themselves!
110 Macro_element_pt.clear();
111
112 } // End of ~Domain
113
114
115 /// Access to i-th macro element
117 {
118 return Macro_element_pt[i];
119 }
120
121
122 /// Number of macro elements in domain
123 unsigned nmacro_element()
124 {
125 return Macro_element_pt.size();
126 }
127
128 /// Output macro elements
129 void output(const std::string& filename, const unsigned& nplot)
130 {
131 std::ofstream outfile;
132 outfile.open(filename.c_str());
133 output(outfile, nplot);
134 outfile.close();
135 }
136
137 /// Output macro elements
138 void output(std::ostream& outfile, const unsigned& nplot)
139 {
140 unsigned nmacro = Macro_element_pt.size();
141 for (unsigned i_macro = 0; i_macro < nmacro; i_macro++)
142 {
143 Macro_element_pt[i_macro]->output(outfile, nplot);
144 }
145 }
146
147
148 /// Vector representation of the i_macro-th macro element
149 /// boundary i_direct (e.g. N/S/W/E in 2D) at time level t
150 /// (t=0: present; t>0: previous): f(s)
151 virtual void macro_element_boundary(const unsigned& t,
152 const unsigned& i_macro,
153 const unsigned& i_direct,
154 const Vector<double>& s,
155 Vector<double>& f) = 0;
156
157
158 /// Vector representation of the i_macro-th macro element
159 /// boundary i_direct (e.g. N/S/W/E in 2D) at continuous time, t
160 virtual void macro_element_boundary(const double& t,
161 const unsigned& i_macro,
162 const unsigned& i_direct,
163 const Vector<double>& s,
165 {
166 // Throw an error
167 throw OomphLibError("Domain::macro_element_boundary() is broken virtual.",
168 OOMPH_CURRENT_FUNCTION,
169 OOMPH_EXCEPTION_LOCATION);
170 } // End of macro_element_boundary
171
172
173 /// Vector representation of the i_macro-th macro element
174 /// boundary i_direct (e.g. N/S/W/E in 2D) at current time: f(s).
175 void macro_element_boundary(const unsigned& i_macro,
176 const unsigned& i_direct,
177 const Vector<double>& s,
179 {
180 // Call unsteady version for current time
181 unsigned t = 0;
182 macro_element_boundary(t, i_macro, i_direct, s, f);
183 }
184
185
186 /// Output all macro element boundaries as tecplot zones
188 const unsigned& nplot)
189 {
190 std::ofstream outfile;
191 outfile.open(filename.c_str());
192 output_macro_element_boundaries(outfile, nplot);
193 outfile.close();
194 }
195
196 /// Output all macro element boundaries as tecplot zones
197 void output_macro_element_boundaries(std::ostream& outfile,
198 const unsigned& nplot)
199 {
200 // Loop over macro elements
201 unsigned nmacro = nmacro_element();
202 for (unsigned i = 0; i < nmacro; i++)
203 {
205 }
206 }
207
208
209 /// Vector representation of the i_macro-th macro element
210 /// boundary derivatives i_direct (e.g. N/S/W/E in 2D) at time level t
211 /// (t=0: present; t>0: previous): f(s). Broken virtual.
212 virtual void dmacro_element_boundary(const unsigned& t,
213 const unsigned& i_macro,
214 const unsigned& i_direct,
215 const Vector<double>& s,
217 {
218 throw OomphLibError(
219 "Domain::dmacro_element_boundary() is broken virtual.",
220 OOMPH_CURRENT_FUNCTION,
221 OOMPH_EXCEPTION_LOCATION);
222 }
223
224
225 /// Vector representation of the i_macro-th macro element boundary
226 /// derivatives i_direct (e.g. N/S/W/E in 2D) at continuous time level t.
227 /// Broken virtual.
228 virtual void dmacro_element_boundary(const double& t,
229 const unsigned& i_macro,
230 const unsigned& i_direct,
231 const Vector<double>& s,
233 {
234 throw OomphLibError(
235 "Domain::dmacro_element_boundary() is broken virtual.",
236 OOMPH_CURRENT_FUNCTION,
237 OOMPH_EXCEPTION_LOCATION);
238 }
239
240
241 /// Vector representation of the i_macro-th macro element
242 /// boundary derivatives i_direct (e.g. N/S/W/E in 2D) at current time:
243 /// f(s).
244 void dmacro_element_boundary(const unsigned& i_macro,
245 const unsigned& i_direct,
246 const Vector<double>& s,
248 {
249 // Call unsteady version for current time
250 unsigned t = 0;
251 dmacro_element_boundary(t, i_macro, i_direct, s, f);
252 }
253
254
255 /// Vector representation of the i_macro-th macro element
256 /// boundary second derivatives i_direct (e.g. N/S/W/E in 2D) at time level
257 /// t (t=0: present; t>0: previous): f(s). Broken virtual.
258 virtual void d2macro_element_boundary(const unsigned& t,
259 const unsigned& i_macro,
260 const unsigned& i_direct,
261 const Vector<double>& s,
263 {
264 throw OomphLibError(
265 "Domain::d2macro_element_boundary() is broken virtual.",
266 OOMPH_CURRENT_FUNCTION,
267 OOMPH_EXCEPTION_LOCATION);
268 }
269
270 /// Vector representation of the i_macro-th macro element boundary
271 /// seocond derivatives i_direct (e.g. N/S/W/E in 2D) at continuous time
272 /// level t. Broken virtual.
273 virtual void d2macro_element_boundary(const double& t,
274 const unsigned& i_macro,
275 const unsigned& i_direct,
276 const Vector<double>& s,
278 {
279 throw OomphLibError(
280 "Domain::d2macro_element_boundary() is broken virtual.",
281 OOMPH_CURRENT_FUNCTION,
282 OOMPH_EXCEPTION_LOCATION);
283 }
284
285 /// Vector representation of the i_macro-th macro element
286 /// boundary second derivatives i_direct (e.g. N/S/W/E in 2D) at
287 /// current time: f(s).
288 void d2macro_element_boundary(const unsigned& i_macro,
289 const unsigned& i_direct,
290 const Vector<double>& s,
292 {
293 // Call unsteady version for current time
294 unsigned t = 0;
295 d2macro_element_boundary(t, i_macro, i_direct, s, f);
296 }
297
298
299 protected:
300 /// Vector of pointers to macro elements
302 };
303
304
305 /// //////////////////////////////////////////////////////////////////////
306 /// //////////////////////////////////////////////////////////////////////
307 // Warped cube domain
308 /// //////////////////////////////////////////////////////////////////////
309 /// //////////////////////////////////////////////////////////////////////
310
311
312 //=================================================================
313 /// Warped cube as domain which is parametrised by
314 /// a single macro element
315 //=================================================================
317 {
318 public:
319 /// Constructor:
321 {
322 // Resize
323 Macro_element_pt.resize(1);
324
325 // Create macro element
326 Macro_element_pt[0] = new QMacroElement<3>(this, 0);
327 }
328
329 /// Broken copy constructor
331
332 /// Broken assignment operator
333 void operator=(const WarpedCubeDomain&) = delete;
334
335 /// Destructor (empty; clean up handled in base class)
337
338
339 /// Warp the unit cube
340 void warp_it(Vector<double>& f);
341
342
343 /// Vector representation of the i_macro-th macro element
344 /// boundary i_direct (L/R/D/U/B/F) at time level t
345 /// (t=0: present; t>0: previous):
346 /// f(s).
347 void macro_element_boundary(const unsigned& t,
348 const unsigned& i_macro,
349 const unsigned& i_direct,
350 const Vector<double>& s,
351 Vector<double>& f);
352
353
354 private:
355 /// Left boundary face
356 /// zeta \f$ \in [-1,1]^2 \f$
357 void r_L(const unsigned& t, const Vector<double>& zeta, Vector<double>& f);
358
359 /// Right boundary face
360 /// zeta \f$ \in [-1,1]^2 \f$
361 void r_R(const unsigned& t, const Vector<double>& zeta, Vector<double>& f);
362
363
364 /// Down boundary face
365 /// zeta \f$ \in [-1,1]^2 \f$
366 void r_D(const unsigned& t, const Vector<double>& zeta, Vector<double>& f);
367
368
369 /// Up boundary face
370 /// zeta \f$ \in [-1,1]^2 \f$
371 void r_U(const unsigned& t, const Vector<double>& zeta, Vector<double>& f);
372
373
374 /// Back boundary face
375 /// zeta \f$ \in [-1,1]^2 \f$
376 void r_B(const unsigned& t, const Vector<double>& zeta, Vector<double>& f);
377
378
379 /// Front boundary face
380 /// zeta \f$ \in [-1,1]^2 \f$
381 void r_F(const unsigned& t, const Vector<double>& zeta, Vector<double>& f);
382 };
383
384
385} // namespace oomph
386
387#endif
static char t char * s
Definition: cfortran.h:568
cstr elem_len * i
Definition: cfortran.h:603
char t
Definition: cfortran.h:568
Base class for Domains with curvilinear and/or time-dependent boundaries. Domain boundaries are typic...
Definition: domain.h:67
Domain()
Constructor.
Definition: domain.h:70
virtual void macro_element_boundary(const double &t, const unsigned &i_macro, const unsigned &i_direct, const Vector< double > &s, Vector< double > &f)
Vector representation of the i_macro-th macro element boundary i_direct (e.g. N/S/W/E in 2D) at conti...
Definition: domain.h:160
void operator=(const Domain &)=delete
Broken assignment operator.
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
void output_macro_element_boundaries(std::ostream &outfile, const unsigned &nplot)
Output all macro element boundaries as tecplot zones.
Definition: domain.h:197
virtual void d2macro_element_boundary(const double &t, const unsigned &i_macro, const unsigned &i_direct, const Vector< double > &s, Vector< double > &f)
Vector representation of the i_macro-th macro element boundary seocond derivatives i_direct (e....
Definition: domain.h:273
void dmacro_element_boundary(const unsigned &i_macro, const unsigned &i_direct, const Vector< double > &s, Vector< double > &f)
Vector representation of the i_macro-th macro element boundary derivatives i_direct (e....
Definition: domain.h:244
void output(const std::string &filename, const unsigned &nplot)
Output macro elements.
Definition: domain.h:129
void d2macro_element_boundary(const unsigned &i_macro, const unsigned &i_direct, const Vector< double > &s, Vector< double > &f)
Vector representation of the i_macro-th macro element boundary second derivatives i_direct (e....
Definition: domain.h:288
virtual void macro_element_boundary(const unsigned &t, const unsigned &i_macro, const unsigned &i_direct, const Vector< double > &s, Vector< double > &f)=0
Vector representation of the i_macro-th macro element boundary i_direct (e.g. N/S/W/E in 2D) at time ...
void macro_element_boundary(const unsigned &i_macro, const unsigned &i_direct, const Vector< double > &s, Vector< double > &f)
Vector representation of the i_macro-th macro element boundary i_direct (e.g. N/S/W/E in 2D) at curre...
Definition: domain.h:175
void output(std::ostream &outfile, const unsigned &nplot)
Output macro elements.
Definition: domain.h:138
MacroElement * macro_element_pt(const unsigned &i)
Access to i-th macro element.
Definition: domain.h:116
void output_macro_element_boundaries(const std::string &filename, const unsigned &nplot)
Output all macro element boundaries as tecplot zones.
Definition: domain.h:187
Domain(const Domain &)=delete
Broken copy constructor.
virtual void dmacro_element_boundary(const unsigned &t, const unsigned &i_macro, const unsigned &i_direct, const Vector< double > &s, Vector< double > &f)
Vector representation of the i_macro-th macro element boundary derivatives i_direct (e....
Definition: domain.h:212
virtual void dmacro_element_boundary(const double &t, const unsigned &i_macro, const unsigned &i_direct, const Vector< double > &s, Vector< double > &f)
Vector representation of the i_macro-th macro element boundary derivatives i_direct (e....
Definition: domain.h:228
virtual ~Domain()
Destructor: Strictly speaking, whoever creates an object dynamically should be responsible for the cl...
Definition: domain.h:87
virtual void d2macro_element_boundary(const unsigned &t, const unsigned &i_macro, const unsigned &i_direct, const Vector< double > &s, Vector< double > &f)
Vector representation of the i_macro-th macro element boundary second derivatives i_direct (e....
Definition: domain.h:258
Base class for MacroElement s that are used during mesh refinement in domains with curvlinear and/or ...
Definition: macro_element.h:73
virtual void output_macro_element_boundaries(std::ostream &outfile, const unsigned &nplot)=0
Output all macro element boundaries as tecplot zones.
An OomphLibError object which should be thrown when an run-time error is encountered....
QMacroElement specialised to 3 spatial dimensions.
//////////////////////////////////////////////////////////////////////
Definition: domain.h:317
void r_U(const unsigned &t, const Vector< double > &zeta, Vector< double > &f)
Up boundary face zeta .
Definition: domain.cc:159
void operator=(const WarpedCubeDomain &)=delete
Broken assignment operator.
void r_R(const unsigned &t, const Vector< double > &zeta, Vector< double > &f)
Right boundary face zeta .
Definition: domain.cc:125
void macro_element_boundary(const unsigned &t, const unsigned &i_macro, const unsigned &i_direct, const Vector< double > &s, Vector< double > &f)
Vector representation of the i_macro-th macro element boundary i_direct (L/R/D/U/B/F) at time level t...
Definition: domain.cc:47
WarpedCubeDomain(const WarpedCubeDomain &)=delete
Broken copy constructor.
void r_F(const unsigned &t, const Vector< double > &zeta, Vector< double > &f)
Front boundary face zeta .
Definition: domain.cc:194
void r_L(const unsigned &t, const Vector< double > &zeta, Vector< double > &f)
Left boundary face zeta .
Definition: domain.cc:107
void r_D(const unsigned &t, const Vector< double > &zeta, Vector< double > &f)
Down boundary face zeta .
Definition: domain.cc:142
void r_B(const unsigned &t, const Vector< double > &zeta, Vector< double > &f)
Back boundary face zeta .
Definition: domain.cc:177
void warp_it(Vector< double > &f)
Warp the unit cube.
Definition: domain.cc:210
WarpedCubeDomain()
Constructor:
Definition: domain.h:320
~WarpedCubeDomain()
Destructor (empty; clean up handled in base class)
Definition: domain.h:336
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...