CppNoddy  0.90
Files
A COMPLETE LIST OF ALL EXAMPLES

Files

file  Arc_circle.cpp
 A simple arc-length continuation solving the equation

\[ x^2 + p^2 = 2\,, \]

where $p$ is a parameter.

 
file  Arc_circle_vector.cpp
 A simple arc-length continuation solving the vector equation

\[ x^2 + p^2 = 1\,, y = \sin(x) \]

where $p$ is a parameter.

 
file  Arc_Shoot_FalknerSkan.cpp
 Arc-length continue the Falkner-Skan equation

\[ f'''(y) + f(y) f''(y) + \beta \left ( 1 - f'(y)^2 \right )= 0\,, \]

for varying values of the Hartree parameter $ \beta $ – around the well known limit point.

 
file  Arc_Trans_Fold.cpp
 Solve the nonlinear scalar residual problem

\[ R \equiv (x - 3)( (x-2)^2 + (p-4) ) = 0 \]

by arc-length continuation from the starting solution $ x=0, p=0 $.

 
file  BVP_Berman.cpp
 Solving the Berman suction-channel solution in the form

\[ f^(iv)(y) = Re ( f(y)f'''(y) - f'(y)f''(y) ) \]

subject to $ f(\pm 1) = \pm 1 $ and $ f'(\pm 1) = 0 $ by applying the ODE_BVP class.

 
file  BVP_Blasius.cpp
 Solving the Blasius equation

\[ f'''(y) + f(y) f''(y) = 0\,, \]

with $ f(0)=f'(0)=0 $ and $ f'(\infty) = 1 $ in the domain $ y \in [0,\infty ] $ by applying the ODE_BVP class.

 
file  BVP_Harmonic.cpp
 Solving the Harmonic equation

\[ f''(z) + f(z) = 0 \]

subject to $ f(0) = 0 $ and $ f(1) = 1 $ (OR $ f(i) = 1 $) by applying the ODE_BVP class.

 
file  BVP_JH_arc_NV.cpp
 Arc length conitinuation of the equation for self-similar flow between two planar angled walls; the Jeffery-Hamel flow.
 
file  BVP_Karman.cpp
 Solving the Karman rotating-disk equations for the flow above an infinite rotating disk:

\[ U''(y) = U^2(y) + V(y)U'(y) - W^2(y) \]

\[ W''(y) = 2U(y)W(y) + V(y)W'(y) \]

\[ 2U(y) + V'(y) = 0 \]

with boundary conditions $ U(0)=V(0)=0 $, $ W(0)=1 $ and $ U(\infty ) \to 0 $, $ W(\infty ) \to 0 $.

 
file  BVP_Karman_adapt.cpp
 Adaptively solve the Karman rotating-disk equations for the flow above an infinite rotating disk:

\[ U''(y) = U^2(y) + V(y)U'(y) - W^2(y) \]

\[ W''(y) = 2U(y)W(y) + V(y)W'(y) \]

\[ 2U(y) + V'(y) = 0 \]

with boundary conditions $ U(0)=V(0)=0 $, $ W(0)=1 $ and $ U(\infty ) \to 0 $, $ W(\infty ) \to 0 $.

 
file  BVP_Karman_arc.cpp
 Arc-length continuation of the Karman rotating-disk equations for the flow above an infinite rotating disk:

\[ U''(y) = U^2(y) + V(y)U'(y) - W^2(y) + s^2 \]

\[ W''(y) = 2U(y)W(y) + V(y)W'(y) \]

\[ 2U(y) + V'(y) = 0 \]

with boundary conditions $ U(0)=V(0)=0 $, $ W(0)=1 $ and $ U(\infty ) \to 0 $, $ W(\infty ) \to s $.

 
file  BVP_Karman_Jacobian.cpp
 Solving the Karman rotating-disk equations for the flow above an infinite rotating disk by applying a user-provided Jacobian

\[ U''(y) = U^2(y) + V(y)U'(y) - W^2(y) \]

\[ W''(y) = 2U(y)W(y) + V(y)W'(y) \]

\[ 2U(y) + V'(y) = 0 \]

with boundary conditions $ U(0)=V(0)=0 $, $ W(0)=1 $ and $ U(\infty ) \to 0 $, $ W(\infty ) \to 0 $.

 
file  BVP_nonIdentity.cpp
 Solving the equation

\[ f(y) f''(y) + f'(y)^2 = 1+\gamma y \]

subject to $ f(0) = 1 $ and $ f(1) = 2 $.

 
file  BVP_Harmonic.cpp
 Solving the Harmonic equation

\[ f''(z) + f(z) = 0 \]

subject to $ f(0) = 0 $ and $ f(1) = 1 $ (OR $ f(i) = 1 $) by applying the ODE_BVP class.

 
file  BVP_Troesch.cpp
 Solving the Troesch equation

\[ f''(y) = c \sinh (cy) \]

subject to $ f(0) = 0 $ and $ f(1) = 1 $.

 
file  Shoot_Berman.cpp
 Solving the fourth-order Berman (porous channel) similarity equation

\[ f'''(y) = Re \left ( f(y)f''(y) - f'(y)^2 - K \right )\]

where $y\in [-1,1]$ and $K$ is a pressure constant and $Re$ is the Reynolds number based on the channel half-height and the wall suction.

 
file  Shoot_Blasius.cpp
 Solving the Blasius equation

\[ f'''(y) + f(y) f''(y) = 0\,, \]

with $ f(0)=f'(0)=0 $ and $ f'(\infty) = 1 $ via Runge-Kutta and (scalar) Newton iteration.

 
file  Matrix_CompareNative.cpp
 A quick check that the overhead associated with the matrix container class is less than 5% compared to a native array.
 
file  MatrixMult.cpp
 Do some matrix multiplications and compare the native N^3 multiply with the BLAS implementation.
 
file  MatrixSolves.cpp
 Example of the simple linear solvers implemented for dense, banded and sparse matrix objects.
 
file  MatrixSolves.cpp
 Example of the simple linear solvers implemented for dense, banded and sparse matrix objects.
 
file  Vec_DenseVector.cpp
 Some simple sanity checks for the NVector class with both double and complex types.
 
file  Vec_Overloading.cpp
 Just a quick and simple check that NVector operator overloading is functioning.
 
file  Vec_SparseVector.cpp
 A superficial sanity check of one_norm and vector arithmetic for the sparse vector class.
 
file  IBVP_linear.cpp
 Solving the linear equation

\[ - u_x - u_t + u_{yy} = ( ( 1 - y^2 )( x + t ) - 2 ) e^{-xt}\,, \]

subject to $ u(x=0,y,t) = 1-y^2 $ $ u(x,t=0,y) = 1 - y^2 $ and $ f(x, y = \pm 1,t ) = 0 $.

 
file  IBVP_nonlinear_fast.cpp
 Solving the nonlinear problem

\[ -u u_x - u_t + u_{yy} = y^2 t^2 e^{-2x} - y e^{-x}\,, \]

subject to $ u(x=0,y,t) = ty $, $ u(x,t=0,y) = 0 $ and $ f(x, y = 0,t ) = 0 $, $ f(x, y = 1,t ) = t $.

 
file  IBVP_nonlinear_slow.cpp
 Solving the nonlinear problem

\[ -u u_x - u_t + u_{yy} = y^2 t^2 e^{-2x} - y e^{-x}\,, \]

subject to $ u(x=0,y,t) = ty $, $ u(x,t=0,y) = 0 $ and $ f(x, y = 0,t ) = 0 $, $ f(x, y = 1,t ) = t $.

 
file  EVP_complex.cpp
 Solves a 4x4 complex generalised eigenvalue problem

\[ A_{4x4} \,{\underline x}_i = \lambda_i\, B_{4x4}\, {\underline x}_i \]

for the 4 eigenvalues $ \lambda_i $, $i=1,2,3,4.$.

 
file  EVP_complex_sparse.cpp
 Solves a 4x4 complex generalised eigenvalue problem

\[ A_{4x4} \,{\underline x}_i = \lambda_i\, B_{4x4}\, {\underline x}_i \]

for the 4 eigenvalues $ \lambda_i $, $i=1,2,3,4.$.

 
file  EVP_Harmonic.cpp
 Solves the harmonic equation

\[ f''(x) + \lambda f(x) = 0 \]

as an eigenvalue problem for $ \lambda $ over the unit domain with homogeneous boundary conditions for $ f(x) $, returning any eigenvalue(s) with absolute value less than 10.

 
file  EVP_Harmonic_easy.cpp
 Solves the harmonic equation

\[ f''(x) + \lambda f(x) = 0 \]

as an eigenvalue problem for $ \lambda $ over the unit domain with homogeneous boundary conditions for $ f(x) $, returning the smallest eigenvalue.

 
file  EVP_local_Harmonic.cpp
 Solves the harmonic equation

\[ f''(x) + \lambda f(x) = 0 \]

as a LOCAL eigenvalue problem for $ \lambda $ over the unit domain with homogeneous boundary conditions for $ f(x) $ but using the nonlinear BVP solver to refine a guess at an eigenvalue.

 
file  EVP_OrrSommerfeld.cpp
 Solves the following linear eigenvalue problem for values $ c $ that satisfy :

\[ \phi''(y) - \alpha^2 \phi(y) - \psi(y) = 0\,, \]

\[ \psi''(y) - \alpha^2 \psi(y) - i \alpha Re \left \{ ( U(y) - c ) \psi(y) - U''(y) \phi \right \} = 0\,, \]

subject to $ \phi(\pm 1) = \phi'(\pm 1) = 0 $ where $ \alpha = 1.02 $, $ Re = 5772.2 $ and $ U(y) = 1 - y^2 $.

 
file  EVP_OrrSommerfeld_easy.cpp
 Solves the following linear eigenvalue problem for values $ c $ that satisfy :

\[ \phi''(y) - \alpha^2 \phi(y) - \psi(y) = 0\,, \]

\[ \psi''(y) - \alpha^2 \psi(y) - i \alpha Re \left \{ ( U(y) - c ) \psi(y) - U''(y) \phi \right \} = 0\,, \]

subject to $ \phi(\pm 1) = \phi'(\pm 1) = 0 $ where $ \alpha = 1.02 $, $ Re = 5772.2 $ and $ U(y) = 1 - y^2 $.

 
file  EVP_OrrSommerfeld_neutralcurve.cpp
 Solves the following linear eigenvalue problem for values $ c $ that satisfy :

\[ \phi''(y) - \alpha^2 \phi(y) - \psi(y) = 0\,, \]

\[ \psi''(y) - \alpha^2 \psi(y) - i \alpha Re \left \{ ( U(y) - c ) \psi(y) - U''(y) \phi \right \} = 0\,, \]

subject to $ \phi(\pm 1) = \phi'(\pm 1) = 0 $ determining the values of $ \alpha $ and $ Re $ that lead to $c_i = 0$.

 
file  EVP_OrrSommerfeld_sparse.cpp
 Solves the following linear eigenvalue problem for values $ c $ that satisfy :

\[ \phi''(y) - \alpha^2 \phi(y) - \psi(y) = 0\,, \]

\[ \psi''(y) - \alpha^2 \psi(y) - i \alpha Re \left \{ ( U(y) - c ) \psi(y) - U''(y) \phi \right \} = 0\,, \]

subject to $ \phi(\pm 1) = \phi'(\pm 1) = 0 $ where $ \alpha = 1.02 $, $ Re = 5772.2 $ and $ U(y) = 1 - y^2 $.

 
file  EVP_OrrSommerfeld.cpp
 Solves the following linear eigenvalue problem for values $ c $ that satisfy :

\[ \phi''(y) - \alpha^2 \phi(y) - \psi(y) = 0\,, \]

\[ \psi''(y) - \alpha^2 \psi(y) - i \alpha Re \left \{ ( U(y) - c ) \psi(y) - U''(y) \phi \right \} = 0\,, \]

subject to $ \phi(\pm 1) = \phi'(\pm 1) = 0 $ where $ \alpha = 1.02 $, $ Re = 5772.2 $ and $ U(y) = 1 - y^2 $.

 
file  EVP_Rayleigh.cpp
 Solves the Rayleigh problem for values $ c $ that satisfy :

\[ (U_B(y)-c) (\phi''(y) - \alpha^2 \phi(y)) - U_B''(y) \phi(y) = 0\,, \]

subject to $ \phi( 0 ) = \phi( 2\pi ) = 0 $; it determines the critical wavenumber $\alpha $ such that $ c_i=0 $ for $ U_B(y)=\sin(y) $.

 
file  EVP_real_sparse.cpp
 Solves a 2x2 generalised eigenvalue problem

\[ A_{2x2} \,{\underline x}_i = \lambda_i\, B_{2x2}\, {\underline x}_i \]

for the 2 eigenvalues $ \lambda_i $, $i=1,2.$.

 
file  EVP_Shoot_Biharmonic.cpp
 Solving a one-dimensional "Bi-harmonic" eigenvalue problem (EVP)

\[ \left ( \frac{\mbox{d}^2}{\mbox{d}x^2} - \lambda \right )^2 f(x) = 0\,, \quad \mbox{where} \quad f(0)=f(1)=f'(0)=f'(1)=0\,,\]

via Runge-Kutta and (vector) Newton iteration.

 
file  ExceptionChecks.cpp
 We do some obviously dumb things to induce a handful of common failures.
 
file  NewtonIter.cpp
 A vector Newton iteration to find a root of

\[ f(z) = z^3 - 1 \]

by splitting it into a vector equation (real & imaginary parts).

 
file  Quad.cpp
 Compute the integral

\[ \int_0^{20} \cos(x) \exp \left ( -\frac{x}{4} \right ) \mbox{d}x \]

with varying schemes, then compare the result to the exact value

\[ \frac{4 e^{-5}}{17} \left ( e^5 - \cos (20) + 4\sin (20) \right ) \]

.

 
file  TrivialComplex.cpp
 A pointless repeated computation test for timing the std::complex class.
 
file  HYP_acoustic_impedance.cpp
 Solve the constant coefficient linear sound wave problem

\[ p_t + K u_x = 0 \]

\[ \rho u_t + p_x = 0 \]

for a right-propagating square pressure pulse in a medium with constant bulk modulus $K=4$ and density $\rho = 1$ if $\vert x \vert < 1$ and $\rho = 4$ elsewhere.

 
file  HYP_acoustic_reflection.cpp
 Solve the constant coefficient linear sound wave problem

\[ p_t + K u_x = 0 \]

\[ \rho u_t + p_x = 0 \]

for a right-propagating square pulse in a medium with constant bulk modulus $K=1$ and density $\rho = 1$ and reflecting boundary conditions at both sides.

 
file  HYP_nonlinear_advection.cpp
 Solving the 1D `nonlinear advection equation'

\[ Q_t + \left ( \frac{Q^2}{2} \right )_x = 0 \quad \mbox{where} \quad Q=Q(x,t) \]

using a TVD Lax-Friedrichs scheme for $ x\in[0,1]$.

 
file  HYP_radial_dam_break.cpp
 Solve the shallow water equations in one dimension for an initial column of fluid

\[ h_t + (uh)_r = -hu/r \]

\[ (uh)_t + (hu^2 + gh^2 /2 )_r = -hu^2/r \]

The result is compared to the same problem solved using Clawpack, evaluated at the single point x=0.5.

 
file  HYP_shallow_source_NV.cpp
 Solve the shallow water equations in one dimension

\[ h_t + (uh)_x = 0 \]

\[ (uh)_t + (hu^2 + gh^2 /2 )_x = -ghz'(x) \]

where the momentum is fixed upstream, and the flow depth is fixed downstream and $ z(x) $ is the topography shape.

 
file  HYP_shallow_water_NV.cpp
 Solve the shallow water equations in one dimension for an initial (small) hump of fluid

\[ h_t + (uh)_x = 0 \]

\[ (uh)_t + (hu^2 + gh^2 /2 )_x = 0 \]

where $g=1$ and the boundaries are reflecting.

 
file  HYP_shocktube_Lax_NV.cpp
 Solving the 1D Euler problem for gas dynamics

\[ \rho_t + \left ( m \right )_x = 0 \]

\[ m_t + \left ( \rho u^2 + p \right )_x = 0 \]

\[ E_t + \left ( u ( E + p ) \right )_x = 0 \]

where

\[ u = m / \rho \]

\[ p = ( \gamma - 1 ) ( E - \frac12 \rho u^2 ) \]

and $ \gamma = 1.4 $.

 
file  HYP_shocktube_Sod.cpp
 Solving the 1D Euler problem for gas dynamics

\[ \rho_t + \left ( m \right )_x = 0 \]

\[ m_t + \left ( \rho u^2 + p \right )_x = 0 \]

\[ E_t + \left ( u ( E + p ) \right )_x = 0 \]

where

\[ u = m / \rho \]

\[ p = ( \gamma - 1 ) ( E - \frac12 \rho u^2 ) \]

and $ \gamma = 1.4 $.

 
file  HYP_2D_acoustic_NV.cpp
 A linear acoustic pulse propagating towards a cylindrical region of higher (four times) bulk modulus.
 
file  HYP_2D_Euler_NV.cpp
 Solving the Euler equations for a compressible gas with Sod-like initial conditions in a rectangular box $ [0,0.3] \times [0,0.3]$, with no-momentum flux through the walls.
 
file  HYP_2D_linear_advection_xy.cpp
 Solving the 2D advection equation

\[ Q_t + \left ( \frac{Q}{\sqrt{2}} \right )_x + \left ( \frac{Q}{\sqrt{2}} \right )_y= 0 \quad \mbox{where} \quad Q=Q(x,y,t) \]

using a TVD Lax-Friedrichs scheme for $ (x,y)\in[-1,1]\times[-1,1]$.

 
file  HYP_2D_nonlinear_advection_x.cpp
 Solving the 1D `nonlinear advection equation'

\[ Q_t + \left ( \frac{Q^2}{2} \right )_x = 0 \quad \mbox{where} \quad Q=Q(x,y,t) \]

using a TVD Lax-Friedrichs scheme for $ (x,y)\in[-1,1]\times[-1,1]$.

 
file  HYP_2D_nonlinear_advection_xy.cpp
 Solving the 2D `nonlinear advection equation'

\[ Q_t + \left ( \frac{Q^2}{\sqrt{2}} \right )_x + \left ( \frac{Q^2}{\sqrt{2}} \right )_y = 0 \quad \mbox{where} \quad Q=Q(x,y,t) \]

using a TVD Lax-Friedrichs scheme for $ (x,y)\in[-1,1]\times[-1,1]$.

 
file  HYP_2D_nonlinear_advection_y.cpp
 Solving the 1D `nonlinear advection equation'

\[ Q_t + \left ( \frac{Q^2}{2} \right )_y = 0 \quad \mbox{where} \quad Q=Q(x,y,t) \]

using a TVD Lax-Friedrichs scheme for $ (x,y)\in[-1,1]\times[-1,1]$.

 
file  HYP_2D_radial_dam_break.cpp
 A radial dam-break problem for the 2D shallow water equations.
 
file  HYP_2D_RayTay_NV.cpp
 Solving the Euler equations for a compressible gas including a buoyancy force in a rectangular box $ [-.25,.25] \times [-.75,.75]$, with no-momentum flux through the walls.
 
file  HYP_2D_shallow_source.cpp
 Two dimensional shallow water equations over topography.
 
file  IBVP_diffusion.cpp
 Solving the heat diffusion equation

\[ f_t = f_{yy} \]

subject to $ f(0) = 0 $ and $ f(1) = 0 $ with initial condition $ f(y,t=0) = y(1-y) $.

 
file  IBVP_diffusion_nonlinear.cpp
 Solving the unstead diffusion problem:

\[ U_t - U U_{yy} = -Ae^{-t} sin(\pi y) + ( (1+y) + Ae^{-t} sin(\pi y) )\pi^2 Ae^{-t} sin(\pi y)/\sigma \]

with boundary conditions $ U(y=0)=1, U(y=1)=2 $; where $ A=10 $.

 
file  IBVP_Karman.cpp
 Solving the unsteady Karman rotating-disk equations for the flow above an infinite rotating disk in a rotating fluid:

\[ -U_t + U_{yy} = U^2 + VU_y - W^2 - W_\infty^2 \]

\[ -W_t + W_{yy} = 2U W + V W_y \]

\[ 2U + V_y = 0 \]

with boundary conditions $ U(y=0)=V(y=0)=0 $, $ W(y=0)=\Omega(t) $ and $ U(y \to \infty ) \to 0 $, $ W(y \to \infty ) \to 0 $.

 
file  IBVP_nonlinear_advdiff.cpp
 Solving the nonlinear advection diffusion equation

\[ U_{yy} - Re U U_t = S( y, t ) \]

subject to $ U(y=0,t) = 1 $ and $ U(y=1,t) = 2 $ with initial condition $ U(y,t=0) = 1 + y + \epsilon y(1-y) $ and a source term

\[ S(y,t) = ( 1 + y + \epsilon y(1-y)e^{-t} ) \epsilon y(1-y ) e^{-t} - 2\epsilon e^{-t} / Re \]

for some constant parameters $\epsilon $ and $ Re $.

 
file  IVP_Harmonic.cpp
 Integrate the harmonic equation

\[ f''(y) + \lambda f(y) = 0 \]

with $\lambda=10$ from $ y = 0$ to $1$ as an IVP, using an adaptive Runge-Kutta-Fehlberg routine.

 
file  IVP_Lorenz.cpp
 Integrate the Lorenz equations

\[ \dot x = a( y - x )\,,\quad \dot y = x ( b - z ) - y\,, \quad \dot z = -c z + xy\,, \]

forward in time using an adaptive Runge-Kutta-Fehlberg routine.

 
file  1DNodeMesh.cpp
 A simple check of the OneD_Node_Mesh container that stores nodal data over a given mesh.
 
file  1DNodeMesh_Airy.cpp
 Solves the Airy equation

\[ f''(x) - xf(x) = 0 \]

on the negative real axis over the range [-10,0] then pushes the data into a OneD_GenMesh object and integrates the result.

 
file  2DNodeMesh.cpp
 A simple check of the TwoD_Node_Mesh container that stores nodal data over a given mesh.
 
file  Poisson_C.cpp
 Solving a Cartesian Poisson problem:

\[ \nabla^2 \psi(x,y) = 2( x^2 + y^2 ) \]

with

\[ \psi(x,\pm 1) = x^2\,, \quad\mbox{and}\quad \psi(\pm 1, y) = y^2 \]

where $ (x,y) \in [-1,1]\times[-1,1] $.

 
file  Poisson_m.cpp
 Solving a Poisson problem in the meridional plane of a cylinder:

\[ \nabla^2 \psi(r,z) = 2 r^2 \]

with

\[ \psi(r,\pm 1) = r^2\,, \quad\mbox{and}\quad \psi(0, z) = \psi(1,z) = 0 \]

where $ (r,z) \in [0,1]\times[-1,1] $.

 
file  Poisson_Stokes.cpp
 Solving a Poisson-like problem in the meridional plane of a cylinder for the Stokes streamfunction

\[ D^2 \psi(r,z) = 2 r^2 \]

with

\[ \psi(r,\pm 1) = r^2\,, \quad\mbox{and}\quad \psi(0, z) = \psi(1,z) = 0 \]

where $ (r,z) \in [0,1]\times[-1,1] $ and

\[ D^2 \equiv \frac{\partial^2}{\partial r^2} - \frac{1}{r}\frac{\partial}{\partial r} +\frac{\partial^2}{\partial z^2} \]

The global problem is solved (in one step) and result is compared to the exact solution

\[ \psi(r,z) = r^2z^2 \]

.

 
file  MatrixSolves.cpp
 Example of the simple linear solvers implemented for dense, banded and sparse matrix objects.
 

Detailed Description

© 2012

R.E. Hewitt