24int main(
int argc,
char* argv[])
26 SlepcSession::getInstance(argc,argv);
29 cout <<
"=== EVP: Temporal spectra of the Orr-Sommerfeld eqn =\n";
30 cout <<
"=== with a matrix problem assembled by hand and \n";
31 cout <<
"=== eigenproblem solved with SLEPc sparse solver.\n";
35 const std::size_t nodes( 1001 );
37 const std::size_t N( 2 * nodes );
39 const double left = -1.0;
40 const double right = 1.0;
42 const double d = ( right - left ) / ( nodes - 1 );
49 const double alpha ( 1.02 );
50 const double Re ( 5772.2 );
59 for ( std::size_t i = 1; i <= nodes - 2; ++i )
62 const double y = left + i * d;
64 const double U = ( 1.0 - y * y );
65 const double Udd = -2.0;
68 std::size_t row = 2 * i;
69 a( row, row ) = -2.0 / ( d * d ) - alpha * alpha;
70 a( row, row - 2 ) = 1.0 / ( d * d );
71 a( row, row + 2 ) = 1.0 / ( d * d );
72 a( row, row + 1 ) = -1.0;
76 a( row, row ) = -2.0 / ( d * d ) - alpha * alpha - I * alpha * Re *
U;
77 a( row, row - 2 ) = 1.0 / ( d * d );
78 a( row, row + 2 ) = 1.0 / ( d * d );
79 a( row, row - 1 ) = I * alpha * Re * Udd;
81 b( row, row ) = - I * alpha * Re;
84 a( N - 2, N - 2 ) = 1.5 / d;
85 a( N - 2, N - 4 ) = -2.0 / d;
86 a( N - 2, N - 6 ) = 0.5 / d;
87 a( N - 1, N - 2 ) = 1.0;
95 SparseLinearEigenSystem<D_complex> system( &a, &b );
98 system.set_order(
"EPS_TARGET_MAGNITUDE" );
104 catch (
const std::runtime_error &error )
106 cout <<
" \033[1;31;48m * FAILED THROUGH EXCEPTION BEING RAISED \033[0m\n";
110 system.set_shift(
D_complex( 0.0, -0.1 ) );
111 system.tag_eigenvalues_upper( + 1 );
112 lambdas = system.get_tagged_eigenvalues();
114 double min_growth_rate( lambdas[ 0 ].imag() );
116 const double tol = 1.e-3;
118 std::string dirname(
"./DATA");
119 mkdir( dirname.c_str(), S_IRWXU );
122 spectrum.
push_ptr( &lambdas,
"evs" );
127 eigenvectors = system.get_tagged_eigenvectors();
131 if ( lambdas.
nelts() > 0 ) {
133 for (
unsigned i = 0; i < nodes; ++i ) {
134 mesh(i,0) = eigenvectors(index,2*i+0);
135 mesh(i,1) = eigenvectors(index,2*i+1);
137 for (
unsigned i = 1; i < nodes-1; ++i ) {
138 mesh(i,2) = (mesh(i+1,0)-mesh(i-1,0))/(2*d);
139 mesh(i,3) = -I*alpha*mesh(i,0);
143 mesh.
dump_gnu(
"./DATA/eigenmode.dat");
145 if ( std::abs( min_growth_rate ) < tol )
147 cout <<
"\033[1;32;48m * PASSED \033[0m\n";
151 cout <<
"\033[1;31;48m * FAILED \033[0m\n";
152 cout <<
" Final error = " << min_growth_rate <<
"\n";
A shorter bundled include file for ODE_BVP and PDE_IBVP codes.
Specification of the sparse linear eigensystem class.
A matrix class that constructs a DENSE matrix as a row major std::vector of DenseVectors.
An DenseVector class – a dense vector object.
std::size_t nelts() const
Get the number of elements in the vector Since the vector is dense, the number of elements is the siz...
void dump() const
Dump to std::cout.
A one dimensional mesh utility object.
void normalise(const std::size_t &var)
Normalise all data in the mesh based on one variable.
void dump_gnu(std::string filename, int precision=10) const
A simple method for dumping data to a file for gnuplot.
A matrix class that constructs a SPARSE matrix as a row major std::vector of SparseVectors.
void push_ptr(double *scalar, std::string desc="")
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.