| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// Trilinos: An Object-Oriented Solver Framework |
| 4 |
// |
| 5 |
// Copyright 2001-2024 NTESS and the Trilinos contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
/* ******************************************************************** */ |
| 11 |
/* See the file COPYRIGHT for a complete copyright notice, contact */ |
| 12 |
/* person and disclaimer. */ |
| 13 |
/* ******************************************************************** */ |
| 14 |
/*! |
| 15 |
* \file nlnml_ConstrainedMultiLevelOperator.H |
| 16 |
* |
| 17 |
* \class NLNML_ConstrainedMultiLevelOperator |
| 18 |
* |
| 19 |
* \brief a wrapper for ML's MultiLevelOperator that additionally enforces constraints |
| 20 |
* |
| 21 |
* \date Last update do Doxygen: 31-Mar-05 |
| 22 |
* |
| 23 |
*/ |
| 24 |
#include "TrilinosCouplings_config.h" |
| 25 |
|
| 26 |
#if defined(HAVE_ML_NOX) && defined(HAVE_ML_EPETRA) && defined(HAVE_ML_AZTECOO) && defined(HAVE_ML_TEUCHOS) && defined(HAVE_ML_IFPACK) && defined(HAVE_ML_AMESOS) && defined(HAVE_ML_EPETRAEXT) |
| 27 |
|
| 28 |
#ifndef NLNML_CONSTRAINEDMULTILEVELOPERATOR_H |
| 29 |
#define NLNML_CONSTRAINEDMULTILEVELOPERATOR_H |
| 30 |
|
| 31 |
// ML-headers |
| 32 |
#include "ml_common.h" |
| 33 |
#include "ml_include.h" |
| 34 |
#include "ml_epetra.h" |
| 35 |
#include "ml_epetra_operator.h" |
| 36 |
|
| 37 |
// epetra-headers |
| 38 |
#include "Epetra_Map.h" |
| 39 |
#include "Epetra_Vector.h" |
| 40 |
#include "Epetra_MultiVector.h" |
| 41 |
#include "Epetra_Operator.h" |
| 42 |
#include "Epetra_CrsMatrix.h" |
| 43 |
#include "Epetra_RowMatrix.h" |
| 44 |
#include "Epetra_CrsGraph.h" |
| 45 |
#include "Epetra_LinearProblem.h" |
| 46 |
#include "Epetra_Object.h" |
| 47 |
#include "Epetra_Comm.h" |
| 48 |
#include "Epetra_SerialComm.h" |
| 49 |
#ifdef ML_MPI |
| 50 |
#include "Epetra_MpiComm.h" |
| 51 |
#endif |
| 52 |
#include "Epetra_SerialComm.h" |
| 53 |
|
| 54 |
// Teuchos |
| 55 |
#include "Teuchos_RefCountPtr.hpp" |
| 56 |
#include "Teuchos_ParameterList.hpp" |
| 57 |
|
| 58 |
#include "nlnml_coarselevelnoxinterface.H" |
| 59 |
|
| 60 |
|
| 61 |
using namespace Teuchos; |
| 62 |
namespace NLNML |
| 63 |
{ |
| 64 |
|
| 65 |
class NLNML_ConstrainedMultiLevelOperator : public virtual Epetra_Operator |
| 66 |
{ |
| 67 |
public: |
| 68 |
|
| 69 |
explicit NLNML_ConstrainedMultiLevelOperator( |
| 70 |
RefCountPtr<ML_Epetra::MultiLevelOperator> ml_operator, |
| 71 |
RefCountPtr<NLNML::NLNML_CoarseLevelNoxInterface> coarseinterface, |
| 72 |
bool applyconstraints); |
| 73 |
|
| 74 |
virtual ~NLNML_ConstrainedMultiLevelOperator() {} |
| 75 |
|
| 76 |
//! Returns the label of this class. |
| 77 |
/*! |
| 78 |
Returns the label of this class. |
| 79 |
*/ |
| 80 |
const char* Label() const {return(&(label_[0]));} |
| 81 |
|
| 82 |
//! get Comm of this class |
| 83 |
/*! |
| 84 |
Derived from Epetra_Operator, returns ref to the Epetra_Comm of this class |
| 85 |
*/ |
| 86 |
const Epetra_Comm & Comm() const {return(comm_);} |
| 87 |
|
| 88 |
//! Get fine level OperatorDomainMap. |
| 89 |
/*! |
| 90 |
Derived from Epetra_Operator, get fine level OperatorDomainMap. |
| 91 |
*/ |
| 92 |
const Epetra_Map & OperatorDomainMap() const {return ml_operator_->OperatorDomainMap();} |
| 93 |
|
| 94 |
//! Get fine level OperatorRangeMap. |
| 95 |
/*! |
| 96 |
Derived from Epetra_Operator, get fine level OperatorRangeMap. |
| 97 |
*/ |
| 98 |
const Epetra_Map & OperatorRangeMap() const {return ml_operator_->OperatorRangeMap();} |
| 99 |
|
| 100 |
//! ApplyInverse the preconditioner |
| 101 |
/*! |
| 102 |
ApplyInverse the preconditioner. Method is derived from Epetra_Operator. |
| 103 |
\param X (In) : Epetra_MultiVector matching the fine level map of this |
| 104 |
preconditioner |
| 105 |
\param Y (Out) : Epetra_MultiVector containing the result on output |
| 106 |
*/ |
| 107 |
int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const ; |
| 108 |
|
| 109 |
//! Apply the preconditioner, not implemented. |
| 110 |
/*! |
| 111 |
Derived from Epetra_Operator, not implemented. |
| 112 |
*/ |
| 113 |
int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const |
| 114 |
{ std::cout << "NLNML_ConstrainedMultiLevelOperator::Apply does not make sense for an ML-Multilevel Operator\n" |
| 115 |
<< "Use ApplyInverse\n";throw -1;return(-1);} |
| 116 |
|
| 117 |
//! SetUseTranspose, not implemented. |
| 118 |
/*! |
| 119 |
Derived from Epetra_Operator, not implemented. |
| 120 |
*/ |
| 121 |
int SetUseTranspose(bool UseTranspose) { return 0;} |
| 122 |
|
| 123 |
//! NormInf, not implemented. |
| 124 |
/*! |
| 125 |
Derived from Epetra_Operator, not implemented. |
| 126 |
*/ |
| 127 |
double NormInf() const {std::cout << "NLNML_ConstrainedMultiLevelOperator::NormInf not impl.\n"; |
| 128 |
return(-1.0);} |
| 129 |
|
| 130 |
//! UseTranspose, not implemented. |
| 131 |
/*! |
| 132 |
Derived from Epetra_Operator, not implemented. |
| 133 |
*/ |
| 134 |
bool UseTranspose() const {return false;} |
| 135 |
|
| 136 |
//! HasNormInf, not implemented. |
| 137 |
/*! |
| 138 |
Derived from Epetra_Operator, always returns false. |
| 139 |
*/ |
| 140 |
bool HasNormInf() const {return false;} |
| 141 |
|
| 142 |
private: |
| 143 |
|
| 144 |
explicit NLNML_ConstrainedMultiLevelOperator(NLNML::NLNML_ConstrainedMultiLevelOperator& old); |
| 145 |
NLNML_ConstrainedMultiLevelOperator operator = (const NLNML_ConstrainedMultiLevelOperator& old); |
| 146 |
|
| 147 |
const char* label_; |
| 148 |
const Epetra_Comm& comm_; |
| 149 |
RefCountPtr<NLNML::NLNML_CoarseLevelNoxInterface> coarseinterface_; |
| 150 |
RefCountPtr<ML_Epetra::MultiLevelOperator> ml_operator_; |
| 151 |
bool applyconstraints_; |
| 152 |
|
| 153 |
}; // class NLNML_ConstrainedMultiLevelOperator |
| 154 |
} // namespace NLNML |
| 155 |
|
| 156 |
#endif |
| 157 |
#endif |