CppNoddy  0.92
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
CppNoddy::OneD_Hyperbolic_System Class Reference

A class to represent a one dimensional hyperbolic system of equations. More...

#include <OneD_Hyperbolic_System.h>

Inheritance diagram for CppNoddy::OneD_Hyperbolic_System:
CppNoddy::Uncopyable CppNoddy::Example::Acoustic_1d CppNoddy::Example::Acoustic_1d_ref CppNoddy::Example::Euler_1d CppNoddy::Example::NlinAdv CppNoddy::Example::Shallow_1d_rad

Public Member Functions

 OneD_Hyperbolic_System (const unsigned &order)
 
virtual ~OneD_Hyperbolic_System ()
 An empty destructor, virtual since we have virtual methods. More...
 
virtual void flux_fn (const double &x, const DenseVector< double > &q, DenseVector< double > &f) const
 A virtual flux function. More...
 
virtual void Jac_flux_fn (const double &x, const DenseVector< double > &q, DenseMatrix< double > &J) const
 A virtual function function to define the Jacobian of the flux function. More...
 
virtual double max_charac_speed (const DenseVector< double > &q) const
 A virtual method that is used to bound the shock speed and must be implemented by the user. More...
 
virtual bool_vec edge_values (const int face_index, const double &x, DenseVector< double > &q, const double &t=0.0) const
 Define the edge boundary conditions. More...
 
virtual void source_fn (const double &x, const DenseVector< double > &q, const DenseVector< double > &slope, DenseVector< double > &r) const
 
unsigned get_order ()
 

Protected Attributes

const std::size_t ORDER_OF_SYSTEM
 The order of the system of equations. More...
 

Detailed Description

A class to represent a one dimensional hyperbolic system of equations.

Definition at line 13 of file OneD_Hyperbolic_System.h.

Constructor & Destructor Documentation

◆ OneD_Hyperbolic_System()

CppNoddy::OneD_Hyperbolic_System::OneD_Hyperbolic_System ( const unsigned &  order)
inlineexplicit
Parameters
orderThe order of the hyperbolic system

Definition at line 20 of file OneD_Hyperbolic_System.h.

20 : ORDER_OF_SYSTEM(order) {
21 }
const std::size_t ORDER_OF_SYSTEM
The order of the system of equations.

◆ ~OneD_Hyperbolic_System()

virtual CppNoddy::OneD_Hyperbolic_System::~OneD_Hyperbolic_System ( )
inlinevirtual

An empty destructor, virtual since we have virtual methods.

Definition at line 24 of file OneD_Hyperbolic_System.h.

25 {}

Member Function Documentation

◆ edge_values()

virtual bool_vec CppNoddy::OneD_Hyperbolic_System::edge_values ( const int  face_index,
const double &  x,
DenseVector< double > &  q,
const double &  t = 0.0 
) const
inlinevirtual

Define the edge boundary conditions.

Parameters
face_indexAn index for the face: -1=left +1=right for OneD_TVDLF_Mesh
xThe position vector along the face
qThe unknowns specified along the face
tA time for unsteady edge conditions

Reimplemented in CppNoddy::Example::Acoustic_1d_ref, and CppNoddy::Example::NlinAdv.

Definition at line 78 of file OneD_Hyperbolic_System.h.

78 {
79 return std::vector<bool>(ORDER_OF_SYSTEM, false);
80 }

References ORDER_OF_SYSTEM.

◆ flux_fn()

virtual void CppNoddy::OneD_Hyperbolic_System::flux_fn ( const double &  x,
const DenseVector< double > &  q,
DenseVector< double > &  f 
) const
inlinevirtual

A virtual flux function.

Parameters
xThe spatial coordinate
qThe unknowns
fThe flux function

Reimplemented in CppNoddy::Example::Acoustic_1d, CppNoddy::Example::Acoustic_1d_ref, CppNoddy::Example::NlinAdv, CppNoddy::Example::Shallow_1d_rad, and CppNoddy::Example::Euler_1d.

Definition at line 31 of file OneD_Hyperbolic_System.h.

31 {
32 std::string problem;
33 problem = "The Hyperbolic_Conservative_System::flux_fn method has not been implemented.\n";
34 problem += "You have to implement this method to define the system.\n";
35 throw ExceptionRuntime(problem);
36 }

Referenced by Jac_flux_fn().

◆ get_order()

unsigned CppNoddy::OneD_Hyperbolic_System::get_order ( )
inline

Definition at line 85 of file OneD_Hyperbolic_System.h.

85 {
86 return ORDER_OF_SYSTEM;
87 }

References ORDER_OF_SYSTEM.

◆ Jac_flux_fn()

virtual void CppNoddy::OneD_Hyperbolic_System::Jac_flux_fn ( const double &  x,
const DenseVector< double > &  q,
DenseMatrix< double > &  J 
) const
inlinevirtual

A virtual function function to define the Jacobian of the flux function.

The default method uses first-order finite differencing to compute the Jacobian if not otherwise specified by the user.

Parameters
xThe position
qThe unknowns
JThe Jacobian of the flux function

first order differencing is the default unless overloaded

Definition at line 45 of file OneD_Hyperbolic_System.h.

45 {
46 /// first order differencing is the default unless overloaded
47 double delta(1.e-8);
48 DenseVector<double> state(q);
49 DenseVector<double> temp1(ORDER_OF_SYSTEM, 0.0);
50 DenseVector<double> temp2(ORDER_OF_SYSTEM, 0.0);
51 flux_fn(x, q, temp1);
52 // default is to FD the Jacobian
53 for(std::size_t i = 0; i < ORDER_OF_SYSTEM; ++i) {
54 state[ i ] += delta;
55 flux_fn(x, state, temp2);
56 state[ i ] -= delta;
57 J.set_col(i, (temp2 - temp1) / delta);
58 }
59 }
void set_col(const std::size_t &col, const DenseVector< _Type > &x)
Set a column of the matrix.
virtual void flux_fn(const double &x, const DenseVector< double > &q, DenseVector< double > &f) const
A virtual flux function.
const double delta(0.5)

References flux_fn(), ORDER_OF_SYSTEM, and CppNoddy::DenseMatrix< _Type >::set_col().

◆ max_charac_speed()

virtual double CppNoddy::OneD_Hyperbolic_System::max_charac_speed ( const DenseVector< double > &  q) const
inlinevirtual

A virtual method that is used to bound the shock speed and must be implemented by the user.

Parameters
qThe unknowns
Returns
A bound on the maximum wave speed

Reimplemented in CppNoddy::Example::Acoustic_1d, CppNoddy::Example::Acoustic_1d_ref, CppNoddy::Example::NlinAdv, CppNoddy::Example::Shallow_1d_rad, and CppNoddy::Example::Euler_1d.

Definition at line 65 of file OneD_Hyperbolic_System.h.

65 {
66 std::string problem;
67 problem = "The Hyperbolic_Conservative_System::max_shock_speed method has not\n";
68 problem += "been implemented. You have to implement this method to define the system.\n";
69 throw ExceptionRuntime(problem);
70 }

◆ source_fn()

virtual void CppNoddy::OneD_Hyperbolic_System::source_fn ( const double &  x,
const DenseVector< double > &  q,
const DenseVector< double > &  slope,
DenseVector< double > &  r 
) const
inlinevirtual

Reimplemented in CppNoddy::Example::Shallow_1d_rad.

Definition at line 82 of file OneD_Hyperbolic_System.h.

82 {
83 }

Member Data Documentation

◆ ORDER_OF_SYSTEM

const std::size_t CppNoddy::OneD_Hyperbolic_System::ORDER_OF_SYSTEM
protected

The order of the system of equations.

Definition at line 92 of file OneD_Hyperbolic_System.h.

Referenced by edge_values(), get_order(), and Jac_flux_fn().


The documentation for this class was generated from the following file:

© 2012

R.E. Hewitt