22 double z(
const double &x,
const double &y )
26 double rsq( ( x - 10 ) * ( x - 10 ) + 0.0 * y * y );
27 return A * std::exp( - 0.5 * rsq );
52 f[
hu ] = q[
hu ] * q[
hu ] / q[
h ] +
g * q[
h ] * q[
h ] / 2;
53 f[
hv ] = q[
hu ] * q[
hv ] / q[
h ];
59 f[
hu ] = q[
hu ] * q[
hv ] / q[
h ];
60 f[
hv ] = q[
hv ] * q[
hv ] / q[
h ] +
g * q[
h ] * q[
h ] / 2;
68 J( 1,
h ) = - q[
hu ] * q[
hu ] / ( q[
h ] * q[
h ] ) +
g * q[
h ];
69 J( 1,
hu ) = 2 * q[
hu ] / q[
h ];
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 ];
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 ];
84 J( 2,
h ) = - q[
hv ] * q[
hv ] / ( q[
h ] * q[
h ] ) +
g * q[
h ];
85 J( 2,
hv ) = 2 * q[
hv ] / q[
h ];
92 double cc = sqrt(
g * q[
h ] );
94 double U = q[
hu ] / q[
h ];
95 double V = q[
hv ] / q[
h ];
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 ) );
104 std::vector<bool> comps( q.
size(),
false );
105 switch ( face_index )
121 const double delta( 1.e-6 );
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;
139 cout <<
"=== Hyperbolic: 2D shallow water over topography ====\n";
142 std::string dirname(
"./DATA");
143 mkdir( dirname.c_str(), S_IRWXU );
144 std::string filename_stub(
"./DATA/HYP_2D_shallow_source" );
146 const double west = 0;
147 const double east = 25;
148 const double south = -3;
149 const double north = 3;
150 const unsigned Nx = 401;
151 const unsigned Ny = 3;
156 TwoD_TVDLF_Mesh Shallow_2d_mesh( faces_x, faces_y, &conservative_problem, Example::Q_init );
159 int file_counter( 0 );
160 int loop_counter( 0 );
161 const double t_end = 5;
164 if ( loop_counter % 10 == 0 )
169 Shallow_2d_mesh.
update( 0.49, std::abs( Shallow_2d_mesh.
get_time() - t_end ) );
173 while ( Shallow_2d_mesh.
get_time() < t_end );
180 double E( abs( h_10 - 0.116773 ) );
183 cout <<
"\033[1;31;48m * FAILED \033[0m\n";
189 cout <<
"\033[1;32;48m * PASSED \033[0m\n";
A shorter bundled include file for hyperbolic problems.
A matrix class that constructs a DENSE matrix as a row major std::vector of DenseVectors.
An DenseVector class – a dense vector object.
std::size_t size() const
A pass-thru definition to get the size of the vector.
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.
std::vector< bool > edge_values(const int &face_index, const DenseVector< double > &x, DenseVector< double > &q) const
edge conditions
void source_fn(const DenseVector< double > &x, const DenseVector< double > &q, DenseVector< double > &r) const
void max_charac_speed(const DenseVector< double > &x, const DenseVector< double > &q, DenseVector< double > &c) const
Bound the wave speed.
void flux_fn_y(const DenseVector< double > &x, const DenseVector< double > &q, DenseVector< double > &f) const
A virtual flux function for the y-derivative.
void flux_fn_x(const DenseVector< double > &x, const DenseVector< double > &q, DenseVector< double > &f) const
Define the vector flux.
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.
Shallow_2d_source()
One dimemsional constant coefft acoustic problem.
A class to represent a two-dimensional hyperbolic system of equations.
DenseVector< double > get_point_values(const DenseVector< double > &x)
Get the vector of unknowns at a point in the 2D mesh.
void dump_gnu(std::string filename)
Dump the data to a given filename in a gnuplot format.
const double & get_time() const
Get a const reference to the time value for the current mesh.
double update(const double &CFL, const double &max_dt=std::numeric_limits< long double >::max())
Update the mesh object.
void set_limiter(const unsigned &id)
Set the limiter type to be applied in the slope values.
void Q_init(const double &x, DenseVector< double > &q)
Set the initial state of the system.
double A(1.0)
initial hump amplitude
double g(1.0)
gravitational acceleration
DenseVector< double > power_node_vector(const double &lower, const double &upper, const std::size_t &N, const double &power)
Return a DENSE vector with the nodal points of a non-uniform mesh distributed between the upper/lower...
std::string stringify(const int &val)
Return an integer value as a string - useful for file naming.
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...