CppNoddy  0.92
Loading...
Searching...
No Matches
Classes | Namespaces | Functions
BlasiusShooting.cpp File Reference

Solving the Blasius equation. More...

#include <IVP_bundle.h>
#include "../Utils_Fill.h"

Go to the source code of this file.

Classes

class  CppNoddy::Example::Blasius_equation
 Define the Blasius equation by inheriting Equation base class. More...
 
class  CppNoddy::Example::Blasius_residual
 Define a residual function using the boundary conditions for the Blasius profile. More...
 

Namespaces

namespace  CppNoddy
 A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechanics.
 
namespace  CppNoddy::Example
 

Functions

int main ()
 

Detailed Description

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.

Solving a BVP via local methods such as these is generally not a great way of doing things. Actually, in this case the BVP can formally be converted to an IVP and iteration can be avoided altogether. Here we check the iteration plus IVP approach by comparing it with the Cauchy problem formulation.

Definition in file BlasiusShooting.cpp.

Function Documentation

◆ main()

int main ( )

Definition at line 92 of file BlasiusShooting.cpp.

93{
94 cout << "\n";
95 cout << "=== BVP_Shoot: scalar Newton solution of Blasius ====\n";
96 cout << "\n";
97
98 Example::Blasius_residual problem;
99 // instantiate a scalar Newton class for the one Blasius residual
100 Newton<double> Blasius( &problem );
101
102 DenseVector<double> stress( 1, 0.0 );
103 stress[ 0 ] = 1.0;
104 try
105 {
106 Blasius.iterate( stress );
107 }
108 catch (const std::runtime_error &error )
109 {
110 cout << " \033[1;31;48m * FAILED THROUGH EXCEPTION BEING RAISED \033[0m\n";
111 return 1;
112 }
113
114 // output the data
115 std::string dirname("./DATA");
116 mkdir( dirname.c_str(), S_IRWXU );
117 TrackerFile my_file( "./DATA/Blasius.dat" );
118 my_file.push_ptr( &( problem.ode -> get_mesh() ) );
119 my_file.update();
120
121 // There is a rescaling that removes any need to iterate
122 // c = f'(infty) when stress = 1 at the plate
123 const double c = 1.65519036023e0;
124 const double answer = 1. / pow( c, 3. / 2. );
125
126 const double tol( 1.e-6 ); // A pass/fail tolerance
127 if ( abs( stress[0] - answer ) > tol )
128 {
129 cout << "\033[1;31;48m * FAILED \033[0m\n";
130 cout.precision( 14 );
131 cout << abs( stress[0] - answer ) << " > " << tol << "\n";
132 return 1;
133 }
134 else
135 {
136 cout << "\033[1;32;48m * PASSED \033[0m\n";
137 return 0;
138 }
139}
An DenseVector class – a dense vector object.
Definition: DenseVector.h:34
A vector NEWTON iteration class.
Definition: Newton.h:25

References CppNoddy::Newton< _Type >::iterate(), CppNoddy::Example::Blasius_residual::ode, CppNoddy::TrackerFile::push_ptr(), and CppNoddy::TrackerFile::update().

© 2012

R.E. Hewitt