29 const double delta(0.5);
49int main(
int argc,
char *argv[] )
51 SlepcSession::getInstance(argc,argv);
54 cout <<
"=== EVP: Harmonic equation solved using LAPACK =====\n";
55 cout <<
"=== with a manually assembled matrix problem.\n";
56 cout <<
"=== The problem is solved along a path in the complex\n";
57 cout <<
"=== plane, deformed away from the real axis.\n";
61 cout <<
" Number of nodal points : Leading eigenvalue error : Total CPU time taken (ms) \n";
69 for (
int i = 2; i < 11; ++i )
71 N = ( size_t ) ( std::pow( 2., i ) );
72 const double delta = 1. / ( N - 1 );
73 const double delta2 = delta * delta;
80 for (
unsigned j = 1; j < N-1; ++j ) {
83 a( j, j-1 ) = (1.0/pow(Example::zx(x),2.0))/delta2 + (Example::zxx(x)/pow(Example::zx(x),3.0))/(2*delta);
84 a( j, j) = -(2.0/pow(Example::zx(x),2.0))/delta2;
85 a( j, j+1 ) = (1.0/pow(Example::zx(x),2.0))/delta2 - (Example::zxx(x)/pow(Example::zx(x),3.0))/(2*delta);
91 a( N - 1, N - 1 ) = 1.0;
92 a( N - 1, N - 2 ) = 0.0;
94 SparseLinearEigenSystem<D_complex> system( &a, &b );
95 system.set_calc_eigenvectors(
true );
97 system.set_order(
"EPS_TARGET_MAGNITUDE" );
103 }
catch (
const std::runtime_error &error ) {
104 cout <<
" \033[1;31;48m * FAILED THROUGH EXCEPTION BEING RAISED \033[0m\n";
108 system.tag_eigenvalues_disc( + 1, 10. );
109 lambdas = system.get_tagged_eigenvalues();
111 eigenvectors = system.get_tagged_eigenvectors();
113 cout <<
" " << N <<
" : " << lambdas[ 0 ].real() - M_PI * M_PI <<
" +i " << lambdas[0].imag()
114 <<
" : " << timer.
get_time() <<
"\n";
125 for (
unsigned j = 0; j < N; ++j ) {
127 mesh.
coord(j) = Example::z(xNodes[j]);
128 mesh(j,0) = eigenvectors(index,j+0);
131 mesh.
dump_gnu(
"/DATA/complexMesh.dat");
132 const double tol = 1.e-4;
133 if ( abs( lambdas[ 0 ].real() - M_PI * M_PI ) > tol )
138 cout <<
"\033[1;31;48m * FAILED \033[0m\n";
139 cout <<
" Final error = " << abs( lambdas[ 0 ].real() - M_PI * M_PI ) <<
"\n";
143 cout <<
"\033[1;32;48m * PASSED \033[0m\n";
A shorter bundled include file for ODE_EVP and general eigenvalue problems.
Specification of the sparse linear eigensystem class.
A spec for a collection of utility functions.
A matrix class that constructs a DENSE matrix as a row major std::vector of DenseVectors.
An DenseVector class – a dense vector object.
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 matrix class that constructs a SPARSE matrix as a row major std::vector of SparseVectors.
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.