46#ifndef MUELU_REFMAXWELL_DECL_HPP
47#define MUELU_REFMAXWELL_DECL_HPP
62#ifdef HAVE_MUELU_KOKKOS_REFACTOR
80#include "MueLu_TrilinosSmoother.hpp"
81#include "MueLu_Hierarchy.hpp"
83#include "Xpetra_Map_fwd.hpp"
84#include "Xpetra_Matrix_fwd.hpp"
85#include "Xpetra_MatrixFactory_fwd.hpp"
86#include "Xpetra_MultiVectorFactory_fwd.hpp"
87#include "Xpetra_VectorFactory_fwd.hpp"
88#include "Xpetra_CrsMatrixWrap_fwd.hpp"
90#if defined(HAVE_MUELU_IFPACK2) && (!defined(HAVE_MUELU_EPETRA))
91#define MUELU_REFMAXWELL_CAN_USE_HIPTMAIR
93#include "Ifpack2_Hiptmair.hpp"
97#if defined(HAVE_MUELU_STRATIMIKOS) && defined(HAVE_MUELU_THYRA)
98#include <Thyra_LinearOpWithSolveBase.hpp>
135#undef MUELU_REFMAXWELL_SHORT
140 typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType
magnitudeType;
154 RefMaxwell(Teuchos::RCP<Hierarchy> HH, Teuchos::RCP<Hierarchy> H22) :
175 const Teuchos::RCP<Matrix> & D0_Matrix,
176 const Teuchos::RCP<Matrix> & Ms_Matrix,
177 const Teuchos::RCP<Matrix> & M0inv_Matrix,
178 const Teuchos::RCP<Matrix> & M1_Matrix,
179 const Teuchos::RCP<MultiVector> & Nullspace,
180 const Teuchos::RCP<RealValuedMultiVector> & Coords,
181 Teuchos::ParameterList& List,
182 bool ComputePrec =
true)
184 initialize(D0_Matrix,Ms_Matrix,M0inv_Matrix,M1_Matrix,Nullspace,Coords,List);
200 const Teuchos::RCP<Matrix> & D0_Matrix,
201 const Teuchos::RCP<Matrix> & M0inv_Matrix,
202 const Teuchos::RCP<Matrix> & M1_Matrix,
203 const Teuchos::RCP<MultiVector> & Nullspace,
204 const Teuchos::RCP<RealValuedMultiVector> & Coords,
205 Teuchos::ParameterList& List,
206 bool ComputePrec =
true)
208 initialize(D0_Matrix,M1_Matrix,M0inv_Matrix,M1_Matrix,Nullspace,Coords,List);
222 const Teuchos::RCP<Matrix> & M0inv_Matrix,
223 const Teuchos::RCP<Matrix> & M1_Matrix,
224 const Teuchos::RCP<MultiVector> & Nullspace,
225 const Teuchos::RCP<RealValuedMultiVector> & Coords,
228 initialize(D0_Matrix,M1_Matrix,M0inv_Matrix,M1_Matrix,Nullspace,Coords,List);
242 const Teuchos::RCP<Matrix> & D0_Matrix,
243 const Teuchos::RCP<Matrix> & M1_Matrix,
244 const Teuchos::RCP<MultiVector> & Nullspace,
245 const Teuchos::RCP<RealValuedMultiVector> & Coords,
246 Teuchos::ParameterList& List,
249 initialize(D0_Matrix,M1_Matrix,Teuchos::null,M1_Matrix,Nullspace,Coords,List);
262 const Teuchos::RCP<Matrix> & M1_Matrix,
263 const Teuchos::RCP<MultiVector> & Nullspace,
264 const Teuchos::RCP<RealValuedMultiVector> & Coords,
267 initialize(D0_Matrix,M1_Matrix,Teuchos::null,M1_Matrix,Nullspace,Coords,List);
277 Teuchos::ParameterList& List,
278 bool ComputePrec =
true)
281 RCP<MultiVector> Nullspace = List.get<RCP<MultiVector> >(
"Nullspace", Teuchos::null);
282 RCP<RealValuedMultiVector> Coords = List.get<RCP<RealValuedMultiVector> >(
"Coordinates", Teuchos::null);
283 RCP<Matrix> D0_Matrix = List.get<RCP<Matrix> >(
"D0");
284 RCP<Matrix> Ms_Matrix;
285 if (List.isType<RCP<Matrix> >(
"Ms"))
286 Ms_Matrix = List.get<RCP<Matrix> >(
"Ms");
288 Ms_Matrix = List.get<RCP<Matrix> >(
"M1");
289 RCP<Matrix> M1_Matrix = List.get<RCP<Matrix> >(
"M1");
290 RCP<Matrix> M0inv_Matrix = List.get<RCP<Matrix> >(
"M0inv", Teuchos::null);
292 initialize(D0_Matrix,Ms_Matrix,M0inv_Matrix,M1_Matrix,Nullspace,Coords,List);
294 if (SM_Matrix != Teuchos::null)
316 void compute(
bool reuse=
false);
325 void resetMatrix(Teuchos::RCP<Matrix> SM_Matrix_new,
bool ComputePrec=
true);
330 void apply (
const MultiVector& X, MultiVector& Y,
331 Teuchos::ETransp mode = Teuchos::NO_TRANS,
332 Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
333 Scalar beta = Teuchos::ScalarTraits<Scalar>::zero())
const;
338 void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel = Teuchos::VERB_HIGH)
const;
342 const MultiVector & B,
343 MultiVector & R)
const {
344 using STS = Teuchos::ScalarTraits<Scalar>;
345 R.update(STS::one(),B,STS::zero());
346 this->
apply (X, R, Teuchos::NO_TRANS, -STS::one(), STS::one());
362 void initialize(
const Teuchos::RCP<Matrix> & D0_Matrix,
363 const Teuchos::RCP<Matrix> & Ms_Matrix,
364 const Teuchos::RCP<Matrix> & M0inv_Matrix,
365 const Teuchos::RCP<Matrix> & M1_Matrix,
366 const Teuchos::RCP<MultiVector> & Nullspace,
367 const Teuchos::RCP<RealValuedMultiVector> & Coords,
368 Teuchos::ParameterList& List);
377 void solveH(
const MultiVector& RHS, MultiVector& X)
const;
380 void solve22(
const MultiVector& RHS, MultiVector& X)
const;
386 void dump(
const Matrix& A, std::string name)
const;
389 void dump(
const MultiVector& X, std::string name)
const;
395 void dump(
const Teuchos::ArrayRCP<bool>& v, std::string name)
const;
397#ifdef HAVE_MUELU_KOKKOS_REFACTOR
410#if defined(MUELU_REFMAXWELL_CAN_USE_HIPTMAIR)
411 Teuchos::RCP<Ifpack2::Preconditioner<Scalar,LocalOrdinal,GlobalOrdinal,Node> > hiptmairPreSmoother_, hiptmairPostSmoother_;
414#if defined(HAVE_MUELU_STRATIMIKOS) && defined(HAVE_MUELU_THYRA)
415 RCP<Thyra::PreconditionerBase<Scalar> > thyraPrecH_, thyraPrec22_;
423#ifdef HAVE_MUELU_KOKKOS_REFACTOR
448 mutable Teuchos::RCP<MultiVector>
P11res_,
P11x_,
P11resSubComm_,
P11xSubComm_,
D0res_,
D0x_,
D0resSubComm_,
D0xSubComm_,
residual_,
P11resTmp_,
D0resTmp_,
D0TR11Tmp_;
454#define MUELU_REFMAXWELL_SHORT
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Static class that holds the complete list of valid MueLu parameters.
Preconditioner (wrapped as a Xpetra::Operator) for Maxwell's equations in curl-curl form.
Teuchos::RCP< MultiVector > D0xSubComm_
Teuchos::RCP< MultiVector > NullspaceH_
Nullspace for (1,1) problem.
Teuchos::RCP< MultiVector > P11resTmp_
void dumpCoords(const RealValuedMultiVector &X, std::string name) const
dump out real-valued multivector
Teuchos::ScalarTraits< Scalar >::coordinateType coordinateType
Teuchos::RCP< SmootherBase > PreSmoother_
Teuchos::RCP< MultiVector > P11x_
Teuchos::RCP< MultiVector > residual_
Teuchos::ArrayRCP< bool > BCrows_
Teuchos::RCP< Matrix > D0_Matrix_
Teuchos::RCP< const Import > D0origImporter_
Teuchos::RCP< Teuchos::ParameterList > A22_AP_reuse_data_
Teuchos::RCP< MultiVector > P11res_
Temporary memory.
RefMaxwell(const Teuchos::RCP< Matrix > &D0_Matrix, const Teuchos::RCP< Matrix > &M1_Matrix, const Teuchos::RCP< MultiVector > &Nullspace, const Teuchos::RCP< RealValuedMultiVector > &Coords, Teuchos::ParameterList &List)
Teuchos::ArrayRCP< bool > BCdomain_
Xpetra::MultiVector< coordinateType, LO, GO, NO > RealValuedMultiVector
Teuchos::RCP< RealValuedMultiVector > Coords_
Coordinates.
void formCoarseMatrix()
Compute P11^{T}*A*P11 efficiently.
Teuchos::RCP< Matrix > AH_
Teuchos::RCP< Teuchos::TimeMonitor > getTimer(std::string name, RCP< const Teuchos::Comm< int > > comm=Teuchos::null) const
get a (synced) timer
void allocateMemory(int numVectors) const
allocate multivectors for solve
Teuchos::RCP< Matrix > M0inv_Matrix_
RefMaxwell(const Teuchos::RCP< Matrix > &SM_Matrix, const Teuchos::RCP< Matrix > &D0_Matrix, const Teuchos::RCP< Matrix > &M1_Matrix, const Teuchos::RCP< MultiVector > &Nullspace, const Teuchos::RCP< RealValuedMultiVector > &Coords, Teuchos::ParameterList &List, bool ComputePrec)
Teuchos::RCP< MultiVector > D0x_
Teuchos::RCP< Matrix > SM_Matrix_
Various matrices.
Teuchos::RCP< Teuchos::ParameterList > AH_AP_reuse_data_
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::VERB_HIGH) const
void initialize(const Teuchos::RCP< Matrix > &D0_Matrix, const Teuchos::RCP< Matrix > &Ms_Matrix, const Teuchos::RCP< Matrix > &M0inv_Matrix, const Teuchos::RCP< Matrix > &M1_Matrix, const Teuchos::RCP< MultiVector > &Nullspace, const Teuchos::RCP< RealValuedMultiVector > &Coords, Teuchos::ParameterList &List)
Teuchos::RCP< Matrix > D0_T_Matrix_
Teuchos::ParameterList smootherList_
Teuchos::RCP< MultiVector > D0res_
void apply(const MultiVector &X, MultiVector &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, Scalar alpha=Teuchos::ScalarTraits< Scalar >::one(), Scalar beta=Teuchos::ScalarTraits< Scalar >::zero()) const
Teuchos::RCP< SmootherPrototype > PostSmootherData_
int BCedges_
Vectors for BCs.
Teuchos::RCP< Teuchos::ParameterList > A22_RAP_reuse_data_
bool hasTransposeApply() const
Indicates whether this operator supports applying the adjoint operator.
Teuchos::RCP< SmootherPrototype > PreSmootherData_
bool disable_addon_
Some options.
void solveH(const MultiVector &RHS, MultiVector &X) const
apply solve to 1-1 block only
Teuchos::ParameterList precList22_
Teuchos::RCP< const Import > ImporterH_
Importer to coarse (1,1) hierarchy.
RefMaxwell(const Teuchos::RCP< Matrix > &SM_Matrix, const Teuchos::RCP< Matrix > &D0_Matrix, const Teuchos::RCP< Matrix > &M0inv_Matrix, const Teuchos::RCP< Matrix > &M1_Matrix, const Teuchos::RCP< MultiVector > &Nullspace, const Teuchos::RCP< RealValuedMultiVector > &Coords, Teuchos::ParameterList &List, bool ComputePrec=true)
Teuchos::RCP< Matrix > A22_
Teuchos::RCP< Matrix > R11_
Teuchos::ScalarTraits< Scalar >::magnitudeType magnitudeType
const Teuchos::RCP< Matrix > & getJacobian() const
Returns Jacobian matrix SM.
Teuchos::RCP< const Import > Importer22_
void buildProlongator()
Setup the prolongator for the (1,1)-block.
Teuchos::RCP< Teuchos::ParameterList > AH_RAP_reuse_data_
Teuchos::RCP< Matrix > A_nodal_Matrix_
Teuchos::RCP< Matrix > P11_
RefMaxwell(Teuchos::RCP< Hierarchy > HH, Teuchos::RCP< Hierarchy > H22)
Constructor with Hierarchies.
virtual ~RefMaxwell()
Destructor.
bool use_as_preconditioner_
Teuchos::ArrayRCP< bool > BCcols_
Teuchos::RCP< MultiVector > P11resSubComm_
Teuchos::RCP< MultiVector > P11xSubComm_
Teuchos::RCP< Hierarchy > Hierarchy22_
Teuchos::RCP< SmootherBase > PostSmoother_
Teuchos::RCP< MultiVector > D0resTmp_
Teuchos::RCP< Matrix > Addon_Matrix_
Teuchos::RCP< Matrix > M1_Matrix_
void setFineLevelSmoother()
Set the fine level smoother.
Teuchos::RCP< MultiVector > D0TR11Tmp_
void applyInverseAdditive(const MultiVector &RHS, MultiVector &X) const
apply additive algorithm for 2x2 solve
bool fuseProlongationAndUpdate_
RefMaxwell(const Teuchos::RCP< Matrix > &SM_Matrix, Teuchos::ParameterList &List, bool ComputePrec=true)
RefMaxwell(const Teuchos::RCP< Matrix > &D0_Matrix, const Teuchos::RCP< Matrix > &M0inv_Matrix, const Teuchos::RCP< Matrix > &M1_Matrix, const Teuchos::RCP< MultiVector > &Nullspace, const Teuchos::RCP< RealValuedMultiVector > &Coords, Teuchos::ParameterList &List)
Teuchos::RCP< const Map > getRangeMap() const
Returns the Xpetra::Map object associated with the range of this operator.
Teuchos::RCP< RealValuedMultiVector > CoordsH_
void compute(bool reuse=false)
Setup the preconditioner.
Teuchos::RCP< Hierarchy > HierarchyH_
Two hierarchies: one for the coarse (1,1)-block, another for the (2,2)-block.
Teuchos::ParameterList precList11_
Teuchos::RCP< Matrix > Ms_Matrix_
RefMaxwell(const Teuchos::RCP< Matrix > &SM_Matrix, const Teuchos::RCP< Matrix > &D0_Matrix, const Teuchos::RCP< Matrix > &Ms_Matrix, const Teuchos::RCP< Matrix > &M0inv_Matrix, const Teuchos::RCP< Matrix > &M1_Matrix, const Teuchos::RCP< MultiVector > &Nullspace, const Teuchos::RCP< RealValuedMultiVector > &Coords, Teuchos::ParameterList &List, bool ComputePrec=true)
Teuchos::ParameterList parameterList_
Parameter lists.
Teuchos::RCP< MultiVector > D0resSubComm_
bool useHiptmairSmoothing_
void resetMatrix(Teuchos::RCP< Matrix > SM_Matrix_new, bool ComputePrec=true)
Reset system matrix.
void setParameters(Teuchos::ParameterList &list)
Set parameters.
Teuchos::RCP< MultiVector > Nullspace_
Nullspace.
bool D0_T_R11_colMapsMatch_
void dump(const Matrix &A, std::string name) const
dump out matrix
void solve22(const MultiVector &RHS, MultiVector &X) const
apply solve to 2-2 block only
Teuchos::RCP< const Map > D0origDomainMap_
Teuchos::RCP< const Map > getDomainMap() const
Returns the Xpetra::Map object associated with the domain of this operator.
void residual(const MultiVector &X, const MultiVector &B, MultiVector &R) const
Compute a residual R = B - (*this) * X.
Verbose class for MueLu classes.
Namespace for MueLu classes and methods.