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

Solving the 1D Euler problem for gas dynamics. More...

#include <OneD_HYP_bundle.h>

Go to the source code of this file.

Classes

class  CppNoddy::Example::Euler_1d
 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  { rho , m , E }
 

Functions

double CppNoddy::Example::gamma (1.4)
 Adiabatic index – ratio of specific heats. More...
 
void CppNoddy::Example::Q_init (const double &x, DenseVector< double > &q)
 Set the initial state of the system. More...
 
int main ()
 

Detailed Description

Solving the 1D Euler problem for gas dynamics.

\[ \rho_t + \left ( m \right )_x = 0 \]

\[ m_t + \left ( \rho u^2 + p \right )_x = 0 \]

\[ E_t + \left ( u ( E + p ) \right )_x = 0 \]

where

\[ u = m / \rho \]

\[ p = ( \gamma - 1 ) ( E - \frac12 \rho u^2 ) \]

and $ \gamma = 1.4 $. The initial conditions correspond to Sod's problem

\[ (\rho, m, E ) = (  1, 0, 2.5 ) \]

for $ x < \frac12 $

\[ (\rho, m, E ) = ( 0.125, 0, 0.25 ) \]

for $ x > \frac12 $.

Definition in file HYPSodsShocktube.cpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
rho 

Definition at line 18 of file HYPSodsShocktube.cpp.

18{ rho, m, E };

Function Documentation

◆ main()

int main ( )

Definition at line 83 of file HYPSodsShocktube.cpp.

84{
85 cout << "\n";
86 cout << "=== Hyperbolic: 1D Euler gasdynamics shocktube =====\n";
87 cout << "\n";
88
89 // define the domain/mesh
90 const double left = 0.0;
91 const double right = 1.0;
92 const unsigned N = 400;
93 DenseVector<double> faces_x = Utility::uniform_node_vector( left, right, N );
94
95 double t = 0.0;
96
97 Example::Euler_1d conservative_problem;
98 OneD_TVDLF_Mesh Euler_mesh( faces_x, &conservative_problem, Example::Q_init );
99 Euler_mesh.set_limiter( 0 );
100
101 double I1 = Euler_mesh.integrate()[0];
102 int loop_counter( 0 );
103 int file_counter( 0 );
104
105 std::string dirname("./DATA");
106 mkdir( dirname.c_str(), S_IRWXU );
107 std::string filename_stub;
108 filename_stub = "./DATA/HYP_shocktube_sod";
109 TrackerFile my_file( 10 );
110 OneD_Node_Mesh<double> soln = Euler_mesh.get_soln();
111 my_file.push_ptr( &soln, "mesh" );
112
113 do
114 {
115 if ( loop_counter % 10 == 0 )
116 {
117 my_file.set_filename( filename_stub + Utility::stringify( file_counter ) + ".dat" );
118 soln = Euler_mesh.get_soln( );
119 my_file.update();
120 file_counter += 1;
121 }
122 t += Euler_mesh.update( 0.499 );
123 ++loop_counter;
124 }
125 while ( ( t < 0.2 ) && ( loop_counter < 1000 ) );
126
127 double I2 = Euler_mesh.integrate()[0];
128 // These are clawpack results (to 4dp) with N=400 and minmod for the
129 // density of the two density steps ...
130 soln = Euler_mesh.get_soln( );
131 double E1 = std::abs( soln.get_interpolated_vars( 0.575 )[0] - 0.4264 );
132 double E2 = std::abs( soln.get_interpolated_vars( 0.75 )[0] - 0.2656 );
133 // check against the clawpack data, and that the mass is conserved.
134 if ( ( E1 > 1.e-3 ) || ( E2 > 1.e-3 ) || ( std::abs( I1 - I2 ) > 1.e-8 ) || ( loop_counter >= 1000 ) )
135 {
136 cout << "\033[1;31;48m * FAILED \033[0m\n";
137 cout << E1 << " " << E2 << " " << std::abs( I1 - I2 ) << " " << loop_counter << "\n";
138 return 1;
139 }
140 else
141 {
142 cout << "\033[1;32;48m * PASSED \033[0m\n";
143 return 0;
144 }
145
146} // 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.
std::string stringify(const int &val)
Return an integer value as a string - useful for file naming.
Definition: Utility.cpp:193
DenseVector< double > uniform_node_vector(const double &lower, const double &upper, const std::size_t &N)
Return a DENSE vector with the nodal points of a uniform mesh distributed between the upper/lower bou...
Definition: Utility.cpp:113

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

© 2012

R.E. Hewitt