38 f[ 1 ] = -
E*sin(M_PI*Y) + ((1+Y)+
E*sin(M_PI*Y))*(M_PI*M_PI)*
E*sin(M_PI*Y)/
sigma;
78 b[ 0 ] =
z[
U ] - 1.0;
90 b[ 0 ] =
z[
U ] - 2.0;
103 cout <<
"=== IBVP: A nonlinear diffusion problem ============\n";
120 unsigned max_steps = ( unsigned ) ( 2.0 / dt );
125 for (
unsigned i = 0; i < ny; ++i )
127 double y( diffusion.
solution().coord(i) );
128 diffusion.
solution()( i,
U ) = (1+y) + Example::A*sin(M_PI*y);
129 diffusion.
solution()( i,
Ud ) = 1 + Example::A*M_PI*cos(M_PI*y);
133 std::string dirname(
"./DATA");
134 mkdir( dirname.c_str(), S_IRWXU );
135 TrackerFile metric(
"./DATA/IBVP_diffusion_metric.dat" );
139 TrackerFile profs(
"./DATA/IBVP_diffusion_profs.dat" );
147 double max_error( 0.0 );
149 for (
unsigned i = 1; i < max_steps; ++i )
154 diffusion.
step2( dt );
156 catch (
const std::runtime_error &error )
158 cout <<
" \033[1;31;48m * FAILED THROUGH EXCEPTION BEING RAISED \033[0m\n";
163 cout << diffusion.
coord() <<
"\n";
171 double Uexact = 1 + yy + Example::A*exp(-diffusion.
coord())*sin(M_PI*yy);
172 double error = diffusion.
solution().get_interpolated_vars( 0.5 )[
U ] - Uexact;
173 max_error = std::max( std::abs( error ), max_error );
180 const double tol( 1.e-4 );
182 if ( max_error > tol )
184 cout <<
"\033[1;31;48m * FAILED \033[0m\n";
185 cout <<
" Max difference over time steps = " << max_error <<
"\n";
190 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 > &f) const
Define the Karman equations.
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.
Diffusion_equations()
The problem is 2nd order and real.
void matrix1(const DenseVector< double > &z, DenseMatrix< double > &m) const
Define the unsteady terms by providing the mass matrix.
void matrix0(const DenseVector< double > &z, DenseMatrix< double > &m) const
Define the domain-derivative terms by providing the mass matrix.
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.
Define the boundary conditions.
void residual_fn(const DenseVector< double > &z, DenseVector< double > &b) const
void residual_fn(const DenseVector< double > &z, DenseVector< double > &b) const
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.
_Xtype & coord(const unsigned &i)
General handle access to the coordinates.
A simple CPU-clock-tick timer for timing metods.
void start()
Start the timer & reset stored time to zero.
int & counter()
Increment an internal discrete counter.
void print() const
Write a string to cout stating the time taken.
void stop()
Stop the clock & add the current time interval to the previously stored values ready for printing.
void push_ptr(double *scalar, std::string desc="")
double A(1.0)
initial hump amplitude
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...
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...