45 double c = sqrt(
K /
rho );
54 std::vector<bool> inflow( q.
size(),
false );
65 if ( ( x < 0.5 ) && ( x > -0.5 ) )
67 q[
p ] = std::exp( -20 * x * x );
68 q[
u ] = q[
p ] / sqrt(
K *
rho );
72 q[
p ] = q[
u ] = 0.0;
86 cout <<
"=== Hyperbolic: 1D acoustic wave reflection problem =\n";
90 const double left = -3.0;
91 const double right = 3.0;
92 const unsigned N = 800;
101 OneD_TVDLF_Mesh Acoustic_mesh( faces_x, &conservative_problem, Example::Q_init );
105 double I1 = Acoustic_mesh.
integrate()[0];
106 int loop_counter( 0 );
107 int file_counter( 1 );
109 std::string dirname(
"./DATA");
110 mkdir( dirname.c_str(), S_IRWXU );
111 std::string filename_stub;
112 filename_stub =
"./DATA/HYP_acoustic_ref";
119 if ( loop_counter % 10 == 0 )
127 t += Acoustic_mesh.
update( 0.49, t_end - t );
130 while ( ( t < t_end ) && ( loop_counter < 1100 ) );
132 double I2 = Acoustic_mesh.
integrate()[0];
138 for ( std::size_t i = 0; i < soln.
get_nnodes(); ++i )
142 Example::Q_init( soln.
coord( i ), q );
144 diff = std::max( diff, q[0] - soln( i, 0 ) );
148 if ( ( diff > 1.e-2 ) || ( std::abs( I1 - I2 ) > 1.e-8 ) )
150 cout <<
"\033[1;31;48m * FAILED \033[0m\n";
151 cout <<
"difference in the reflected wave = " << diff <<
"\n";
152 cout <<
"difference in the integral = " << std::abs( I1 - I2 ) <<
"\n";
157 cout <<
"\033[1;32;48m * PASSED \033[0m\n";
A shorter bundled include file for hyperbolic problems.
An DenseVector class – a dense vector object.
std::size_t size() const
A pass-thru definition to get the size of the vector.
Acoustic_1d_ref()
One dimemsional constant coefft acoustic problem.
std::vector< bool > edge_values(const int face_index, const double &x, DenseVector< double > &q, const double &t) const
edge conditions
double max_charac_speed(const DenseVector< double > &q) const
Bound the shock speed.
void flux_fn(const double &x, const DenseVector< double > &q, DenseVector< double > &f) const
Define the vector flux.
A class to represent a one dimensional hyperbolic system of equations.
A one dimensional mesh utility object.
const _Xtype & coord(const std::size_t &node) const
Access a nodal position.
std::size_t get_nnodes() const
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
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...