MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_RefMaxwell_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_REFMAXWELL_DECL_HPP
47 #define MUELU_REFMAXWELL_DECL_HPP
48 
49 #include "MueLu_ConfigDefs.hpp"
50 #include "MueLu_BaseClass.hpp"
52 
58 #include "MueLu_Utilities_fwd.hpp"
59 
60 #ifdef HAVE_MUELU_KOKKOS_REFACTOR
67 #endif
68 
75 
77 #include "MueLu_TrilinosSmoother.hpp"
78 #include "MueLu_Hierarchy.hpp"
79 
80 #include "Xpetra_Map_fwd.hpp"
81 #include "Xpetra_Matrix_fwd.hpp"
86 
87 #if defined(HAVE_MUELU_IFPACK2) && (!defined(HAVE_MUELU_EPETRA) || defined(HAVE_MUELU_INST_DOUBLE_INT_INT))
89 #include "Ifpack2_Hiptmair.hpp"
90 #endif
91 
92 namespace MueLu {
93 
120  template <class Scalar,
121  class LocalOrdinal,
122  class GlobalOrdinal,
123  class Node>
124  class RefMaxwell : public VerboseObject, public Xpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> {
125 
126 #undef MUELU_REFMAXWELL_SHORT
127 #include "MueLu_UseShortNames.hpp"
128 
129  public:
130 
133 
136  HierarchyH_(Teuchos::null),
137  Hierarchy22_(Teuchos::null),
138  disable_addon_(true),
139  mode_("additive")
140  {
141  }
142 
145  HierarchyH_(HH),
146  Hierarchy22_(H22),
147  disable_addon_(false),
148  mode_("additive")
149  {
150  }
151 
163  RefMaxwell(const Teuchos::RCP<Matrix> & SM_Matrix,
164  const Teuchos::RCP<Matrix> & D0_Matrix,
165  const Teuchos::RCP<Matrix> & M0inv_Matrix,
166  const Teuchos::RCP<Matrix> & M1_Matrix,
167  const Teuchos::RCP<MultiVector> & Nullspace,
170  bool ComputePrec = true)
171  {
172  initialize(D0_Matrix,M0inv_Matrix,M1_Matrix,Nullspace,Coords,List);
173 
174  resetMatrix(SM_Matrix);
175 
176  // compute preconditioner (optionally)
177  if(ComputePrec)
178  compute();
179  }
180 
190  RefMaxwell(const Teuchos::RCP<Matrix> & D0_Matrix,
191  const Teuchos::RCP<Matrix> & M0inv_Matrix,
192  const Teuchos::RCP<Matrix> & M1_Matrix,
193  const Teuchos::RCP<MultiVector> & Nullspace,
195  Teuchos::ParameterList& List) : SM_Matrix_(Teuchos::null)
196  {
197  initialize(D0_Matrix,M0inv_Matrix,M1_Matrix,Nullspace,Coords,List);
198  }
199 
210  RefMaxwell(const Teuchos::RCP<Matrix> & SM_Matrix,
211  const Teuchos::RCP<Matrix> & D0_Matrix,
212  const Teuchos::RCP<Matrix> & M1_Matrix,
213  const Teuchos::RCP<MultiVector> & Nullspace,
216  bool ComputePrec)
217  {
218  initialize(D0_Matrix,Teuchos::null,M1_Matrix,Nullspace,Coords,List);
219 
220  resetMatrix(SM_Matrix);
221 
222  // compute preconditioner (optionally)
223  if(ComputePrec)
224  compute();
225  }
226 
235  RefMaxwell(const Teuchos::RCP<Matrix> & D0_Matrix,
236  const Teuchos::RCP<Matrix> & M1_Matrix,
237  const Teuchos::RCP<MultiVector> & Nullspace,
239  Teuchos::ParameterList& List) : SM_Matrix_(Teuchos::null)
240  {
241  initialize(D0_Matrix,Teuchos::null,M1_Matrix,Nullspace,Coords,List);
242  }
243 
250  RefMaxwell(const Teuchos::RCP<Matrix> & SM_Matrix,
252  bool ComputePrec = true)
253  {
254 
255  RCP<MultiVector> Nullspace = List.get<RCP<MultiVector> >("Nullspace", Teuchos::null);
256  RCP<RealValuedMultiVector> Coords = List.get<RCP<RealValuedMultiVector> >("Coordinates", Teuchos::null);
257  RCP<Matrix> D0_Matrix = List.get<RCP<Matrix> >("D0");
258  RCP<Matrix> M1_Matrix = List.get<RCP<Matrix> >("M1");
259  RCP<Matrix> M0inv_Matrix = List.get<RCP<Matrix> >("M0inv", Teuchos::null);
260 
261  initialize(D0_Matrix,M0inv_Matrix,M1_Matrix,Nullspace,Coords,List);
262 
263  if (SM_Matrix != Teuchos::null)
264  resetMatrix(SM_Matrix);
265 
266  // compute preconditioner (optionally)
267  if(ComputePrec)
268  compute();
269  }
270 
272  virtual ~RefMaxwell() {}
273 
276 
279 
282  return SM_Matrix_;
283  }
284 
287 
289  void compute();
290 
292  void buildProlongator();
293 
295  void formCoarseMatrix();
296 
298  void resetMatrix(Teuchos::RCP<Matrix> SM_Matrix_new);
299 
303  void apply (const MultiVector& X, MultiVector& Y,
305  Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
306  Scalar beta = Teuchos::ScalarTraits<Scalar>::zero()) const;
307 
309  bool hasTransposeApply() const;
310 
311 #ifdef HAVE_MUELU_DEPRECATED_CODE
312  template <class NewNode>
314  MUELU_DEPRECATED
315  clone (const RCP<NewNode>& new_node) const {
317  (HierarchyH_->template clone<NewNode> (new_node),
318  Hierarchy22_->template clone<NewNode> (new_node)));
319  }
320 #endif
321 
323 
324  private:
325 
335  void initialize(const Teuchos::RCP<Matrix> & D0_Matrix,
336  const Teuchos::RCP<Matrix> & M0inv_Matrix,
337  const Teuchos::RCP<Matrix> & M1_Matrix,
338  const Teuchos::RCP<MultiVector> & Nullspace,
340  Teuchos::ParameterList& List);
341 
343  void solveH() const;
344 
346  void solve22() const;
347 
349  void applyInverseAdditive(const MultiVector& RHS, MultiVector& X) const;
350 
352  void applyInverse121(const MultiVector& RHS, MultiVector& X) const;
353 
355  void applyInverse212(const MultiVector& RHS, MultiVector& X) const;
356 
358  void applyInverse11only(const MultiVector& RHS, MultiVector& X) const;
359 
363 #if defined(HAVE_MUELU_IFPACK2) && (!defined(HAVE_MUELU_EPETRA) || defined(HAVE_MUELU_INST_DOUBLE_INT_INT))
364  Teuchos::RCP<Ifpack2::Preconditioner<Scalar,LocalOrdinal,GlobalOrdinal,Node> > hiptmairPreSmoother_, hiptmairPostSmoother_;
365 #endif
371 #ifdef HAVE_MUELU_KOKKOS_REFACTOR
374 #endif
387  std::string mode_;
390  };
391 
392 } // namespace
393 
394 #define MUELU_REFMAXWELL_SHORT
395 #endif // MUELU_REFMAXWELL_DECL_HPP
const Teuchos::RCP< Matrix > & getJacobian() const
Returns Jacobian matrix SM.
Teuchos::RCP< SmootherBase > PostSmoother_
Teuchos::RCP< const Import > Importer22_
RCP< Map< LocalOrdinal, GlobalOrdinal, Node2 > > clone(const Map< LocalOrdinal, GlobalOrdinal, Node1 > &map, const RCP< Node2 > &node2)
void solveH() const
solve coarse (1,1) block
Teuchos::RCP< Matrix > D0_T_Matrix_
Teuchos::ArrayRCP< const bool > BCrows_
Vectors for BCs.
Teuchos::RCP< Matrix > Ms_Matrix_
void solve22() const
solve (2,2) block
Teuchos::RCP< MultiVector > D0xTmp_
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< const Map > getDomainMap() const
Returns the Xpetra::Map object associated with the domain of this operator.
Teuchos::RCP< Matrix > D0_Matrix_
T & get(const std::string &name, T def_value)
Teuchos::RCP< Matrix > SM_Matrix_
Various matrices.
Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > MultiVector
Teuchos::RCP< MultiVector > D0res_
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::ParameterList smootherList_
Teuchos::ArrayRCP< const bool > BCcols_
Teuchos::RCP< Matrix > A22_
Teuchos::RCP< MultiVector > D0resTmp_
void setParameters(Teuchos::ParameterList &list)
Set parameters.
void buildProlongator()
Setup the prolongator for the (1,1)-block.
Teuchos::ScalarTraits< Scalar >::magnitudeType magnitudeType
Teuchos::RCP< MultiVector > P11res_
Temporary memory.
Preconditioner (wrapped as a Xpetra::Operator) for Maxwell&#39;s equations in curl-curl form...
Xpetra::MultiVector< magnitudeType, LO, GO, NO > RealValuedMultiVector
Teuchos::RCP< Matrix > M0inv_Matrix_
Teuchos::RCP< MultiVector > residual_
Teuchos::RCP< MultiVector > D0x_
void applyInverseAdditive(const MultiVector &RHS, MultiVector &X) const
apply additive algorithm for 2x2 solve
Teuchos::RCP< MultiVector > P11resTmp_
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::ParameterList precList11_
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)
void compute()
Setup the preconditioner.
Teuchos::RCP< Matrix > P11_
Teuchos::RCP< Matrix > A_nodal_Matrix_
Teuchos::RCP< Hierarchy > Hierarchy22_
Teuchos::RCP< Matrix > M1_Matrix_
Teuchos::RCP< RealValuedMultiVector > CoordsH_
void applyInverse212(const MultiVector &RHS, MultiVector &X) const
apply 2-1-2 algorithm for 2x2 solve
void initialize(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< SmootherBase > PreSmoother_
void applyInverse121(const MultiVector &RHS, MultiVector &X) const
apply 1-2-1 algorithm for 2x2 solve
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::VERB_HIGH) const
bool disable_addon_
Some options.
virtual ~RefMaxwell()
Destructor.
Teuchos::ParameterList parameterList_
Parameter lists.
Teuchos::RCP< RealValuedMultiVector > Coords_
Coordinates.
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< MultiVector > P11x_
Teuchos::RCP< Matrix > R11_
Teuchos::RCP< const Map > getRangeMap() const
Returns the Xpetra::Map object associated with the range of this operator.
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
void applyInverse11only(const MultiVector &RHS, MultiVector &X) const
apply solve to 1-1 block only
Teuchos::RCP< Matrix > AH_
void formCoarseMatrix()
Compute P11^{T}*A*P11 efficiently.
Teuchos::RCP< MultiVector > P11xTmp_
Teuchos::RCP< Hierarchy > HierarchyH_
Two hierarchies: one for the coarse (1,1)-block, another for the (2,2)-block.
RefMaxwell(Teuchos::RCP< Hierarchy > HH, Teuchos::RCP< Hierarchy > H22)
Constructor with Hierarchies.
Teuchos::ParameterList precList22_
Teuchos::RCP< MultiVector > Nullspace_
Nullspace.
void resetMatrix(Teuchos::RCP< Matrix > SM_Matrix_new)
Reset system matrix.
RefMaxwell(const Teuchos::RCP< Matrix > &SM_Matrix, Teuchos::ParameterList &List, bool ComputePrec=true)
bool hasTransposeApply() const
Indicates whether this operator supports applying the adjoint operator.
Teuchos::RCP< const Import > ImporterH_
Importer to coarse (1,1) hierarchy.