Xyce
6.1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
N_NLS_NOX_SharedSystem.h
Go to the documentation of this file.
1
//-----------------------------------------------------------------------------
2
// Copyright Notice
3
//
4
// Copyright 2002 Sandia Corporation. Under the terms
5
// of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
6
// Government retains certain rights in this software.
7
//
8
// Xyce(TM) Parallel Electrical Simulator
9
// Copyright (C) 2002-2014 Sandia Corporation
10
//
11
// This program is free software: you can redistribute it and/or modify
12
// it under the terms of the GNU General Public License as published by
13
// the Free Software Foundation, either version 3 of the License, or
14
// (at your option) any later version.
15
//
16
// This program is distributed in the hope that it will be useful,
17
// but WITHOUT ANY WARRANTY; without even the implied warranty of
18
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
// GNU General Public License for more details.
20
//
21
// You should have received a copy of the GNU General Public License
22
// along with this program. If not, see <http://www.gnu.org/licenses/>.
23
//-----------------------------------------------------------------------------
24
25
//-------------------------------------------------------------------------
26
// Filename : $RCSfile: N_NLS_NOX_SharedSystem.h,v $
27
//
28
// Purpose : Interface to let multiple N_NLS::NOX::Group's
29
// share a single system of RHS Vector, Jacobian
30
// matrix, Newton vector, and gradient vector.
31
// Closely related to the NOX::Epetra::SharedSystem
32
// class.
33
//
34
// Special Notes :
35
//
36
// Creator : Tammy Kolda, NLS, 8950
37
//
38
// Creation Date : 01/31/02
39
//
40
// Revision Information:
41
// ---------------------
42
//
43
// Revision Number: $Revision: 1.24 $
44
//
45
// Revision Date : $Date: 2014/02/24 23:49:24 $
46
//
47
// Current Owner : $Author: tvrusso $
48
//-------------------------------------------------------------------------
49
50
#ifndef Xyce_N_NLS_NOX_SharedSystem_h
51
#define Xyce_N_NLS_NOX_SharedSystem_h
52
53
// ---------- Standard Includes ----------
54
55
// ---------- Xyce Includes ----------
56
57
// ---------- NOX Includes ----------
58
59
#include "
N_NLS_NOX_Vector.h
"
60
#include "
N_NLS_NOX_Group.h
"
61
62
// ---------- Forward Declarations ----------
63
64
class
N_LAS_Vector;
65
class
N_LAS_Matrix;
66
class
Ifpack_IlukGraph;
67
class
Ifpack_CrsRiluk;
68
69
namespace
N_NLS_NOX {
70
class
Interface;
71
}
72
73
namespace
NOX {
74
namespace
Parameter {
75
class
List;
76
}
77
}
78
79
//-----------------------------------------------------------------------------
80
// Class : N_NLS::NOX::SharedSystem
81
//
82
// Purpose :
83
//
84
// Interface to let multiple N_NLS::NOX::Group's share the
85
// vectors and matrices in the Xyce nonlinear solver.
86
//
87
// Closely related conceptually to the
88
// NOX::Epetra::SharedJacobian class.
89
//
90
// Creator : Tammy Kolda, SNL, 8950
91
//
92
// Creation Date : 1/31/02
93
//-----------------------------------------------------------------------------
94
95
namespace
N_NLS_NOX {
96
class
SharedSystem
{
97
98
public
:
99
100
//---------------------------------------------------------------------------
101
// Function : SharedSystem
102
// Purpose : Constructor. Creates a shared system containing
103
// the soln vector, the previous solution vector,
104
// the RHS vector, the Newton vector, the Jacobian
105
// matrix, and a reference to the interface used to
106
// call the evaluation functions.
107
//---------------------------------------------------------------------------
108
SharedSystem
(N_LAS_Vector& x,
109
N_LAS_Vector& f,
110
N_LAS_Matrix& jacobian,
111
N_LAS_Vector& newton,
112
N_LAS_Vector& gradient,
113
N_LAS_System& lasSys,
114
N_NLS_NOX::Interface
& interface);
115
116
//---------------------------------------------------------------------------
117
// Function : ~SharedSystem
118
// Purpose : Destructor.
119
//---------------------------------------------------------------------------
120
~SharedSystem
();
121
122
123
//---------------------------------------------------------------------------
124
// Function : reset
125
// Purpose : reset the Xyce fill objects - pointers may have changed!
126
//---------------------------------------------------------------------------
127
void
reset
(N_LAS_Vector& x,
128
N_LAS_Vector& f,
129
N_LAS_Matrix& jacobian,
130
N_LAS_Vector& newton,
131
N_LAS_Vector& gradient,
132
N_LAS_System& lasSys,
133
N_NLS_NOX::Interface
& interface);
134
135
//---------------------------------------------------------------------------
136
// Function : isJacobianOwner
137
// Purpose : Verify that the group pointed to by grp is owner of the
138
// Jacobian matrix.
139
//---------------------------------------------------------------------------
140
inline
bool
isJacobianOwner
(
const
Group
* grp)
const
141
{
142
return
(grp ==
ownerOfJacobian_
);
143
};
144
145
//---------------------------------------------------------------------------
146
// Function : areStateVectors
147
// Purpose : To compute a Jacobian, the state vectors must be
148
// updated with respect to the solution in the group.
149
// However, the state vectors are updated ONLY during
150
// calls to compute the residual. This method checks
151
// to see if the state vectors still correspond to this
152
// group. Returns true if state vectors are correct.
153
//---------------------------------------------------------------------------
154
inline
bool
areStateVectors
(
const
Group
* grp)
const
155
{
156
return
(grp ==
ownerOfStateVectors_
);
157
};
158
159
//---------------------------------------------------------------------------
160
// Function : computeF
161
// Purpose : Compute the F corresponding to the current
162
// primary solution vector. Makes the primary
163
// solution vector owner in to the owner of the F.
164
//---------------------------------------------------------------------------
165
bool
computeF
(
const
Vector
& solution,
Vector
& F,
const
Group
* grp);
166
167
//---------------------------------------------------------------------------
168
// Function : computeJacobian
169
// Purpose : Compute the Jacobian corresponding to the current
170
// primary solution vector.
171
//---------------------------------------------------------------------------
172
bool
computeJacobian
(
Group
* grp);
173
174
//---------------------------------------------------------------------------
175
// Function : computeNewton
176
// Purpose : Compute the Newton corresponding to the current
177
// primary solution vector.
178
//---------------------------------------------------------------------------
179
bool
computeNewton
(
const
Vector
& F,
Vector
& Newton,
180
Teuchos::ParameterList& params);
181
182
//---------------------------------------------------------------------------
183
// Function : computeGradient
184
// Purpose : Compute the Gradient corresponding to the current
185
// primary solution vector.
186
//---------------------------------------------------------------------------
187
bool
computeGradient
(
const
Vector
& F,
Vector
& Gradient);
188
189
bool
applyJacobian
(
const
Vector
& input,
Vector
& result)
const
;
190
191
bool
applyJacobianTranspose
(
const
Vector
& input,
Vector
& result)
const
;
192
193
N_NLS_NOX::Vector
&
getSolutionVector
();
194
195
// Take ownership of const Jacobian.
196
const
N_LAS_Matrix&
getJacobian
()
const
;
197
198
// Take ownership of Jacobian and get a reference to it.
199
N_LAS_Matrix&
getJacobian
(
const
Group
* grp);
200
201
// Take ownership of the state vectors.
202
void
getStateVectors
(
const
Group
* grp);
203
204
// Get a pointer to the N_LAS_System object
205
N_LAS_System*
getLasSystem
();
206
207
#ifdef Xyce_DEBUG_NONLINEAR
208
// Use for debugging (corresponding to the ones in N_NLS_NonLinearSolver).
209
void
debugOutput1 (N_LAS_Matrix & jacobian, N_LAS_Vector & rhs);
210
void
debugOutput3 (N_LAS_Vector & dxVector, N_LAS_Vector & xVector);
211
#endif
212
213
// Preconditioning objects for the Group::applyRightPreconditioning method
214
bool
computePreconditioner
();
215
bool
deletePreconditioner
();
216
bool
applyRightPreconditioning
(
bool
useTranspose,
217
Teuchos::ParameterList& params,
218
const
Vector
& input,
219
Vector
& result);
220
221
// This is used to construct vectors in the group. We used to
222
// clone a time integrator vector but when the DC Op point fails,
223
// somewhere (I have no idea where) it decides to delete vectors
224
// before the Nonlinear solver can delete theirs. This causes
225
// a seg fault.
226
//
227
N_NLS_NOX::Vector
*
cloneSolutionVector
()
const
;
228
229
// Take ownership of const newton vector
230
const
N_NLS_NOX::Vector
&
getNewtonVector
()
const
;
231
232
void
printSoln
(std::ostream &os) {
xyceSolnPtr_
->
print
(os);}
233
void
printRes
(std::ostream &os) {
xyceFPtr_
->
print
(os);}
234
235
private
:
236
237
// Views of xyce objects used in the fill
238
Vector
*
xyceSolnPtr_
;
// Solution vector
239
Vector
*
xyceFPtr_
;
// Residual Vector
240
N_LAS_Matrix*
xyceJacobianPtr_
;
// Jacobian matrix
241
Vector
*
xyceNewtonPtr_
;
// Newton Vector
242
Vector
*
xyceGradientPtr_
;
// gradient Vector
243
N_LAS_System*
xyceLasSysPtr_
;
// LAS System
244
N_NLS_NOX::Interface
*
xyceInterfacePtr_
;
// Nonlinear Solver Interface
245
246
// Flag for Matrix Free Loads tscoffe/tmei 07/29/08
247
bool
matrixFreeFlag_
;
248
249
const
Group
*
ownerOfJacobian_
;
250
const
Group
*
ownerOfStateVectors_
;
251
252
// Ifpack preconditioning objects for applyRightPreconditioning method
253
mutable
Ifpack_IlukGraph*
ifpackGraphPtr_
;
254
mutable
Ifpack_CrsRiluk*
ifpackPreconditionerPtr_
;
255
256
};
// class SharedSystem
257
}
// namespace N_NLS_NOX
258
259
#endif // Xyce_N_NLS_NOX_SharedSystem_h
260
src
NonlinearSolverPKG
include
N_NLS_NOX_SharedSystem.h
Generated on Mon Mar 24 2014 10:54:40 for Xyce by
1.8.3.1