86 cout <<
"=== IBVP: An unsteady diffusion eqn =================\n";
102 unsigned max_steps = ( unsigned ) ( 3.0 / dt );
109 for (
unsigned i = 0; i < ny; ++i )
111 double y = heat.
solution().coord( i );
117 double max_diff( 0.0 );
119 for (
unsigned i = 1; i < max_steps; ++i )
126 catch (
const std::runtime_error &error )
128 cout <<
" \033[1;31;48m * FAILED THROUGH EXCEPTION BEING RAISED \033[0m\n";
133 unsigned mid = ( ny - 1 ) / 2;
134 double y = left + mid * ( right - left ) / ( ny - 1 );
137 double correction( 0.0 );
141 correction = 8 / ( std::pow( en * M_PI, 3 ) )
142 * std::exp( -std::pow( en * M_PI, 2 ) * heat.
coord() ) * std::sin( en * M_PI * y );
145 while ( std::abs( correction ) > tol / 10. );
147 max_diff = std::max( max_diff, std::abs(
u - heat.
solution()( mid,
f ) ) );
151 if ( abs( max_diff ) < tol )
158 cout <<
"\033[1;31;48m * FAILED \033[0m\n";
163 cout <<
"\033[1;32;48m * PASSED \033[0m\n";
A shorter bundled include file for initial boundary value problems.
A matrix class that constructs a DENSE matrix as a row major std::vector of DenseVectors.
An DenseVector class – a dense vector object.
An equation object base class used in the PDE_double_IBVP class.
void residual_fn(const DenseVector< double > &z, DenseVector< double > &b) const
Diff_equation()
The problem is 2nd order and real.
void get_jacobian_of_matrix0_mult_vector(const DenseVector< double > &state, const DenseVector< double > &vec, DenseMatrix< double > &h) const
To speed things up we'll overload this to say the mass matrix is constant.
void get_jacobian_of_matrix1_mult_vector(const DenseVector< double > &state, const DenseVector< double > &vec, DenseMatrix< double > &h) const
To speed things up we'll overload this to say the mass matrix is constant.
void matrix0(const DenseVector< double > &z, DenseMatrix< double > &m) const
Define the (BVP) deriv by providing the identity matrix.
void matrix1(const DenseVector< double > &z, DenseMatrix< double > &m) const
Define the unsteady terms by providing the mass matrix.
void residual_fn(const DenseVector< double > &z, DenseVector< double > &g) const
Define the equation.
A templated object for real/complex vector system of unsteady equations.
void step2(const double &dt)
A Crank-Nicolson 'time' stepper.
OneD_Node_Mesh< _Type > & solution()
double & coord()
Return a reference to the current value of the 'timelike/parabolic' coordinate.
A base class to be inherited by objects that define residuals.
double g(1.0)
gravitational acceleration
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...