49 cout <<
"=== EVP: Harmonic equation solved using LAPACK =====\n";
50 cout <<
"=== with a manually assembled matrix problem.\n";
51 cout <<
"=== The problem is solved along a path in the complex\n";
52 cout <<
"=== plane, deformed away from the real axis.\n";
56 cout <<
" Number of nodal points : Leading eigenvalue error : Total CPU time taken (ms) \n";
64 for (
int i = 2; i < 11; ++i )
66 N = ( size_t ) ( std::pow( 2., i ) );
67 const double delta = 1. / ( N - 1 );
68 const double delta2 = delta * delta;
75 for (
unsigned j = 1; j < N-1; ++j ) {
78 a( j, j-1 ) = (1.0/pow(Example::zx(x),2.0))/delta2 + (Example::zxx(x)/pow(Example::zx(x),3.0))/(2*delta);
79 a( j, j) = -(2.0/pow(Example::zx(x),2.0))/delta2;
80 a( j, j+1 ) = (1.0/pow(Example::zx(x),2.0))/delta2 - (Example::zxx(x)/pow(Example::zx(x),3.0))/(2*delta);
86 a( N - 1, N - 1 ) = 1.0;
87 a( N - 1, N - 2 ) = 0.0;
96 }
catch (
const std::runtime_error &error ) {
97 cout <<
" \033[1;31;48m * FAILED THROUGH EXCEPTION BEING RAISED \033[0m\n";
106 cout <<
" " << N <<
" : " << lambdas[ 0 ].real() - M_PI * M_PI <<
" +i " << lambdas[0].imag()
107 <<
" : " << timer.
get_time() <<
"\n";
118 for (
unsigned j = 0; j < N; ++j ) {
120 mesh.
coord(j) = Example::z(xNodes[j]);
121 mesh(j,0) = eigenvectors(index,j+0);
124 mesh.
dump_gnu(
"/DATA/complexMesh.dat");
125 const double tol = 1.e-4;
126 if ( abs( lambdas[ 0 ].real() - M_PI * M_PI ) > tol )
131 cout <<
"\033[1;31;48m * FAILED \033[0m\n";
132 cout <<
" Final error = " << abs( lambdas[ 0 ].real() - M_PI * M_PI ) <<
"\n";
136 cout <<
"\033[1;32;48m * PASSED \033[0m\n";
A shorter bundled include file for ODE_EVP and general eigenvalue problems.
A spec for a collection of utility functions.
A linear Nth-order generalised eigensystem class.
void tag_eigenvalues_disc(const int &val, const double &radius)
Tag those eigenvalues that are within a disc centred at a point in the complex plane.
DenseVector< D_complex > get_tagged_eigenvalues() const
Get the the tagged eigenvalues.
void eigensolve()
Solve the matrix linear eigensystem.
DenseMatrix< D_complex > get_tagged_eigenvectors() const
Get the the tagged eigenvectors.
A matrix class that constructs a DENSE matrix as a row major std::vector of DenseVectors.
An DenseVector class – a dense vector object.
void set_calc_eigenvectors(bool flag)
Compute the eigenvectors in any eigenvalue computation.
A one dimensional mesh utility object.
const _Xtype & coord(const std::size_t &node) const
Access a nodal position.
void dump_gnu(std::string filename, int precision=10) const
A simple method for dumping data to a file for gnuplot.
A simple CPU-clock-tick timer for timing metods.
double get_time() const
Return the time.
void start()
Start the timer & reset stored time to zero.
void stop()
Stop the clock & add the current time interval to the previously stored values ready for printing.
const D_complex eye(0., 1.0)
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.