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

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

#include <TwoD_Hyperbolic_System.h>

Inheritance diagram for CppNoddy::TwoD_Hyperbolic_System:
CppNoddy::Uncopyable CppNoddy::Example::NlinAdv CppNoddy::Example::NlinAdv CppNoddy::Example::NlinAdv CppNoddy::Example::NlinAdv CppNoddy::Example::Shallow_2d_rad CppNoddy::Example::Shallow_2d_source

Public Member Functions

 TwoD_Hyperbolic_System (const unsigned &order)
 
virtual ~TwoD_Hyperbolic_System ()
 An empty destructor, virtual since we have virtual methods. More...
 
virtual void flux_fn_x (const DenseVector< double > &x, const DenseVector< double > &q, DenseVector< double > &f) const
 A virtual flux function for the x-derivative. More...
 
virtual void flux_fn_y (const DenseVector< double > &x, const DenseVector< double > &q, DenseVector< double > &f) const
 A virtual flux function for the y-derivative. More...
 
virtual void Jac_flux_fn_x (const DenseVector< double > &x, const DenseVector< double > &q, DenseMatrix< double > &J) const
 A virtual function function to define the Jacobian of the x-flux function. More...
 
virtual void Jac_flux_fn_y (const DenseVector< double > &x, const DenseVector< double > &q, DenseMatrix< double > &J) const
 A virtual function function to define the Jacobian of the y-flux function. More...
 
virtual void max_charac_speed (const DenseVector< double > &x, const DenseVector< double > &q, DenseVector< double > &c) const
 A virtual method that is used to bound the characteristic speed in both directions. More...
 
virtual std::vector< bool > edge_values (const int &face_index, const DenseVector< double > &x, DenseVector< double > &q) const
 Define the edge boundary conditions. More...
 
virtual void edge_slopes (const int &face_index, const DenseVector< double > &x, DenseVector< double > &sigma_n) const
 Define the edge boundary condition slopes. More...
 
virtual void source_fn (const DenseVector< double > &x, const DenseVector< double > &q, DenseVector< double > &r) const
 
unsigned get_order ()
 

Protected Attributes

const unsigned ORDER_OF_SYSTEM
 The order of the system of equations. More...
 

Detailed Description

A class to represent a two-dimensional hyperbolic system of equations.

Definition at line 12 of file TwoD_Hyperbolic_System.h.

Constructor & Destructor Documentation

◆ TwoD_Hyperbolic_System()

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

Definition at line 17 of file TwoD_Hyperbolic_System.h.

17 : ORDER_OF_SYSTEM(order)
18 {}
const unsigned ORDER_OF_SYSTEM
The order of the system of equations.

◆ ~TwoD_Hyperbolic_System()

virtual CppNoddy::TwoD_Hyperbolic_System::~TwoD_Hyperbolic_System ( )
inlinevirtual

An empty destructor, virtual since we have virtual methods.

Definition at line 21 of file TwoD_Hyperbolic_System.h.

22 {}

Member Function Documentation

◆ edge_slopes()

virtual void CppNoddy::TwoD_Hyperbolic_System::edge_slopes ( const int &  face_index,
const DenseVector< double > &  x,
DenseVector< double > &  sigma_n 
) const
inlinevirtual

Define the edge boundary condition slopes.

These default to zero unless otherwise over-ridden.

Parameters
face_indexAn index for the face: 0,1,2,3 for S,E,N,W on the TwoD_TVDLF_Mesh
xThe global position vector
sigma_nSpecify the slope normal to the face

Definition at line 124 of file TwoD_Hyperbolic_System.h.

124 {
125 }

◆ edge_values()

virtual std::vector< bool > CppNoddy::TwoD_Hyperbolic_System::edge_values ( const int &  face_index,
const DenseVector< double > &  x,
DenseVector< double > &  q 
) const
inlinevirtual

Define the edge boundary conditions.

Parameters
face_indexAn index for the face: 0,1,2,3 for S,E,N,W on the TwoD_TVDLF_Mesh
xThe global position vector
qSpecify the unknowns specified along the face
Returns
A vector that defines which components have been set as inflow

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

Definition at line 114 of file TwoD_Hyperbolic_System.h.

114 {
115 return std::vector<bool>(ORDER_OF_SYSTEM, false);
116 }

References ORDER_OF_SYSTEM.

◆ flux_fn_x()

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

A virtual flux function for the x-derivative.

Parameters
xThe vector position
qThe unknowns
fThe flux function

Reimplemented in CppNoddy::Example::NlinAdv, CppNoddy::Example::NlinAdv, CppNoddy::Example::NlinAdv, CppNoddy::Example::NlinAdv, CppNoddy::Example::Shallow_2d_rad, and CppNoddy::Example::Shallow_2d_source.

Definition at line 28 of file TwoD_Hyperbolic_System.h.

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

Referenced by Jac_flux_fn_x().

◆ flux_fn_y()

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

A virtual flux function for the y-derivative.

Parameters
xThe vector position
qThe unknowns
fThe flux function

Reimplemented in CppNoddy::Example::NlinAdv, CppNoddy::Example::NlinAdv, CppNoddy::Example::NlinAdv, CppNoddy::Example::NlinAdv, CppNoddy::Example::Shallow_2d_rad, and CppNoddy::Example::Shallow_2d_source.

Definition at line 39 of file TwoD_Hyperbolic_System.h.

39 {
40 std::string problem;
41 problem = "The Hyperbolic_Conservative_System::flux_fn_y method has not been implemented.\n";
42 problem += "You have to implement this method to define the system.\n";
43 throw ExceptionRuntime(problem);
44 }

Referenced by Jac_flux_fn_y().

◆ get_order()

unsigned CppNoddy::TwoD_Hyperbolic_System::get_order ( )
inline

Definition at line 130 of file TwoD_Hyperbolic_System.h.

130 {
131 return ORDER_OF_SYSTEM;
132 }

References ORDER_OF_SYSTEM.

◆ Jac_flux_fn_x()

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

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

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

Parameters
xThe vector position
qThe unknowns
JThe Jacobian of the flux function

cheap & nasty differencing

Reimplemented in CppNoddy::Example::Shallow_2d_rad, and CppNoddy::Example::Shallow_2d_source.

Definition at line 53 of file TwoD_Hyperbolic_System.h.

53 {
54 /// cheap & nasty differencing
55 const double delta(1.e-8);
56 DenseVector<double> state(q);
57 DenseVector<double> temp1(ORDER_OF_SYSTEM, 0.0);
58 DenseVector<double> temp2(ORDER_OF_SYSTEM, 0.0);
59 flux_fn_x(x, state, temp1);
60 // default is to FD the Jacobian
61 for(std::size_t i = 0; i < ORDER_OF_SYSTEM; ++i) {
62 state[ i ] += delta;
63 flux_fn_x(x, state, temp2);
64 state[ i ] -= delta;
65 J.set_col(i, (temp2 - temp1) / delta);
66 }
67 }
void set_col(const std::size_t &col, const DenseVector< _Type > &x)
Set a column of the matrix.
virtual void flux_fn_x(const DenseVector< double > &x, const DenseVector< double > &q, DenseVector< double > &f) const
A virtual flux function for the x-derivative.
const double delta(0.5)

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

◆ Jac_flux_fn_y()

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

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

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

Parameters
xThe vector position
qThe unknowns
JThe Jacobian of the flux function

cheap & nasty differencing

Reimplemented in CppNoddy::Example::Shallow_2d_rad, and CppNoddy::Example::Shallow_2d_source.

Definition at line 76 of file TwoD_Hyperbolic_System.h.

76 {
77 /// cheap & nasty differencing
78 const double delta(1.e-8);
79 DenseVector<double> state(q);
80 DenseVector<double> temp1(ORDER_OF_SYSTEM, 0.0);
81 DenseVector<double> temp2(ORDER_OF_SYSTEM, 0.0);
82 flux_fn_y(x, state, temp1);
83 // default is to FD the Jacobian
84 for(std::size_t i = 0; i < ORDER_OF_SYSTEM; ++i) {
85 state[ i ] += delta;
86 flux_fn_y(x, state, temp2);
87 state[ i ] -= delta;
88 J.set_col(i, (temp2 - temp1) / delta);
89 }
90 }
virtual void flux_fn_y(const DenseVector< double > &x, const DenseVector< double > &q, DenseVector< double > &f) const
A virtual flux function for the y-derivative.

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

◆ max_charac_speed()

virtual void CppNoddy::TwoD_Hyperbolic_System::max_charac_speed ( const DenseVector< double > &  x,
const DenseVector< double > &  q,
DenseVector< double > &  c 
) const
inlinevirtual

A virtual method that is used to bound the characteristic speed in both directions.

It determines the time step in order that the CFL constraint holds. It is sometimes required to specify a speed that is a function of position and to even specify the two-directional speeds. eg. your mesh may actually be w.r.t. a polar coordinate system in which the physical mesh size grows linearly with radius, so one of the speeds should be scaled accordingly.

Parameters
xThe global coordinate
qThe unknowns
cThe speed

Reimplemented in CppNoddy::Example::NlinAdv, CppNoddy::Example::NlinAdv, CppNoddy::Example::NlinAdv, CppNoddy::Example::NlinAdv, CppNoddy::Example::Shallow_2d_rad, and CppNoddy::Example::Shallow_2d_source.

Definition at line 101 of file TwoD_Hyperbolic_System.h.

101 {
102 std::string problem;
103 problem = "The Hyperbolic_Conservative_System::max_charac_speed method has not\n";
104 problem += "been implemented. You have to implement this method to define the system.\n";
105 throw ExceptionRuntime(problem);
106 }

◆ source_fn()

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

Reimplemented in CppNoddy::Example::Shallow_2d_source.

Definition at line 127 of file TwoD_Hyperbolic_System.h.

127 {
128 }

Member Data Documentation

◆ ORDER_OF_SYSTEM

const unsigned CppNoddy::TwoD_Hyperbolic_System::ORDER_OF_SYSTEM
protected

The order of the system of equations.

Definition at line 137 of file TwoD_Hyperbolic_System.h.

Referenced by edge_values(), get_order(), Jac_flux_fn_x(), and Jac_flux_fn_y().


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

© 2012

R.E. Hewitt