/usr/include/trilinos/MueLu_RefMaxwell_decl.hpp is in libtrilinos-muelu-dev 12.4.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | // @HEADER
//
// ***********************************************************************
//
// MueLu: A package for multigrid based preconditioning
// Copyright 2012 Sandia Corporation
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact
// Jonathan Hu (jhu@sandia.gov)
// Andrey Prokopenko (aprokop@sandia.gov)
// Ray Tuminaro (rstumin@sandia.gov)
//
// ***********************************************************************
//
// @HEADER
#ifndef MUELU_REFMAXWELL_DECL_HPP
#define MUELU_REFMAXWELL_DECL_HPP
#include "MueLu.hpp"
#include "MueLu_ConfigDefs.hpp"
#include "MueLu_BaseClass.hpp"
#include "MueLu_Utilities.hpp"
#include "MueLu_SaPFactory.hpp"
#include "MueLu_TentativePFactory.hpp"
#include "MueLu_SmootherFactory.hpp"
#include "MueLu_CoalesceDropFactory.hpp"
#include "MueLu_UncoupledAggregationFactory.hpp"
#include "MueLu_TrilinosSmoother.hpp"
#if defined(HAVE_MUELU_TPETRA) && defined(HAVE_MUELU_IFPACK2)
#include "Tpetra_Operator.hpp"
#include "Tpetra_CrsMatrix.hpp"
#include "Tpetra_MultiVector_decl.hpp"
#include "MatrixMarket_Tpetra.hpp"
#include "Xpetra_Matrix.hpp"
#include "Xpetra_MatrixFactory.hpp"
#include "Xpetra_CrsMatrixWrap.hpp"
#include "Xpetra_BlockedCrsMatrix.hpp"
#include "Xpetra_TpetraMultiVector.hpp"
#include "Xpetra_ExportFactory.hpp"
namespace MueLu {
/*!
@brief Preconditioner (wrapped as a Tpetra::Operator) for Maxwell's equations in curl-curl form.
This uses a 2x2 block reformulation.
Reference:
P. Bochev, J. Hu, C. Siefert, and R. Tuminaro. "An algebraic multigrid approach based on
a compatible gauge reformulation of Maxwell's equations." SIAM Journal on Scientific
Computing, 31(1), 557-583.
@ingroup MueLuAdapters
*/
template <class Scalar =
Tpetra::Operator<>::scalar_type,
class LocalOrdinal =
typename Tpetra::Operator<Scalar>::local_ordinal_type,
class GlobalOrdinal =
typename Tpetra::Operator<Scalar, LocalOrdinal>::global_ordinal_type,
class Node =
typename Tpetra::Operator<Scalar, LocalOrdinal, GlobalOrdinal>::node_type>
class RefMaxwell : public Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> {
#undef MUELU_REFMAXWELL_SHORT
#include "MueLu_UseShortNames.hpp"
public:
typedef Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> TMap;
typedef Tpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> TCRS;
typedef Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> TROW;
typedef Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> TMV;
typedef Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> XMap;
typedef Xpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> XMV;
typedef Xpetra::TpetraMultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> XTMV;
typedef Xpetra::CrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> XCRS;
typedef Xpetra::TpetraCrsMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> XTCRS;
typedef Xpetra::Matrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> XMat;
typedef Xpetra::CrsMatrixWrap<Scalar,LocalOrdinal,GlobalOrdinal,Node> XCrsWrap;
//! Constructor
RefMaxwell() :
Hierarchy11_(Teuchos::null),
Hierarchy22_(Teuchos::null),
disable_addon_(true),
mode_("additive")
{
}
//! Constructor with Hierarchies
RefMaxwell(Teuchos::RCP<Hierarchy> H11, Teuchos::RCP<Hierarchy> H22) :
Hierarchy11_(H11),
Hierarchy22_(H22),
disable_addon_(false),
mode_("additive")
{
}
/** Constructor with Jacobian (with add on)
*
* \param[in] SM_Matrix Jacobian
* \param[in] D0_Matrix Discrete Gradient
* \param[in] M0inv_Matrix Inverse of lumped nodal mass matrix (add on only)
* \param[in] M1_Matrix Edge mass matrix for the
* \param[in] Nullspace Null space (needed for periodic)
* \param[in] coords Nodal coordinates
* \param[in] precList Parameter list
* \param[in] ComputePrec If true, compute the preconditioner immediately
*/
RefMaxwell(const Teuchos::RCP<TCRS> & SM_Matrix,
const Teuchos::RCP<TCRS> & D0_Matrix,
const Teuchos::RCP<TCRS> & M0inv_Matrix,
const Teuchos::RCP<TCRS> & M1_Matrix,
const Teuchos::RCP<TMV> & Nullspace,
const Teuchos::RCP<TMV> & Coords,
Teuchos::ParameterList& List,
bool ComputePrec = true)
{
initialize(D0_Matrix,M0inv_Matrix,M1_Matrix,Nullspace,Coords,List);
resetMatrix(SM_Matrix);
// compute preconditioner (optionally)
if(ComputePrec)
compute();
}
/** Constructor without Jacobian (with add on)
*
* \param[in] D0_Matrix Discrete Gradient
* \param[in] M0inv_Matrix Inverse of lumped nodal mass matrix (add on only)
* \param[in] M1_Matrix Edge mass matrix for the
* \param[in] Nullspace Null space (needed for periodic)
* \param[in] coords Nodal coordinates
* \param[in] precList Parameter list
*/
RefMaxwell(const Teuchos::RCP<TCRS> & D0_Matrix,
const Teuchos::RCP<TCRS> & M0inv_Matrix,
const Teuchos::RCP<TCRS> & M1_Matrix,
const Teuchos::RCP<TMV> & Nullspace,
const Teuchos::RCP<TMV> & Coords,
Teuchos::ParameterList& List)
{
initialize(D0_Matrix,M0inv_Matrix,M1_Matrix,Nullspace,Coords,List);
}
/** Constructor with Jacobian (no add on)
*
* \param[in] SM_Matrix Jacobian
* \param[in] D0_Matrix Discrete Gradient
* \param[in] M1_Matrix Edge mass matrix for the
* \param[in] Nullspace Null space (needed for periodic)
* \param[in] coords Nodal coordinates
* \param[in] precList Parameter list
* \param[in] ComputePrec If true, compute the preconditioner immediately
*/
RefMaxwell(const Teuchos::RCP<TCRS> & SM_Matrix,
const Teuchos::RCP<TCRS> & D0_Matrix,
const Teuchos::RCP<TCRS> & M1_Matrix,
const Teuchos::RCP<TMV> & Nullspace,
const Teuchos::RCP<TMV> & Coords,
Teuchos::ParameterList& List,
bool ComputePrec = true)
{
initialize(D0_Matrix,Teuchos::null,M1_Matrix,Nullspace,Coords,List);
resetMatrix(SM_Matrix);
// compute preconditioner (optionally)
if(ComputePrec)
compute();
}
/** Constructor without Jacobian (no add on)
*
* \param[in] D0_Matrix Discrete Gradient
* \param[in] M1_Matrix Edge mass matrix for the
* \param[in] Nullspace Null space (needed for periodic)
* \param[in] coords Nodal coordinates
* \param[in] precList Parameter list
*/
RefMaxwell(const Teuchos::RCP<TCRS> & D0_Matrix,
const Teuchos::RCP<TCRS> & M1_Matrix,
const Teuchos::RCP<TMV> & Nullspace,
const Teuchos::RCP<TMV> & Coords,
Teuchos::ParameterList& List)
{
initialize(D0_Matrix,Teuchos::null,M1_Matrix,Nullspace,Coords,List);
}
//! Destructor.
virtual ~RefMaxwell() {}
//! Returns the Tpetra::Map object associated with the domain of this operator.
Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > getDomainMap() const;
//! Returns the Tpetra::Map object associated with the range of this operator.
Teuchos::RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > getRangeMap() const;
//! Set parameters
void setParameters(Teuchos::ParameterList& list);
//! Setup the preconditioner
void compute();
//! Setup the prolongator for the (1,1)-block
void buildProlongator();
//! Compute P11^{T}*A*P11 efficiently
void formCoarseMatrix();
//! Reset system matrix
void resetMatrix(Teuchos::RCP<TCRS> SM_Matrix_new);
//! apply additive algorithm for 2x2 solve
void applyInverseAdditive(const XTMV& RHS, XTMV& X) const;
//! apply 1-2-1 algorithm for 2x2 solve
void applyInverse121(const XTMV& RHS, XTMV& X) const;
//! apply 2-1-2 algorithm for 2x2 solve
void applyInverse212(const XTMV& RHS, XTMV& X) const;
//! Returns in Y the result of a Tpetra::Operator applied to a Tpetra::MultiVector X.
//! \param[in] X - Tpetra::MultiVector of dimension NumVectors to multiply with matrix.
//! \param[out] Y - Tpetra::MultiVector of dimension NumVectors containing result.
void apply(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& X,
Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>& Y,
Teuchos::ETransp mode = Teuchos::NO_TRANS,
Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
Scalar beta = Teuchos::ScalarTraits<Scalar>::one()) const;
//! Indicates whether this operator supports applying the adjoint operator.
bool hasTransposeApply() const;
template <class NewNode>
Teuchos::RCP< RefMaxwell<Scalar, LocalOrdinal, GlobalOrdinal, NewNode> >
clone (const RCP<NewNode>& new_node) const {
return Teuchos::rcp (new RefMaxwell<Scalar, LocalOrdinal, GlobalOrdinal, NewNode>
(Hierarchy11_->template clone<NewNode> (new_node),
Hierarchy22_->template clone<NewNode> (new_node)));
}
private:
/** Initialize with matrices except the Jacobian (don't compute the preconditioner)
*
* \param[in] D0_Matrix Discrete Gradient
* \param[in] M0inv_Matrix Inverse of lumped nodal mass matrix (add on only)
* \param[in] M1_Matrix Edge mass matrix
* \param[in] Nullspace Null space (needed for periodic)
* \param[in] coords Nodal coordinates
* \param[in] precList Parameter list
*/
void initialize(const Teuchos::RCP<TCRS> & D0_Matrix,
const Teuchos::RCP<TCRS> & M0inv_Matrix,
const Teuchos::RCP<TCRS> & M1_Matrix,
const Teuchos::RCP<TMV> & Nullspace,
const Teuchos::RCP<TMV> & Coords,
Teuchos::ParameterList& List);
//! Two hierarchies: one for the (1,1)-block, another for the (2,2)-block
Teuchos::RCP<Hierarchy> Hierarchy11_, Hierarchy22_, HierarchySmoother_;
//! Top Level
Teuchos::RCP<Level> TopLevel_;
//! Various matrices
Teuchos::RCP<XMat> SM_Matrix_, D0_Matrix_, M0inv_Matrix_, M1_Matrix_, Ms_Matrix_;
Teuchos::RCP<XMat> TMT_Matrix_, TMT_Agg_Matrix_, P11_, A11_, A22_;
//! Vectors for BCs
std::vector<LocalOrdinal> BCrows_, BCcols_;
//! Nullspace
Teuchos::RCP<XMV> Nullspace_, Coords_;
//! Parameter lists
Teuchos::ParameterList parameterList_, precList11_, precList22_, smootherList_;
//! Some options
bool disable_addon_;
std::string mode_;
};
} // namespace
#endif //ifdef HAVE_MUELU_TPETRA
#define MUELU_REFMAXWELL_SHORT
#endif // MUELU_REFMAXWELL_DECL_HPP
|