1#ifndef DUNE_PDELAB_BACKEND_ISTL_GENEO_LIPTONBABUSKABASIS_HH
2#define DUNE_PDELAB_BACKEND_ISTL_GENEO_LIPTONBABUSKABASIS_HH
7#include <dune/pdelab/backend/istl/geneo/subdomainbasis.hh>
8#include <dune/pdelab/backend/istl/geneo/arpackpp_geneo.hh>
19 template<
class GFS,
class M,
class X,
class Y,
int dim>
20 class LiptonBabuskaBasis :
public SubdomainBasis<X>
22 typedef Dune::PDELab::Backend::Native<M> ISTLM;
23 typedef Dune::PDELab::Backend::Native<X> ISTLX;
26 LiptonBabuskaBasis(
const GFS& gfs,
const M& AF_exterior,
const M& AF_ovlp,
const double eigenvalue_threshold, X& part_unity,
27 int& nev,
int nev_arpack,
double shift = 0.001,
bool add_part_unity =
false,
int verbose = 0) {
28 using Dune::PDELab::Backend::native;
35 auto AF_interior = AF_exterior;
36 native(AF_interior) -= native(AF_ovlp);
38 ArpackGeneo::ArPackPlusPlus_Algorithms<ISTLM, X> arpack(native(AF_exterior));
41 std::vector<double> eigenvalues(nev_arpack,0.0);
42 std::vector<X> eigenvectors(nev_arpack,X(gfs,0.0));
44 arpack.computeGenNonSymMinMagnitude(native(AF_interior), eps, eigenvectors, eigenvalues, shift);
48 if (eigenvalue_threshold >= 0) {
49 for (
int i = 0; i < nev; i++) {
50 if (eigenvalues[i] > eigenvalue_threshold) {
56 std::cout <<
"Process " << gfs.gridView().comm().rank() <<
" picked " << cnt <<
" eigenvectors" << std::endl;
63 this->local_basis.resize(cnt);
65 for (
int base_id = 0; base_id < cnt; base_id++) {
66 this->local_basis[base_id] = std::make_shared<X>(part_unity);
69 this->local_basis[base_id]->begin(),this->local_basis[base_id]->end(),
70 eigenvectors[base_id].begin(),
71 this->local_basis[base_id]->begin(),
77 for (
auto& v : this->local_basis) {
78 *v *= 1.0 / v->two_norm2();
81 if (add_part_unity && eigenvalues[0] > 1E-10) {
82 this->local_basis.insert (this->local_basis.begin(), std::make_shared<X>(part_unity));
83 this->local_basis.pop_back();
Base class for Dune-Exceptions.
Definition: exceptions.hh:96
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
constexpr auto max
Function object that returns the greater of the given values.
Definition: hybridutilities.hh:484
Dune namespace.
Definition: alignedallocator.hh:13