28 #ifndef OOMPH_SCALAR_ADVECTION_ELEMENTS_HEADER
29 #define OOMPH_SCALAR_ADVECTION_ELEMENTS_HEADER
33 #include <oomph-lib-config.h>
37 #include "../generic/Qelements.h"
38 #include "../generic/Qspectral_elements.h"
39 #include "../generic/dg_elements.h"
46 template<
unsigned DIM>
78 for (
unsigned i = 0;
i < DIM;
i++)
86 (*Wind_fct_pt)(x, wind);
117 std::ostream& outfile,
124 const unsigned n_flux = this->
nflux();
126 const unsigned n_node = this->
nnode();
129 DShape dpsidx(n_node, DIM);
134 error.resize(n_flux);
136 for (
unsigned i = 0;
i < n_flux;
i++)
145 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
158 for (
unsigned l = 0; l < n_node; l++)
161 const double psi_ = psi(l);
162 for (
unsigned i = 0;
i < DIM;
i++)
167 for (
unsigned i = 0;
i < n_flux;
i++)
179 for (
unsigned i = 0;
i < DIM;
i++)
189 for (
unsigned i = 0;
i < n_flux;
i++)
191 error[
i] += pow((interpolated_u[
i] - exact_u[
i]), 2.0) *
W;
192 norm[
i] += interpolated_u[
i] * interpolated_u[
i] *
W;
199 template<
unsigned DIM,
unsigned NNODE_1D>
241 void output(std::ostream& outfile,
const unsigned& n_plot)
249 void output(FILE* file_pt)
251 ScalarAdvectionEquations<NFLUX,DIM>::output(file_pt);
256 void output(FILE* file_pt, const unsigned &n_plot)
258 ScalarAdvectionEquations<NFLUX,DIM>::output(file_pt,n_plot);
263 void output_fct(std::ostream &outfile, const unsigned &n_plot,
264 FiniteElement::SteadyExactSolutionFctPt
267 ScalarAdvectionEquations<NFLUX,DIM>::
268 output_fct(outfile,n_plot,exact_soln_pt);}
274 void output_fct(std::ostream &outfile, const unsigned &n_plot,
276 FiniteElement::UnsteadyExactSolutionFctPt
279 ScalarAdvectionEquations<NFLUX,DIM>::
280 output_fct(outfile,n_plot,time,exact_soln_pt);
313 template<
unsigned DIM,
unsigned NNODE_1D>
322 double J = this->dshape_eulerian(
s, psi, dpsidx);
326 for (
unsigned i = 0;
i < NNODE_1D;
i++)
329 for (
unsigned j = 0; j < DIM; j++)
331 dtestdx(
i, j) = dpsidx(
i, j);
346 template<
unsigned DIM,
unsigned NNODE_1D>
355 double J = this->dshape_eulerian_at_knot(ipt, psi, dpsidx);
377 template<
unsigned DIM,
unsigned NNODE_1D>
391 template<
class ELEMENT>
427 ->get_wind_scalar_adv(ipt,
s, x, Wind);
431 for (
unsigned i = 0;
i <
dim;
i++)
433 dot += Wind[
i] * n_out[
i];
439 for (
unsigned n = 0; n < n_value; n++)
441 flux[n] =
dot * u_int[n];
446 for (
unsigned n = 0; n < n_value; n++)
448 flux[n] =
dot * u_ext[n];
459 template<
unsigned DIM,
unsigned NNODE_1D>
468 template<
unsigned NNODE_1D>
501 Face_element_pt.resize(2);
521 residuals, jacobian, mass_matrix, flag);
523 this->add_flux_contributions_to_residuals(residuals, jacobian, flag);
536 if (nexternal_data() > 0)
538 std::ostringstream error_stream;
540 <<
"Cannot use a discontinuous formulation for the mass matrix when\n"
541 <<
"there are external data.\n "
542 <<
"Do not call Problem::enable_discontinuous_formulation()\n";
545 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
550 const unsigned n_dof = this->ndof();
553 minv_res.resize(n_dof);
554 for (
unsigned n = 0; n < n_dof; n++)
560 if (Mass_matrix_reuse_is_enabled && Mass_matrix_has_been_computed)
563 this->fill_in_contribution_to_residuals(minv_res);
572 this->fill_in_contribution_to_mass_matrix(minv_res, M);
575 Inverse_mass_diagonal.clear();
576 for (
unsigned n = 0; n < n_dof; n++)
578 Inverse_mass_diagonal.push_back(1.0 / M(n, n));
582 Mass_matrix_has_been_computed =
true;
585 for (
unsigned n = 0; n < n_dof; n++)
587 minv_res[n] *= Inverse_mass_diagonal[n];
596 template<
unsigned NNODE_1D>
608 template<
unsigned NNODE_1D>
638 Face_element_pt.resize(4);
660 residuals, jacobian, mass_matrix, flag);
662 this->add_flux_contributions_to_residuals(residuals, jacobian, flag);
670 template<
unsigned NNODE_1D>
682 template<
unsigned DIM,
unsigned NNODE_1D>
718 void output(std::ostream& outfile,
const unsigned& n_plot)
726 void output(FILE* file_pt)
728 ScalarAdvectionEquations<NFLUX,DIM>::output(file_pt);
733 void output(FILE* file_pt, const unsigned &n_plot)
735 ScalarAdvectionEquations<NFLUX,DIM>::output(file_pt,n_plot);
740 void output_fct(std::ostream &outfile, const unsigned &n_plot,
741 FiniteElement::SteadyExactSolutionFctPt
744 ScalarAdvectionEquations<NFLUX,DIM>::
745 output_fct(outfile,n_plot,exact_soln_pt);}
751 void output_fct(std::ostream &outfile, const unsigned &n_plot,
753 FiniteElement::UnsteadyExactSolutionFctPt
756 ScalarAdvectionEquations<NFLUX,DIM>::
757 output_fct(outfile,n_plot,time,exact_soln_pt);
790 template<
unsigned DIM,
unsigned NNODE_1D>
799 double J = this->dshape_eulerian(
s, psi, dpsidx);
803 for (
unsigned i = 0;
i < NNODE_1D;
i++)
806 for (
unsigned j = 0; j < DIM; j++)
808 dtestdx(
i, j) = dpsidx(
i, j);
823 template<
unsigned DIM,
unsigned NNODE_1D>
832 double J = this->dshape_eulerian_at_knot(ipt, psi, dpsidx);
854 template<
unsigned DIM,
unsigned NNODE_1D>
856 :
public virtual QElement<DIM - 1, NNODE_1D>
868 template<
unsigned DIM,
unsigned NNODE_1D>
877 template<
unsigned NNODE_1D>
908 Face_element_pt.resize(2);
930 residuals, jacobian, mass_matrix, flag);
932 this->add_flux_contributions_to_residuals(residuals, jacobian, flag);
940 template<
unsigned NNODE_1D>
952 template<
unsigned NNODE_1D>
982 Face_element_pt.resize(4);
1008 residuals, jacobian, mass_matrix, flag);
1010 this->add_flux_contributions_to_residuals(residuals, jacobian, flag);
1018 template<
unsigned NNODE_1D>
1020 :
public virtual QElement<1, NNODE_1D>
A Base class for DGElements.
Base class for Discontinuous Galerkin Faces. These are responsible for calculating the normal fluxes ...
~DGScalarAdvectionElement()
DGScalarAdvectionElement()
unsigned required_nflux()
Set the number of flux components.
void calculate_element_averages(double *&average_value)
Calculate the averages in the element.
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 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...
unsigned required_nflux()
Set the number of flux components.
~DGScalarAdvectionElement()
void calculate_element_averages(double *&average_value)
Calculate the averages in the element.
DGScalarAdvectionElement()
General DGScalarAdvectionClass. Establish the template parameters.
FaceElement for Discontinuous Galerkin Problems.
DGScalarAdvectionFaceElement(FiniteElement *const &element_pt, const int &face_index)
Constructor.
unsigned required_nflux()
Set the number of flux components.
void numerical_flux(const Vector< double > &n_out, const Vector< double > &u_int, const Vector< double > &u_ext, Vector< double > &flux)
Calculate the normal flux, so this is the dot product of the numerical flux with n_in.
unsigned required_nflux()
Set the number of flux components.
DGSpectralScalarAdvectionElement()
Vector< double > Inverse_mass_diagonal
void calculate_element_averages(double *&average_value)
Calculate the averages in the element.
~DGSpectralScalarAdvectionElement()
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 get_inverse_mass_matrix_times_residuals(Vector< double > &minv_res)
Function that returns the current value of the residuals multiplied by the inverse mass matrix (virtu...
Specialisation for 2D DG Elements.
unsigned required_nflux()
Set the number of flux components.
DGSpectralScalarAdvectionElement()
void calculate_element_averages(double *&average_value)
Calculate the averages in the element.
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...
~DGSpectralScalarAdvectionElement()
General DGScalarAdvectionClass. Establish the template parameters.
A Class for the derivatives of shape functions The class design is essentially the same as Shape,...
Class of matrices containing doubles, and stored as a DenseMatrix<double>, but with solving functiona...
int & face_index()
Index of the face (a number that uniquely identifies the face in the element)
FiniteElement *& bulk_element_pt()
Pointer to higher-dimensional "bulk" element.
FaceGeometry()
Constructor: Call the constructor for the appropriate lower-dimensional QElement.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
A general Finite Element class.
double nodal_value(const unsigned &n, const unsigned &i) const
Return the i-th value stored at local node n. Produces suitably interpolated values for hanging nodes...
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-...
virtual double interpolated_x(const Vector< double > &s, const unsigned &i) const
Return FE interpolated coordinate x[i] at local coordinate s.
unsigned dim() const
Return the spatial dimension of the element, i.e. the number of local coordinates required to paramet...
unsigned nnode() const
Return the number of nodes.
Integral *const & integral_pt() const
Return the pointer to the integration scheme (const version)
double nodal_position(const unsigned &n, const unsigned &i) const
Return the i-th coordinate at local node n. If the node is hanging, the appropriate interpolation is ...
virtual void build_face_element(const int &face_index, FaceElement *face_element_pt)
Function for building a lower dimensional FaceElement on the specified face of the FiniteElement....
unsigned nodal_dimension() const
Return the required Eulerian dimension of the nodes in this element.
void(* UnsteadyExactSolutionFctPt)(const double &, const Vector< double > &, Vector< double > &)
Function pointer for function that computes Vector-valued time-dependent function as .
Base class for the flux transport equations templated by the dimension DIM. The equations that are so...
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 output(std::ostream &outfile)
Output the element data — typically the values at the nodes in a format suitable for post-processing.
virtual unsigned nweight() const =0
Return the number of integration points of the scheme.
virtual double weight(const unsigned &i) const =0
Return weight of i-th integration point.
An OomphLibError object which should be thrown when an run-time error is encountered....
/////////////////////////////////////////////////////////////////////// /////////////////////////////...
/////////////////////////////////////////////////////////////////////// /////////////////////////////...
Non-spectral version of the classes.
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.
QScalarAdvectionElement(const QScalarAdvectionElement< DIM, NNODE_1D > &dummy)=delete
Broken copy constructor.
unsigned required_nvalue(const unsigned &n) const
Broken assignment operator.
double dshape_and_dtest_eulerian_flux_transport(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.
double dshape_and_dtest_eulerian_at_knot_flux_transport(const unsigned &ipt, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const
Shape, test functions & derivs. w.r.t. to global coords. at integration point ipt....
QScalarAdvectionElement()
Constructor: Call constructors for QElement and Advection Diffusion equations.
void output(std::ostream &outfile)
Output function: x,y,u or x,y,z,u.
General QLegendreElement class.
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.
QSpectralScalarAdvectionElement()
Constructor: Call constructors for QElement and Advection Diffusion equations.
double dshape_and_dtest_eulerian_flux_transport(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.
unsigned required_nvalue(const unsigned &n) const
Broken assignment operator.
QSpectralScalarAdvectionElement(const QSpectralScalarAdvectionElement< DIM, NNODE_1D > &dummy)=delete
Broken copy constructor.
void output(std::ostream &outfile)
Output function: x,y,u or x,y,z,u.
double dshape_and_dtest_eulerian_at_knot_flux_transport(const unsigned &ipt, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const
Shape, test functions & derivs. w.r.t. to global coords. at integration point ipt....
////////////////////////////////////////////////////////////////// //////////////////////////////////...
Base class for advection equations.
ScalarAdvectionWindFctPt Wind_fct_pt
Function pointer to the wind function.
unsigned required_nvalue(const unsigned &n) const
The number of unknowns at each node is the number of values.
ScalarAdvectionWindFctPt wind_fct_pt() const
Access function: Pointer to wind function. Const version.
ScalarAdvectionWindFctPt & wind_fct_pt()
Access function: Pointer to wind function.
unsigned nflux() const
A single flux is interpolated.
virtual void get_wind_scalar_adv(const unsigned &ipt, const Vector< double > &s, const Vector< double > &x, Vector< double > &wind) const
Return the wind at a given position.
void compute_error(std::ostream &outfile, FiniteElement::UnsteadyExactSolutionFctPt initial_condition_pt, const double &t, Vector< double > &error, Vector< double > &norm)
Compute the error and norm of solution integrated over the element Does not plot the error in the out...
ScalarAdvectionEquations()
Constructor.
void dflux_du(const Vector< double > &u, RankThreeTensor< double > &df_du)
Return the flux derivatives as a function of the unknowns.
void flux(const Vector< double > &u, DenseMatrix< double > &f)
Return the flux as a function of the unknown.
void(* ScalarAdvectionWindFctPt)(const Vector< double > &x, Vector< double > &wind)
Typedef for a wind function as a possible function of position.
A Class for shape functions. In simple cases, the shape functions have only one index that can be tho...
double dot(const Vector< double > &a, const Vector< double > &b)
Probably not always best/fastest because not optimised for dimension but useful...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...