CppNoddy  0.92
Loading...
Searching...
No Matches
Classes | Namespaces | Enumerations | Functions
BVPKarman.cpp File Reference
#include <BVP_bundle.h>
#include "../Utils_Fill.h"

Go to the source code of this file.

Classes

class  CppNoddy::Example::Karman_equations
 Define the Karman equations. More...
 
class  CppNoddy::Example::Karman_left_BC
 Define the boundary conditions. More...
 
class  CppNoddy::Example::Karman_right_BC
 

Namespaces

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

Enumerations

enum  {
  U , Ud , V , W ,
  Wd
}
 

Functions

int main ()
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
Ud 
Wd 

Definition at line 20 of file BVPKarman.cpp.

20{U, Ud, V, W, Wd};
@ V
Definition: BVPKarman.cpp:20
@ Wd
Definition: BVPKarman.cpp:20
@ W
Definition: BVPKarman.cpp:20
@ U
Definition: BVPKarman.cpp:20
@ Ud
Definition: BVPKarman.cpp:20

Function Documentation

◆ main()

int main ( )

Definition at line 86 of file BVPKarman.cpp.

87{
88 cout << "\n";
89 cout << "=== BVP: finite-difference soln of Karman eqns ======\n";
90 cout << "\n";
91
92 Example::Karman_equations problem;
93 Example::Karman_left_BC BC_left;
94 Example::Karman_right_BC BC_right;
95
96 // Boundary layer is from 0 to 20
97 double left = 0.0;
98 double right = 20.0;
99 // number of nodal points
100 int N = 801;
101
102 DenseVector<double> nodes = Utility::uniform_node_vector( left, right, N );
103 ODE_BVP<double> ode( &problem, nodes, &BC_left, &BC_right );
104
105 // (re)set the solution to the initial guess
106 for ( int i = 0; i < N; ++i )
107 {
108 double y = ode.solution().coord( i );
109 ode.solution()( i, U ) = 0.0;
110 ode.solution()( i, Ud ) = 0.0;
111 ode.solution()( i, V ) = 0.0;
112 ode.solution()( i, W ) = exp( -y );
113 ode.solution()( i, Wd ) = -exp( -y );
114 }
115
116 try
117 {
118 ode.solve2();
119 }
120 catch (const std::runtime_error &error )
121 {
122 cout << " \033[1;31;48m * FAILED THROUGH EXCEPTION BEING RAISED \033[0m\n";
123 return 1;
124 }
125
126 // check the BL transpiration vs the known solution
127 double tol( 1.e-4 );
128 if ( abs( ode.solution()( N - 1, V ) + 0.88447 ) > tol )
129 {
130 cout << "\033[1;31;48m * FAILED \033[0m\n";
131 cout << " Difference = " << abs( ode.solution()( N - 1, V ) + 0.88447 ) << "\n";
132 return 1;
133 }
134 else
135 {
136 cout << "\033[1;32;48m * PASSED \033[0m\n";
137 return 0;
138 }
139
140}
An DenseVector class – a dense vector object.
Definition: DenseVector.h:34
A templated object for real/complex vector system of first-order ordinary differential equations.
Definition: ODE_BVP.h:37
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...
Definition: Utility.cpp:113

References CppNoddy::ODE_BVP< _Type, _Xtype >::solution(), CppNoddy::ODE_BVP< _Type, _Xtype >::solve2(), U, Ud, CppNoddy::Utility::uniform_node_vector(), V, W, and Wd.

© 2012

R.E. Hewitt