30 double rho(
const double &x )
32 if ( std::abs( x ) < 1.0 )
56 f[
u ] = q[
p ] /
rho( x );
73 if ( ( x < -1.5 ) && ( x > -2.5 ) )
76 q[
u ] = q[
p ] / sqrt(
K *
rho( x ) );
80 q[
p ] = q[
u ] = 0.0;
94 cout <<
"=== Hyperbolic: 1D acoustic wave, impedance problem =\n";
98 const double left = -7.0;
99 const double right = 7.0;
100 const unsigned N = 800;
109 OneD_TVDLF_Mesh Acoustic_mesh( faces_x, &conservative_problem, Example::Q_init );
113 double I1 = Acoustic_mesh.
integrate()[0];
114 int loop_counter( 4 );
115 int file_counter( 1 );
117 std::string dirname(
"./DATA");
118 mkdir( dirname.c_str(), S_IRWXU );
119 std::string filename_stub;
120 filename_stub =
"./DATA/HYP_acoustic_imp";
127 t += Acoustic_mesh.
update( 0.499, t_end - t );
129 if ( loop_counter % 2 == 0 )
139 while ( ( t < t_end ) && ( loop_counter < 1500 ) );
142 double I2 = Acoustic_mesh.
integrate()[0];
148 if ( ( E1 > 1.e-4 ) || ( E2 > 1.e-4 ) || ( std::abs( I1 - I2 ) > 1.e-8 ) || ( loop_counter >= 1500 ) )
150 cout <<
"\033[1;31;48m * FAILED \033[0m\n";
155 cout <<
"\033[1;32;48m * PASSED \033[0m\n";
A shorter bundled include file for hyperbolic problems.
An DenseVector class – a dense vector object.
void flux_fn(const double &x, const DenseVector< double > &q, DenseVector< double > &f) const
Define the vector flux.
Acoustic_1d()
One dimemsional constant coefft acoustic problem.
double max_charac_speed(const DenseVector< double > &q) const
Bound the shock speed.
A class to represent a one dimensional hyperbolic system of equations.
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.
OneD_Node_Mesh< double > get_soln(std::string location="centre", std::string colour="black")
Get a OneD_Mesh<double> object containing the one dimensional data in the usual format.
double update(const double &CFL, const double &max_dt=std::numeric_limits< long double >::max())
Update all the elements in this mesh to a new time step.
void set_limiter(unsigned id)
Set the limiter type to be applied in the slope values.
DenseVector< double > integrate() const
Integrate the concentration values across the entire mesh.
void push_ptr(double *scalar, std::string desc="")
void set_filename(std::string filename)
void Q_init(const double &x, DenseVector< double > &q)
Set the initial state of the system.
double K(4.0)
bulk modulus
double rho_small(1.0)
lower density
double rho_big(4.0)
higher density
std::string stringify(const int &val)
Return an integer value as a string - useful for file naming.
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...
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...