1#ifndef DUNE_PDELAB_BACKEND_ISTL_GENEO_GENEOBASIS_HH
2#define DUNE_PDELAB_BACKEND_ISTL_GENEO_GENEOBASIS_HH
7#include <dune/pdelab/backend/istl/geneo/subdomainbasis.hh>
8#include <dune/pdelab/backend/istl/geneo/arpackpp_geneo.hh>
21 template<
class GFS,
class M,
class X,
int dim>
22 class GenEOBasis :
public SubdomainBasis<X>
24 typedef Dune::PDELab::Backend::Native<M> ISTLM;
25 typedef Dune::PDELab::Backend::Native<X> ISTLX;
42 GenEOBasis(
const GFS& gfs,
const M& AF_exterior,
const M& AF_ovlp,
const double eigenvalue_threshold, X& part_unity,
43 int& nev,
int nev_arpack = -1,
double shift = 0.001,
bool add_part_unity =
false,
int verbose = 0) {
44 using Dune::PDELab::Backend::native;
53 for (
auto row_iter = native(ovlp_mat).begin(); row_iter != native(ovlp_mat).end(); row_iter++) {
54 for (
auto col_iter = row_iter->begin(); col_iter != row_iter->end(); col_iter++) {
55 *col_iter *= native(part_unity)[row_iter.index()] * native(part_unity)[col_iter.index()];
60 ArpackGeneo::ArPackPlusPlus_Algorithms<ISTLM, X> arpack(native(AF_exterior));
63 std::vector<double> eigenvalues(nev_arpack,0.0);
64 std::vector<X> eigenvectors(nev_arpack,X(gfs,0.0));
66 arpack.computeGenNonSymMinMagnitude(native(ovlp_mat), eps, eigenvectors, eigenvalues, shift);
70 if (eigenvalue_threshold >= 0) {
71 for (
int i = 0; i < nev; i++) {
72 if (eigenvalues[i] > eigenvalue_threshold) {
78 std::cout <<
"Process " << gfs.gridView().comm().rank() <<
" picked " << cnt <<
" eigenvectors" << std::endl;
86 this->local_basis.resize(cnt);
87 for (
int base_id = 0; base_id < cnt; base_id++) {
88 this->local_basis[base_id] = std::make_shared<X>(part_unity);
91 this->local_basis[base_id]->begin(),this->local_basis[base_id]->end(),
92 eigenvectors[base_id].begin(),
93 this->local_basis[base_id]->begin(),
99 for (
auto& v : this->local_basis) {
100 *v *= 1.0 / v->two_norm2();
105 if (add_part_unity && eigenvalues[0] > 1E-10) {
106 this->local_basis.insert (this->local_basis.begin(), std::make_shared<X>(part_unity));
107 this->local_basis.pop_back();
Base class for Dune-Exceptions.
Definition: exceptions.hh:94
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
auto max(ADLTag< 0 >, const V &v1, const V &v2)
implements binary Simd::max()
Definition: defaults.hh:79
Dune namespace.
Definition: alignedallocator.hh:14