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 
38 namespace oomph
39 {
40  class MacroElement;
41  class GeomObject;
42 
43  class GeomReference;
44 
45 
46  //=================================================================
65  //=================================================================
66  class Domain
67  {
68  public:
71  {
72  // Make sure all containers are empty (a bit paranoid, I know...)
73  Macro_element_pt.resize(0);
74  }
75 
77  Domain(const Domain&) = delete;
78 
80  void operator=(const Domain&) = delete;
81 
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 
116  MacroElement* macro_element_pt(const unsigned& i)
117  {
118  return Macro_element_pt[i];
119  }
120 
121 
123  unsigned nmacro_element()
124  {
125  return Macro_element_pt.size();
126  }
127 
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 
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 
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 
160  virtual void macro_element_boundary(const double& t,
161  const unsigned& i_macro,
162  const unsigned& i_direct,
163  const Vector<double>& s,
164  Vector<double>& f)
165  {
166  // Throw an error
167  throw OomphLibError("Domain::macro_element_boundary() is broken virtual.",
170  } // End of macro_element_boundary
171 
172 
175  void macro_element_boundary(const unsigned& i_macro,
176  const unsigned& i_direct,
177  const Vector<double>& s,
178  Vector<double>& f)
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 
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 
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 
212  virtual void dmacro_element_boundary(const unsigned& t,
213  const unsigned& i_macro,
214  const unsigned& i_direct,
215  const Vector<double>& s,
216  Vector<double>& f)
217  {
218  throw OomphLibError(
219  "Domain::dmacro_element_boundary() is broken virtual.",
222  }
223 
224 
228  virtual void dmacro_element_boundary(const double& t,
229  const unsigned& i_macro,
230  const unsigned& i_direct,
231  const Vector<double>& s,
232  Vector<double>& f)
233  {
234  throw OomphLibError(
235  "Domain::dmacro_element_boundary() is broken virtual.",
238  }
239 
240 
244  void dmacro_element_boundary(const unsigned& i_macro,
245  const unsigned& i_direct,
246  const Vector<double>& s,
247  Vector<double>& f)
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 
258  virtual void d2macro_element_boundary(const unsigned& t,
259  const unsigned& i_macro,
260  const unsigned& i_direct,
261  const Vector<double>& s,
262  Vector<double>& f)
263  {
264  throw OomphLibError(
265  "Domain::d2macro_element_boundary() is broken virtual.",
268  }
269 
273  virtual void d2macro_element_boundary(const double& t,
274  const unsigned& i_macro,
275  const unsigned& i_direct,
276  const Vector<double>& s,
277  Vector<double>& f)
278  {
279  throw OomphLibError(
280  "Domain::d2macro_element_boundary() is broken virtual.",
283  }
284 
288  void d2macro_element_boundary(const unsigned& i_macro,
289  const unsigned& i_direct,
290  const Vector<double>& s,
291  Vector<double>& f)
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:
302  };
303 
304 
307  // Warped cube domain
310 
311 
312  //=================================================================
315  //=================================================================
316  class WarpedCubeDomain : public Domain
317  {
318  public:
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 
331 
333  void operator=(const WarpedCubeDomain&) = delete;
334 
337 
338 
340  void warp_it(Vector<double>& f);
341 
342 
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:
357  void r_L(const unsigned& t, const Vector<double>& zeta, Vector<double>& f);
358 
361  void r_R(const unsigned& t, const Vector<double>& zeta, Vector<double>& f);
362 
363 
366  void r_D(const unsigned& t, const Vector<double>& zeta, Vector<double>& f);
367 
368 
371  void r_U(const unsigned& t, const Vector<double>& zeta, Vector<double>& f);
372 
373 
376  void r_B(const unsigned& t, const Vector<double>& zeta, Vector<double>& f);
377 
378 
381  void r_F(const unsigned& t, const Vector<double>& zeta, Vector<double>& f);
382  };
383 
384 
385 } // namespace oomph
386 
387 #endif
int i
Definition: BiCGSTAB_step_by_step.cpp:9
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)
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)
Definition: domain.h:273
void dmacro_element_boundary(const unsigned &i_macro, const unsigned &i_direct, const Vector< double > &s, Vector< double > &f)
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)
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
void macro_element_boundary(const unsigned &i_macro, const unsigned &i_direct, const Vector< double > &s, Vector< double > &f)
Definition: domain.h:175
MacroElement * macro_element_pt(const unsigned &i)
Access to i-th macro element.
Definition: domain.h:116
void output(std::ostream &outfile, const unsigned &nplot)
Output macro elements.
Definition: domain.h:138
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)
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)
Definition: domain.h:228
virtual ~Domain()
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)
Definition: domain.h:258
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.
Definition: oomph_definitions.h:222
Definition: macro_element.h:373
Definition: domain.h:317
void r_U(const unsigned &t, const Vector< double > &zeta, Vector< double > &f)
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)
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)
Definition: domain.cc:47
WarpedCubeDomain(const WarpedCubeDomain &)=delete
Broken copy constructor.
void r_F(const unsigned &t, const Vector< double > &zeta, Vector< double > &f)
Definition: domain.cc:194
void r_L(const unsigned &t, const Vector< double > &zeta, Vector< double > &f)
Definition: domain.cc:107
void r_D(const unsigned &t, const Vector< double > &zeta, Vector< double > &f)
Definition: domain.cc:142
void r_B(const unsigned &t, const Vector< double > &zeta, Vector< double > &f)
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
static int f(const TensorMap< Tensor< int, 3 > > &tensor)
Definition: cxx11_tensor_map.cpp:237
RealScalar s
Definition: level1_cplx_impl.h:130
EIGEN_STRONG_INLINE const Eigen::CwiseBinaryOp< Eigen::internal::scalar_zeta_op< typename DerivedX::Scalar >, const DerivedX, const DerivedQ > zeta(const Eigen::ArrayBase< DerivedX > &x, const Eigen::ArrayBase< DerivedQ > &q)
Definition: SpecialFunctionsArrayAPI.h:152
string filename
Definition: MergeRestartFiles.py:39
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
t
Definition: plotPSD.py:36
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86