Debian Codegraph @

packages/trilinoscouplings/src/ml/NonlinML/ml_nox_coarse_prepostoperator.cpp

raw
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 // ---------- Includes ----------
21 #include <ctime>
22 #include <iostream>
23 #include "ml_nox_coarse_prepostoperator.H"
24
25 /*----------------------------------------------------------------------*
26 | ctor (public) m.gee 10/05|
27 *----------------------------------------------------------------------*/
28 ML_NOX::Ml_Nox_CoarsePrePostOperator::Ml_Nox_CoarsePrePostOperator(
29 ML_NOX::Nox_CoarseProblem_Interface& coarseinterface,
30 ML_NOX::Ml_Nox_Fineinterface& fineinterface) :
31 coarseinterface_(coarseinterface),
32 fineinterface_(fineinterface)
33 {
34 type_ = "Ml_Nox_CoarsePrePostOperator";
35 return;
36 }
37
38 /*----------------------------------------------------------------------*
39 | copy-ctor (public) m.gee 10/05|
40 *----------------------------------------------------------------------*/
41 ML_NOX::Ml_Nox_CoarsePrePostOperator::Ml_Nox_CoarsePrePostOperator(const ML_NOX::Ml_Nox_CoarsePrePostOperator& source) :
42 coarseinterface_(source.coarseinterface_),
43 fineinterface_(source.fineinterface_)
44 {
45 type_ = source.type_;
46 return;
47 }
48
49 /*----------------------------------------------------------------------*
50 | clone (public) m.gee 10/05|
51 *----------------------------------------------------------------------*/
52 NOX::Parameter::Arbitrary* ML_NOX::Ml_Nox_CoarsePrePostOperator::clone() const
53 {
54 ML_NOX::Ml_Nox_CoarsePrePostOperator* tmp
55 = new ML_NOX::Ml_Nox_CoarsePrePostOperator(*this);
56 return tmp;
57 }
58
59 /*----------------------------------------------------------------------*
60 | dtor (public) m.gee 10/05|
61 *----------------------------------------------------------------------*/
62 ML_NOX::Ml_Nox_CoarsePrePostOperator::~Ml_Nox_CoarsePrePostOperator()
63 {
64 return;
65 }
66
67 /*----------------------------------------------------------------------*
68 | (public) m.gee 10/05|
69 *----------------------------------------------------------------------*/
70 void ML_NOX::Ml_Nox_CoarsePrePostOperator::runPreSolve(const NOX::Solver::Generic& solver)
71 {
72 #if 0
73 cout << "Ml_Nox_CoarsePrePostOperator::runPreSolve called\n";
74
75 // get the current solution out of the solver
76 NOX::Abstract::Group& solgroup = const_cast<NOX::Abstract::Group&>(solver.getSolutionGroup());
77 const NOX::Epetra::Vector* noxsolution =
78 dynamic_cast<const NOX::Epetra::Vector*>(&solgroup.getX());
79 Epetra_Vector& epetrasolution = const_cast<Epetra_Vector&>(noxsolution->getEpetraVector());
80
81 #if 1 // this is expensive and might be removed
82 // test whether we habe a level 0 (fine level) vector here
83 if (!epetrasolution.Map().PointSameAs(fineinterface_.getMap()))
84 {
85 cout << "**ERR**: Ml_Nox_CoarsePrePostOperator::runPreSolve:\n";
86 cout << "**ERR**: incoming vector map does not match fine interface.Map()\n";
87 cout << "**ERR**: file/line: " << __FILE__ << "(" << __LINE__ << ")\n"; throw -1;
88 }
89 #endif
90
91 // make the application apply its constraints to this vector
92 fineinterface_.ApplyAllConstraints(epetrasolution);
93
94 // put the vector back into the solver
95 solgroup = const_cast<NOX::Abstract::Group&>(solver.getSolutionGroup());
96 noxsolution = dynamic_cast<const NOX::Epetra::Vector*>(&solgroup.getX());
97 Epetra_Vector& epetrasolutionnew = const_cast<Epetra_Vector&>(noxsolution->getEpetraVector());
98
99 epetrasolutionnew.Scale(1.0,epetrasolution);
100
101 #endif
102 return;
103 }
104 /*----------------------------------------------------------------------*
105 | (public) m.gee 10/05|
106 *----------------------------------------------------------------------*/
107 void ML_NOX::Ml_Nox_CoarsePrePostOperator::runPostSolve(const NOX::Solver::Generic& solver)
108 {
109 #if 0
110 cout << "Ml_Nox_CoarsePrePostOperator::runPostSolve called\n";
111 #endif
112 return;
113 }
114
115 /*----------------------------------------------------------------------*
116 | (public) m.gee 10/05|
117 *----------------------------------------------------------------------*/
118 void ML_NOX::Ml_Nox_CoarsePrePostOperator::runPreIterate(const NOX::Solver::Generic& solver)
119 {
120 #if 0
121 cout << "Ml_Nox_CoarsePrePostOperator::runPreIterate called\n";
122 #endif
123 return;
124 }
125
126 /*----------------------------------------------------------------------*
127 | (public) m.gee 10/05|
128 *----------------------------------------------------------------------*/
129 void ML_NOX::Ml_Nox_CoarsePrePostOperator::runPostIterate(const NOX::Solver::Generic& solver)
130 {
131 #if 0
132 cout << "Ml_Nox_CoarsePrePostOperator::runPostIterate called\n";
133 #endif
134 return;
135 }
136
137
138 #endif // defined(HAVE_ML_NOX) && defined(HAVE_ML_EPETRA)