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