Xyce  6.1
N_NLS_LOCA_Group.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-2015 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_LOCA_Group.h,v $
27 //
28 // Purpose : Interface to Xyce for LOCA groups.
29 //
30 // Special Notes :
31 //
32 // Creator : Roger Pawlowski, NLS, 9233
33 //
34 // Creation Date : 02/17/03
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.41 $
40 //
41 // Revision Date : $Date: 2015/07/11 23:40:30 $
42 //
43 // Current Owner : $Author: erkeite $
44 //-------------------------------------------------------------------------
45 
46 #ifndef Xyce_N_NLS_LOCA_Group_h
47 #define Xyce_N_NLS_LOCA_Group_h
48 
49 // ---------- Standard Includes ----------
50 
51 // ---------- Xyce Includes ----------
52 
53 #ifdef Xyce_PARALLEL_MPI
54 #include "N_PDS_ParMap.h"
55 #include "N_PDS_ParComm.h"
56 #endif
57 
58 #include <N_ANP_fwd.h>
59 #include <N_IO_fwd.h>
60 #include <N_LAS_fwd.h>
61 #include <N_LOA_fwd.h>
62 #include <N_NLS_fwd.h>
63 #include <N_UTL_fwd.h>
64 
65 // ---------- NOX Includes ----------
66 
67 #include "N_NLS_NOX_Group.h" // base class
68 #include "LOCA_Abstract_Group.H" // base class
69 #include "LOCA_Parameter_Vector.H" // data member
70 #include "LOCA_DerivUtils.H" // data member
71 #include "N_LAS_Vector.h" // data member
72 #include "Teuchos_RCP.hpp" // data member
73 
74 namespace Xyce {
75 namespace Nonlinear {
76 namespace N_NLS_LOCA {
77 
78 //-----------------------------------------------------------------------------
79 // Class : N_NLS::LOCA::Group
80 //
81 // Purpose :
82 //
83 // NOX Group Interface for Xyce
84 //
85 // Creator : Roger Pawlowski, SNL, 9233
86 //
87 // Creation Date : 2/17/03
88 //-----------------------------------------------------------------------------
89 
90 class Group : public N_NLS_NOX::Group, public LOCA::Abstract::Group {
91 
92 public:
93 
94  //! Basic Constructor
95  Group(Teuchos::RCP<LOCA::GlobalData> globalData,
98 
99  //! Copy Constructor
100  Group(const Group& source, NOX::CopyType type = NOX::DeepCopy);
101 
102  //! Destructor
103  ~Group();
104 
105  //! Assignment Operator
106  NOX::Abstract::Group& operator=(const NOX::Abstract::Group& source);
107 
108  //! Assignment Operator
110 
111  //! Assignment Operator
112  LOCA::Abstract::Group& operator=(const LOCA::Abstract::Group& source);
113 
114  //! Assignment Operator
115  Group& operator=(const Group& source);
116 
117  //! Special LOCA assignment operator
118  void copy (const NOX::Abstract::Group &source);
119 
120  //! Cloning function
121  Teuchos::RCP<NOX::Abstract::Group>
122  clone(NOX::CopyType type = NOX::DeepCopy) const;
123 
124  //! Overloaded function evluation routine
125  NOX::Abstract::Group::ReturnType computeF();
126 
127  //! Overloaded Jacobian evaluation routine
128  NOX::Abstract::Group::ReturnType computeJacobian();
129 
130  //! Overloaded dfdp sensitivity calculation
131  NOX::Abstract::Group::ReturnType computeDfDpMulti (const std::vector< int > & paramIDs, NOX::Abstract::MultiVector & dfdp, bool isValidF);
132 
133  void setParams(const LOCA::ParameterVector& p);
134 
135  const LOCA::ParameterVector& getParams() const;
136 
137  void setParam(int paramID, double value);
138 
139  double getParam(int paramID) const;
140 
141  void setParam(std::string paramID, double value);
142 
143  double getParam(std::string paramID) const;
144 
145  void setScaleVec(const NOX::Abstract::Vector& s);
146 
147  const NOX::Abstract::Vector& getScaleVec() const;
148 
149  NOX::Abstract::Group::ReturnType
150  augmentJacobianForHomotopy(double conParamValue);
151 
152  void printSolution (const double conParam) const;
153 
154  void printSolution (const NOX::Abstract::Vector &x,
155  const double conParam) const;
156 
157  void preProcessContinuationStep(LOCA::Abstract::Iterator::StepStatus stepStatus);
158  void postProcessContinuationStep(LOCA::Abstract::Iterator::StepStatus stepStatus);
159 
160  // Pseudo Transient methods
161  void setAugmentLinearSystem(bool enable,
162  const Teuchos::RCP<N_NLS_NOX::AugmentLinSys>& ls);
163 
164  // Continuation flag accessors
165  void setNonContinuationFlag (bool value);
166  bool getNonContinuationFlag ();
167 
168  // dcop restart functions
169  void setOutputLinear (Xyce::NodeNameMap * op,
170  Xyce::NodeNameMap * allNodes,
171  N_PDS_Comm * pdsCommPtr);
172 
173 private:
174 
175  // dcop restart data.
178  std::map<int, double> oldSol_;
179  Xyce::NodeNameMap *op_;
180  Xyce::NodeNameMap *allNodes_;
181  N_PDS_Comm * pdsCommPtr_;
182 
183  // dcop restart function
184  void outputLinearSystem_ (Xyce::Linear::Matrix* jacobian,
185  Xyce::Linear::Vector* solution,
186  Xyce::Linear::Vector* residual_vector);
187 
188  //! Keep a reference to the loader to set parameters.
190 
191  //! For output to a file we need xyce's output manager.
192  Xyce::IO::OutputMgr& outputMgr;
193 
194  //! need xyce's time integration manager.
196 
197  //! Parameter vector container
198  LOCA::ParameterVector params;
199 
200  //! Utilities for computing derivatives
201  LOCA::DerivUtils derivUtils;
202 
203  //! Temporary vector used for homotopy calculation
204  Xyce::Linear::Vector* tmpVectorPtr;
205 
206  //! LOCA Scaling Vector
207  const NOX::Abstract::Vector* scalingVecPtr;
208 
209  // Objects for Pseudo transient continuation
211  Teuchos::RCP<N_NLS_NOX::AugmentLinSys> augmentLSStrategy_;
212 
213  // Flag to indicate if this is a traditional newton solve or not.
215 
216 };
217 
218 }}} // namespace N_NLS_LOCA
219 
220 #endif // Xyce_N_NLS_LOCA_Group_h
221 
NOX::Abstract::Group::ReturnType augmentJacobianForHomotopy(double conParamValue)
void preProcessContinuationStep(LOCA::Abstract::Iterator::StepStatus stepStatus)
NOX::Abstract::Group & operator=(const NOX::Abstract::Group &source)
Assignment Operator.
Pure virtual class to augment a linear system.
Teuchos::RCP< NOX::Abstract::Group > clone(NOX::CopyType type=NOX::DeepCopy) const
Cloning function.
Group(Teuchos::RCP< LOCA::GlobalData > globalData, N_NLS_NOX::SharedSystem &s, Xyce::Loader::NonlinearEquationLoader &l, Xyce::IO::OutputMgr &o, Xyce::Analysis::AnalysisManager &t)
Basic Constructor.
NOX::Abstract::Group::ReturnType computeDfDpMulti(const std::vector< int > &paramIDs, NOX::Abstract::MultiVector &dfdp, bool isValidF)
Overloaded dfdp sensitivity calculation.
Xyce::IO::OutputMgr & outputMgr
For output to a file we need xyce's output manager.
double getParam(int paramID) const
const T & value(const ParameterBase &entity, const Descriptor &descriptor)
Returns the value of the parameter for the entity.
Definition: N_DEV_Pars.h:1224
void setParam(int paramID, double value)
NOX::Abstract::Group::ReturnType computeJacobian()
Overloaded Jacobian evaluation routine.
void setOutputLinear(Xyce::NodeNameMap *op, Xyce::NodeNameMap *allNodes, N_PDS_Comm *pdsCommPtr)
void printSolution(const double conParam) const
void copy(const NOX::Abstract::Group &source)
Special LOCA assignment operator.
void setScaleVec(const NOX::Abstract::Vector &s)
void outputLinearSystem_(Xyce::Linear::Matrix *jacobian, Xyce::Linear::Vector *solution, Xyce::Linear::Vector *residual_vector)
Xyce::Loader::NonlinearEquationLoader & loader
Keep a reference to the loader to set parameters.
Teuchos::RCP< N_NLS_NOX::AugmentLinSys > augmentLSStrategy_
Xyce::Analysis::AnalysisManager & anaInt
need xyce's time integration manager.
const NOX::Abstract::Vector & getScaleVec() const
LOCA::DerivUtils derivUtils
Utilities for computing derivatives.
LOCA::ParameterVector params
Parameter vector container.
const NOX::Abstract::Vector * scalingVecPtr
LOCA Scaling Vector.
const LOCA::ParameterVector & getParams() const
NOX::Abstract::Group::ReturnType computeF()
Overloaded function evluation routine.
void postProcessContinuationStep(LOCA::Abstract::Iterator::StepStatus stepStatus)
void setAugmentLinearSystem(bool enable, const Teuchos::RCP< N_NLS_NOX::AugmentLinSys > &ls)
void setParams(const LOCA::ParameterVector &p)
Xyce::Linear::Vector * tmpVectorPtr
Temporary vector used for homotopy calculation.