16#include "../Utils_Fill.h"
26 double source(
const double& x,
const double& y,
const double& t )
28 return -y * std::exp( -x ) + std::pow( y * t * std::exp( -x ), 2 );
88 const double x =
coord( 0 );
89 const double t =
coord( 1 );
90 b[ 0 ] =
z[
U ] - t * std::exp( - x );
103 cout <<
"=== double_IBVP: non-constant mass matrix example ===\n";
127 &BC_bottom, &BC_top );
130 for (
unsigned i = 0; i < nx; ++i )
132 for (
unsigned j = 0; j < ny; ++j )
139 double max_error( 0.0 );
147 double t_next = nlin.
t() + dt;
148 for (
unsigned j = 0; j < ny; ++j )
150 double y = nlin.
solution().coord( 0, j ).second;
155 for (
unsigned i = 0; i < nx; ++i )
157 for (
unsigned j = 0; j < ny; ++j )
159 double x = nlin.
solution().coord( i, j ).first;
160 double y = nlin.
solution().coord( i, j ).second;
161 double exact_u = y * nlin.
t() * exp( - x );
162 max_error = max( max_error, abs( exact_u - nlin.
solution()( i, j,
U ) ) );
167 while ( nlin.
t() < t_end );
169 const double tol( 1.e-4 );
171 if ( max_error > tol )
173 cout <<
"\033[1;31;48m * FAILED \033[0m\n";
174 cout <<
" Difference = " << max_error <<
"\n";
179 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 residual_fn(const DenseVector< double > &z, DenseVector< double > &b) const
void residual_fn(const DenseVector< double > &z, DenseVector< double > &f) const
Define a nonlinear advection diffusion problem.
void matrix2(const DenseVector< double > &z, DenseMatrix< double > &m) const
Providing the matrix for x evolution.
void matrix1(const DenseVector< double > &z, DenseMatrix< double > &m) const
Providing the matrix for t evolution.
nonlinear()
The problem is 2nd order and real.
void matrix0(const DenseVector< double > &z, DenseMatrix< double > &m) const
Define the unsteady terms by providing the mass matrix for t evolution.
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.