4#include "conbase_fork.hh"
6#include "neumann_boundary_condition.hh"
8#include "two_level_schwarz.hh"
10#include "subdomainprojectedcoarsespace.hh"
12#include "partitionofunity.hh"
13#include "localoperator_ovlp_region.hh"
15#include "geneobasis.hh"
16#include "liptonbabuskabasis.hh"
17#include "partitionofunitybasis.hh"
23 template<
class V,
class GFS,
class GO,
class LOP,
class CON,
class MBE>
25 public PDELab::OVLPScalarProductImplementation<GFS>,
26 public PDELab::LinearResultStorage
33 CG_GenEO(V& x0_,
const GFS& gfs_, LOP& lop_, CON& constraints_, MBE& mbe_, Composites::SolverInfo & si_, Dune::MPIHelper& helper_,
int cells_) :
34 PDELab::OVLPScalarProductImplementation<GFS>(gfs_),
38 constraints(constraints_),
46 typedef typename GFS::template ConstraintsContainer<double>::Type C;
48 C cg_ext; cg_ext.clear();
50 Dune::PDELab::constraints(constraints,gfs,cg);
52 std::vector<double> times;
58 Dune::PDELab::constraints_exterior(constraints,gfs,cg_ext);
59 auto cc_bnd_neu_int_dir = C();
61 cc_bnd_neu_int_dir.clear();
62 Dune::PDELab::constraints(pnbc,gfs,cc_bnd_neu_int_dir);
65 typedef typename GO::Jacobian J;
68 GO go(gfs,cg,gfs,cg,lop,mbe);
74 GO go_neu(gfs,cg_ext,gfs,cg_ext,lop,mbe);
77 go_neu.jacobian(x0,AF_neu);
80 typedef Dune::PDELab::LocalOperatorOvlpRegion<LOP, GFS> LOP_ovlp;
81 LOP_ovlp lop_ovlp(lop,gfs);
82 typedef Dune::PDELab::GridOperator<GFS,GFS,LOP_ovlp,MBE,RF,RF,RF,C,C> GO_ovlp;
83 GO_ovlp go_ovlp(gfs,cg_ext,gfs,cg_ext,lop_ovlp,mbe);
84 typedef typename GO_ovlp::Jacobian J2;
87 go_ovlp.jacobian(x0,AF_ovlp);
90 typedef Dune::PDELab::OverlappingOperator<C,J,V,V> POP;
92 typedef Dune::PDELab::istl::ParallelHelper<GFS> PIH;
94 typedef Dune::PDELab::OverlappingScalarProduct<GFS,V> OSP;
99 auto gv = gfs.gridView();
101 double eigenvalue_threshold = solver_info.eigenvalue_threshold*(double)solver_info.overlap/(cells+solver_info.overlap);
102 if(helper.rank() == 0) std::cout <<
"Eigenvalue threshhold: " << eigenvalue_threshold << std::endl;
105 typedef Dune::PDELab::LocalFunctionSpace<GFS, Dune::PDELab::AnySpaceTag> LFSU;
106 typedef typename LFSU::template Child<0>::Type LFS;
108 LFS lfs = lfsu.template child<0>();
114 std::shared_ptr<V> part_unity;
115 if (solver_info.widlund_part_unity ==
false)
116 part_unity = sarkisPartitionOfUnity<3,V>(gfs, lfs, cc_bnd_neu_int_dir);
118 part_unity = standardPartitionOfUnity<3,V>(gfs, lfs, cc_bnd_neu_int_dir);
124 Dune::PDELab::set_constrained_dofs(cg_ext,0.0,dummy);
126 int nev = solver_info.nev;
128 std::shared_ptr<SubdomainBasis<V> > subdomain_basis;
131 subdomain_basis = std::make_shared<GenEOBasis<GFS,J,V,V,Composites::SolverInfo,3> >(gfs, AF_neu, AF_ovlp, eigenvalue_threshold, *part_unity, solver_info);
133 subdomain_basis = std::make_shared<ZEMBasis<GFS,LFS,V,3,3> >(gfs, lfs, *part_unity);
137 subdomain_basis = std::make_shared<PartitionOfUnityBasis<V> >(*part_unity);
141 auto partunityspace = std::make_shared<SubdomainProjectedCoarseSpace<GFS,J,V,V,3> >(gfs, AF_neu, subdomain_basis, verb);
144 typedef TwoLevelOverlappingAdditiveSchwarzDC<GFS,J,V,V> PREC_DC;
146 std::shared_ptr<PREC_DC> prec;
150 prec = std::make_shared<PREC_DC>(gfs, AF, partunityspace,solver_info.coarseSpaceActive);
152 MPI_Barrier(gfs.gridView().comm());
153 if(helper.rank()==0) std::cout <<
"Geneo setup time " << watch.elapsed() << std::endl;
154 times.push_back(watch.elapsed());
165 std::shared_ptr<CGSolverFork<V>> solver;
166 solver = std::make_shared<CGSolverFork<V> >(popf,ospf,*prec,solver_info.KrylovTol,solver_info.MaxIt,solver_info.verb,
true);
167 Dune::InverseOperatorResult result;
168 solver->apply(v,d,result);
170 times.push_back(watch.elapsed());
174 solver_info.setTimes(times);
175 solver_info.recordResult(result);
178 std::cout <<
"Solver not available . . . Please install UMFPACK as part of SuiteSparse" << std::endl;
184 template<
class M,
class V2,
class W>
185 void apply(M& A, V2& z, W& r,
typename Dune::template FieldTraits<typename V2::ElementType >::real_type reduction)
187 this->apply(z,r,reduction);
194 const CON& constraints;
196 Composites::SolverInfo& solver_info;
197 Dune::MPIHelper& helper;
Definition: neumann_boundary_condition.hh:13