28 #ifndef OOMPH_EULER_ELEMENTS_HEADER
29 #define OOMPH_EULER_ELEMENTS_HEADER
33 #include <oomph-lib-config.h>
37 #include "../generic/Qspectral_elements.h"
38 #include "../generic/dg_elements.h"
45 template<
unsigned DIM>
87 if (this->Average_prim_value != 0)
92 if (this->Average_gradient != 0)
130 std::ostream& outfile,
137 const unsigned n_flux = this->
nflux();
139 const unsigned n_node = this->
nnode();
142 DShape dpsidx(n_node, DIM);
147 error.resize(n_flux);
149 for (
unsigned i = 0;
i < n_flux;
i++)
158 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
171 for (
unsigned l = 0; l < n_node; l++)
174 const double psi_ = psi(l);
175 for (
unsigned i = 0;
i < DIM;
i++)
180 for (
unsigned i = 0;
i < n_flux;
i++)
192 for (
unsigned i = 0;
i < n_flux;
i++)
194 error[
i] += pow((interpolated_u[
i] - exact_u[
i]), 2.0) *
W;
195 norm[
i] += interpolated_u[
i] * interpolated_u[
i] *
W;
211 void output(std::ostream& outfile,
const unsigned& n_plot);
216 const unsigned n_flux = this->
nflux();
218 if (this->Average_prim_value == 0)
220 this->Average_prim_value =
new double[n_flux];
223 if (this->Average_gradient == 0)
225 this->Average_gradient =
new double[n_flux * DIM];
235 OOMPH_CURRENT_FUNCTION,
236 OOMPH_EXCEPTION_LOCATION);
247 OOMPH_CURRENT_FUNCTION,
248 OOMPH_EXCEPTION_LOCATION);
255 template<
unsigned DIM,
unsigned NNODE_1D>
290 void output(std::ostream& outfile,
const unsigned& n_plot)
298 void output(FILE* file_pt)
300 EulerEquations<NFLUX,DIM>::output(file_pt);
305 void output(FILE* file_pt, const unsigned &n_plot)
307 EulerEquations<NFLUX,DIM>::output(file_pt,n_plot);
312 void output_fct(std::ostream &outfile, const unsigned &n_plot,
313 FiniteElement::SteadyExactSolutionFctPt
316 EulerEquations<NFLUX,DIM>::
317 output_fct(outfile,n_plot,exact_soln_pt);}
323 void output_fct(std::ostream &outfile, const unsigned &n_plot,
325 FiniteElement::UnsteadyExactSolutionFctPt
328 EulerEquations<NFLUX,DIM>::
329 output_fct(outfile,n_plot,time,exact_soln_pt);
362 template<
unsigned DIM,
unsigned NNODE_1D>
371 double J = this->dshape_eulerian(
s, psi, dpsidx);
375 for (
unsigned i = 0;
i < NNODE_1D;
i++)
378 for (
unsigned j = 0; j < DIM; j++)
380 dtestdx(
i, j) = dpsidx(
i, j);
395 template<
unsigned DIM,
unsigned NNODE_1D>
404 double J = this->dshape_eulerian_at_knot(ipt, psi, dpsidx);
426 template<
unsigned DIM,
unsigned NNODE_1D>
440 template<
class ELEMENT>
463 dynamic_cast<ELEMENT*
>(element_pt)->face_integration_pt());
474 const unsigned&
i)
const
497 ELEMENT* cast_bulk_element_pt =
501 const unsigned dim = cast_bulk_element_pt->dim();
503 const unsigned n_flux = this->
Nflux;
505 const double gamma = cast_bulk_element_pt->gamma();
511 cast_bulk_element_pt->flux(u_int, flux_int);
512 cast_bulk_element_pt->flux(u_ext, flux_ext);
515 for (
unsigned i = 0;
i < n_flux;
i++)
517 for (
unsigned j = 0; j <
dim; j++)
519 flux_av(
i, j) = 0.5 * (flux_int(
i, j) + flux_ext(
i, j));
525 for (
unsigned i = 0;
i < n_flux;
i++)
527 for (
unsigned j = 0; j <
dim; j++)
529 flux[
i] += flux_av(
i, j) * n_out[j];
537 for (
unsigned i = 0;
i < 2;
i++)
539 jump[
i] = u_int[
i] - u_ext[
i];
544 double velocity_jump = 0.0;
545 for (
unsigned j = 0; j <
dim; j++)
547 velocity_jump += (u_int[2 + j] - u_ext[2 + j]) * n_out[j];
550 for (
unsigned j = 0; j <
dim; j++)
552 jump[2 + j] = velocity_jump * n_out[j];
580 double p_int = cast_bulk_element_pt->pressure(u_int);
581 double p_ext = cast_bulk_element_pt->pressure(u_ext);
587 oomph_info <<
"Negative int pressure" << p_int <<
"\n";
592 oomph_info <<
"Negative ext pressure " << p_ext <<
"\n";
596 double H_int = (u_int[1] + p_int) / u_int[0];
597 double H_ext = (u_ext[1] + p_ext) / u_ext[0];
601 for (
unsigned j = 0; j <
dim; j++)
603 vel_int[j] = u_int[2 + j] / u_int[0];
604 vel_ext[j] = u_ext[2 + j] / u_ext[0];
609 double s_int = sqrt(u_int[0]);
610 double s_ext = sqrt(u_ext[0]);
611 double sum = s_int + s_ext;
614 for (
unsigned j = 0; j <
dim; j++)
616 vel_average[j] = (s_int * vel_int[j] + s_ext * vel_ext[j]) / sum;
620 double H_average = (s_int * H_int + s_ext * H_ext) / sum;
623 double arg = H_average;
624 for (
unsigned j = 0; j <
dim; j++)
626 arg -= 0.5 * vel_average[j];
628 arg *= (gamma - 1.0);
632 oomph_info <<
"Square of sound speed is negative!\n";
635 double a = sqrt(arg);
640 for (
unsigned j = 0; j <
dim; j++)
642 vel += vel_average[j] * n_out[j];
651 double lambda = std::fabs(eigA[0]);
652 for (
unsigned i = 1;
i < 3;
i++)
654 if (std::fabs(eigA[
i]) > lambda)
656 lambda = std::fabs(eigA[
i]);
683 for (
unsigned i = 0;
i < n_flux;
i++)
685 flux[
i] += 0.5 * lambda * jump[
i];
695 template<
class ELEMENT>
723 const unsigned&
i)
const
747 for (
unsigned j = 0; j < nodal_dim; j++)
749 dot += n[j] * u[2 + j];
753 for (
unsigned j = 0; j < nodal_dim; j++)
755 u[2 + j] -= 2.0 *
dot * n[j];
764 template<
unsigned DIM,
unsigned NNODE_1D>
773 template<
unsigned NNODE_1D>
785 return this->nflux();
815 Face_element_pt.resize(2);
835 residuals, jacobian, mass_matrix, flag);
837 this->add_flux_contributions_to_residuals(residuals, jacobian, flag);
889 template<
unsigned NNODE_1D>
901 template<
unsigned NNODE_1D>
913 return this->nflux();
927 this->set_integration_scheme(
935 return &Default_face_integration_scheme;
940 Face_element_pt.resize(4);
962 residuals, jacobian, mass_matrix, flag);
964 this->add_flux_contributions_to_residuals(residuals, jacobian, flag);
972 template<
unsigned NNODE_1D>
A Base class for DGElements.
FaceElement for Discontinuous Galerkin Problems.
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_out.
unsigned required_nflux()
Set the number of flux components.
DGEulerFaceElement(FiniteElement *const &element_pt, const int &face_index)
Constructor.
double zeta_nodal(const unsigned &n, const unsigned &k, const unsigned &i) const
Specify the value of nodal zeta from the face geometry The "global" intrinsic coordinate of the eleme...
FaceElement for Discontinuous Galerkin Problems with reflection boundary conditions.
double zeta_nodal(const unsigned &n, const unsigned &k, const unsigned &i) const
Specify the value of nodal zeta from the face geometry The "global" intrinsic coordinate of the eleme...
void interpolated_u(const Vector< double > &s, Vector< double > &u)
We overload interpolated_u to reflect.
unsigned required_nflux()
Set the number of flux components.
DGEulerFaceReflectionElement(FiniteElement *const &element_pt, const int &face_index)
Constructor.
Base class for Discontinuous Galerkin Faces. These are responsible for calculating the normal fluxes ...
virtual void interpolated_u(const Vector< double > &s, Vector< double > &f)
Return the interpolated values of the unknown fluxes.
Vector< double > Inverse_mass_diagonal
Integral * face_integration_pt() const
void calculate_element_averages(double *&average_value)
Calculate the averages in the element.
unsigned required_nflux()
Overload the required number of fluxes for the DGElement.
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...
~DGSpectralEulerElement()
unsigned required_nflux()
Overload the required number of fluxes for the DGElement.
void calculate_element_averages(double *&average_value)
Calculate the averages in the element.
~DGSpectralEulerElement()
static Gauss< 1, NNODE_1D > Default_face_integration_scheme
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...
Integral * face_integration_pt() const
General DGEulerClass. Establish the template parameters.
A Class for the derivatives of shape functions The class design is essentially the same as Shape,...
Base class for Euler equations.
virtual ~EulerEquations()
Destructor.
double & average_gradient(const unsigned &i, const unsigned &j)
Return access to the average gradient.
double pressure(const Vector< double > &u) const
Calculate the pressure from the unknowns.
void flux(const Vector< double > &u, DenseMatrix< double > &f)
Return the flux as a function of the unknown.
double * Average_prim_value
Storage for the average primitive values.
void compute_error(std::ostream &outfile, FiniteElement::UnsteadyExactSolutionFctPt exact_solution_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...
void output(std::ostream &outfile)
Output function: x,y,u or x,y,z,u.
double gamma() const
Return the value of gamma.
unsigned nflux() const
DIM momentum-components, a density and an energy are transported.
double * Average_gradient
Storage for the approximated gradients.
unsigned required_nvalue(const unsigned &n) const
The number of unknowns at each node is the number of flux components.
double & average_prim_value(const unsigned &i)
Return the average values.
static double Default_Gamma_Value
double *const & gamma_pt() const
Access function for the pointer to gamma (const version)
void allocate_memory_for_averages()
EulerEquations()
Return the flux derivatives as a function of the unknowns.
double *& gamma_pt()
Access function for the pointer to gamma.
int & face_index()
Index of the face (a number that uniquely identifies the face in the element)
void outer_unit_normal(const Vector< double > &s, Vector< double > &unit_normal) const
Compute outer unit normal at the specified local coordinate.
double zeta_nodal(const unsigned &n, const unsigned &k, const unsigned &i) const
In a FaceElement, the "global" intrinsic coordinate of the element along the boundary,...
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.
virtual void set_integration_scheme(Integral *const &integral_pt)
Set the spatial integration scheme.
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.
Class for multidimensional Gauss Lobatto Legendre integration rules empty - just establishes template...
Generic class for numerical integration schemes:
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....
/////////////////////////////////////////////////////////////////////// /////////////////////////////...
/////////////////////////////////////////////////////////////////////// /////////////////////////////...
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.
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....
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.
QSpectralEulerElement()
Constructor: Call constructors for QElement and Advection Diffusion equations.
QSpectralEulerElement(const QSpectralEulerElement< DIM, NNODE_1D > &dummy)=delete
Broken copy constructor.
void output(std::ostream &outfile)
Broken assignment operator.
A Class for shape functions. In simple cases, the shape functions have only one index that can be tho...
void initialise(const _Tp &__value)
Iterate over all values and set to the desired value.
double dot(const Vector< double > &a, const Vector< double > &b)
Probably not always best/fastest because not optimised for dimension but useful...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
OomphInfo oomph_info
Single (global) instantiation of the OomphInfo object – this is used throughout the library as a "rep...