Debian Codegraph @

packages/nox/test/epetra/MultiPhysics/NOX_Epetra_SchurOperator.C

raw
1 // @HEADER
2 // *****************************************************************************
3 // NOX: An Object-Oriented Nonlinear Solver Package
4 //
5 // Copyright 2002 NTESS and the NOX contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9
10 #include "NOX_Epetra_SchurOperator.H"
11 #include "Problem_Manager.H"
12
13 using namespace NOX;
14 using namespace NOX::Epetra;
15
16 SchurOp::SchurOp( int probId_, int depId_, SchurInterface & interface_) :
17 schurInterface(interface_),
18 probId(probId_),
19 depId(depId_),
20 label("Schur-Coupling Operator")
21 {
22 }
23
24 //-----------------------------------------------------------------------------
25
26 SchurOp::~SchurOp()
27 {
28 }
29
30 //-----------------------------------------------------------------------------
31
32 int
33 SchurOp::SetUseTranspose( bool UseTranspose )
34 {
35 if (UseTranspose == true)
36 {
37 std::string msg = "ERROR: NOX::Epetra::SchurOp::SetUseTranspose() - Transpose is unavailable for this operator!";
38 throw msg;
39 }
40 return (-1);
41 }
42
43 //-----------------------------------------------------------------------------
44
45 int
46 SchurOp::Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const
47 {
48 //Problem_Manager & problemManager = dynamic_cast<Problem_Manager&>(schurInterface);
49
50 // Convert X and Y from an Epetra_MultiVectors to Epetra_Vectors
51 // and NOX::Epetra::Vectors. This is done so we use a consistent
52 // vector space for norms and inner products.
53 Teuchos::RCP<Epetra_Vector> wrappedX = Teuchos::rcp(new Epetra_Vector(View, X, 0));
54 Teuchos::RCP<Epetra_Vector> wrappedY = Teuchos::rcp(new Epetra_Vector(View, Y, 0));
55 Teuchos::RCP<Epetra_Vector> tempX = Teuchos::rcp(new Epetra_Vector(*wrappedX) );
56 Teuchos::RCP<Epetra_Vector> tempY = Teuchos::rcp(new Epetra_Vector(*wrappedY) );
57
58 // The substance of this operator ----- to do RWH 10/24/2006
59
60 //cout << "Incoming X :\n" << *wrappedX << std::endl;
61 //problemManager.applyBlockAction( depId, probId, *wrappedX, *tempY);
62 schurInterface.applyBlockAction( depId, probId, *wrappedX, *tempY );
63 //cout << "After applyBlockAction(" << depId << ", " << probId << ") :\n" << *tempY << std::endl;
64 //problemManager.getBlockInverseOperator(depId)->ApplyInverse(*tempY, *tempY);
65 schurInterface.applyBlockInverseAction( depId, depId, *tempY, *tempY );
66 //cout << "After ApplyInverse :\n" << *tempY << std::endl;
67 //problemManager.applyBlockAction( probId, depId, *tempY, *tempX);
68 schurInterface.applyBlockAction( probId, depId, *tempY, *tempX );
69 //cout << "After applyBlockAction(" << probId << ", " << depId << ") :\n" << *tempX << std::endl;
70
71 //problemManager.getBlockJacobianMatrix(probId)->Apply(*wrappedX, *wrappedY);
72 schurInterface.applyBlockAction( probId, probId, *wrappedX, *wrappedY );
73 //cout << "After Apply of diagonal block :\n" << *wrappedY << std::endl;
74 wrappedY->Update(-1.0, *tempX, 1.0);
75 //cout << "After combingin; final result :\n" << *wrappedY << std::endl;
76
77 return (0);
78 }
79
80 //-----------------------------------------------------------------------------
81
82 int
83 SchurOp::ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const
84 {
85 std::cout << "ERROR: NOX::Epetra::SchurOp::ApplyInverse() - Not valid "
86 << "for this operator!" << std::endl;
87 throw std::runtime_error("NOX Error");
88
89 return (-1);
90 }
91
92 //-----------------------------------------------------------------------------
93
94 double
95 SchurOp::NormInf() const
96 {
97 std::cout << "ERROR: NOX::Epetra::SchurOp::NormInf() - Not Available for "
98 << "this operator!" << std::endl;
99 throw std::runtime_error("NOX Error");
100
101 return 1.0;
102 }
103
104 //-----------------------------------------------------------------------------
105
106 const char*
107 SchurOp::Label () const
108 {
109 return label.c_str();
110 }
111
112 //-----------------------------------------------------------------------------
113
114 bool
115 SchurOp::UseTranspose() const
116 {
117 return false;
118 }
119
120 //-----------------------------------------------------------------------------
121
122 bool
123 SchurOp::HasNormInf() const
124 {
125 return false;
126 }
127
128 //-----------------------------------------------------------------------------
129
130 const Epetra_Comm &
131 SchurOp::Comm() const
132 {
133
134 return schurInterface.getComm();
135 }
136
137 //-----------------------------------------------------------------------------
138
139 const Epetra_Map &
140 SchurOp::OperatorDomainMap() const
141 {
142 //Problem_Manager & problemManager = dynamic_cast<Problem_Manager&>(schurInterface);
143
144 //return problemManager.getBlockJacobianMatrix(probId)->OperatorDomainMap();
145
146 if( !schurInterface.hasExplicitOperator( probId, probId ) )
147 throw "ERROR: NOX::Epetra::SchurOp::OperatorDomainMap() - No available explicit operator for this block.";
148
149 return schurInterface.getExplicitOperator(probId, probId)->OperatorDomainMap();
150 }
151
152 //-----------------------------------------------------------------------------
153
154 const Epetra_Map &
155 SchurOp::OperatorRangeMap() const
156 {
157 //Problem_Manager & problemManager = dynamic_cast<Problem_Manager&>(schurInterface);
158
159 //return problemManager.getBlockJacobianMatrix(probId)->OperatorRangeMap();
160 if( !schurInterface.hasExplicitOperator( probId, probId ) )
161 throw "ERROR: NOX::Epetra::SchurOp::OperatorRangeMap() - No available explicit operator for this block.";
162
163 return schurInterface.getExplicitOperator(probId, probId)->OperatorRangeMap();
164 }
165
166 //-----------------------------------------------------------------------------
167
168 void
169 SchurOp::modifyRHS( Teuchos::RCP<Epetra_Vector> & probVec, Teuchos::RCP<Epetra_Vector> & depVec )
170 {
171 //Problem_Manager & problemManager = dynamic_cast<Problem_Manager&>(schurInterface);
172
173 Teuchos::RCP<Epetra_Vector> tempX = Teuchos::rcp( new Epetra_Vector(*probVec) );
174 Teuchos::RCP<Epetra_Vector> tempY = Teuchos::rcp( new Epetra_Vector(*depVec ) );
175
176 //problemManager.getBlockInverseOperator(depId)->ApplyInverse(*depVec, *tempY);
177 //problemManager.applyBlockAction( probId, depId, *tempY, *tempX);
178 schurInterface.applyBlockInverseAction( depId, depId, *depVec, *tempY );
179 schurInterface.applyBlockAction( probId, depId, *tempY, *tempX);
180
181 probVec->Update(-1.0, *tempX, 1.0);
182
183 return;
184 }
185
186 //-----------------------------------------------------------------------------
187