32 #ifndef OOMPH_SCALAR_ADVECTION_ELEMENTS_HEADER 33 #define OOMPH_SCALAR_ADVECTION_ELEMENTS_HEADER 37 #include <oomph-lib-config.h> 41 #include "../generic/Qelements.h" 42 #include "../generic/Qspectral_elements.h" 43 #include "../generic/dg_elements.h" 51 template<
unsigned DIM>
64 inline unsigned nflux()
const {
return 1;}
81 for(
unsigned i=0;
i<DIM;
i++) {wind[
i]= 0.0;}
86 (*Wind_fct_pt)(x,wind);
109 initial_condition_pt,
const double &
t,
113 const unsigned n_flux = this->
nflux();
115 const unsigned n_node = this->
nnode();
118 DShape dpsidx(n_node,DIM);
123 error.resize(n_flux); norm.resize(n_flux);
124 for(
unsigned i=0;
i<n_flux;
i++) {error[
i] = 0.0; norm[
i] = 0.0;}
129 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
142 for(
unsigned l=0;l<n_node;l++)
145 const double psi_ = psi(l);
146 for(
unsigned i=0;
i<DIM;
i++)
151 for(
unsigned i=0;
i<n_flux;
i++)
163 for(
unsigned i=0;
i<DIM;
i++)
165 interpolated_x[
i] -= wind[
i]*
t;
173 for(
unsigned i=0;
i<n_flux;
i++)
176 pow((interpolated_u[
i] - exact_u[
i]),2.0)*
W;
177 norm[
i] += interpolated_u[
i]*interpolated_u[
i]*
W;
186 template <
unsigned DIM,
unsigned NNODE_1D>
229 void output(std::ostream &outfile,
const unsigned &n_plot)
235 void output(FILE* file_pt)
237 ScalarAdvectionEquations<NFLUX,DIM>::output(file_pt);
242 void output(FILE* file_pt, const unsigned &n_plot)
244 ScalarAdvectionEquations<NFLUX,DIM>::output(file_pt,n_plot);
249 void output_fct(std::ostream &outfile, const unsigned &n_plot,
250 FiniteElement::SteadyExactSolutionFctPt
253 ScalarAdvectionEquations<NFLUX,DIM>::
254 output_fct(outfile,n_plot,exact_soln_pt);}
260 void output_fct(std::ostream &outfile, const unsigned &n_plot,
262 FiniteElement::UnsteadyExactSolutionFctPt
265 ScalarAdvectionEquations<NFLUX,DIM>::
266 output_fct(outfile,n_plot,time,exact_soln_pt);
301 template<
unsigned DIM,
unsigned NNODE_1D>
314 for(
unsigned i=0;
i<NNODE_1D;
i++)
317 for(
unsigned j=0;j<DIM;j++)
319 dtestdx(
i,j) = dpsidx(
i,j);
335 template<
unsigned DIM,
unsigned NNODE_1D>
368 template<
unsigned DIM,
unsigned NNODE_1D>
388 template<
class ELEMENT>
396 const int &face_index) :
421 dynamic_cast<ELEMENT*
>(this->bulk_element_pt())->
426 for(
unsigned i=0;
i<
dim;
i++) {dot += Wind[
i]*n_out[
i];}
428 const unsigned n_value = this->required_nflux();
431 for(
unsigned n=0;n<n_value;n++) {flux[n] = dot*u_int[n];}
435 for(
unsigned n=0;n<n_value;n++) {flux[n] = dot*u_ext[n];}
447 template<
unsigned DIM,
unsigned NNODE_1D>
457 template<
unsigned NNODE_1D>
470 unsigned required_nflux() {
return 1;}
483 void build_all_faces()
486 Face_element_pt.resize(2);
495 DGSpectralScalarAdvectionElement<1,NNODE_1D> >
512 this->add_flux_contributions_to_residuals(residuals,jacobian,flag);
521 void get_inverse_mass_matrix_times_residuals(
Vector<double> &minv_res)
526 std::ostringstream error_stream;
528 "Cannot use a discontinuous formulation for the mass matrix when\n" 530 "there are external data.\n " <<
531 "Do not call Problem::enable_discontinuous_formulation()\n";
534 OOMPH_CURRENT_FUNCTION,
535 OOMPH_EXCEPTION_LOCATION);
540 const unsigned n_dof = this->
ndof();
543 minv_res.resize(n_dof);
544 for(
unsigned n=0;n<n_dof;n++) {minv_res[n] = 0.0;}
547 if(Mass_matrix_reuse_is_enabled && Mass_matrix_has_been_computed)
562 Inverse_mass_diagonal.clear();
563 for(
unsigned n=0;n<n_dof;n++) {Inverse_mass_diagonal.push_back(1.0/M(n,n));}
566 Mass_matrix_has_been_computed=
true;
569 for(
unsigned n=0;n<n_dof;n++) {minv_res[n] *= Inverse_mass_diagonal[n];}
581 template<
unsigned NNODE_1D>
594 template<
unsigned NNODE_1D>
609 unsigned required_nflux() {
return 1;}
618 void build_all_faces()
620 Face_element_pt.resize(4);
627 DGSpectralScalarAdvectionElement<2,NNODE_1D> >
631 DGSpectralScalarAdvectionElement<2,NNODE_1D> >
635 DGSpectralScalarAdvectionElement<2,NNODE_1D> >
652 this->add_flux_contributions_to_residuals(residuals,jacobian,flag);
662 template<
unsigned NNODE_1D>
675 template <
unsigned DIM,
unsigned NNODE_1D>
677 public virtual QElement<DIM,NNODE_1D>,
714 void output(std::ostream &outfile,
const unsigned &n_plot)
720 void output(FILE* file_pt)
722 ScalarAdvectionEquations<NFLUX,DIM>::output(file_pt);
727 void output(FILE* file_pt, const unsigned &n_plot)
729 ScalarAdvectionEquations<NFLUX,DIM>::output(file_pt,n_plot);
734 void output_fct(std::ostream &outfile, const unsigned &n_plot,
735 FiniteElement::SteadyExactSolutionFctPt
738 ScalarAdvectionEquations<NFLUX,DIM>::
739 output_fct(outfile,n_plot,exact_soln_pt);}
745 void output_fct(std::ostream &outfile, const unsigned &n_plot,
747 FiniteElement::UnsteadyExactSolutionFctPt
750 ScalarAdvectionEquations<NFLUX,DIM>::
751 output_fct(outfile,n_plot,time,exact_soln_pt);
786 template<
unsigned DIM,
unsigned NNODE_1D>
799 for(
unsigned i=0;
i<NNODE_1D;
i++)
802 for(
unsigned j=0;j<DIM;j++)
804 dtestdx(
i,j) = dpsidx(
i,j);
820 template<
unsigned DIM,
unsigned NNODE_1D>
853 template<
unsigned DIM,
unsigned NNODE_1D>
856 public virtual QElement<DIM-1,NNODE_1D>
872 template<
unsigned DIM,
unsigned NNODE_1D>
882 template<
unsigned NNODE_1D>
893 unsigned required_nflux() {
return 1;}
905 void build_all_faces()
908 Face_element_pt.resize(2);
917 DGScalarAdvectionElement<1,NNODE_1D> >
934 this->add_flux_contributions_to_residuals(residuals,jacobian,flag);
944 template<
unsigned NNODE_1D>
957 template<
unsigned NNODE_1D>
968 unsigned required_nflux() {
return 1;}
981 void build_all_faces()
983 Face_element_pt.resize(4);
990 DGScalarAdvectionElement<2,NNODE_1D> >
994 DGScalarAdvectionElement<2,NNODE_1D> >
998 DGScalarAdvectionElement<2,NNODE_1D> >
1015 this->add_flux_contributions_to_residuals(residuals,jacobian,flag);
1025 template<
unsigned NNODE_1D>
1027 public virtual QElement<1,NNODE_1D>
Class of matrices containing doubles, and stored as a DenseMatrix<double>, but with solving functiona...
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.
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
void output(std::ostream &outfile)
Output the element data — typically the values at the nodes in a format suitable for post-processing...
unsigned required_nvalue(const unsigned &n) const
Broken assignment operator.
QSpectralScalarAdvectionElement()
Constructor: Call constructors for QElement and Advection Diffusion equations.
void flux(const Vector< double > &u, DenseMatrix< double > &f)
Return the flux as a function of the unknown.
QScalarAdvectionElement()
Constructor: Call constructors for QElement and Advection Diffusion equations.
DGScalarAdvectionFaceElement(FiniteElement *const &element_pt, const int &face_index)
Constructor.
Specialisation for 2D DG Elements.
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-...
void output(std::ostream &outfile)
Output function: x,y,u or x,y,z,u.
ScalarAdvectionWindFctPt & wind_fct_pt()
Access function: Pointer to wind function.
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 ...
ScalarAdvectionEquations()
Constructor.
Specialisation for 2D DG Elements.
unsigned required_nvalue(const unsigned &n) const
Broken assignment operator.
A general Finite Element class.
void(* UnsteadyExactSolutionFctPt)(const double &, const Vector< double > &, Vector< double > &)
Function pointer for function that computes Vector-valued time-dependent function as ...
ScalarAdvectionWindFctPt Wind_fct_pt
Function pointer to the wind function.
A Base class for DGElements.
General DGScalarAdvectionClass. Establish the template parameters.
void fill_in_contribution_to_residuals(Vector< double > &residuals)
Compute the element's residual Vector.
FaceElement for Discontinuous Galerkin Problems.
virtual double weight(const unsigned &i) const =0
Return weight of i-th integration point.
unsigned nflux() const
A single flux is interpolated.
FaceGeometry()
Constructor: Call the constructor for the appropriate lower-dimensional QElement. ...
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 nexternal_data() const
Return the number of external data objects.
unsigned ndof() const
Return the number of equations/dofs in the element.
unsigned nodal_dimension() const
Return the required Eulerian dimension of the nodes in this element.
virtual double interpolated_x(const Vector< double > &s, const unsigned &i) const
Return FE interpolated coordinate x[i] at 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...
unsigned required_nflux()
Set the number of flux components.
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...
Integral *const & integral_pt() const
Return the pointer to the integration scheme (const version)
QSpectralScalarAdvectionElement(const QSpectralScalarAdvectionElement< DIM, NNODE_1D > &dummy)
Broken copy constructor.
void output(std::ostream &outfile)
Output function: x,y,u or x,y,z,u.
Base class for advection equations.
QScalarAdvectionElement(const QScalarAdvectionElement< DIM, NNODE_1D > &dummy)
Broken copy constructor.
FaceGeometry()
Constructor: Call the constructor for the appropriate lower-dimensional QElement. ...
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. Return Jacobian.
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 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. Return Jacobian.
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.
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...
void dflux_du(const Vector< double > &u, RankThreeTensor< double > &df_du)
Return the flux derivatives as a function of the unknowns.
Non-spectral version of the classes.
General DGScalarAdvectionClass. Establish the template parameters.
void fill_in_contribution_to_mass_matrix(Vector< double > &residuals, DenseMatrix< double > &mass_matrix)
Assemble the contributions to the mass matrix and residuals.
unsigned dim() const
Return the spatial dimension of the element, i.e. the number of local coordinates required to paramet...
double dot(const Vector< double > &a, const Vector< double > &b)
Probably not always best/fastest because not optimised for dimension but useful...
unsigned required_nvalue(const unsigned &n) const
The number of unknowns at each node is the number of values.
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 Jacob...
virtual unsigned nweight() const =0
Return the number of integration points of the scheme.
Base class for Discontinuous Galerkin Faces. These are responsible for calculating the normal fluxes ...
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.
ScalarAdvectionWindFctPt wind_fct_pt() const
Access function: Pointer to wind function. Const version.
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...
void calculate_element_averages(double *&average_values)
Compute the average values of the fluxes.
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 nnode() const
Return the number of nodes.
void numerical_flux(const Vector< double > &n_out, const Vector< double > &u_int, const Vector< double > &u_ext, Vector< double > &flux)
void compute_error(std::ostream &outfile, FiniteElement::UnsteadyExactSolutionFctPt initial_condition_pt, const double &t, Vector< double > &error, Vector< double > &norm)
void(* ScalarAdvectionWindFctPt)(const Vector< double > &x, Vector< double > &wind)
Typedef for a wind function as a possible function of position.