CppNoddy  0.92
Loading...
Searching...
No Matches
EVPRayleigh_lapack.cpp
Go to the documentation of this file.
1/// \file EVPRayleigh_lapack.cpp
2/// \ingroup Tests
3/// \ingroup EVP
4/// Solves the Rayleigh problem for values \f$ c \f$
5/// that satisfy :
6/// \f[ (U_B(y)-c) (\phi''(y) - \alpha^2 \phi(y)) - U_B''(y) \phi(y) = 0\,, \f]
7/// subject to \f$ \phi( 0 ) = \phi( 2\pi ) = 0 \f$; it determines the
8/// critical wavenumber \f$\alpha \f$ such that \f$ c_i=0 \f$ for \f$ U_B(y)=\sin(y) \f$.
9/// The test compares the critical wavenumber with the predicted value of \f$ \sqrt(3)/2 \f$.
10
11#include <EVP_bundle.h>
12#include <HST.h>
13
14namespace CppNoddy
15{
16 namespace Example
17 {
18 // complex base flow in complex plane
20 // Rayleigh wavenumber
21 double alpha;
22 // base flow profile
23 D_complex U( const D_complex& y )
24 {
25 return std::sin( y );
26 }
27 // curvature of the baseflow
29 {
30 return - std::sin( y );
31 }
32 }
33}
34
35using namespace CppNoddy;
36using namespace std;
37
38int main()
39{
40
41 cout << "\n";
42 cout << "=== EVP: Rayleigh modes, Tollmien's example =========\n";
43 cout << "\n";
44
45 Example::alpha = 0.8; // the wavenumber
46 double tol = 1.e-5; // tolerance for the test
47 double left = 0.0; // from y = 0
48 double right = 2 * M_PI; // to y= 2*pi
49 unsigned N( 801 );
50 // a real distribution of nodes
51 DenseVector<double> r_nodes( Utility::power_node_vector( left, right, N, 1.0 ) );
52 DenseVector<D_complex> c_nodes( r_nodes );
53 // make a distribution of nodes in the complex plane
54 for ( unsigned i = 0; i < N; ++i )
55 {
56 D_complex y( r_nodes[ i ] );
57 c_nodes[ i ] -= .2 * D_complex( 0.0, 1.0 ) * y * std::exp( - y );
58 }
59
60 // make a base flow on the complex distribution of nodes
61 OneD_Node_Mesh<D_complex, D_complex> base( c_nodes, 2 );
62 for ( unsigned i = 0; i < c_nodes.size(); ++i )
63 {
64 D_complex y = c_nodes[ i ];
65 base( i, 0 ) = Example::U( y );
66 base( i, 1 ) = Example::Udd( y );
67 }
68
69 // make the Rayleigh EVP, with 'CHANNEL' boundary conditions
70 HST::Rayleigh<D_complex> my_ray( base, Example::alpha, "CHANNEL" );
71 // do a global solve
72 my_ray.global_evp();
73
74 unsigned i_ev = 0;
75 for ( unsigned i = 0; i < my_ray.eigenvalues().size(); ++i )
76 {
77 if ( my_ray.eigenvalues()[ i ].imag() > 0.05 )
78 {
79 // there should be only one
80 i_ev = i;
81 }
82 }
83
84 my_ray.iterate_to_neutral( i_ev );
85
86 if ( std::abs( my_ray.alpha() - .5*sqrt( 3. ) ) < tol )
87 {
88 cout << "\033[1;32;48m * PASSED \033[0m\n";
89 return 0;
90 }
91 cout << "\033[1;31;48m * FAILED \033[0m\n";
92 cout << " Final error in critical wavenumber = " << std::abs( my_ray.alpha() - .5*sqrt( 3. ) ) << "\n";
93 return 1;
94
95}
@ U
Definition: BVPKarman.cpp:20
int main()
A shorter bundled include file for ODE_EVP and general eigenvalue problems.
Some classes useful for hydrodynamic stability theory problems.
An DenseVector class – a dense vector object.
Definition: DenseVector.h:34
std::size_t size() const
A pass-thru definition to get the size of the vector.
Definition: DenseVector.h:330
void iterate_to_neutral(std::size_t i_ev)
Iterate on the wavenumber ALPHA, using the local_evp routine, to drive a selected eigenvalue to be ne...
DenseVector< std::complex< double > > & eigenvalues()
A handle to the eigenvalues vector.
Definition: HST.h:134
void global_evp()
Solve the global eigenvalue problem for the Rayleigh equation by employing a second-order finite-diff...
double & alpha()
A handle to the wavenumber.
Definition: HST.h:140
A one dimensional mesh utility object.
double Udd(double y)
Globally define the base flow curvature.
OneD_Node_Mesh< D_complex, D_complex > baseflow
DenseVector< double > power_node_vector(const double &lower, const double &upper, const std::size_t &N, const double &power)
Return a DENSE vector with the nodal points of a non-uniform mesh distributed between the upper/lower...
Definition: Utility.cpp:123
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.
Definition: Types.h:98

© 2012

R.E. Hewitt