flux_transport_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 flux transport elements base class
27
28#ifndef OOMPH_FLUX_TRANSPORT_ELEMENTS_HEADER
29#define OOMPH_FLUX_TRANSPORT_ELEMENTS_HEADER
30
31// Config header generated by autoconfig
32#ifdef HAVE_CONFIG_H
33#include <oomph-lib-config.h>
34#endif
35
36#include "../generic/elements.h"
37
38
39namespace oomph
40{
41 //==================================================================
42 /// Base class for the flux transport equations templated by the
43 /// dimension DIM. The equations that are solved are
44 /// \f[ \frac{\partial u_{i}}{\partial t} + \frac{\partial}{\partial x_{j}} \left(F_{ij}(u_{k})\right), \f]
45 /// where \f$ F_{ij} \f$ is a matrix of flux components.
46 //==================================================================
47 template<unsigned DIM>
49 {
50 protected:
51 /// Return the number of fluxes (default zero)
52 virtual inline unsigned nflux() const
53 {
54 return 0;
55 }
56
57 /// Return the index at which the i-th unknown value
58 /// is stored. The default value, i, is appropriate for single-physics
59 /// problems.
60 /// In derived multi-physics elements, this function should be overloaded
61 /// to reflect the chosen storage scheme. Note that these equations require
62 /// that the unknowns are always stored at the same indices at each node.
63 virtual inline unsigned u_index_flux_transport(const unsigned& i) const
64 {
65 return i;
66 }
67
68 /// Return the flux as a function of the unknown. This interface
69 /// could (should) be generalised)
70 virtual void flux(const Vector<double>& u, DenseMatrix<double>& f)
71 {
72 std::ostringstream error_stream;
73 error_stream
74 << "Default empty flux function called\n"
75 << "This should be overloaded with a specific flux function\n"
76 << "in a derived class\n";
77 throw OomphLibError(
78 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
79 }
80
81 /// Return the flux derivatives as a funciton of the unknowns
82 /// Default finite-different implementation
83 virtual void dflux_du(const Vector<double>& u,
85
86 /// Shape/test functions and derivs w.r.t. to global coords at
87 /// local coord. s; return Jacobian of mapping
89 const Vector<double>& s,
90 Shape& psi,
91 DShape& dpsidx,
92 Shape& test,
93 DShape& dtestdx) const = 0;
94
95 /// Shape/test functions and derivs w.r.t. to global coords at
96 /// integration point ipt; return Jacobian of mapping
98 const unsigned& ipt,
99 Shape& psi,
100 DShape& dpsidx,
101 Shape& test,
102 DShape& dtestdx) const = 0;
103
104
105 public:
106 /// Constructor
108
109 /// Empty destructor
111
112 /// Compute the element's residual Vector
114 {
115 // Call the generic residuals function with flag set to 0
116 // and using a dummy matrix argument
118 residuals,
121 0);
122 }
123
124 /// Compute the element's residual Vector and the jacobian matrix
125 /// Virtual function can be overloaded by hanging-node version
127 DenseMatrix<double>& jacobian)
128 {
129 // Call the generic routine with the flag set to 1
131 residuals, jacobian, GeneralisedElement::Dummy_matrix, 1);
132 }
133
134 /// Add the element's contribution to its residuals vector,
135 /// jacobian matrix and mass matrix
137 Vector<double>& residuals,
138 DenseMatrix<double>& jacobian,
139 DenseMatrix<double>& mass_matrix)
140 {
141 // Call the generic routine with the flag set to 2
143 residuals, jacobian, mass_matrix, 2);
144 }
145
146 /// Assemble the contributions to the mass matrix and residuals
148 DenseMatrix<double>& mass_matrix)
149 {
151 residuals, GeneralisedElement::Dummy_matrix, mass_matrix, 3);
152 }
153
154
155 /// Compute the residuals for the Navier--Stokes equations;
156 /// flag=1(or 0): do (or don't) compute the Jacobian as well.
158 Vector<double>& residuals,
159 DenseMatrix<double>& jacobian,
160 DenseMatrix<double>& mass_matrix,
161 unsigned flag);
162
163 // Get the value of the unknowns
165 const unsigned& i);
166
167 /// i-th component of du/dt at local node n.
168 /// Uses suitably interpolated value for hanging nodes.
169 double du_dt_flux_transport(const unsigned& n, const unsigned& i) const;
170
171 /// Compute the average values of the fluxes
172 void calculate_element_averages(double*& average_values);
173
174 // Default output function
175 void output(std::ostream& outfile)
176 {
177 unsigned nplot = 5;
178 output(outfile, nplot);
179 }
180
181 void output(std::ostream& outfile, const unsigned& nplot);
182 };
183
184} // namespace oomph
185
186#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
A general Finite Element class.
Definition: elements.h:1313
Base class for the flux transport equations templated by the dimension DIM. The equations that are so...
void fill_in_contribution_to_mass_matrix(Vector< double > &residuals, DenseMatrix< double > &mass_matrix)
Assemble the contributions to the mass matrix and residuals.
virtual double dshape_and_dtest_eulerian_at_knot_flux_transport(const unsigned &ipt, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const =0
Shape/test functions and derivs w.r.t. to global coords at integration point ipt; return Jacobian of ...
virtual unsigned u_index_flux_transport(const unsigned &i) const
Return the index at which the i-th unknown value is stored. The default value, i, is appropriate for ...
virtual void fill_in_generic_residual_contribution_flux_transport(Vector< double > &residuals, DenseMatrix< double > &jacobian, DenseMatrix< double > &mass_matrix, unsigned flag)
Compute the residuals for the Navier–Stokes equations; flag=1(or 0): do (or don't) compute the Jacobi...
void calculate_element_averages(double *&average_values)
Compute the average values of the fluxes.
void fill_in_contribution_to_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian)
Compute the element's residual Vector and the jacobian matrix Virtual function can be overloaded by h...
virtual void dflux_du(const Vector< double > &u, RankThreeTensor< double > &df_du)
Return the flux derivatives as a funciton of the unknowns Default finite-different implementation.
double interpolated_u_flux_transport(const Vector< double > &s, const unsigned &i)
Return the i-th unknown at the local coordinate s.
virtual double dshape_and_dtest_eulerian_flux_transport(const Vector< double > &s, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const =0
Shape/test functions and derivs w.r.t. to global coords at local coord. s; return Jacobian of mapping...
double du_dt_flux_transport(const unsigned &n, const unsigned &i) const
i-th component of du/dt at local node n. Uses suitably interpolated value for hanging nodes.
virtual void flux(const Vector< double > &u, DenseMatrix< double > &f)
Return the flux as a function of the unknown. This interface could (should) be generalised)
void fill_in_contribution_to_residuals(Vector< double > &residuals)
Compute the element's residual Vector.
void fill_in_contribution_to_jacobian_and_mass_matrix(Vector< double > &residuals, DenseMatrix< double > &jacobian, DenseMatrix< double > &mass_matrix)
Add the element's contribution to its residuals vector, jacobian matrix and mass matrix.
virtual ~FluxTransportEquations()
Empty destructor.
virtual unsigned nflux() const
Return the number of fluxes (default zero)
void output(std::ostream &outfile)
Output the element data — typically the values at the nodes in a format suitable for post-processing.
static DenseMatrix< double > Dummy_matrix
Empty dense matrix used as a dummy argument to combined residual and jacobian functions in the case w...
Definition: elements.h:227
An OomphLibError object which should be thrown when an run-time error is encountered....
////////////////////////////////////////////////////////////////// //////////////////////////////////...
Definition: matrices.h:1370
A Class for shape functions. In simple cases, the shape functions have only one index that can be tho...
Definition: shape.h:76
//////////////////////////////////////////////////////////////////// ////////////////////////////////...