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// 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 flux transport elements base class
31 
32 #ifndef OOMPH_FLUX_TRANSPORT_ELEMENTS_HEADER
33 #define OOMPH_FLUX_TRANSPORT_ELEMENTS_HEADER
34 
35 // Config header generated by autoconfig
36 #ifdef HAVE_CONFIG_H
37 #include <oomph-lib-config.h>
38 #endif
39 
40 #include "../generic/elements.h"
41 
42 
43 namespace oomph
44 {
45 
46  //==================================================================
47  ///Base class for the flux transport equations templated by the
48  ///dimension DIM. The equations that are solved are
49  /// \f[ \frac{\partial u_{i}}{\partial t} + \frac{\partial}{\partial x_{j}}
50  /// \left(F_{ij}(u_{k})\right), \f]
51  /// where \f$ F_{ij} \f$ is a matrix of flux components.
52  //==================================================================
53 template<unsigned DIM>
54 class FluxTransportEquations : public virtual FiniteElement
55 {
56 
57 protected:
58 
59  /// \short Return the number of fluxes (default zero)
60  virtual inline unsigned nflux() const {return 0;}
61 
62  /// \short Return the index at which the i-th unknown value
63  /// is stored. The default value, i, is appropriate for single-physics
64  /// problems.
65  /// In derived multi-physics elements, this function should be overloaded
66  /// to reflect the chosen storage scheme. Note that these equations require
67  /// that the unknowns are always stored at the same indices at each node.
68  virtual inline unsigned u_index_flux_transport(const unsigned &i)
69  const {return i;}
70 
71  /// \short Return the flux as a function of the unknown. This interface
72  /// could (should) be generalised)
73  virtual void flux(const Vector<double> &u, DenseMatrix<double> &f)
74  {
75  std::ostringstream error_stream;
76  error_stream << "Default empty flux function called\n"
77  << "This should be overloaded with a specific flux function\n"
78  << "in a derived class\n";
79  throw OomphLibError(error_stream.str(),
80  OOMPH_CURRENT_FUNCTION,
81  OOMPH_EXCEPTION_LOCATION);
82  }
83 
84  /// \short Return the flux derivatives as a funciton of the unknowns
85  /// Default finite-different implementation
86  virtual void dflux_du(const Vector<double> &u,
88 
89  /// \short Shape/test functions and derivs w.r.t. to global coords at
90  /// local coord. s; return Jacobian of mapping
92  const Vector<double> &s,
93  Shape &psi,
94  DShape &dpsidx,
95  Shape &test,
96  DShape &dtestdx) const=0;
97 
98  /// \short Shape/test functions and derivs w.r.t. to global coords at
99  /// integration point ipt; return Jacobian of mapping
101  const unsigned &ipt,
102  Shape &psi,
103  DShape &dpsidx,
104  Shape &test,
105  DShape &dtestdx)
106  const=0;
107 
108 
109 public:
110 
111  ///Constructor
113 
114  ///Empty destructor
116 
117  /// Compute the element's residual Vector
119  {
120  //Call the generic residuals function with flag set to 0
121  //and using a dummy matrix argument
125  }
126 
127  ///\short Compute the element's residual Vector and the jacobian matrix
128  /// Virtual function can be overloaded by hanging-node version
130  DenseMatrix<double> &jacobian)
131  {
132  //Call the generic routine with the flag set to 1
134  residuals,jacobian,GeneralisedElement::Dummy_matrix,1);
135  }
136 
137  /// Add the element's contribution to its residuals vector,
138  /// jacobian matrix and mass matrix
140  Vector<double> &residuals, DenseMatrix<double> &jacobian,
141  DenseMatrix<double> &mass_matrix)
142  {
143  //Call the generic routine with the flag set to 2
145  residuals,jacobian,mass_matrix,2);
146  }
147 
148  ///Assemble the contributions to the mass matrix and residuals
150  DenseMatrix<double> &mass_matrix)
151  {
153  residuals,GeneralisedElement::Dummy_matrix,mass_matrix,3);
154  }
155 
156 
157  ///\short Compute the residuals for the Navier--Stokes equations;
158  /// flag=1(or 0): do (or don't) compute the Jacobian as well.
160  Vector<double> &residuals, DenseMatrix<double> &jacobian,
161  DenseMatrix<double> &mass_matrix, unsigned flag);
162 
163  //Get the value of the unknowns
165  const unsigned &i);
166 
167  /// \short 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  /// \short 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 
185 }
186 
187 #endif
void output(std::ostream &outfile)
Output the element data — typically the values at the nodes in a format suitable for post-processing...
cstr elem_len * i
Definition: cfortran.h:607
A general Finite Element class.
Definition: elements.h:1274
void fill_in_contribution_to_residuals(Vector< double > &residuals)
Compute the element&#39;s residual Vector.
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) ...
virtual unsigned nflux() const
Return the number of fluxes (default zero)
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 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...
A Rank 3 Tensor class.
Definition: matrices.h:1337
void fill_in_contribution_to_jacobian_and_mass_matrix(Vector< double > &residuals, DenseMatrix< double > &jacobian, DenseMatrix< double > &mass_matrix)
static char t char * s
Definition: cfortran.h:572
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 ...
double interpolated_u_flux_transport(const Vector< double > &s, const unsigned &i)
Return the i-th unknown at the local coordinate s.
void fill_in_contribution_to_mass_matrix(Vector< double > &residuals, DenseMatrix< double > &mass_matrix)
Assemble the contributions to the mass matrix and residuals.
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&#39;t) compute the Jacob...
virtual ~FluxTransportEquations()
Empty destructor.
void calculate_element_averages(double *&average_values)
Compute the average values of the fluxes.
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 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...
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:228
void fill_in_contribution_to_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian)
Compute the element&#39;s residual Vector and the jacobian matrix Virtual function can be overloaded by h...