33 #ifndef OOMPH_DG_ELEMENT_HEADER 34 #define OOMPH_DG_ELEMENT_HEADER 38 #include <oomph-lib-config.h> 73 virtual inline unsigned flux_index(
const unsigned &
i)
const {
return i;}
88 {
return Neighbour_face_pt[
i];}
124 std::ostringstream error_stream;
126 <<
"Empty numerical flux function called\n" 127 <<
"This function should be overloaded with a specific flux\n" 128 <<
"that is appropriate to the equations being solved.\n";
130 OOMPH_CURRENT_FUNCTION,
131 OOMPH_EXCEPTION_LOCATION);
200 Mass_matrix_reuse_is_enabled(false),
201 Mass_matrix_has_been_computed(false),
202 Can_delete_mass_matrix(true) { }
208 if((M_pt!=0) && Can_delete_mass_matrix) {
delete M_pt;}
209 if(this->Average_value!=0) {
delete[] Average_value; Average_value=0;}
219 Mass_matrix_reuse_is_enabled=
true;
220 Mass_matrix_has_been_computed=
false;
228 if(!Can_delete_mass_matrix) {M_pt = 0;}
230 Mass_matrix_reuse_is_enabled =
false;
232 Mass_matrix_has_been_computed=
false;
247 this->M_pt = element_pt->
M_pt;
250 Mass_matrix_reuse_is_enabled=
true;
251 Mass_matrix_has_been_computed=
true;
253 Can_delete_mass_matrix =
false;
257 void pre_compute_mass_matrix();
260 virtual void build_all_faces()=0;
265 virtual void get_inverse_mass_matrix_times_residuals(
273 std::vector<bool> &boundary_flag,
277 const unsigned n_node = this->
nnode();
279 if(boundary_flag.size() != n_node)
281 std::ostringstream error_stream;
283 <<
"Size of boundary_flag vector is " 284 << boundary_flag.size() <<
"\n" 285 <<
"It must be the same as the number of nodes in the element " 289 OOMPH_CURRENT_FUNCTION,
290 OOMPH_EXCEPTION_LOCATION);
295 for(
unsigned n=0;n<n_node;n++)
310 this->build_all_faces();
313 DG_mesh_pt = mesh_pt;
322 const unsigned n_node = this->
nnode();
323 for(
unsigned n=0;n<n_node;n++)
330 this->build_all_faces();
333 DG_mesh_pt = mesh_pt;
340 unsigned nface()
const {
return Face_element_pt.size();}
350 unsigned n_face = nface();
351 for(
unsigned f=0;f<n_face;f++)
353 face_element_pt(f)->output(outfile);
358 void get_neighbouring_face_and_local_coordinate(
const int &
face_index,
369 unsigned n_face = this->nface();
370 for(
unsigned f=0;f<n_face;f++)
372 face_element_pt(f)->setup_neighbour_info(add_face_data_as_external);
373 face_element_pt(f)->report_info();
385 unsigned n_face = this->nface();
386 for(
unsigned f=0;f<n_face;f++)
388 face_element_pt(f)->add_flux_contributions(residuals,jacobian,flag);
393 void slope_limit(
SlopeLimiter*
const &slope_limiter_pt);
399 OOMPH_CURRENT_FUNCTION,
400 OOMPH_EXCEPTION_LOCATION);
405 {this->calculate_element_averages(this->Average_value);}
413 OOMPH_CURRENT_FUNCTION,
414 OOMPH_EXCEPTION_LOCATION);
416 return Average_value[
i];
426 OOMPH_CURRENT_FUNCTION,
427 OOMPH_EXCEPTION_LOCATION);
429 return Average_value[
i];
453 "Empty neighbour_finder() has been called.\n";
455 "This function is implemented in the base class of a DGMesh.\n";
457 "It must be overloaded in a specific DGMesh\n";
460 OOMPH_CURRENT_FUNCTION,
461 OOMPH_EXCEPTION_LOCATION);
471 const unsigned n_element = this->nelement();
472 for(
unsigned e=0;
e<n_element;
e++)
475 ->setup_face_neighbour_info(add_face_data_as_external);
483 const unsigned n_element = this->nelement();
484 for(
unsigned e=0;
e<n_element;
e++)
487 ->calculate_averages();
491 for(
unsigned e=0;
e<n_element;
e++)
494 ->slope_limit(slope_limiter_pt);
519 OOMPH_CURRENT_FUNCTION,
520 OOMPH_EXCEPTION_LOCATION);
552 void limit(
const unsigned &
i,
MinModLimiter(const double &m=0.0, const bool &muscl=false)
Constructor takes a value for the modification parameter M (default to zero — classic min mod) and a...
Class of matrices containing doubles, and stored as a DenseMatrix<double>, but with solving functiona...
bool mass_matrix_has_been_computed()
Access function for the boolean to indicate whether the mass matrix has been computed.
virtual void numerical_flux_at_knot(const unsigned &ipt, const Shape &psi, Vector< double > &flux, DenseMatrix< double > &dflux_du_int, DenseMatrix< double > &dflux_du_ext, unsigned flag)
Calculate the normal numerical flux at the integration point. This is the most general interface that...
bool MUSCL
Boolean flag to indicate a MUSCL or straight min-mod limiter.
virtual void dnumerical_flux_du(const Vector< double > &n_out, const Vector< double > &u_int, const Vector< double > &u_ext, DenseMatrix< double > &dflux_du_int, DenseMatrix< double > &dflux_du_ext)
Calculate the derivative of the normal flux, which is the dot product of our approximation to the flu...
Vector< Vector< unsigned > > Neighbour_external_data
virtual ~SlopeLimiter()
virtual destructor
void calculate_averages()
Calculate the elemental averages.
static double FaceTolerance
virtual ~DGElement()
Virtual destructor, destroy the mass matrix, if we created it Clean-up storage associated with averag...
virtual void limit(const unsigned &i, const Vector< DGElement *> &required_element_pt)
Basic function.
void report_info()
Output information about the present element and its neighbour.
virtual void neighbour_finder(FiniteElement *const &bulk_element_pt, const int &face_index, const Vector< double > &s_bulk, FaceElement *&face_element_pt, Vector< double > &s_face)
Vector< Vector< double > > Neighbour_local_coordinate
Vector of neighbouring local coordinates at the integration points.
int & face_index()
Index of the face (a number that uniquely identifies the face in the element)
FaceElement * neighbour_face_pt(const unsigned &i)
Access function for neighbouring face information.
Vector< FaceElement * > Neighbour_face_pt
Vector of neighbouring face elements at the integration points.
A general Finite Element class.
double * Average_value
Pointer to storage for the average values of the of the variables over the element.
void add_flux_contributions_to_residuals(Vector< double > &residuals, DenseMatrix< double > &jacobian, unsigned flag)
A Base class for DGElements.
virtual unsigned required_nflux()
Set the number of flux components.
virtual Node * construct_boundary_node(const unsigned &n)
Construct the local node n as a boundary node; that is a node that MAY be placed on a mesh boundary a...
double & average_value(const unsigned &i)
Return the average values.
void disable_mass_matrix_reuse()
Function that disables the reuse of the mass matrix.
DGFaceElement * face_element_pt(const unsigned &i)
Access function for the faces.
DGMesh * DG_mesh_pt
Pointer to Mesh, which will be responsible for the neighbour finding.
void pre_compute_mass_matrix()
Function that computes and stores the (inverse) mass matrix.
bool Mass_matrix_reuse_is_enabled
Boolean flag to indicate whether to reuse the mass matrix.
TimeStepper *& time_stepper_pt()
Access function for pointer to time stepper: Null if object is not time-dependent.
virtual ~DGFaceElement()
Empty Destructor.
Base class for slope limiters.
void output_faces(std::ostream &outfile)
Output the faces of the element.
const double & average_value(const unsigned &i) const
Return the average values.
virtual void interpolated_u(const Vector< double > &s, Vector< double > &f)
Return the interpolated values of the unknown fluxes.
virtual Node * construct_node(const unsigned &n)
Construct the local node n and return a pointer to the newly created node object. ...
virtual void set_mass_matrix_from_element(DGElement *const &element_pt)
Set the mass matrix to point to one in another element.
bool Can_delete_mass_matrix
Boolean flag to indicate whether the mass matrix can be deleted (i.e. was it created by this element)...
virtual void get_interpolation_data(Vector< Data *> &interpolation_data)
Get the data that are used to interpolate the unkowns in the element. These must be returned in order...
void limit_slopes(SlopeLimiter *const &slope_limiter_pt)
void setup_face_neighbour_info(const bool &add_face_data_as_external=false)
void setup_neighbour_info(const bool &add_neighbour_data_to_bulk)
virtual void calculate_element_averages(double *&average_values)
Calculate the averages in the element.
double M
Constant that is used in the modified min-mod function to provide better properties at extrema...
SlopeLimiter()
Empty constructor.
unsigned nface() const
Return the number of faces.
void set_mesh_pt(DGMesh *&mesh_pt)
virtual ~MinModLimiter()
Empty destructor.
void setup_face_neighbour_info(const bool &add_face_data_as_external)
Base class for Discontinuous Galerkin Faces. These are responsible for calculating the normal fluxes ...
void construct_nodes_and_faces(DGMesh *const &mesh_pt, TimeStepper *const &time_stepper_pt)
Construct the nodes and faces of the element.
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
FiniteElement *& bulk_element_pt()
Pointer to higher-dimensional "bulk" element.
virtual unsigned flux_index(const unsigned &i) const
Return the index at which the i-th unknown flux is stored.
void enable_mass_matrix_reuse()
Function that allows the reuse of the mass matrix.
Vector< FaceElement * > Face_element_pt
Vector of pointers to faces of the element.
DGElement()
Constructor, initialise the pointers to zero.
DenseDoubleMatrix * M_pt
Pointer to storage for a mass matrix that can be recycled if desired.
virtual 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, which is the dot product of our approximation to the flux with the outer u...
unsigned nnode() const
Return the number of nodes.
Base class for time-stepping schemes. Timestepper provides an approximation of the temporal derivativ...
void construct_boundary_nodes_and_faces(DGMesh *const &mesh_pt, std::vector< bool > &boundary_flag, TimeStepper *const &time_stepper_pt)
Construct all nodes and faces of the element. The vector of booleans boundary should be the same size...
void add_flux_contributions(Vector< double > &residuals, DenseMatrix< double > &jacobian, unsigned flag)
Add the contribution from integrating the numerical flux.
bool Mass_matrix_has_been_computed
Boolean flag to indicate whether the mass matrix has been computed.
DGFaceElement()
Empty Constructor.
virtual unsigned required_nflux()
Set the number of flux components.