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// Version 1.0; svn revision $LastChangedRevision$
7 //LIC//
8 //LIC// $LastChangedDate$
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_DOMAIN_HEADER
31 #define OOMPH_DOMAIN_HEADER
32 
33 
34 // Config header generated by autoconfig
35 #ifdef HAVE_CONFIG_H
36  #include <oomph-lib-config.h>
37 #endif
38 
39 //oomph-lib headers
40 #include "macro_element.h"
41 
42 namespace oomph
43 {
44 
45 class MacroElement;
46 class GeomObject;
47 
48 class GeomReference;
49 
50 
51 //=================================================================
52 /// \short Base class for Domains with curvilinear and/or time-dependent
53 /// boundaries. Domain boundaries are typically represented by GeomObject s
54 /// and the Domain itself is decomposed into a number of MacroElement s
55 /// as shown in this 2D example:
56 /// \image html DomainWithMacroElementSketch.gif
57 /// Any instantiation of a specific Domain needs to implement the pure
58 /// virtual member function
59 /// \code Domain::macro_element_boundary(...) \endcode
60 /// which returns a Vector representation of each of the MacroElement s'
61 /// boundaries, parametrised by the coordinate(s) along this
62 /// boundary. For instance, in the above example,
63 /// the eastern boundary of MacroElement 1 is given by
64 /// the appropriate fraction of the curvilinear boundary;
65 /// its northern boundary (which coincides with the southern
66 /// boundary of MacroElement 2) is given by the straight line emanating
67 /// from the curvilinear boundary, etc. The MacroElement s obtain
68 /// their boundary positions via member function pointers to
69 /// \c Domain::macro_element_boundary(...).
70 //=================================================================
71 class Domain
72 {
73 
74 public:
75 
76  /// Constructor
77  Domain()
78  {
79  // Make sure all containers are empty (a bit paranoid, I know...)
80  Macro_element_pt.resize(0);
81  }
82 
83  /// Broken copy constructor
84  Domain(const Domain&)
85  {
86  BrokenCopy::broken_copy("Domain");
87  }
88 
89  /// Broken assignment operator
90  void operator=(const Domain&)
91  {
92  BrokenCopy::broken_assign("Domain");
93  }
94 
95  /// Virtual destructor: Empty
96  virtual ~Domain(){};
97 
98 
99  /// \short Access to i-th macro element
100  MacroElement* macro_element_pt(const unsigned& i)
101  {
102  return Macro_element_pt[i];
103  }
104 
105 
106  /// Number of macro elements in domain
107  unsigned nmacro_element()
108  {
109  return Macro_element_pt.size();
110  }
111 
112  /// Output macro elements
113  void output(const std::string& filename, const unsigned& nplot)
114  {
115  std::ofstream outfile;
116  outfile.open(filename.c_str());
117  output(outfile,nplot);
118  outfile.close();
119  }
120 
121  /// Output macro elements
122  void output(std::ostream &outfile, const unsigned& nplot)
123  {
124  unsigned nmacro=Macro_element_pt.size();
125  for (unsigned i_macro=0;i_macro<nmacro;i_macro++)
126  {
127  Macro_element_pt[i_macro]->output(outfile,nplot);
128  }
129  }
130 
131 
132  /// \short Vector representation of the i_macro-th macro element
133  /// boundary i_direct (e.g. N/S/W/E in 2D) at time level t
134  /// (t=0: present; t>0: previous): f(s)
135  virtual void macro_element_boundary(const unsigned& t,
136  const unsigned& i_macro,
137  const unsigned& i_direct,
138  const Vector<double>& s,
139  Vector<double>& f)=0;
140 
141 
142  /// \short Vector representation of the i_macro-th macro element
143  /// boundary i_direct (e.g. N/S/W/E in 2D) at current time: f(s).
144  void macro_element_boundary(const unsigned& i_macro,
145  const unsigned& i_direct,
146  const Vector<double>& s,
147  Vector<double>& f)
148  {
149  // Call unsteady version for current time
150  unsigned t=0;
151  macro_element_boundary(t,i_macro,i_direct,s,f);
152  }
153 
154 
155 
156  /// \short Output all macro element boundaries as tecplot zones
158  const unsigned& nplot)
159  {
160  std::ofstream outfile;
161  outfile.open(filename.c_str());
162  output_macro_element_boundaries(outfile,nplot);
163  outfile.close();
164  }
165 
166  /// \short Output all macro element boundaries as tecplot zones
167  void output_macro_element_boundaries(std::ostream &outfile,
168  const unsigned& nplot)
169  {
170  // Loop over macro elements
171  unsigned nmacro=nmacro_element();
172  for (unsigned i=0;i<nmacro;i++)
173  {
175  }
176  }
177 
178 
179  /// \short Vector representation of the i_macro-th macro element
180  /// boundary derivatives i_direct (e.g. N/S/W/E in 2D) at time level t
181  /// (t=0: present; t>0: previous): f(s). Broken virtual.
182  virtual void dmacro_element_boundary(const unsigned& t,
183  const unsigned& i_macro,
184  const unsigned& i_direct,
185  const Vector<double>& s,
186  Vector<double>& f)
187  {
188  throw OomphLibError("Domain::dmacro_element_boundary() is broken virtual.",
189  OOMPH_CURRENT_FUNCTION,
190  OOMPH_EXCEPTION_LOCATION);
191  }
192 
193  /// \short Vector representation of the i_macro-th macro element
194  /// boundary derivatives i_direct (e.g. N/S/W/E in 2D) at current time: f(s).
195  void dmacro_element_boundary(const unsigned& i_macro,
196  const unsigned& i_direct,
197  const Vector<double>& s,
198  Vector<double>& f)
199  {
200  // Call unsteady version for current time
201  unsigned t=0;
202  dmacro_element_boundary(t,i_macro,i_direct,s,f);
203  }
204 
205 
206  /// \short Vector representation of the i_macro-th macro element
207  /// boundary second derivatives i_direct (e.g. N/S/W/E in 2D) at time level t
208  /// (t=0: present; t>0: previous): f(s). Broken virtual.
209  virtual void d2macro_element_boundary(const unsigned& t,
210  const unsigned& i_macro,
211  const unsigned& i_direct,
212  const Vector<double>& s,
213  Vector<double>& f)
214  {
215  throw OomphLibError("Domain::d2macro_element_boundary() is broken virtual.",
216  OOMPH_CURRENT_FUNCTION,
217  OOMPH_EXCEPTION_LOCATION);
218  }
219 
220  /// \short Vector representation of the i_macro-th macro element
221  /// boundary second derivatives i_direct (e.g. N/S/W/E in 2D) at
222  /// current time: f(s).
223  void d2macro_element_boundary(const unsigned& i_macro,
224  const unsigned& i_direct,
225  const Vector<double>& s,
226  Vector<double>& f)
227  {
228  // Call unsteady version for current time
229  unsigned t=0;
230  d2macro_element_boundary(t,i_macro,i_direct,s,f);
231  }
232 
233 
234 protected:
235 
236  /// \short Vector of pointers to macro elements
238 
239 };
240 
241 
242 
243 
244 /////////////////////////////////////////////////////////////////////////
245 /////////////////////////////////////////////////////////////////////////
246 // Warped cube domain
247 /////////////////////////////////////////////////////////////////////////
248 /////////////////////////////////////////////////////////////////////////
249 
250 
251 //=================================================================
252 /// \short Warped cube as domain which is parametrised by
253 /// a single macro element
254 //=================================================================
255 class WarpedCubeDomain : public Domain
256 {
257 
258 public:
259 
260 
261 
262  /// \short Constructor:
264  {
265  // Resize
266  Macro_element_pt.resize(1);
267 
268  // Create macro element
269  Macro_element_pt[0]=new QMacroElement<3>(this,0);
270  }
271 
272  /// Broken copy constructor
274  {
275  BrokenCopy::broken_copy("WarpedCubeDomain");
276  }
277 
278  /// Broken assignment operator
280  {
281  BrokenCopy::broken_assign("WarpedCubeDomain");
282  }
283 
284 
285  /// Destructor: Kill macro elements
287  {
288  delete Macro_element_pt[0];
289  }
290 
291 
292  /// Warp the unit cube
293  void warp_it(Vector<double>& f);
294 
295 
296  /// \short Vector representation of the i_macro-th macro element
297  /// boundary i_direct (L/R/D/U/B/F) at time level t
298  /// (t=0: present; t>0: previous):
299  /// f(s).
300  void macro_element_boundary(const unsigned& t,
301  const unsigned& i_macro,
302  const unsigned& i_direct,
303  const Vector<double>& s,
304  Vector<double>& f);
305 
306 
307 private:
308 
309  /// \short Left boundary face
310  /// zeta \f$ \in [-1,1]^2 \f$
311  void r_L(const unsigned& t, const Vector<double>& zeta,
312  Vector<double>& f);
313 
314  /// \short Right boundary face
315  /// zeta \f$ \in [-1,1]^2 \f$
316  void r_R(const unsigned& t, const Vector<double>& zeta,
317  Vector<double>& f);
318 
319 
320  /// \short Down boundary face
321  /// zeta \f$ \in [-1,1]^2 \f$
322  void r_D(const unsigned& t, const Vector<double>& zeta,
323  Vector<double>& f);
324 
325 
326  /// \short Up boundary face
327  /// zeta \f$ \in [-1,1]^2 \f$
328  void r_U(const unsigned& t, const Vector<double>& zeta,
329  Vector<double>& f);
330 
331 
332  /// \short Back boundary face
333  /// zeta \f$ \in [-1,1]^2 \f$
334  void r_B(const unsigned& t, const Vector<double>& zeta,
335  Vector<double>& f);
336 
337 
338  /// \short Front boundary face
339  /// zeta \f$ \in [-1,1]^2 \f$
340  void r_F(const unsigned& t, const Vector<double>& zeta,
341  Vector<double>& f);
342 
343 };
344 
345 
346 }
347 
348 #endif
~WarpedCubeDomain()
Destructor: Kill macro elements.
Definition: domain.h:286
unsigned nmacro_element()
Number of macro elements in domain.
Definition: domain.h:107
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
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:195
Domain(const Domain &)
Broken copy constructor.
Definition: domain.h:84
void operator=(const WarpedCubeDomain &)
Broken assignment operator.
Definition: domain.h:279
virtual void output_macro_element_boundaries(std::ostream &outfile, const unsigned &nplot)=0
Output all macro element boundaries as tecplot zones.
cstr elem_len * i
Definition: cfortran.h:607
void output(std::ostream &outfile, const unsigned &nplot)
Output macro elements.
Definition: domain.h:122
Vector< MacroElement * > Macro_element_pt
Vector of pointers to macro elements.
Definition: domain.h:237
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:144
char t
Definition: cfortran.h:572
MacroElement * macro_element_pt(const unsigned &i)
Access to i-th macro element.
Definition: domain.h:100
void output_macro_element_boundaries(std::ostream &outfile, const unsigned &nplot)
Output all macro element boundaries as tecplot zones.
Definition: domain.h:167
Domain()
Constructor.
Definition: domain.h:77
static char t char * s
Definition: cfortran.h:572
void output_macro_element_boundaries(const std::string &filename, const unsigned &nplot)
Output all macro element boundaries as tecplot zones.
Definition: domain.h:157
WarpedCubeDomain(const WarpedCubeDomain &)
Broken copy constructor.
Definition: domain.h:273
void operator=(const Domain &)
Broken assignment operator.
Definition: domain.h:90
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:223
virtual ~Domain()
Virtual destructor: Empty.
Definition: domain.h:96
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:209
void broken_assign(const std::string &class_name)
Issue error message and terminate execution.
WarpedCubeDomain()
Constructor:
Definition: domain.h:263
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn&#39;t been defined.
void output(const std::string &filename, const unsigned &nplot)
Output macro elements.
Definition: domain.h:113
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:182
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 ...
Warped cube as domain which is parametrised by a single macro element.
Definition: domain.h:255
Base class for Domains with curvilinear and/or time-dependent boundaries. Domain boundaries are typic...
Definition: domain.h:71