macro_element.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_MACROELEMENT_HEADER
27 #define OOMPH_MACROELEMENT_HEADER
28 
29 
30 // Config header generated by autoconfig
31 #ifdef HAVE_CONFIG_H
32 #include <oomph-lib-config.h>
33 #endif
34 
35 #ifdef OOMPH_HAS_MPI
36 #include "mpi.h"
37 #endif
38 
39 // oomph-lib headers
40 #include "Vector.h"
41 #include "oomph_utilities.h"
42 #include "quadtree.h"
43 #include "octree.h"
44 
45 namespace oomph
46 {
47  class Domain;
48 
49  //================================================================
71  //=================================================================
73  {
74  public:
79  {
80 #ifdef LEAK_CHECK
81  LeakCheckNames::MacroElement_build += 1;
82 #endif
83  }
84 
87  {
88  throw OomphLibError("Don't call empty constructor for MacroElement!",
91  }
92 
93 
95  MacroElement(const MacroElement& dummy) = delete;
96 
98  void operator=(const MacroElement&) = delete;
99 
101  virtual ~MacroElement()
102  {
103 #ifdef LEAK_CHECK
104  LeakCheckNames::MacroElement_build -= 1;
105 #endif
106  }
107 
108 
111  void output(std::ostream& outfile, const int& nplot)
112  {
113  unsigned t = 0;
114  output(t, outfile, nplot);
115  }
116 
117 
120  virtual void output(const unsigned& t,
121  std::ostream& outfile,
122  const unsigned& nplot) = 0;
123 
124 
127  {
128  // Evaluate at current timestep
129  unsigned t = 0;
130  macro_map(t, s, r);
131  }
132 
133 
137  virtual void macro_map(const unsigned& t,
138  const Vector<double>& s,
139  Vector<double>& r) = 0;
140 
141 
143  virtual void macro_map(const double& t,
144  const Vector<double>& s,
145  Vector<double>& r)
146  {
147  // Create an output stream
148  std::ostringstream error_message_stream;
149 
150  // Create an error message
151  error_message_stream << "The function macro_map(...) is broken virtual\n"
152  << "If you need it, please implement it!"
153  << std::endl;
154 
155  // Throw an error
156  throw OomphLibError(error_message_stream.str(),
159  } // End of macro_map
160 
161 
163  virtual void output_macro_element_boundaries(std::ostream& outfile,
164  const unsigned& nplot) = 0;
165 
166 
171  const unsigned& t, const Vector<double>& s, DenseMatrix<double>& jacobian)
172  {
173  // error message stream
174  std::ostringstream error_message;
175  error_message << "assemble_macro_to_eulerian_jacobian(...) not \n"
176  << "implemented for this element\n"
177  << std::endl;
178  // throw error
179  throw OomphLibError(
180  error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
181  }
182 
183 
187  const unsigned& t,
188  const Vector<double>& s,
189  DenseMatrix<double>& jacobian2)
190  {
191  // error message stream
192  std::ostringstream error_message;
193  error_message << "assemble_macro_to_eulerian_jacobian2(...) not \n"
194  << "implemented for this element\n"
195  << std::endl;
196  // throw error
197  throw OomphLibError(
198  error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
199  }
200 
201 
206  DenseMatrix<double>& jacobian)
207  {
208  unsigned t = 0;
210  }
211 
212 
216  DenseMatrix<double>& jacobian2)
217  {
218  unsigned t = 0;
220  }
221 
224  {
225  return Macro_element_number;
226  }
227 
230  {
231  return Domain_pt;
232  }
233 
234  protected:
237 
240  };
241 
242 
246 
247 
248  //================================================================
254  //=================================================================
255  template<int DIM>
257  {
258  };
259 
260 
261  //================================================================
276  //=================================================================
277  template<>
278  class QMacroElement<2> : public MacroElement
279  {
280  public:
285 
286 
289  {
290  throw OomphLibError("Don't call empty constructor for QMacroElement!",
293  }
294 
296  QMacroElement(const QMacroElement& dummy) = delete;
297 
299  void operator=(const QMacroElement&) = delete;
300 
302  virtual ~QMacroElement(){};
303 
306  void output(const unsigned& t, std::ostream& outfile, const unsigned& nplot)
307  {
308  Vector<double> x(2), f(2);
309  outfile << "ZONE I=" << nplot << ", J=" << nplot << std::endl;
310  for (unsigned i = 0; i < nplot; i++)
311  {
312  x[1] = -1.0 + 2.0 * double(i) / double(nplot - 1);
313  for (unsigned j = 0; j < nplot; j++)
314  {
315  x[0] = -1.0 + 2.0 * double(j) / double(nplot - 1);
316  macro_map(t, x, f);
317  outfile << f[0] << " " << f[1] << std::endl;
318  }
319  }
320  }
321 
322 
324  void output_macro_element_boundaries(std::ostream& outfile,
325  const unsigned& nplot);
326 
329  void macro_map(const unsigned& t,
330  const Vector<double>& S,
331  Vector<double>& r);
332 
333 
335  void macro_map(const double& t, const Vector<double>& s, Vector<double>& r);
336 
337 
341  const unsigned& t,
342  const Vector<double>& s,
343  DenseMatrix<double>& jacobian);
344 
345 
349  const unsigned& t,
350  const Vector<double>& s,
351  DenseMatrix<double>& jacobian2);
352  };
353 
354 
355  //================================================================
370  //=================================================================
371  template<>
372  class QMacroElement<3> : public MacroElement
373  {
374  public:
379 
382  {
383  throw OomphLibError("Don't call empty constructor for QMacroElement!",
386  }
387 
389  QMacroElement(const QMacroElement& dummy) = delete;
390 
392  void operator=(const QMacroElement&) = delete;
393 
395  virtual ~QMacroElement(){};
396 
397 
400  void output(const unsigned& t, std::ostream& outfile, const unsigned& nplot)
401  {
402  Vector<double> x(3), f(3);
403 
404  outfile << "ZONE I=" << nplot << ", J=" << nplot << ", k=" << nplot
405  << std::endl;
406  for (unsigned i = 0; i < nplot; i++)
407  {
408  x[2] = -1.0 + 2.0 * double(i) / double(nplot - 1);
409 
410  for (unsigned j = 0; j < nplot; j++)
411  {
412  x[1] = -1.0 + 2.0 * double(j) / double(nplot - 1);
413 
414  for (unsigned k = 0; k < nplot; k++)
415  {
416  x[0] = -1.0 + 2.0 * double(k) / double(nplot - 1);
417 
418  macro_map(t, x, f);
419 
420  outfile << f[0] << " " << f[1] << " " << f[2] << std::endl;
421  }
422  }
423  }
424  }
425 
426 
428  void output_macro_element_boundaries(std::ostream& outfile,
429  const unsigned& nplot);
430 
433  void macro_map(const unsigned& t,
434  const Vector<double>& S,
435  Vector<double>& r);
436  };
437 
438 } // namespace oomph
439 
440 #endif
int i
Definition: BiCGSTAB_step_by_step.cpp:9
The simulation can be subdivided into Domain's used in parallel code.
Definition: Domain.h:42
Definition: domain.h:67
Definition: macro_element.h:73
Domain * Domain_pt
Pointer to domain.
Definition: macro_element.h:236
virtual void assemble_macro_to_eulerian_jacobian2(const unsigned &t, const Vector< double > &s, DenseMatrix< double > &jacobian2)
Definition: macro_element.h:186
void assemble_macro_to_eulerian_jacobian(const Vector< double > &s, DenseMatrix< double > &jacobian)
Definition: macro_element.h:205
virtual void output(const unsigned &t, std::ostream &outfile, const unsigned &nplot)=0
virtual void macro_map(const double &t, const Vector< double > &s, Vector< double > &r)
Get global position r(s) at continuous time value, t.
Definition: macro_element.h:143
virtual void output_macro_element_boundaries(std::ostream &outfile, const unsigned &nplot)=0
Output all macro element boundaries as tecplot zones.
void operator=(const MacroElement &)=delete
Broken assignment operator.
virtual void macro_map(const unsigned &t, const Vector< double > &s, Vector< double > &r)=0
void macro_map(const Vector< double > &s, Vector< double > &r)
The mapping from local to global coordinates at the current time : r(s)
Definition: macro_element.h:126
void output(std::ostream &outfile, const int &nplot)
Definition: macro_element.h:111
unsigned Macro_element_number
What is the number of the current macro element within its domain.
Definition: macro_element.h:239
Domain *& domain_pt()
Access function to the Domain_pt.
Definition: macro_element.h:229
virtual ~MacroElement()
Empty destructor.
Definition: macro_element.h:101
unsigned & macro_element_number()
Access function to the Macro_element_number.
Definition: macro_element.h:223
virtual void assemble_macro_to_eulerian_jacobian(const unsigned &t, const Vector< double > &s, DenseMatrix< double > &jacobian)
Definition: macro_element.h:170
MacroElement(Domain *domain_pt, const unsigned &macro_element_number)
Definition: macro_element.h:77
MacroElement(const MacroElement &dummy)=delete
Broken copy constructor.
void assemble_macro_to_eulerian_jacobian2(const Vector< double > &s, DenseMatrix< double > &jacobian2)
Definition: macro_element.h:215
MacroElement()
Default constructor (empty and broken)
Definition: macro_element.h:86
Definition: oomph_definitions.h:222
void output(const unsigned &t, std::ostream &outfile, const unsigned &nplot)
Definition: macro_element.h:306
void operator=(const QMacroElement &)=delete
Broken assignment operator.
QMacroElement(const QMacroElement &dummy)=delete
Broken copy constructor.
virtual ~QMacroElement()
Empty destructor.
Definition: macro_element.h:302
QMacroElement(Domain *domain_pt, const unsigned &macro_element_number)
Definition: macro_element.h:283
QMacroElement()
Default constructor (empty and broken)
Definition: macro_element.h:288
QMacroElement(Domain *domain_pt, const unsigned &macro_element_number)
Definition: macro_element.h:377
QMacroElement()
Default constructor (empty and broken)
Definition: macro_element.h:381
void output(const unsigned &t, std::ostream &outfile, const unsigned &nplot)
Definition: macro_element.h:400
virtual ~QMacroElement()
Empty destructor.
Definition: macro_element.h:395
QMacroElement(const QMacroElement &dummy)=delete
Broken copy constructor.
void operator=(const QMacroElement &)=delete
Broken assignment operator.
Definition: macro_element.h:257
static int f(const TensorMap< Tensor< int, 3 > > &tensor)
Definition: cxx11_tensor_map.cpp:237
RealScalar s
Definition: level1_cplx_impl.h:130
char char char int int * k
Definition: level2_impl.h:374
r
Definition: UniformPSDSelfTest.py:20
@ S
Definition: quadtree.h:62
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
list x
Definition: plotDoE.py:28
t
Definition: plotPSD.py:36
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2