| 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 |
// ML-headers |
| 15 |
#include "ml_common.h" |
| 16 |
#include "TrilinosCouplings_config.h" |
| 17 |
|
| 18 |
#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) |
| 19 |
|
| 20 |
#ifndef ML_NOX_MATRIXFREELEVEL_H |
| 21 |
#define ML_NOX_MATRIXFREELEVEL_H |
| 22 |
|
| 23 |
#include <vector> |
| 24 |
|
| 25 |
// epetra-headers |
| 26 |
#include "Epetra_Map.h" |
| 27 |
#include "Epetra_Vector.h" |
| 28 |
#include "Epetra_MultiVector.h" |
| 29 |
#include "Epetra_IntVector.h" |
| 30 |
#include "Epetra_Operator.h" |
| 31 |
#include "Epetra_CrsMatrix.h" |
| 32 |
#include "Epetra_RowMatrix.h" |
| 33 |
#include "Epetra_CrsGraph.h" |
| 34 |
#include "Epetra_LinearProblem.h" |
| 35 |
#include "Epetra_Object.h" |
| 36 |
#include "Epetra_Comm.h" |
| 37 |
#include "Epetra_SerialComm.h" |
| 38 |
#ifdef ML_MPI |
| 39 |
#include "Epetra_MpiComm.h" |
| 40 |
#endif |
| 41 |
#include "Epetra_MapColoring.h" |
| 42 |
#include "Epetra_Export.h" |
| 43 |
#include "Epetra_Import.h" |
| 44 |
|
| 45 |
// NOX-headers |
| 46 |
#include <NOX.H> |
| 47 |
#include <NOX_Epetra.H> |
| 48 |
#include "NOX_EpetraNew_Interface_Required.H" |
| 49 |
#include "NOX_EpetraNew_Interface_Jacobian.H" |
| 50 |
#include "NOX_EpetraNew_Interface_Preconditioner.H" |
| 51 |
#include "NOX_EpetraNew_FiniteDifference.H" |
| 52 |
#include "NOX_EpetraNew_FiniteDifferenceColoring.H" |
| 53 |
|
| 54 |
// ML-headers |
| 55 |
#include "ml_include.h" |
| 56 |
#include "ml_epetra_utils.h" |
| 57 |
#include "ml_epetra.h" |
| 58 |
#include "ml_epetra_operator.h" |
| 59 |
#include "ml_MultiLevelOperator.h" |
| 60 |
#include "ml_nox_fineinterface.H" // interface to user code on fine level |
| 61 |
#include "ml_nox_coarseinterface.H" // interface to user code on coarse levels |
| 62 |
#include "ml_nox_preconditioner_utils.H" // interface to user code on coarse levels |
| 63 |
|
| 64 |
// the graph coloring class |
| 65 |
#include "EpetraExt_MapColoring.h" |
| 66 |
#include "EpetraExt_MapColoringIndex.h" |
| 67 |
|
| 68 |
// ---------- Forward Declarations ---------- |
| 69 |
class Epetra_MultiVector; |
| 70 |
class Epetra_BlockMap; |
| 71 |
class Epetra_Comm; |
| 72 |
class Nox_Problem_Interface; |
| 73 |
class Nox_CoarseProblem_Interface; |
| 74 |
class Epetra_MapColoring; |
| 75 |
class Epetra_IntVector; |
| 76 |
|
| 77 |
namespace ML_NOX |
| 78 |
{ |
| 79 |
class ML_Nox_MatrixfreeLevel |
| 80 |
{ |
| 81 |
|
| 82 |
public: |
| 83 |
// constructor |
| 84 |
explicit ML_Nox_MatrixfreeLevel(int level, int nlevel, int plevel, ML* ml, ML_Aggregate* ag, |
| 85 |
Epetra_CrsMatrix** P, ML_NOX::Ml_Nox_Fineinterface& interface, |
| 86 |
const Epetra_Comm& comm, const Epetra_Vector& xfine, |
| 87 |
double fd_alpha, double fd_beta, bool fd_centered, |
| 88 |
bool isDiagonalOnly, int bsize); |
| 89 |
|
| 90 |
// a reconstructor |
| 91 |
bool recreateLevel(int level, int nlevel, int plevel, ML* ml, ML_Aggregate* ag, |
| 92 |
Epetra_CrsMatrix** P, ML_NOX::Ml_Nox_Fineinterface& interface, |
| 93 |
const Epetra_Comm& comm, const Epetra_Vector& xfine); |
| 94 |
// destructor |
| 95 |
~ML_Nox_MatrixfreeLevel(); |
| 96 |
|
| 97 |
// return ptr to underlying Epetra_CrsMatrix |
| 98 |
Epetra_CrsMatrix* getunderlyingMatrix() { return A_; } |
| 99 |
|
| 100 |
// return ptr to coarse interface |
| 101 |
ML_NOX::Nox_CoarseProblem_Interface* getCoarseinterface() { return coarseinterface_; } |
| 102 |
|
| 103 |
// set the ptr to the P-hierarchy in the coarseinterface_ |
| 104 |
bool setP(Epetra_CrsMatrix** P) { if (coarseinterface_) return coarseinterface_->setP(P); |
| 105 |
else return false; } |
| 106 |
|
| 107 |
// destroy the P-hierarchy in the coarse interface |
| 108 |
bool destroyP() { if (coarseinterface_) return coarseinterface_->destroyP(); |
| 109 |
else return false; } |
| 110 |
|
| 111 |
private: |
| 112 |
// don't want copy-ctor and = operator |
| 113 |
ML_Nox_MatrixfreeLevel(ML_NOX::ML_Nox_MatrixfreeLevel& old); |
| 114 |
ML_Nox_MatrixfreeLevel operator = (const ML_NOX::ML_Nox_MatrixfreeLevel& old); |
| 115 |
|
| 116 |
// destroy the FD object |
| 117 |
bool destroyFD() { if (FD_) delete FD_; FD_ = 0; A_ = 0; graph_ = 0; return true;} |
| 118 |
// compare pointwise the global Indices in 2 graphs, returns false if not equal |
| 119 |
bool compare_graphs(const Epetra_CrsGraph* newgraph, const Epetra_CrsGraph* oldgraph); |
| 120 |
|
| 121 |
int level_; |
| 122 |
int nlevel_; |
| 123 |
int ml_printlevel_; |
| 124 |
ML* ml_; |
| 125 |
ML_Aggregate* ag_; |
| 126 |
ML_NOX::Ml_Nox_Fineinterface& fineinterface_; |
| 127 |
const Epetra_Comm& comm_; |
| 128 |
ML_NOX::Nox_CoarseProblem_Interface* coarseinterface_; |
| 129 |
Epetra_CrsGraph* graph_; |
| 130 |
Epetra_CrsMatrix* A_; |
| 131 |
//EpetraExt::CrsGraph_MapColoring* MapColoring_; |
| 132 |
Epetra_MapColoring* colorMap_; |
| 133 |
EpetraExt::CrsGraph_MapColoringIndex* colorMapIndex_; |
| 134 |
vector<Epetra_IntVector>* colorcolumns_; |
| 135 |
double fd_alpha_; // FiniteDifferencing parameters (for matrixfree only) |
| 136 |
double fd_beta_; |
| 137 |
bool fd_centered_; |
| 138 |
bool isDiagonalOnly_; |
| 139 |
int bsize_; |
| 140 |
#if 1 |
| 141 |
NOX::EpetraNew::FiniteDifferenceColoring* FD_; |
| 142 |
#else |
| 143 |
NOX::EpetraNew::FiniteDifference* FD_; |
| 144 |
#endif |
| 145 |
|
| 146 |
}; // class ML_Nox_MatrixfreeLevel |
| 147 |
} // namespace ML_NOX |
| 148 |
|
| 149 |
|
| 150 |
#endif // ML_NOX_MATRIXFREELEVEL_H |
| 151 |
#endif // defined(HAVE_ML_NOX) && defined(HAVE_ML_EPETRA) |