32 #ifndef OOMPH_EULER_ELEMENTS_HEADER 33 #define OOMPH_EULER_ELEMENTS_HEADER 37 #include <oomph-lib-config.h> 41 #include "../generic/Qspectral_elements.h" 42 #include "../generic/dg_elements.h" 50 template<
unsigned DIM>
68 inline unsigned nflux()
const {
return DIM+2;}
89 if(this->Average_prim_value!=0)
91 if(this->Average_gradient!=0)
114 exact_solution_pt,
const double &
t,
118 const unsigned n_flux = this->
nflux();
120 const unsigned n_node = this->
nnode();
123 DShape dpsidx(n_node,DIM);
128 error.resize(n_flux);
130 for(
unsigned i=0;
i<n_flux;
i++)
131 {error[
i] = 0.0; norm[
i] = 0.0;}
136 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
149 for(
unsigned l=0;l<n_node;l++)
152 const double psi_ = psi(l);
153 for(
unsigned i=0;
i<DIM;
i++)
158 for(
unsigned i=0;
i<n_flux;
i++)
170 for(
unsigned i=0;
i<n_flux;
i++)
173 pow((interpolated_u[
i] - exact_u[
i]),2.0)*
W;
174 norm[
i] += interpolated_u[
i]*interpolated_u[
i]*
W;
190 void output(std::ostream &outfile,
const unsigned &n_plot);
195 const unsigned n_flux = this->
nflux();
197 if(this->Average_prim_value==0)
198 {this->Average_prim_value =
new double[n_flux];}
200 if(this->Average_gradient==0)
201 {this->Average_gradient =
new double[n_flux*DIM];}
207 if(Average_gradient==0)
210 OOMPH_CURRENT_FUNCTION,
211 OOMPH_EXCEPTION_LOCATION);
213 return Average_gradient[DIM*i+j];
219 if(Average_prim_value==0)
222 OOMPH_CURRENT_FUNCTION,
223 OOMPH_EXCEPTION_LOCATION);
225 return Average_prim_value[
i];
231 template <
unsigned DIM,
unsigned NNODE_1D>
271 void output(std::ostream &outfile,
const unsigned &n_plot)
277 void output(FILE* file_pt)
279 EulerEquations<NFLUX,DIM>::output(file_pt);
284 void output(FILE* file_pt, const unsigned &n_plot)
286 EulerEquations<NFLUX,DIM>::output(file_pt,n_plot);
291 void output_fct(std::ostream &outfile, const unsigned &n_plot,
292 FiniteElement::SteadyExactSolutionFctPt
295 EulerEquations<NFLUX,DIM>::
296 output_fct(outfile,n_plot,exact_soln_pt);}
302 void output_fct(std::ostream &outfile, const unsigned &n_plot,
304 FiniteElement::UnsteadyExactSolutionFctPt
307 EulerEquations<NFLUX,DIM>::
308 output_fct(outfile,n_plot,time,exact_soln_pt);
343 template<
unsigned DIM,
unsigned NNODE_1D>
356 for(
unsigned i=0;
i<NNODE_1D;
i++)
359 for(
unsigned j=0;j<DIM;j++)
361 dtestdx(
i,j) = dpsidx(
i,j);
377 template<
unsigned DIM,
unsigned NNODE_1D>
410 template<
unsigned DIM,
unsigned NNODE_1D>
430 template<
class ELEMENT>
442 const int &face_index) :
450 Nflux = 2 + element_pt->
dim();
455 dynamic_cast<ELEMENT*>(element_pt)->face_integration_pt());
465 const unsigned &
i)
const 483 ELEMENT* cast_bulk_element_pt =
484 dynamic_cast<ELEMENT*
>(this->bulk_element_pt());
487 const unsigned dim = cast_bulk_element_pt->dim();
489 const unsigned n_flux = this->Nflux;
491 const double gamma = cast_bulk_element_pt->gamma();
497 cast_bulk_element_pt->flux(u_int,flux_int);
498 cast_bulk_element_pt->flux(u_ext,flux_ext);
501 for(
unsigned i=0;
i<n_flux;
i++)
503 for(
unsigned j=0;j<
dim;j++)
505 flux_av(
i,j) = 0.5*(flux_int(
i,j) + flux_ext(
i,j));
511 for(
unsigned i=0;
i<n_flux;
i++)
513 for(
unsigned j=0;j<
dim;j++)
515 flux[
i] += flux_av(
i,j)*n_out[j];
523 for(
unsigned i=0;
i<2;
i++)
525 jump[
i] = u_int[
i] - u_ext[
i];
530 double velocity_jump = 0.0;
531 for(
unsigned j=0;j<
dim;j++)
533 velocity_jump += (u_int[2+j] - u_ext[2+j])*n_out[j];
536 for(
unsigned j=0;j<
dim;j++)
538 jump[2+j] = velocity_jump*n_out[j];
566 double p_int = cast_bulk_element_pt->pressure(u_int);
567 double p_ext = cast_bulk_element_pt->pressure(u_ext);
572 {
oomph_info <<
"Negative int pressure" << p_int <<
"\n"; p_int=0.0;}
574 {
oomph_info <<
"Negative ext pressure " << p_ext <<
"\n"; p_ext=0.0;}
576 double H_int = (u_int[1] + p_int)/u_int[0];
577 double H_ext = (u_ext[1] + p_ext)/u_ext[0];
581 for(
unsigned j=0;j<
dim;j++)
583 vel_int[j] = u_int[2+j]/u_int[0];
584 vel_ext[j] = u_ext[2+j]/u_ext[0];
589 double s_int = sqrt(u_int[0]);
590 double s_ext = sqrt(u_ext[0]);
591 double sum = s_int + s_ext;
594 for(
unsigned j=0;j<
dim;j++)
596 vel_average[j] = (s_int*vel_int[j] + s_ext*vel_ext[j])/sum;
600 double H_average = (s_int*H_int + s_ext*H_ext)/sum;
603 double arg = H_average;
604 for(
unsigned j=0;j<
dim;j++) {arg -= 0.5*vel_average[j];}
605 arg *= (gamma - 1.0);
608 {
oomph_info <<
"Square of sound speed is negative!\n"; arg = 0.0;}
609 double a = sqrt(arg);
614 for(
unsigned j=0;j<
dim;j++) {vel += vel_average[j]*n_out[j];}
622 double lambda = std::fabs(eigA[0]);
623 for(
unsigned i=1;
i<3;
i++)
625 if(std::fabs(eigA[
i]) > lambda) {lambda = std::fabs(eigA[i]);}
651 for(
unsigned i=0;
i<n_flux;
i++) {flux[
i] += 0.5*lambda*jump[
i];}
662 template<
class ELEMENT>
672 const int &face_index) :
680 Nflux = 2 + element_pt->
dim();
690 const unsigned &
i)
const 707 this->outer_unit_normal(s,n);
710 for(
unsigned j=0;j<nodal_dim;j++)
716 for(
unsigned j=0;j<nodal_dim;j++)
718 u[2+j] -= 2.0*dot*n[j];
728 template<
unsigned DIM,
unsigned NNODE_1D>
738 template<
unsigned NNODE_1D>
751 unsigned required_nflux() {
return this->
nflux();}
768 Integral* face_integration_pt()
const {
return 0;}
775 void build_all_faces()
778 Face_element_pt.resize(2);
787 DGSpectralEulerElement<1,NNODE_1D> >
804 this->add_flux_contributions_to_residuals(residuals,jacobian,flag);
857 template<
unsigned NNODE_1D>
870 template<
unsigned NNODE_1D>
883 unsigned required_nflux() {
return this->
nflux();}
901 Integral* face_integration_pt()
const 902 {
return &Default_face_integration_scheme;}
904 void build_all_faces()
906 Face_element_pt.resize(4);
913 DGSpectralEulerElement<2,NNODE_1D> >
917 DGSpectralEulerElement<2,NNODE_1D> >
921 DGSpectralEulerElement<2,NNODE_1D> >
938 this->add_flux_contributions_to_residuals(residuals,jacobian,flag);
948 template<
unsigned NNODE_1D>
FaceElement for Discontinuous Galerkin Problems.
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
FaceGeometry()
Constructor: Call the constructor for the appropriate lower-dimensional QElement. ...
void flux(const Vector< double > &u, DenseMatrix< double > &f)
Return the flux as a function of the unknown.
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-...
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 ...
double & average_prim_value(const unsigned &i)
Return the average values.
virtual void set_integration_scheme(Integral *const &integral_pt)
Set the spatial integration scheme.
static double Default_Gamma_Value
QSpectralEulerElement()
Constructor: Call constructors for QElement and Advection Diffusion equations.
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 ...
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, when viewed as part of a compound geometric object is specified using the boundary coordinate defined by the mesh. Note: Boundary coordinates will have been set up when creating the underlying mesh, and their values will have been stored at the nodes.
A Base class for DGElements.
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.
EulerEquations()
Return the flux derivatives as a function of the unknowns.
double Default_Gamma_Value
double *const & gamma_pt() const
Access function for the pointer to gamma (const version)
virtual double weight(const unsigned &i) const =0
Return weight of i-th integration point.
unsigned required_nflux()
Set the number of flux components.
unsigned nflux() const
DIM momentum-components, a density and an energy are transported.
unsigned required_nvalue(const unsigned &n) const
The number of unknowns at each node is the number of flux components.
unsigned nodal_dimension() const
Return the required Eulerian dimension of the nodes in this element.
FaceElement for Discontinuous Galerkin Problems with reflection boundary conditions.
unsigned required_nflux()
Set the number of flux components.
virtual double interpolated_x(const Vector< double > &s, const unsigned &i) const
Return FE interpolated coordinate x[i] at local coordinate s.
virtual void interpolated_u(const Vector< double > &s, Vector< double > &f)
Return the interpolated values of the unknown fluxes.
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...
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_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)
void allocate_memory_for_averages()
virtual ~EulerEquations()
Destructor.
void output(std::ostream &outfile)
Broken assignment operator.
DGEulerFaceReflectionElement(FiniteElement *const &element_pt, const int &face_index)
Constructor.
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 ...
QSpectralEulerElement(const QSpectralEulerElement< DIM, NNODE_1D > &dummy)
Broken copy constructor.
General DGEulerClass. Establish the template parameters.
void initialise(const _Tp &__value)
Iterate over all values and set to the desired value.
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...
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...
Specialisation for 2D DG Elements.
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 ...
void output(std::ostream &outfile)
Output function: x,y,u or x,y,z,u.
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.
Base class for Euler equations.
double zeta_nodal(const unsigned &n, const unsigned &k, const unsigned &i) const
The "global" intrinsic coordinate of the element when viewed as part of a geometric object should be ...
double * Average_gradient
Storage for the approximated gradients.
double gamma() const
Return the value of gamma.
double * Average_prim_value
Storage for the average primitive values.
unsigned nnode() const
Return the number of nodes.
DGEulerFaceElement(FiniteElement *const &element_pt, const int &face_index)
Constructor.
void numerical_flux(const Vector< double > &n_out, const Vector< double > &u_int, const Vector< double > &u_ext, Vector< double > &flux)
double & average_gradient(const unsigned &i, const unsigned &j)
Return access to the average gradient.
double *& gamma_pt()
Access function for the pointer to gamma.
void interpolated_u(const Vector< double > &s, Vector< double > &u)
We overload interpolated_u to reflect.
void compute_error(std::ostream &outfile, FiniteElement::UnsteadyExactSolutionFctPt exact_solution_pt, const double &t, Vector< double > &error, Vector< double > &norm)
double pressure(const Vector< double > &u) const
Calculate the pressure from the unknowns.
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 zeta_nodal(const unsigned &n, const unsigned &k, const unsigned &i) const
The "global" intrinsic coordinate of the element when viewed as part of a geometric object should be ...