Tadvection_diffusion_reaction_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// Header file for TAdvectionDiffusionReaction elements
27#ifndef OOMPH_TADVECTION_DIFFUSION_REACTION_ELEMENTS_HEADER
28#define OOMPH_TADVECTION_DIFFUSION_REACTION_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"
43
44namespace oomph
45{
46 /// //////////////////////////////////////////////////////////////////////
47 /// //////////////////////////////////////////////////////////////////////
48 // TAdvectionDiffusionReactionElement
49 /// /////////////////////////////////////////////////////////////////////
50 /// /////////////////////////////////////////////////////////////////////
51
52
53 //======================================================================
54 /// TAdvectionDiffusionReactionElement<NREAGENT,DIM,NNODE_1D>
55 /// elements are isoparametric triangular
56 /// DIM-dimensional AdvectionDiffusionReaction elements
57 /// with NNODE_1D nodal points along each
58 /// element edge. Inherits from TElement
59 /// and AdvectionDiffusionReactionEquations
60 //======================================================================
61 template<unsigned NREAGENT, unsigned DIM, unsigned NNODE_1D>
63 : public virtual TElement<DIM, NNODE_1D>,
64 public virtual AdvectionDiffusionReactionEquations<NREAGENT, DIM>,
65 public virtual ElementWithZ2ErrorEstimator
66 {
67 public:
68 /// Constructor: Call constructors for TElement and
69 /// AdvectionDiffusionReaction equations
71 : TElement<DIM, NNODE_1D>(),
73 {
74 }
75
76
77 /// Broken copy constructor
80 dummy) = delete;
81
82 /// Broken assignment operator
85 delete;
86
87 /// Access function for Nvalue: # of `values' (pinned or dofs)
88 /// at node n (always returns the same value at every node, 1)
89 inline unsigned required_nvalue(const unsigned& n) const
90 {
91 return NREAGENT;
92 }
93
94 /// Output function:
95 /// x,y,u or x,y,z,u
96 void output(std::ostream& outfile)
97 {
99 }
100
101 /// Output function:
102 /// x,y,u or x,y,z,u at n_plot^DIM plot points
103 void output(std::ostream& outfile, const unsigned& n_plot)
104 {
106 n_plot);
107 }
108
109
110 /// C-style output function:
111 /// x,y,u or x,y,z,u
112 void output(FILE* file_pt)
113 {
115 }
116
117
118 /// C-style output function:
119 /// x,y,u or x,y,z,u at n_plot^DIM plot points
120 void output(FILE* file_pt, const unsigned& n_plot)
121 {
123 n_plot);
124 }
125
126
127 /// Output function for an exact solution:
128 /// x,y,u_exact
129 void output_fct(std::ostream& outfile,
130 const unsigned& n_plot,
132 {
134 outfile, n_plot, exact_soln_pt);
135 }
136
137
138 /// Output function for a time-dependent exact solution.
139 /// x,y,u_exact (calls the steady version)
140 void output_fct(std::ostream& outfile,
141 const unsigned& n_plot,
142 const double& time,
144 {
146 outfile, n_plot, time, exact_soln_pt);
147 }
148
149 protected:
150 /// Shape, test functions & derivs. w.r.t. to global coords. Return
151 /// Jacobian.
153 const Vector<double>& s,
154 Shape& psi,
155 DShape& dpsidx,
156 Shape& test,
157 DShape& dtestdx) const;
158
159
160 /// Shape, test functions & derivs. w.r.t. to global coords. Return
161 /// Jacobian.
163 const unsigned& ipt,
164 Shape& psi,
165 DShape& dpsidx,
166 Shape& test,
167 DShape& dtestdx) const;
168
169 /// Shape/test functions and derivs w.r.t. to global coords at
170 /// integration point ipt; return Jacobian of mapping (J). Also compute
171 /// derivatives of dpsidx, dtestdx and J w.r.t. nodal coordinates.
173 const unsigned& ipt,
174 Shape& psi,
175 DShape& dpsidx,
176 RankFourTensor<double>& d_dpsidx_dX,
177 Shape& test,
178 DShape& dtestdx,
179 RankFourTensor<double>& d_dtestdx_dX,
180 DenseMatrix<double>& djacobian_dX) const;
181
182 /// Order of recovery shape functions for Z2 error estimation:
183 /// Same order as shape functions.
185 {
186 return (NNODE_1D - 1);
187 }
188
189 /// Number of 'flux' terms for Z2 error estimation
191 {
192 return NREAGENT * DIM;
193 }
194
195 /// Get 'flux' for Z2 error recovery: Standard flux.from
196 /// AdvectionDiffusionReaction equations
198 {
199 this->get_flux(s, flux);
200 }
201
202 /// Number of vertex nodes in the element
203 unsigned nvertex_node() const
204 {
206 }
207
208 /// Pointer to the j-th vertex node in the element
209 Node* vertex_node_pt(const unsigned& j) const
210 {
212 }
213 };
214
215
216 // Inline functions:
217
218
219 //======================================================================
220 /// Define the shape functions and test functions and derivatives
221 /// w.r.t. global coordinates and return Jacobian of mapping.
222 ///
223 /// Galerkin: Test functions = shape functions
224 //======================================================================
225 template<unsigned NREAGENT, unsigned DIM, unsigned NNODE_1D>
228 Shape& psi,
229 DShape& dpsidx,
230 Shape& test,
231 DShape& dtestdx) const
232 {
233 unsigned n_node = this->nnode();
234
235 // Call the geometrical shape functions and derivatives
236 double J = this->dshape_eulerian(s, psi, dpsidx);
237
238 // Loop over the test functions and derivatives and set them equal to the
239 // shape functions
240 for (unsigned i = 0; i < n_node; i++)
241 {
242 test[i] = psi[i];
243 dtestdx(i, 0) = dpsidx(i, 0);
244 dtestdx(i, 1) = dpsidx(i, 1);
245 }
246
247 // Return the jacobian
248 return J;
249 }
250
251
252 //======================================================================
253 /// Define the shape functions and test functions and derivatives
254 /// w.r.t. global coordinates and return Jacobian of mapping.
255 ///
256 /// Galerkin: Test functions = shape functions
257 //======================================================================
258 template<unsigned NREAGENT, unsigned DIM, unsigned NNODE_1D>
261 Shape& psi,
262 DShape& dpsidx,
263 Shape& test,
264 DShape& dtestdx) const
265 {
266 // Call the geometrical shape functions and derivatives
267 double J = this->dshape_eulerian_at_knot(ipt, psi, dpsidx);
268
269 // Set the pointers of the test functions
270 test = psi;
271 dtestdx = dpsidx;
272
273 // Return the jacobian
274 return J;
275 }
276
277
278 //======================================================================
279 /// Define the shape functions (psi) and test functions (test) and
280 /// their derivatives w.r.t. global coordinates (dpsidx and dtestdx)
281 /// and return Jacobian of mapping (J). Additionally compute the
282 /// derivatives of dpsidx, dtestdx and J w.r.t. nodal coordinates.
283 ///
284 /// Galerkin: Test functions = shape functions
285 //======================================================================
286 template<unsigned NREAGENT, unsigned DIM, unsigned NNODE_1D>
289 const unsigned& ipt,
290 Shape& psi,
291 DShape& dpsidx,
292 RankFourTensor<double>& d_dpsidx_dX,
293 Shape& test,
294 DShape& dtestdx,
295 RankFourTensor<double>& d_dtestdx_dX,
296 DenseMatrix<double>& djacobian_dX) const
297 {
298 // Call the geometrical shape functions and derivatives
299 const double J = this->dshape_eulerian_at_knot(
300 ipt, psi, dpsidx, djacobian_dX, d_dpsidx_dX);
301
302 // Set the pointers of the test functions
303 test = psi;
304 dtestdx = dpsidx;
305 d_dtestdx_dX = d_dpsidx_dX;
306
307 // Return the jacobian
308 return J;
309 }
310
311
312 //=======================================================================
313 /// Face geometry for the TAdvectionDiffusionReactionElement elements: The
314 /// spatial dimension of the face elements is one lower than that of the bulk
315 /// element but they have the same number of points along their 1D edges.
316 //=======================================================================
317 template<unsigned NREAGENT, unsigned DIM, unsigned NNODE_1D>
319 TAdvectionDiffusionReactionElement<NREAGENT, DIM, NNODE_1D>>
320 : public virtual TElement<DIM - 1, NNODE_1D>
321 {
322 public:
323 /// Constructor: Call the constructor for the
324 /// appropriate lower-dimensional TElement
325 FaceGeometry() : TElement<DIM - 1, NNODE_1D>() {}
326 };
327
328 //=======================================================================
329 /// Face geometry for the 1D TAdvectionDiffusionReactionElement elements:
330 /// Point elements
331 //=======================================================================
332 template<unsigned NREAGENT, unsigned NNODE_1D>
334 : public virtual PointElement
335 {
336 public:
337 /// Constructor: Call the constructor for the
338 /// appropriate lower-dimensional TElement
340 };
341
342
343} // namespace oomph
344
345#endif
static char t char * s
Definition: cfortran.h:568
cstr elem_len * i
Definition: cfortran.h:603
A class for all elements that solve the Advection Diffusion Reaction equations using isoparametric el...
void get_flux(const Vector< double > &s, Vector< double > &flux) const
Get flux: .
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.
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:4998
void(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution" as .
Definition: elements.h:1759
void(* UnsteadyExactSolutionFctPt)(const double &, const Vector< double > &, Vector< double > &)
Function pointer for function that computes Vector-valued time-dependent function as .
Definition: elements.h:1765
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:3439
////////////////////////////////////////////////////////////////// //////////////////////////////////...
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
//////////////////////////////////////////////////////////////////////
void operator=(const TAdvectionDiffusionReactionElement< NREAGENT, DIM, NNODE_1D > &)=delete
Broken assignment operator.
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, const unsigned &n_plot)
C-style output function: x,y,u or x,y,z,u at n_plot^DIM plot points.
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)
C-style output function: x,y,u or x,y,z,u.
void output(std::ostream &outfile)
Output function: x,y,u or x,y,z,u.
double dshape_and_dtest_eulerian_adv_diff_react(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.
Node * vertex_node_pt(const unsigned &j) const
Pointer to the j-th vertex node in the element.
unsigned nrecovery_order()
Order of recovery shape functions for Z2 error estimation: Same order as shape functions.
unsigned nvertex_node() const
Number of vertex nodes in the element.
void get_Z2_flux(const Vector< double > &s, Vector< double > &flux)
Get 'flux' for Z2 error recovery: Standard flux.from AdvectionDiffusionReaction equations.
double dshape_and_dtest_eulerian_at_knot_adv_diff_react(const unsigned &ipt, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const
Shape, test functions & derivs. w.r.t. to global coords. Return Jacobian.
unsigned required_nvalue(const unsigned &n) const
Access function for Nvalue: # of ‘values’ (pinned or dofs) at node n (always returns the same value a...
TAdvectionDiffusionReactionElement()
Constructor: Call constructors for TElement and AdvectionDiffusionReaction equations.
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.
TAdvectionDiffusionReactionElement(const TAdvectionDiffusionReactionElement< NREAGENT, DIM, NNODE_1D > &dummy)=delete
Broken copy constructor.
unsigned num_Z2_flux_terms()
Number of 'flux' terms for Z2 error estimation.
General TElement class.
Definition: Telements.h:1208
//////////////////////////////////////////////////////////////////// ////////////////////////////////...