CppNoddy  0.92
Loading...
Searching...
No Matches
Classes | Namespaces | Enumerations | Functions
HYPRadialDamBreak.cpp File Reference

Solve the shallow water equations in one dimension for an initial column of fluid. More...

#include <OneD_HYP_bundle.h>

Go to the source code of this file.

Classes

class  CppNoddy::Example::Shallow_1d_rad
 Define the system. More...
 

Namespaces

namespace  CppNoddy
 A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechanics.
 
namespace  CppNoddy::Example
 

Enumerations

enum  { h , hu }
 

Functions

double CppNoddy::Example::g (1.0)
 gravitational acceleration More...
 
double CppNoddy::Example::A (1.0)
 initial hump amplitude More...
 
void CppNoddy::Example::Q_init (const double &x, DenseVector< double > &q)
 Set the initial state of the system. More...
 
int main ()
 

Detailed Description

Solve the shallow water equations in one dimension for an initial column of fluid.

\[ h_t +  (uh)_r = -hu/r \]

\[ (uh)_t + (hu^2 + gh^2 /2 )_r = -hu^2/r \]

The result is compared to the same problem solved using Clawpack, evaluated at the single point x=0.5.

Definition in file HYPRadialDamBreak.cpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
hu 

Definition at line 13 of file HYPRadialDamBreak.cpp.

13{ h, hu };

Function Documentation

◆ main()

int main ( )
Todo:
Include a mechanism for avoiding source term computations at the singular point by indicating where edge conditions are specified. For the time being, we'll bodge it by stopping away from x=0.

Definition at line 75 of file HYPRadialDamBreak.cpp.

76{
77 cout << "\n";
78 cout << "=== Hyperbolic: Shallow water radial dam break ======\n";
79 cout << "\n";
80
81 // There is a singular source_fn at r=0, so we bodge it here (for now).
82 /// \todo Include a mechanism for avoiding source term computations
83 /// at the singular point by indicating where edge conditions are specified.
84 /// For the time being, we'll bodge it by stopping away from x=0.
85 const double left = 1.e-4;
86 const double right = 2.5;
87 const unsigned N = 2001;
88 DenseVector<double> faces_x = Utility::power_node_vector( left, right, N, 1.0 );
89
90 // time
91 double t = 0;
92 double t_end = 0.5;
93
94 // hyperbolic problem
95 Example::Shallow_1d_rad conservative_problem;
96 OneD_TVDLF_Mesh Shallow_mesh( faces_x, &conservative_problem, Example::Q_init );
97 Shallow_mesh.set_limiter( 0 );
98
99 // output
100 int loop_counter( 0 );
101 int file_counter( 0 );
102
103 std::string dirname("./DATA");
104 mkdir( dirname.c_str(), S_IRWXU );
105 std::string filename_stub;
106 filename_stub = "./DATA/HYP_shallow_rad";
107 TrackerFile my_file( 5 );
108 OneD_Node_Mesh<double> soln = Shallow_mesh.get_soln();
109 my_file.push_ptr( &soln, "mesh" );
110
111 do
112 {
113 if ( loop_counter % 50 == 0 )
114 {
115 my_file.set_filename( filename_stub + Utility::stringify( file_counter ) + ".dat" );
116 soln = Shallow_mesh.get_soln();
117 my_file.update();
118 file_counter += 1;
119 }
120 t += Shallow_mesh.update( 0.499, t_end - t );
121 ++loop_counter;
122 }
123 while ( ( t < t_end ) && ( loop_counter < 3000 ) );
124
125 // we test the result against the Clawpack computational result
126 soln = Shallow_mesh.get_soln();
127 double h_clawpack( 1.13466 );
128 double h_test( soln.get_interpolated_vars( 0.5 )[ h ] );
129 if ( abs( h_test - h_clawpack ) > 1.e-3 )
130 {
131 cout << "\033[1;31;48m * FAILED \033[0m\n";
132 cout << " deviation from the Clawpack data = " << abs( h_test - h_clawpack ) << "\n";
133 return 1;
134 }
135 else
136 {
137 cout << "\033[1;32;48m * PASSED \033[0m\n";
138 return 0;
139 }
140
141} // end of main()
An DenseVector class – a dense vector object.
Definition: DenseVector.h:34
A one dimensional mesh utility object.
DenseVector< _Type > get_interpolated_vars(const _Xtype &pos) const
Get the variable data at an interpolated position using a first order scheme.
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...
Definition: Utility.cpp:123
std::string stringify(const int &val)
Return an integer value as a string - useful for file naming.
Definition: Utility.cpp:193

References CppNoddy::OneD_Node_Mesh< _Type, _Xtype >::get_interpolated_vars(), CppNoddy::OneD_TVDLF_Mesh::get_soln(), h, CppNoddy::Utility::power_node_vector(), CppNoddy::TrackerFile::push_ptr(), CppNoddy::TrackerFile::set_filename(), CppNoddy::OneD_TVDLF_Mesh::set_limiter(), CppNoddy::Utility::stringify(), CppNoddy::TrackerFile::update(), and CppNoddy::OneD_TVDLF_Mesh::update().

© 2012

R.E. Hewitt