MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_MultiPhys_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // MueLu: A package for multigrid based preconditioning
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef MUELU_MULTIPHYS_DECL_HPP
47 #define MUELU_MULTIPHYS_DECL_HPP
48 
49 #include "MueLu_ConfigDefs.hpp"
50 #include "MueLu_BaseClass.hpp"
51 
52 #include "MueLu_SaPFactory_fwd.hpp"
53 
55 #include "MueLu_TrilinosSmoother.hpp"
56 #include "MueLu_Utilities_fwd.hpp"
57 #include "MueLu_Level_fwd.hpp"
58 #include "MueLu_Hierarchy_fwd.hpp"
59 #include "MueLu_RAPFactory_fwd.hpp"
60 #include "MueLu_PerfUtils_fwd.hpp"
61 #include "MueLu_SmootherBase.hpp"
62 
63 #if defined(HAVE_MUELU_KOKKOS_REFACTOR)
64 #include "MueLu_Utilities_kokkos_fwd.hpp"
65 #endif
66 
67 #include "Xpetra_Map_fwd.hpp"
68 #include "Xpetra_Matrix_fwd.hpp"
73 
74 namespace MueLu {
75 
82 template <class Scalar,
83  class LocalOrdinal,
84  class GlobalOrdinal,
85  class Node>
86 class MultiPhys : public VerboseObject, public Xpetra::Operator<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
87 #undef MUELU_MULTIPHYS_SHORT
88 #include "MueLu_UseShortNames.hpp"
89 
90  public:
94 
97  : AmatMultiphysics_(Teuchos::null)
98  , hierarchyMultiphysics_(Teuchos::null)
99  , nBlks_(0) {
100  }
101 
112  MultiPhys(const Teuchos::RCP<Matrix>& AmatMultiPhysics,
113  const Teuchos::ArrayRCP<RCP<Matrix>> arrayOfAuxMatrices,
114  const Teuchos::ArrayRCP<Teuchos::RCP<MultiVector>> arrayOfNullspaces,
116  const int nBlks,
118  bool ComputePrec = true)
119  : AmatMultiphysics_(AmatMultiPhysics)
120  , arrayOfAuxMatrices_(arrayOfAuxMatrices)
121  , arrayOfNullspaces_(arrayOfNullspaces)
122  , arrayOfCoords_(arrayOfCoords)
123  , nBlks_(nBlks) {
124  initialize(AmatMultiPhysics, arrayOfAuxMatrices, arrayOfNullspaces, arrayOfCoords, nBlks, List);
125  compute(false);
126  }
127 
129  virtual ~MultiPhys() {}
130 
133 
135  const Teuchos::RCP<const Map> getRangeMap() const;
136 
139 
141  void compute(bool reuse = false);
142 
144  void resetMatrix(Teuchos::RCP<Matrix> SM_Matrix_new, bool ComputePrec = true);
145 
149  void apply(const MultiVector& X, MultiVector& Y,
153 
155  bool hasTransposeApply() const;
156 
158 
160  void residual(const MultiVector& X,
161  const MultiVector& B,
162  MultiVector& R) const {
163  using STS = Teuchos::ScalarTraits<Scalar>;
164  R.update(STS::one(), B, STS::zero());
165  this->apply(X, R, Teuchos::NO_TRANS, -STS::one(), STS::one());
166  }
167 
168  private:
178  void initialize(const Teuchos::RCP<Matrix>& AmatMultiPhysics,
179  const Teuchos::ArrayRCP<RCP<Matrix>> arrayOfAuxMatrices,
180  const Teuchos::ArrayRCP<Teuchos::RCP<MultiVector>> arrayOfNullspaces,
182  const int nBlks,
183  Teuchos::ParameterList& List);
184 
186  void applyInverse(const MultiVector& RHS, MultiVector& X) const;
187 
189  void allocateMemory(int numVectors) const;
190 
192  Teuchos::RCP<Teuchos::TimeMonitor> getTimer(std::string name, RCP<const Teuchos::Comm<int>> comm = Teuchos::null) const;
193 
196 
198 
199  Teuchos::RCP<Matrix> AmatMultiphysics_; // multiphysics discretization matrix
200  Teuchos::RCP<Teuchos::ParameterList> paramListMultiphysics_; // array of parameter lists directing MueLu's construct of subblock P operators
201  Teuchos::RCP<Hierarchy> hierarchyMultiphysics_; // multiphysics discretization matrix
202 
203  Teuchos::ArrayRCP<Teuchos::RCP<Teuchos::ParameterList>> arrayOfParamLists_; // array of parameter lists directing MueLu's construct of subblock P operators
205  Teuchos::ArrayRCP<Teuchos::RCP<Matrix>> arrayOfAuxMatrices_; // array of discretization/auxiliary matrices used to generate subblock prolongators
206  Teuchos::ArrayRCP<Teuchos::RCP<MultiVector>> arrayOfNullspaces_; // array of nullspaces for smoothed aggregation.
207  Teuchos::ArrayRCP<Teuchos::RCP<RealValuedMultiVector>> arrayOfCoords_; // array of coordinates for smoothed aggregation/rebalancing.
208 
209  int nBlks_; // number of PDE sub-systems within multiphysics system
211 };
212 
213 } // namespace MueLu
214 
215 #define MUELU_MULTIPHYS_SHORT
216 #endif // MUELU_MULTIPHYS_DECL_HPP
MueLu::DefaultLocalOrdinal LocalOrdinal
Preconditioner (wrapped as a Xpetra::Operator) for solving MultiPhysics PDEs.
Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > MultiVector
Xpetra::MultiVector< coordinateType, LO, GO, NO > RealValuedMultiVector
Teuchos::ArrayRCP< Teuchos::RCP< Matrix > > arrayOfAuxMatrices_
Teuchos::ScalarTraits< Scalar >::magnitudeType magnitudeType
MueLu::DefaultNode Node
virtual ~MultiPhys()
Destructor.
Verbose class for MueLu classes.
void setParameters(Teuchos::ParameterList &list)
Set parameters.
virtual void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta)=0
Teuchos::ScalarTraits< Scalar >::coordinateType coordinateType
Teuchos::ArrayRCP< Teuchos::RCP< RealValuedMultiVector > > arrayOfCoords_
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)
void applyInverse(const MultiVector &RHS, MultiVector &X) const
apply standard MultiPhys cycle
const Teuchos::RCP< const Map > getDomainMap() const
Returns the Xpetra::Map object associated with the domain of this operator.
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
const Teuchos::RCP< const Map > getRangeMap() const
Returns the Xpetra::Map object associated with the range of this operator.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::VERB_HIGH) const
Teuchos::RCP< Matrix > AmatMultiphysics_
Hierarchies: used to define P for (0,0)-block, .... (nBlks_-1,nBlks_-1) block.
MultiPhys()
Constructor.
bool hasTransposeApply() const
Indicates whether this operator supports applying the adjoint operator.
Teuchos::ArrayRCP< Teuchos::RCP< Teuchos::ParameterList > > arrayOfParamLists_
Teuchos::RCP< Teuchos::TimeMonitor > getTimer(std::string name, RCP< const Teuchos::Comm< int >> comm=Teuchos::null) const
get a (synced) timer
Teuchos::ParameterList parameterList_
ParameterLists.
Teuchos::RCP< Hierarchy > hierarchyMultiphysics_
Teuchos::ArrayRCP< Teuchos::RCP< Hierarchy > > arrayOfHierarchies_
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< Teuchos::ParameterList > paramListMultiphysics_
void residual(const MultiVector &X, const MultiVector &B, MultiVector &R) const
Compute a residual R = B - (*this) * X.
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 resetMatrix(Teuchos::RCP< Matrix > SM_Matrix_new, bool ComputePrec=true)
Reset system matrix.
void compute(bool reuse=false)
Setup the preconditioner.
Teuchos::ArrayRCP< Teuchos::RCP< MultiVector > > arrayOfNullspaces_
void allocateMemory(int numVectors) const
allocate multivectors for solve