MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_MultiPhys_decl.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// MueLu: A package for multigrid based preconditioning
4//
5// Copyright 2012 NTESS and the MueLu contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef MUELU_MULTIPHYS_DECL_HPP
11#define MUELU_MULTIPHYS_DECL_HPP
12
13#include "MueLu_ConfigDefs.hpp"
14#include "MueLu_BaseClass.hpp"
15
17
19#include "MueLu_TrilinosSmoother.hpp"
21#include "MueLu_Level_fwd.hpp"
26
27#include "Xpetra_Map_fwd.hpp"
28#include "Xpetra_Matrix_fwd.hpp"
29#include "Xpetra_MatrixFactory_fwd.hpp"
30#include "Xpetra_MultiVectorFactory_fwd.hpp"
31#include "Xpetra_VectorFactory_fwd.hpp"
32#include "Xpetra_CrsMatrixWrap_fwd.hpp"
33
34namespace MueLu {
35
42template <class Scalar,
43 class LocalOrdinal,
44 class GlobalOrdinal,
45 class Node>
46class MultiPhys : public VerboseObject, public Xpetra::Operator<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
47#undef MUELU_MULTIPHYS_SHORT
49
50 public:
51 typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType magnitudeType;
52 typedef typename Teuchos::ScalarTraits<Scalar>::coordinateType coordinateType;
53 typedef typename Xpetra::MultiVector<coordinateType, LO, GO, NO> RealValuedMultiVector;
54
59 , nBlks_(0) {
60 }
61
72 MultiPhys(const Teuchos::RCP<Matrix>& AmatMultiPhysics,
73 const Teuchos::ArrayRCP<RCP<Matrix>> arrayOfAuxMatrices,
74 const Teuchos::ArrayRCP<Teuchos::RCP<MultiVector>> arrayOfNullspaces,
75 const Teuchos::ArrayRCP<Teuchos::RCP<RealValuedMultiVector>> arrayOfCoords,
76 const int nBlks,
77 Teuchos::ParameterList& List,
78 bool ComputePrec = true)
79 : AmatMultiphysics_(AmatMultiPhysics)
80 , arrayOfAuxMatrices_(arrayOfAuxMatrices)
81 , arrayOfNullspaces_(arrayOfNullspaces)
82 , arrayOfCoords_(arrayOfCoords)
83 , nBlks_(nBlks) {
84 initialize(AmatMultiPhysics, arrayOfAuxMatrices, arrayOfNullspaces, arrayOfCoords, nBlks, List);
85 compute(false);
86 }
87
89 virtual ~MultiPhys() {}
90
92 const Teuchos::RCP<const Map> getDomainMap() const;
93
95 const Teuchos::RCP<const Map> getRangeMap() const;
96
98 void setParameters(Teuchos::ParameterList& list);
99
101 void compute(bool reuse = false);
102
104 void resetMatrix(Teuchos::RCP<Matrix> SM_Matrix_new, bool ComputePrec = true);
105
109 void apply(const MultiVector& X, MultiVector& Y,
110 Teuchos::ETransp mode = Teuchos::NO_TRANS,
111 Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
112 Scalar beta = Teuchos::ScalarTraits<Scalar>::zero()) const;
113
115 bool hasTransposeApply() const;
116
117 void describe(Teuchos::FancyOStream& out, const Teuchos::EVerbosityLevel verbLevel = Teuchos::VERB_HIGH) const;
118
120 void residual(const MultiVector& X,
121 const MultiVector& B,
122 MultiVector& R) const {
123 using STS = Teuchos::ScalarTraits<Scalar>;
124 R.update(STS::one(), B, STS::zero());
125 this->apply(X, R, Teuchos::NO_TRANS, -STS::one(), STS::one());
126 }
127
128 private:
138 void initialize(const Teuchos::RCP<Matrix>& AmatMultiPhysics,
139 const Teuchos::ArrayRCP<RCP<Matrix>> arrayOfAuxMatrices,
140 const Teuchos::ArrayRCP<Teuchos::RCP<MultiVector>> arrayOfNullspaces,
141 const Teuchos::ArrayRCP<Teuchos::RCP<RealValuedMultiVector>> arrayOfCoords,
142 const int nBlks,
143 Teuchos::ParameterList& List);
144
146 void applyInverse(const MultiVector& RHS, MultiVector& X) const;
147
149 void allocateMemory(int numVectors) const;
150
152 Teuchos::RCP<Teuchos::TimeMonitor> getTimer(std::string name, RCP<const Teuchos::Comm<int>> comm = Teuchos::null) const;
153
155 mutable Teuchos::ParameterList parameterList_;
156
158
159 Teuchos::RCP<Matrix> AmatMultiphysics_; // multiphysics discretization matrix
160 Teuchos::RCP<Teuchos::ParameterList> paramListMultiphysics_; // array of parameter lists directing MueLu's construct of subblock P operators
161 Teuchos::RCP<Hierarchy> hierarchyMultiphysics_; // multiphysics discretization matrix
162
163 Teuchos::ArrayRCP<Teuchos::RCP<Teuchos::ParameterList>> arrayOfParamLists_; // array of parameter lists directing MueLu's construct of subblock P operators
164 Teuchos::ArrayRCP<Teuchos::RCP<Hierarchy>> arrayOfHierarchies_;
165 Teuchos::ArrayRCP<Teuchos::RCP<Matrix>> arrayOfAuxMatrices_; // array of discretization/auxiliary matrices used to generate subblock prolongators
166 Teuchos::ArrayRCP<Teuchos::RCP<MultiVector>> arrayOfNullspaces_; // array of nullspaces for smoothed aggregation.
167 Teuchos::ArrayRCP<Teuchos::RCP<RealValuedMultiVector>> arrayOfCoords_; // array of coordinates for smoothed aggregation/rebalancing.
168
169 int nBlks_; // number of PDE sub-systems within multiphysics system
171};
172
173} // namespace MueLu
174
175#define MUELU_MULTIPHYS_SHORT
176#endif // MUELU_MULTIPHYS_DECL_HPP
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
MueLu::DefaultNode Node
Teuchos::RCP< Hierarchy > hierarchyMultiphysics_
const Teuchos::RCP< const Map > getRangeMap() const
Returns the Xpetra::Map object associated with the range of this operator.
Teuchos::ArrayRCP< Teuchos::RCP< MultiVector > > arrayOfNullspaces_
Teuchos::RCP< Teuchos::TimeMonitor > getTimer(std::string name, RCP< const Teuchos::Comm< int > > comm=Teuchos::null) const
get a (synced) timer
Teuchos::ArrayRCP< Teuchos::RCP< Matrix > > arrayOfAuxMatrices_
void compute(bool reuse=false)
Setup the preconditioner.
Teuchos::ScalarTraits< Scalar >::magnitudeType magnitudeType
Teuchos::ParameterList parameterList_
ParameterLists.
void residual(const MultiVector &X, const MultiVector &B, MultiVector &R) const
Compute a residual R = B - (*this) * X.
void allocateMemory(int numVectors) const
allocate multivectors for solve
Teuchos::ScalarTraits< Scalar >::coordinateType coordinateType
void applyInverse(const MultiVector &RHS, MultiVector &X) const
apply standard MultiPhys cycle
Xpetra::MultiVector< coordinateType, LO, GO, NO > RealValuedMultiVector
void setParameters(Teuchos::ParameterList &list)
Set parameters.
void resetMatrix(Teuchos::RCP< Matrix > SM_Matrix_new, bool ComputePrec=true)
Reset system matrix.
Teuchos::RCP< Matrix > AmatMultiphysics_
Hierarchies: used to define P for (0,0)-block, .... (nBlks_-1,nBlks_-1) block.
const Teuchos::RCP< const Map > getDomainMap() const
Returns the Xpetra::Map object associated with the domain of this operator.
virtual ~MultiPhys()
Destructor.
MultiPhys(const Teuchos::RCP< Matrix > &AmatMultiPhysics, const Teuchos::ArrayRCP< RCP< Matrix > > arrayOfAuxMatrices, const Teuchos::ArrayRCP< Teuchos::RCP< MultiVector > > arrayOfNullspaces, const Teuchos::ArrayRCP< Teuchos::RCP< RealValuedMultiVector > > arrayOfCoords, const int nBlks, Teuchos::ParameterList &List, bool ComputePrec=true)
Teuchos::ArrayRCP< Teuchos::RCP< Hierarchy > > arrayOfHierarchies_
bool hasTransposeApply() const
Indicates whether this operator supports applying the adjoint operator.
Teuchos::RCP< Teuchos::ParameterList > paramListMultiphysics_
Teuchos::ArrayRCP< Teuchos::RCP< RealValuedMultiVector > > arrayOfCoords_
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::VERB_HIGH) const
void initialize(const Teuchos::RCP< Matrix > &AmatMultiPhysics, const Teuchos::ArrayRCP< RCP< Matrix > > arrayOfAuxMatrices, const Teuchos::ArrayRCP< Teuchos::RCP< MultiVector > > arrayOfNullspaces, const Teuchos::ArrayRCP< Teuchos::RCP< RealValuedMultiVector > > arrayOfCoords, const int nBlks, Teuchos::ParameterList &List)
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::ArrayRCP< Teuchos::RCP< Teuchos::ParameterList > > arrayOfParamLists_
Namespace for MueLu classes and methods.