Tunsteady_heat_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-2024 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 // Header file for TUnsteadyHeat elements
27 #ifndef OOMPH_TUNSTEADY_HEAT_ELEMENTS_HEADER
28 #define OOMPH_TUNSTEADY_HEAT_ELEMENTS_HEADER
29 
30 
31 // Config header generated by autoconfig
32 #ifdef HAVE_CONFIG_H
33 #include <oomph-lib-config.h>
34 #endif
35 
36 
37 // OOMPH-LIB headers
38 #include "../generic/nodes.h"
39 #include "../generic/oomph_utilities.h"
40 #include "../generic/Telements.h"
41 #include "../generic/error_estimator.h"
42 #include "unsteady_heat_elements.h"
43 
44 namespace oomph
45 {
46  /// //////////////////////////////////////////////////////////////////////
47  /// //////////////////////////////////////////////////////////////////////
48  // TUnsteadyHeatElement
49  /// /////////////////////////////////////////////////////////////////////
50  /// /////////////////////////////////////////////////////////////////////
51 
52 
53  //======================================================================
54  /// TUnsteadyHeatElement<DIM,NNODE_1D> elements are isoparametric triangular
55  /// DIM-dimensional UnsteadyHeat elements with NNODE_1D nodal points along
56  /// each element edge. Inherits from TElement and UnsteadyHeatEquations
57  //======================================================================
58  template<unsigned DIM, unsigned NNODE_1D>
59  class TUnsteadyHeatElement : public virtual TElement<DIM, NNODE_1D>,
60  public virtual UnsteadyHeatEquations<DIM>,
61  public virtual ElementWithZ2ErrorEstimator
62  {
63  public:
64  /// Constructor: Call constructors for TElement and
65  /// UnsteadyHeat equations
67  : TElement<DIM, NNODE_1D>(), UnsteadyHeatEquations<DIM>()
68  {
69  }
70 
71 
72  /// Broken copy constructor
74  delete;
75 
76  /// Broken assignment operator
77  // Commented out broken assignment operator because this can lead to a
78  // conflict warning when used in the virtual inheritence hierarchy.
79  // Essentially the compiler doesn't realise that two separate
80  // implementations of the broken function are the same and so, quite
81  // rightly, it shouts.
82  /*void operator=(const TUnsteadyHeatElement<DIM,NNODE_1D>&) = delete;*/
83 
84  /// Access function for Nvalue: # of `values' (pinned or dofs)
85  /// at node n (always returns the same value at every node, 1)
86  inline unsigned required_nvalue(const unsigned& n) const
87  {
88  return Initial_Nvalue;
89  }
90 
91  /// Output function:
92  /// x,y,u or x,y,z,u
93  void output(std::ostream& outfile)
94  {
96  }
97 
98  /// Output function:
99  /// x,y,u or x,y,z,u at n_plot^DIM plot points
100  void output(std::ostream& outfile, const unsigned& n_plot)
101  {
102  UnsteadyHeatEquations<DIM>::output(outfile, n_plot);
103  }
104 
105 
106  /// C-style output function:
107  /// x,y,u or x,y,z,u
108  void output(FILE* file_pt)
109  {
111  }
112 
113 
114  /// C-style output function:
115  /// x,y,u or x,y,z,u at n_plot^DIM plot points
116  void output(FILE* file_pt, const unsigned& n_plot)
117  {
118  UnsteadyHeatEquations<DIM>::output(file_pt, n_plot);
119  }
120 
121 
122  /// Output function for an exact solution:
123  /// x,y,u_exact
124  void output_fct(std::ostream& outfile,
125  const unsigned& n_plot,
127  {
128  UnsteadyHeatEquations<DIM>::output_fct(outfile, n_plot, exact_soln_pt);
129  }
130 
131 
132  /// Output function for a time-dependent exact solution.
133  /// x,y,u_exact (calls the steady version)
134  void output_fct(std::ostream& outfile,
135  const unsigned& n_plot,
136  const double& time,
138  {
140  outfile, n_plot, time, exact_soln_pt);
141  }
142 
143  protected:
144  /// Shape, test functions & derivs. w.r.t. to global coords. Return
145  /// Jacobian.
147  Shape& psi,
148  DShape& dpsidx,
149  Shape& test,
150  DShape& dtestdx) const;
151 
152 
153  /// Shape, test functions & derivs. w.r.t. to global coords. Return
154  /// Jacobian.
156  const unsigned& ipt,
157  Shape& psi,
158  DShape& dpsidx,
159  Shape& test,
160  DShape& dtestdx) const;
161 
162  /// Shape/test functions and derivs w.r.t. to global coords at
163  /// integration point ipt; return Jacobian of mapping (J). Also compute
164  /// derivatives of dpsidx, dtestdx and J w.r.t. nodal coordinates.
166  const unsigned& ipt,
167  Shape& psi,
168  DShape& dpsidx,
169  RankFourTensor<double>& d_dpsidx_dX,
170  Shape& test,
171  DShape& dtestdx,
172  RankFourTensor<double>& d_dtestdx_dX,
173  DenseMatrix<double>& djacobian_dX) const;
174 
175  /// Order of recovery shape functions for Z2 error estimation:
176  /// Same order as shape functions.
177  unsigned nrecovery_order()
178  {
179  return (NNODE_1D - 1);
180  }
181 
182  /// Number of 'flux' terms for Z2 error estimation
183  unsigned num_Z2_flux_terms()
184  {
185  return DIM;
186  }
187 
188  /// Get 'flux' for Z2 error recovery: Standard flux from
189  /// UnsteadyHeat equations
191  {
192  this->get_flux(s, flux);
193  }
194 
195  /// Number of vertex nodes in the element
196  unsigned nvertex_node() const
197  {
199  }
200 
201  /// Pointer to the j-th vertex node in the element
202  Node* vertex_node_pt(const unsigned& j) const
203  {
205  }
206 
207  private:
208  /// Static unsigned that holds the (same) number of variables at every node
209  static const unsigned Initial_Nvalue;
210  };
211 
212 
213  // Inline functions:
214 
215 
216  //======================================================================
217  /// Define the shape functions and test functions and derivatives
218  /// w.r.t. global coordinates and return Jacobian of mapping.
219  ///
220  /// Galerkin: Test functions = shape functions
221  //======================================================================
222  template<unsigned DIM, unsigned NNODE_1D>
225  Shape& psi,
226  DShape& dpsidx,
227  Shape& test,
228  DShape& dtestdx) const
229  {
230  unsigned n_node = this->nnode();
231 
232  // Call the geometrical shape functions and derivatives
233  double J = this->dshape_eulerian(s, psi, dpsidx);
234 
235  // Loop over the test functions and derivatives and set them equal to the
236  // shape functions
237  for (unsigned i = 0; i < n_node; i++)
238  {
239  test[i] = psi[i];
240  dtestdx(i, 0) = dpsidx(i, 0);
241  dtestdx(i, 1) = dpsidx(i, 1);
242  }
243 
244  // Return the jacobian
245  return J;
246  }
247 
248 
249  //======================================================================
250  /// Define the shape functions and test functions and derivatives
251  /// w.r.t. global coordinates and return Jacobian of mapping.
252  ///
253  /// Galerkin: Test functions = shape functions
254  //======================================================================
255  template<unsigned DIM, unsigned NNODE_1D>
258  Shape& psi,
259  DShape& dpsidx,
260  Shape& test,
261  DShape& dtestdx) const
262  {
263  // Call the geometrical shape functions and derivatives
264  double J = this->dshape_eulerian_at_knot(ipt, psi, dpsidx);
265 
266  // Set the pointers of the test functions
267  test = psi;
268  dtestdx = dpsidx;
269 
270  // Return the jacobian
271  return J;
272  }
273 
274 
275  //======================================================================
276  /// Define the shape functions (psi) and test functions (test) and
277  /// their derivatives w.r.t. global coordinates (dpsidx and dtestdx)
278  /// and return Jacobian of mapping (J). Additionally compute the
279  /// derivatives of dpsidx, dtestdx and J w.r.t. nodal coordinates.
280  ///
281  /// Galerkin: Test functions = shape functions
282  //======================================================================
283  template<unsigned DIM, unsigned NNODE_1D>
286  const unsigned& ipt,
287  Shape& psi,
288  DShape& dpsidx,
289  RankFourTensor<double>& d_dpsidx_dX,
290  Shape& test,
291  DShape& dtestdx,
292  RankFourTensor<double>& d_dtestdx_dX,
293  DenseMatrix<double>& djacobian_dX) const
294  {
295  // Call the geometrical shape functions and derivatives
296  const double J = this->dshape_eulerian_at_knot(
297  ipt, psi, dpsidx, djacobian_dX, d_dpsidx_dX);
298 
299  // Set the pointers of the test functions
300  test = psi;
301  dtestdx = dpsidx;
302  d_dtestdx_dX = d_dpsidx_dX;
303 
304  // Return the jacobian
305  return J;
306  }
307 
308 
309  //=======================================================================
310  /// Face geometry for the TUnsteadyHeatElement elements: The spatial
311  /// dimension of the face elements is one lower than that of the
312  /// bulk element but they have the same number of points
313  /// along their 1D edges.
314  //=======================================================================
315  template<unsigned DIM, unsigned NNODE_1D>
316  class FaceGeometry<TUnsteadyHeatElement<DIM, NNODE_1D>>
317  : public virtual TElement<DIM - 1, NNODE_1D>
318  {
319  public:
320  /// Constructor: Call the constructor for the
321  /// appropriate lower-dimensional TElement
322  FaceGeometry() : TElement<DIM - 1, NNODE_1D>() {}
323  };
324 
325  //=======================================================================
326  /// Face geometry for the 1D TUnsteadyHeatElement elements: Point elements
327  //=======================================================================
328  template<unsigned NNODE_1D>
329  class FaceGeometry<TUnsteadyHeatElement<1, NNODE_1D>>
330  : public virtual PointElement
331  {
332  public:
333  /// Constructor: Call the constructor for the
334  /// appropriate lower-dimensional TElement
336  };
337 
338 
339 } // namespace oomph
340 
341 #endif
static char t char * s
Definition: cfortran.h:568
cstr elem_len * i
Definition: cfortran.h:603
A Class for the derivatives of shape functions The class design is essentially the same as Shape,...
Definition: shape.h:278
Base class for finite elements that can compute the quantities that are required for the Z2 error est...
FaceGeometry()
Constructor: Call the constructor for the appropriate lower-dimensional TElement.
FaceGeometry()
Constructor: Call the constructor for the appropriate lower-dimensional TElement.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
Definition: elements.h:5002
void(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution" as .
Definition: elements.h:1763
void(* UnsteadyExactSolutionFctPt)(const double &, const Vector< double > &, Vector< double > &)
Function pointer for function that computes Vector-valued time-dependent function as .
Definition: elements.h:1769
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
Definition: nodes.h:906
/////////////////////////////////////////////////////////////////////// /////////////////////////////...
Definition: elements.h:3443
////////////////////////////////////////////////////////////////// //////////////////////////////////...
Definition: matrices.h:1701
A Class for shape functions. In simple cases, the shape functions have only one index that can be tho...
Definition: shape.h:76
General TElement class.
Definition: Telements.h:1208
//////////////////////////////////////////////////////////////////////
void output(std::ostream &outfile)
Output function: x,y,u or x,y,z,u.
double dshape_and_dtest_eulerian_at_knot_ust_heat(const unsigned &ipt, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const
Shape, test functions & derivs. w.r.t. to global coords. Return Jacobian.
TUnsteadyHeatElement()
Constructor: Call constructors for TElement and UnsteadyHeat equations.
void output(std::ostream &outfile, const unsigned &n_plot)
Output function: x,y,u or x,y,z,u at n_plot^DIM plot points.
void output(FILE *file_pt)
C-style output function: x,y,u or x,y,z,u.
unsigned nrecovery_order()
Order of recovery shape functions for Z2 error estimation: Same order as shape functions.
unsigned num_Z2_flux_terms()
Number of 'flux' terms for Z2 error estimation.
unsigned nvertex_node() const
Number of vertex nodes in the element.
double dshape_and_dtest_eulerian_ust_heat(const Vector< double > &s, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const
Shape, test functions & derivs. w.r.t. to global coords. Return Jacobian.
void output_fct(std::ostream &outfile, const unsigned &n_plot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output function for an exact solution: x,y,u_exact.
static const unsigned Initial_Nvalue
Static unsigned that holds the (same) number of variables at every node.
TUnsteadyHeatElement(const TUnsteadyHeatElement< DIM, NNODE_1D > &dummy)=delete
Broken copy constructor.
void get_Z2_flux(const Vector< double > &s, Vector< double > &flux)
Get 'flux' for Z2 error recovery: Standard flux from UnsteadyHeat equations.
void output(FILE *file_pt, const unsigned &n_plot)
C-style output function: x,y,u or x,y,z,u at n_plot^DIM plot points.
Node * vertex_node_pt(const unsigned &j) const
Pointer to the j-th vertex node in the element.
unsigned required_nvalue(const unsigned &n) const
Broken assignment operator.
void output_fct(std::ostream &outfile, const unsigned &n_plot, const double &time, FiniteElement::UnsteadyExactSolutionFctPt exact_soln_pt)
Output function for a time-dependent exact solution. x,y,u_exact (calls the steady version)
A class for all isoparametric elements that solve the UnsteadyHeat equations.
void get_flux(const Vector< double > &s, Vector< double > &flux) const
Get flux: flux[i] = du/dx_i.
void output(std::ostream &outfile)
Output with default number of plot points.
void output_fct(std::ostream &outfile, const unsigned &nplot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output exact soln: x,y,u_exact or x,y,z,u_exact at nplot^DIM plot points.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...