supg_advection_diffusion_elements.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_SUPG_ADV_DIFF_ELEMENTS_HEADER
27 #define OOMPH_SUPG_ADV_DIFF_ELEMENTS_HEADER
28 
29 #include "../advection_diffusion/refineable_advection_diffusion_elements.h"
30 
31 namespace oomph
32 {
33  //======================================================================
40  //======================================================================
41  template<unsigned DIM, unsigned NNODE_1D>
43  : public virtual QAdvectionDiffusionElement<DIM, NNODE_1D>
44  {
45  public:
50  : QAdvectionDiffusionElement<DIM, NNODE_1D>()
51  {
52  Tau_SUPG = 0.0;
53  }
54 
56  double get_Tau_SUPG()
57  {
58  return Tau_SUPG;
59  }
60 
61 
64  {
65  Tau_SUPG = 0.0;
66  }
67 
68 
71  {
72  // Find out how many nodes there are
73  unsigned n_node = this->nnode();
74 
75  // Set up memory for the shape functions and their derivatives
76  Shape psi(n_node), test(n_node);
77  DShape dpsidx(n_node, DIM);
78 
79  // Evaluate everything at the element centroid
80  Vector<double> s(DIM, 0.0);
81 
82  // Call the geometrical shape functions and derivatives
83  (void)QElement<DIM, NNODE_1D>::dshape_eulerian(s, psi, dpsidx);
84 
85  // Calculate Eulerian coordinates
87 
88  // Loop over nodes
89  for (unsigned l = 0; l < n_node; l++)
90  {
91  // Loop over directions (we're in 2D)
92  for (unsigned j = 0; j < DIM; j++)
93  {
94  interpolated_x[j] += this->nodal_position(l, j) * psi[l];
95  }
96  }
97 
98  // Element size: Choose the max. diagonal
99  double h = 0;
100  if (DIM == 1)
101  {
102  h = std::fabs(this->vertex_node_pt(1)->x(0) -
103  this->vertex_node_pt(0)->x(0));
104  }
105  else if (DIM == 2)
106  {
107  h =
108  pow(this->vertex_node_pt(3)->x(0) - this->vertex_node_pt(0)->x(0),
109  2) +
110  pow(this->vertex_node_pt(3)->x(1) - this->vertex_node_pt(0)->x(1), 2);
111  double h1 =
112  pow(this->vertex_node_pt(2)->x(0) - this->vertex_node_pt(1)->x(0),
113  2) +
114  pow(this->vertex_node_pt(2)->x(1) - this->vertex_node_pt(1)->x(1), 2);
115  if (h1 > h) h = h1;
116  h = sqrt(h);
117  }
118  else if (DIM == 3)
119  {
120  // diagonals are from nodes 0-7, 1-6, 2-5, 3-4
121  unsigned n1 = 0;
122  unsigned n2 = 7;
123  for (unsigned i = 0; i < 4; i++)
124  {
125  double h1 =
126  pow(this->vertex_node_pt(n1)->x(0) - this->vertex_node_pt(n2)->x(0),
127  2) +
128  pow(this->vertex_node_pt(n1)->x(1) - this->vertex_node_pt(n2)->x(1),
129  2) +
130  pow(this->vertex_node_pt(n1)->x(2) - this->vertex_node_pt(n2)->x(2),
131  2);
132  if (h1 > h) h = h1;
133  n1++;
134  n2--;
135  }
136  h = sqrt(h);
137  }
138 
139  // Get wind
140  Vector<double> wind(DIM);
141  // Dummy ipt argument?
142  unsigned ipt = 0;
143  this->get_wind_adv_diff(ipt, s, interpolated_x, wind);
144  double abs_wind = 0;
145  for (unsigned j = 0; j < DIM; j++)
146  {
147  abs_wind += wind[j] * wind[j];
148  }
149  abs_wind = sqrt(abs_wind);
150 
151  // Mesh Peclet number
152  double Pe_mesh = 0.5 * this->pe() * h * abs_wind;
153 
154  // Stabilisation parameter
155  if (Pe_mesh > 1.0)
156  {
157  Tau_SUPG = h / (2.0 * abs_wind) * (1.0 - 1.0 / Pe_mesh);
158  }
159  else
160  {
161  Tau_SUPG = 0.0;
162  }
163  }
164 
165 
169  void output(std::ostream& outfile, const unsigned& nplot)
170  {
171  // Vector of local coordinates
173 
174  // Tecplot header info
175  outfile << this->tecplot_zone_string(nplot);
176 
177  // Loop over plot points
178  unsigned num_plot_points = this->nplot_points(nplot);
179  for (unsigned iplot = 0; iplot < num_plot_points; iplot++)
180  {
181  // Get local coordinates of plot point
182  this->get_s_plot(iplot, nplot, s);
183 
184  // Get Eulerian coordinate of plot point
186  this->interpolated_x(s, x);
187 
188  for (unsigned i = 0; i < DIM; i++)
189  {
190  outfile << x[i] << " ";
191  }
192  outfile << this->interpolated_u_adv_diff(s) << " ";
193 
194  // Get the wind
195  Vector<double> wind(DIM);
196  // Dummy ipt argument
197  unsigned ipt = 0;
198  this->get_wind_adv_diff(ipt, s, x, wind);
199  for (unsigned i = 0; i < DIM; i++)
200  {
201  outfile << wind[i] << " ";
202  }
203 
204  // Output stabilisation parameter
205  outfile << Tau_SUPG << std::endl;
206  }
207 
208  // Write tecplot footer (e.g. FE connectivity lists)
209  this->write_tecplot_zone_footer(outfile, nplot);
210  }
211 
213  void output(std::ostream& outfile)
214  {
215  FiniteElement::output(outfile);
216  }
217 
219  void output(FILE* file_pt)
220  {
221  FiniteElement::output(file_pt);
222  }
223 
225  void output(FILE* file_pt, const unsigned& n_plot)
226  {
227  FiniteElement::output(file_pt, n_plot);
228  }
229 
230 
231  protected:
235  Shape& psi,
236  DShape& dpsidx,
237  Shape& test,
238  DShape& dtestdx) const;
239 
240 
243  double dshape_and_dtest_eulerian_at_knot_adv_diff(const unsigned& ipt,
244  Shape& psi,
245  DShape& dpsidx,
246  Shape& test,
247  DShape& dtestdx) const;
248 
250  double Tau_SUPG;
251  };
252 
253 
257 
258 
259  //======================================================================
263  //======================================================================
264  template<unsigned DIM, unsigned NNODE_1D>
266  : public QSUPGAdvectionDiffusionElement<DIM, NNODE_1D>,
267  public virtual RefineableAdvectionDiffusionEquations<DIM>,
268  public virtual RefineableQElement<DIM>
269  {
270  public:
274  : RefineableElement(),
278  {
279  }
280 
281 
285  delete;
286 
288  void operator=(
290 
292  unsigned ncont_interpolated_values() const
293  {
294  return 1;
295  }
296 
298  unsigned nvertex_node() const
299  {
301  }
302 
304  Node* vertex_node_pt(const unsigned& j) const
305  {
307  }
308 
310  void rebuild_from_sons(Mesh*& mesh_pt) {}
311 
314  unsigned nrecovery_order()
315  {
316  return (NNODE_1D - 1);
317  }
318 
322  };
323 
324 
325 } // namespace oomph
326 
327 #endif
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
int i
Definition: BiCGSTAB_step_by_step.cpp:9
double interpolated_u_adv_diff(const Vector< double > &s) const
Return FE representation of function value u(s) at local coordinate s.
Definition: advection_diffusion_elements.h:458
virtual void get_wind_adv_diff(const unsigned &ipt, const Vector< double > &s, const Vector< double > &x, Vector< double > &wind) const
Definition: advection_diffusion_elements.h:366
const double & pe() const
Peclet number.
Definition: advection_diffusion_elements.h:318
Definition: shape.h:278
virtual void output(std::ostream &outfile)
Definition: elements.h:3050
virtual std::string tecplot_zone_string(const unsigned &nplot) const
Definition: elements.h:3161
virtual unsigned nvertex_node() const
Definition: elements.h:2491
virtual double interpolated_x(const Vector< double > &s, const unsigned &i) const
Return FE interpolated coordinate x[i] at local coordinate s.
Definition: elements.cc:3962
unsigned nnode() const
Return the number of nodes.
Definition: elements.h:2210
virtual void get_s_plot(const unsigned &i, const unsigned &nplot, Vector< double > &s, const bool &shifted_to_interior=false) const
Definition: elements.h:3148
virtual Node * vertex_node_pt(const unsigned &j) const
Definition: elements.h:2500
virtual unsigned nplot_points(const unsigned &nplot) const
Definition: elements.h:3186
double nodal_position(const unsigned &n, const unsigned &i) const
Definition: elements.h:2317
virtual void write_tecplot_zone_footer(std::ostream &outfile, const unsigned &nplot) const
Definition: elements.h:3174
Definition: mesh.h:67
Definition: nodes.h:906
Definition: advection_diffusion_elements.h:610
Definition: Qelements.h:459
Definition: supg_advection_diffusion_elements.h:44
double dshape_and_dtest_eulerian_adv_diff(const Vector< double > &s, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const
Definition: supg_advection_diffusion_elements.cc:49
void compute_stabilisation_parameter()
Compute stabilisation parameter for the element.
Definition: supg_advection_diffusion_elements.h:70
void output(std::ostream &outfile)
Output at default number of plot points.
Definition: supg_advection_diffusion_elements.h:213
void switch_off_stabilisation()
Set stabilisation parameter for the element to zero.
Definition: supg_advection_diffusion_elements.h:63
double get_Tau_SUPG()
Get stabilisation parameter for the element.
Definition: supg_advection_diffusion_elements.h:56
void output(FILE *file_pt)
C-style output.
Definition: supg_advection_diffusion_elements.h:219
void output(std::ostream &outfile, const unsigned &nplot)
Definition: supg_advection_diffusion_elements.h:169
double Tau_SUPG
SUPG stabilisation parameter.
Definition: supg_advection_diffusion_elements.h:250
void output(FILE *file_pt, const unsigned &n_plot)
C_style output at n_plot points.
Definition: supg_advection_diffusion_elements.h:225
QSUPGAdvectionDiffusionElement()
Definition: supg_advection_diffusion_elements.h:49
double dshape_and_dtest_eulerian_at_knot_adv_diff(const unsigned &ipt, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const
Definition: supg_advection_diffusion_elements.cc:107
Definition: refineable_advection_diffusion_elements.h:58
Definition: refineable_elements.h:97
Definition: Qelements.h:2259
Definition: supg_advection_diffusion_elements.h:269
void rebuild_from_sons(Mesh *&mesh_pt)
Rebuild from sons: empty.
Definition: supg_advection_diffusion_elements.h:310
unsigned nvertex_node() const
Number of vertex nodes in the element.
Definition: supg_advection_diffusion_elements.h:298
unsigned nrecovery_order()
Definition: supg_advection_diffusion_elements.h:314
void operator=(const RefineableQSUPGAdvectionDiffusionElement< DIM, NNODE_1D > &)=delete
Broken assignment operator.
Node * vertex_node_pt(const unsigned &j) const
Pointer to the j-th vertex node in the element.
Definition: supg_advection_diffusion_elements.h:304
RefineableQSUPGAdvectionDiffusionElement()
Definition: supg_advection_diffusion_elements.h:273
unsigned ncont_interpolated_values() const
Number of continuously interpolated values: 1.
Definition: supg_advection_diffusion_elements.h:292
void further_setup_hanging_nodes()
Definition: supg_advection_diffusion_elements.h:321
RefineableQSUPGAdvectionDiffusionElement(const RefineableQSUPGAdvectionDiffusionElement< DIM, NNODE_1D > &dummy)=delete
Broken copy constructor.
Definition: shape.h:76
RealScalar s
Definition: level1_cplx_impl.h:130
#define DIM
Definition: linearised_navier_stokes_elements.h:44
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 pow(const bfloat16 &a, const bfloat16 &b)
Definition: BFloat16.h:625
squared absolute sa ArrayBase::abs2 DOXCOMMA MatrixBase::cwiseAbs2 sa Eigen::abs2 DOXCOMMA Eigen::pow DOXCOMMA ArrayBase::square nearest sa Eigen::floor DOXCOMMA Eigen::ceil DOXCOMMA ArrayBase::round nearest integer not less than the given sa Eigen::floor DOXCOMMA ArrayBase::ceil not a number test
Definition: GlobalFunctions.h:109
Real fabs(const Real &a)
Definition: boostmultiprec.cpp:117
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
list x
Definition: plotDoE.py:28
Definition: indexed_view.cpp:20
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2