CppNoddy  0.92
Loading...
Searching...
No Matches
Public Member Functions | List of all members
CppNoddy::Example::Shallow_2d_source Class Reference

Define the system. More...

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

Public Member Functions

 Shallow_2d_source ()
 One dimemsional constant coefft acoustic problem. More...
 
void flux_fn_x (const DenseVector< double > &x, const DenseVector< double > &q, DenseVector< double > &f) const
 Define the vector flux. More...
 
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...
 
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...
 
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...
 
void max_charac_speed (const DenseVector< double > &x, const DenseVector< double > &q, DenseVector< double > &c) const
 Bound the wave speed. More...
 
std::vector< bool > edge_values (const int &face_index, const DenseVector< double > &x, DenseVector< double > &q) const
 edge conditions More...
 
void source_fn (const DenseVector< double > &x, const DenseVector< double > &q, DenseVector< double > &r) const
 
- Public Member Functions inherited from CppNoddy::TwoD_Hyperbolic_System
 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 ()
 

Additional Inherited Members

- Protected Attributes inherited from CppNoddy::TwoD_Hyperbolic_System
const unsigned ORDER_OF_SYSTEM
 The order of the system of equations. More...
 

Detailed Description

Define the system.

Definition at line 39 of file HYP2DShallowSource.cpp.

Constructor & Destructor Documentation

◆ Shallow_2d_source()

CppNoddy::Example::Shallow_2d_source::Shallow_2d_source ( )
inline

One dimemsional constant coefft acoustic problem.

Definition at line 45 of file HYP2DShallowSource.cpp.

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

Member Function Documentation

◆ edge_values()

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

edge conditions

Reimplemented from CppNoddy::TwoD_Hyperbolic_System.

Definition at line 102 of file HYP2DShallowSource.cpp.

103 {
104 std::vector<bool> comps( q.size(), false );
105 switch ( face_index )
106 {
107 case 1:
108 q[ h ] = 0.33;
109 comps[ h ] = true;
110 break;
111 case 3:
112 q[ hu ] = 0.18;
113 comps[ hu ] = true;
114 break;
115 }
116 return comps;
117 }
std::size_t size() const
A pass-thru definition to get the size of the vector.
Definition: DenseVector.h:330

References h, hu, and CppNoddy::DenseVector< _Type >::size().

◆ flux_fn_x()

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

Define the vector flux.

Reimplemented from CppNoddy::TwoD_Hyperbolic_System.

Definition at line 49 of file HYP2DShallowSource.cpp.

50 {
51 f[ h ] = q[ hu ];
52 f[ hu ] = q[ hu ] * q[ hu ] / q[ h ] + g * q[ h ] * q[ h ] / 2;
53 f[ hv ] = q[ hu ] * q[ hv ] / q[ h ];
54 }
@ f
Definition: BVPBerman.cpp:15
double g(1.0)
gravitational acceleration

References f, CppNoddy::Example::g(), h, hu, and hv.

◆ flux_fn_y()

void CppNoddy::Example::Shallow_2d_source::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 from CppNoddy::TwoD_Hyperbolic_System.

Definition at line 56 of file HYP2DShallowSource.cpp.

57 {
58 f[ h ] = q[ hv ];
59 f[ hu ] = q[ hu ] * q[ hv ] / q[ h ];
60 f[ hv ] = q[ hv ] * q[ hv ] / q[ h ] + g * q[ h ] * q[ h ] / 2;
61 }

References f, CppNoddy::Example::g(), h, hu, and hv.

◆ Jac_flux_fn_x()

void CppNoddy::Example::Shallow_2d_source::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 from CppNoddy::TwoD_Hyperbolic_System.

Definition at line 64 of file HYP2DShallowSource.cpp.

65 {
66 J( 0, hu ) = 1;
67 //
68 J( 1, h ) = - q[ hu ] * q[ hu ] / ( q[ h ] * q[ h ] ) + g * q[ h ];
69 J( 1, hu ) = 2 * q[ hu ] / q[ h ];
70 //
71 J( 2, h ) = - q[ hu ] * q[ hv ] / ( q[ h ] * q[ h ] );
72 J( 2, hu ) = q[ hv ] / q[ h ];
73 J( 2, hv ) = q[ hu ] / q[ h ];
74 }

References CppNoddy::Example::g(), h, hu, and hv.

◆ Jac_flux_fn_y()

void CppNoddy::Example::Shallow_2d_source::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 from CppNoddy::TwoD_Hyperbolic_System.

Definition at line 76 of file HYP2DShallowSource.cpp.

77 {
78 J( 0, hv ) = 1;
79 //
80 J( 1, h ) = - q[ hu ] * q[ hv ] / ( q[ h ] * q[ h ] );
81 J( 1, hu ) = q[ hv ] / q[ h ];
82 J( 1, hv ) = q[ hu ] / q[ h ];
83 //
84 J( 2, h ) = - q[ hv ] * q[ hv ] / ( q[ h ] * q[ h ] ) + g * q[ h ];
85 J( 2, hv ) = 2 * q[ hv ] / q[ h ];
86 }

References CppNoddy::Example::g(), h, hu, and hv.

◆ max_charac_speed()

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

Bound the wave speed.

Reimplemented from CppNoddy::TwoD_Hyperbolic_System.

Definition at line 89 of file HYP2DShallowSource.cpp.

90 {
91 // wave speed
92 double cc = sqrt( g * q[ h ] );
93 // flow speed
94 double U = q[ hu ] / q[ h ];
95 double V = q[ hv ] / q[ h ];
96 // maximum shock speed
97 c[ 0 ] = std::max( std::abs( U + cc ), std::abs( U - cc ) );
98 c[ 1 ] = std::max( std::abs( V + cc ), std::abs( V - cc ) );
99 }
@ V
Definition: BVPKarman.cpp:20
@ U
Definition: BVPKarman.cpp:20

References CppNoddy::Example::g(), h, hu, hv, U, and V.

◆ source_fn()

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

Reimplemented from CppNoddy::TwoD_Hyperbolic_System.

Definition at line 119 of file HYP2DShallowSource.cpp.

120 {
121 const double delta( 1.e-6 );
122 r[ h ] = 0.0;
123 r[ hu ] = - g * q[ h ] * ( z( x[0] + delta, x[1] ) - z( x[0], x[1] ) ) / delta;
124 r[ hv ] = - g * q[ h ] * ( z( x[0], x[1] + delta ) - z( x[0], x[1] ) ) / delta;
125 }
const double delta(0.5)

References CppNoddy::Example::delta(), CppNoddy::Example::g(), h, hu, hv, and CppNoddy::Example::z().


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

© 2012

R.E. Hewitt