14#include "../Utils_Fill.h"
24 template <
typename _Type,
typename _Xtype>
46 template <
typename _Type>
58 template <
typename _Type>
80 cout <<
"=== BVP: finite-difference solution of Harmonic eqn =\n";
84 Example::Harmonic_left_BC <double> real_BC_left;
87 Example::Harmonic_left_BC <D_complex> complex_BC_left;
101 const double tol = 1.e-4;
104 ODE_BVP<double> real_ode( &real_problem, real_nodes, &real_BC_left, &real_BC_right );
110 for (
unsigned i = 0; i < N; ++i )
112 double y = real_ode.
solution().coord( i );
127 catch (
const std::runtime_error &error )
129 cout <<
" \033[1;31;48m * FAILED THROUGH EXCEPTION BEING RAISED \033[0m\n";
134 double real_diff = 0;
135 double complex_diff = 0;
136 for (
unsigned i = 0; i < N; ++i )
138 real_diff = std::max( std::abs( real_ode.
solution()( i,
f ) - sin( real_ode.
solution().coord( i ) ) / sin( 1 ) ), real_diff );
139 complex_diff = std::max( std::abs( complex_ode.
solution()( i,
f ) - sin( complex_ode.
solution().coord( i ) ) / sin( eye ) ), complex_diff );
143 if ( real_diff > tol || complex_diff > tol )
145 cout <<
"\033[1;31;48m * FAILED \033[0m\n";
146 cout <<
"Real problem error " << real_diff <<
"\n";
147 cout <<
"Complex problem error " << complex_diff <<
"\n";
152 cout <<
"\033[1;32;48m * PASSED \033[0m\n";
A shorter bundled include file for ODE_BVP and PDE_IBVP codes.
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 IBVP classes (and others).
const DenseMatrix< _Type > & matrix0() const
Return a handle to the matrix.
Define the harmonic equation by inheriting the Equation base class.
void residual_fn(const DenseVector< _Type > &z, DenseVector< _Type > &g) const
The Berman equation.
Harmonic_equation()
The harmonic equation is a 2nd order ODE.
void residual_fn(const DenseVector< _Type > &z, DenseVector< _Type > &B) const
A blank virtual residual function method.
void residual_fn(const DenseVector< _Type > &z, DenseVector< _Type > &B) const
A blank virtual residual function method.
A templated object for real/complex vector system of first-order ordinary differential equations.
void set_monitor_det(bool flag)
Set the flag that determines if the determinant will be monitored The default is to monitor.
OneD_Node_Mesh< _Type, _Xtype > & solution()
void solve2()
Formulate and solve the ODE using Newton iteration and a second-order finite difference scheme.
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...
std::complex< double > D_complex
A complex double precision number using std::complex.
void fill_identity(CppNoddy::Sequential_Matrix_base< _Type > &A)
Fill diagonal with unit values.