16#include "../Utils_Fill.h"
26 double source(
const double& x,
const double& y,
const double& t )
28 return - 2 * std::exp( -x*t ) + ( 1 - y * y ) * ( x + t ) * std::exp( -x*t );
107 cout <<
"=== double_IBVP: linear diffusive problem ===========\n";
117 double bottom = -1.0;
131 &BC_bottom, &BC_top );
134 for (
unsigned i = 0; i < nx; ++i )
136 for (
unsigned j = 0; j < ny; ++j )
138 double y = diffusion.
solution().coord( i, j ).second;
139 diffusion.
solution()( i, j,
U ) = ( 1.0 - y * y );
144 double max_error( 0.0 );
148 diffusion.
step2( dt );
149 for (
unsigned i = 0; i < nx; ++i )
151 for (
unsigned j = 0; j < ny; ++j )
153 double x = diffusion.
solution().coord( i, j ).first;
154 double y = diffusion.
solution().coord( i, j ).second;
155 double exact_u = ( 1 - y * y ) * exp( - x * diffusion.
t() );
156 max_error = max( max_error, abs( exact_u - diffusion.
solution()( i, j,
U ) ) );
160 while ( diffusion.
t() < t_end );
162 const double tol( 1.e-4 );
164 if ( max_error > tol )
166 cout <<
"\033[1;31;48m * FAILED \033[0m\n";
167 cout <<
" Difference = " << max_error <<
"\n";
172 cout <<
"\033[1;32;48m * PASSED \033[0m\n";
A shorter bundled include file for double 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
void get_jacobian_of_matrix1_mult_vector(const DenseVector< double > &state, const DenseVector< double > &vec, DenseMatrix< double > &h) const
void get_jacobian_of_matrix2_mult_vector(const DenseVector< double > &state, const DenseVector< double > &vec, DenseMatrix< double > &h) const
Return the product of the Jacobian-of-the-matrix and a vector 'vec' when the equation has a given 'st...
void jacobian(const DenseVector< double > &z, DenseMatrix< double > &jac) const
Provide the exact Jacobian rather than using finite-differences.
void get_jacobian_of_matrix0_mult_vector(const DenseVector< double > &state, const DenseVector< double > &vec, DenseMatrix< double > &h) const
void residual_fn(const DenseVector< double > &z, DenseVector< double > &f) const
Define a nonlinear advection diffusion problem.
void matrix1(const DenseVector< double > &z, DenseMatrix< double > &m) const
Define the unsteady terms by providing the mass matrix.
void matrix2(const DenseVector< double > &z, DenseMatrix< double > &m) const
Define the matrix for the current state vector.
diffusion_double()
The problem is 2nd order and real.
void matrix0(const DenseVector< double > &z, DenseMatrix< double > &m) const
A templated object for real/complex vector system of unsteady equations.
void update_previous_solution()
Copy the current solution to the previous solution.
double & t()
Return a reference to the current value of the 'timelike' coordinate.
void step2(const double &dt)
A Crank-Nicolson 'time' stepper.
TwoD_Node_Mesh< _Type > & solution()
A base class to be inherited by objects that define residuals.
_Xtype & coord(const unsigned &i)
General handle access to the coordinates.
double source(const double &x, const double &y, const double &t)
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...
void fill_identity(CppNoddy::Sequential_Matrix_base< _Type > &A)
Fill diagonal with unit values.