18#include "../Utils_Fill.h"
28 double source(
const double& x,
const double& y,
const double& t )
30 return -y * std::exp( -x ) + std::pow( y * t * std::exp( -x ), 2 );
81 h( 1,
U ) = - vec[ 0 ];
111 const double x =
coord( 0 );
112 const double t =
coord( 1 );
113 b[ 0 ] =
z[
U ] - t * std::exp( - x );
126 cout <<
"=== double_IBVP: non-constant mass matrix example ===\n";
150 &BC_bottom, &BC_top );
153 for (
unsigned i = 0; i < nx; ++i )
155 for (
unsigned j = 0; j < ny; ++j )
162 double max_error( 0.0 );
170 double t_next = nlin.
t() + dt;
171 for (
unsigned j = 0; j < ny; ++j )
173 double y = nlin.
solution().coord( 0, j ).second;
178 for (
unsigned i = 0; i < nx; ++i )
180 for (
unsigned j = 0; j < ny; ++j )
182 double x = nlin.
solution().coord( i, j ).first;
183 double y = nlin.
solution().coord( i, j ).second;
184 double exact_u = y * nlin.
t() * exp( - x );
185 max_error = max( max_error, abs( exact_u - nlin.
solution()( i, j,
U ) ) );
190 while ( nlin.
t() < t_end );
192 const double tol( 1.e-4 );
194 if ( max_error > tol )
196 cout <<
"\033[1;31;48m * FAILED \033[0m\n";
197 cout <<
" Difference = " << max_error <<
"\n";
202 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 get_jacobian_of_matrix0_mult_vector(const DenseVector< double > &state, const DenseVector< double > &vec, DenseMatrix< double > &h) const
void matrix2(const DenseVector< double > &z, DenseMatrix< double > &m) const
Define the unsteady terms by providing the mass matrix for x evolution.
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 matrix1(const DenseVector< double > &z, DenseMatrix< double > &m) const
Define the unsteady terms by providing the mass matrix for t evolution.
nonlinear()
The problem is 2nd order and real.
void jacobian(const DenseVector< double > &z, DenseMatrix< double > &jac) const
Provide the exact Jacobian rather than using finite-differences.
void get_jacobian_of_matrix1_mult_vector(const DenseVector< double > &state, const DenseVector< double > &vec, DenseMatrix< double > &h) const
void matrix0(const DenseVector< double > &z, DenseMatrix< double > &m) const
Define the BVP terms.
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.