MueLu Version of the Day
Loading...
Searching...
No Matches
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
53
55#include "MueLu_TrilinosSmoother.hpp"
57#include "MueLu_Level_fwd.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"
69#include "Xpetra_MatrixFactory_fwd.hpp"
70#include "Xpetra_MultiVectorFactory_fwd.hpp"
71#include "Xpetra_VectorFactory_fwd.hpp"
72#include "Xpetra_CrsMatrixWrap_fwd.hpp"
73
74namespace 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
88#undef MUELU_MULTIPHYS_SHORT
90
91 public:
92
93 typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType magnitudeType;
94 typedef typename Teuchos::ScalarTraits<Scalar>::coordinateType coordinateType;
95 typedef typename Xpetra::MultiVector<coordinateType,LO,GO,NO> RealValuedMultiVector;
96
102
113 MultiPhys(const Teuchos::RCP<Matrix> & AmatMultiPhysics,
114 const Teuchos::ArrayRCP<RCP<Matrix>> arrayOfAuxMatrices,
115 const Teuchos::ArrayRCP<Teuchos::RCP<MultiVector>> arrayOfNullspaces,
116 const Teuchos::ArrayRCP<Teuchos::RCP<RealValuedMultiVector>> arrayOfCoords,
117 const int nBlks,
118 Teuchos::ParameterList& List,
119 bool ComputePrec = true):
120 AmatMultiphysics_(AmatMultiPhysics), arrayOfAuxMatrices_(arrayOfAuxMatrices), arrayOfNullspaces_(arrayOfNullspaces),
121 arrayOfCoords_(arrayOfCoords), nBlks_(nBlks)
122 {
123 initialize(AmatMultiPhysics, arrayOfAuxMatrices, arrayOfNullspaces, arrayOfCoords, nBlks, List);
124 compute(false);
125 }
126
128 virtual ~MultiPhys() {}
129
131 Teuchos::RCP<const Map> getDomainMap() const;
132
134 Teuchos::RCP<const Map> getRangeMap() const;
135
137 void setParameters(Teuchos::ParameterList& list);
138
140 void compute(bool reuse=false);
141
143 void resetMatrix(Teuchos::RCP<Matrix> SM_Matrix_new, bool ComputePrec=true);
144
148 void apply (const MultiVector& X, MultiVector& Y,
149 Teuchos::ETransp mode = Teuchos::NO_TRANS,
150 Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
151 Scalar beta = Teuchos::ScalarTraits<Scalar>::zero()) const;
152
154 bool hasTransposeApply() const;
155
156 void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel = Teuchos::VERB_HIGH) const;
157
159 void residual(const MultiVector & X,
160 const MultiVector & B,
161 MultiVector & R) const {
162 using STS = Teuchos::ScalarTraits<Scalar>;
163 R.update(STS::one(),B,STS::zero());
164 this->apply (X, R, Teuchos::NO_TRANS, -STS::one(), STS::one());
165 }
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,
181 const Teuchos::ArrayRCP<Teuchos::RCP<RealValuedMultiVector>> arrayOfCoords,
182 const int nBlks,
183 Teuchos::ParameterList& List);
184
185
187 void applyInverse(const MultiVector& RHS, MultiVector& X) const;
188
190 void allocateMemory(int numVectors) const;
191
193 Teuchos::RCP<Teuchos::TimeMonitor> getTimer(std::string name, RCP<const Teuchos::Comm<int> > comm=Teuchos::null) const;
194
196 mutable Teuchos::ParameterList parameterList_;
197
199
200
201 Teuchos::RCP<Matrix> AmatMultiphysics_; // multiphysics discretization matrix
202 Teuchos::RCP<Teuchos::ParameterList> paramListMultiphysics_;// array of parameter lists directing MueLu's construct of subblock P operators
203 Teuchos::RCP<Hierarchy> hierarchyMultiphysics_; // multiphysics discretization matrix
204
205 Teuchos::ArrayRCP<Teuchos::RCP<Teuchos::ParameterList>> arrayOfParamLists_; // array of parameter lists directing MueLu's construct of subblock P operators
206 Teuchos::ArrayRCP<Teuchos::RCP<Hierarchy>> arrayOfHierarchies_;
207 Teuchos::ArrayRCP<Teuchos::RCP<Matrix>> arrayOfAuxMatrices_; // array of discretization/auxiliary matrices used to generate subblock prolongators
208 Teuchos::ArrayRCP<Teuchos::RCP<MultiVector>> arrayOfNullspaces_; // array of nullspaces for smoothed aggregation.
209 Teuchos::ArrayRCP<Teuchos::RCP<RealValuedMultiVector>> arrayOfCoords_; // array of coordinates for smoothed aggregation/rebalancing.
210
211 int nBlks_; // number of PDE sub-systems within multiphysics system
213
214 };
215
216} // namespace
217
218#define MUELU_MULTIPHYS_SHORT
219#endif // MUELU_MULTIPHYS_DECL_HPP
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
MueLu::DefaultNode Node
Teuchos::RCP< Hierarchy > hierarchyMultiphysics_
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
Teuchos::RCP< const Map > getDomainMap() const
Returns the Xpetra::Map object associated with the domain of this operator.
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.
Xpetra::MultiVector< coordinateType, LO, GO, NO > RealValuedMultiVector
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::RCP< const Map > getRangeMap() const
Returns the Xpetra::Map object associated with the range of this operator.
Teuchos::ArrayRCP< Teuchos::RCP< Teuchos::ParameterList > > arrayOfParamLists_
Namespace for MueLu classes and methods.