Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-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_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.26 $
40 //
41 // Revision Date : $Date: 2014/02/24 23:49:24 $
42 //
43 // Current Owner : $Author: tvrusso $
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 #include <N_IO_fwd.h>
58 #include <N_UTL_fwd.h>
59 #include <N_ANP_fwd.h>
60 
61 // ---------- NOX Includes ----------
62 
63 #include "N_NLS_NOX_Group.h" // base class
64 #include "LOCA_Abstract_Group.H" // base class
65 #include "LOCA_Parameter_Vector.H" // data member
66 #include "LOCA_DerivUtils.H" // data member
67 #include "N_LAS_Vector.h" // data member
68 #include "Teuchos_RefCountPtr.hpp" // data member
69 
70 // ---------- Forward Declarations ----------
71 
72 namespace N_NLS_NOX {
73  class Vector;
74  class SharedSystem;
75  class AugmentLinSys;
76 }
77 
78 namespace NOX {
79  namespace Abstract {
80  class Vector;
81  class Group;
82  }
83  namespace Parameter {
84  class List;
85  }
86 }
87 
88 class N_LOA_Loader;
89 class N_LAS_Matrix;
90 
91 // N_NLS_LOCA namespace is for all LOCA-related classes in the Xyce
92 // Nonlinear Solver Package
93 namespace N_NLS_LOCA {
94 
95 
96 //-----------------------------------------------------------------------------
97 // Class : N_NLS::LOCA::Group
98 //
99 // Purpose :
100 //
101 // NOX Group Interface for Xyce
102 //
103 // Creator : Roger Pawlowski, SNL, 9233
104 //
105 // Creation Date : 2/17/03
106 //-----------------------------------------------------------------------------
107 
108 class Group : public N_NLS_NOX::Group, public LOCA::Abstract::Group {
109 
110 public:
111 
112  //! Basic Constructor
113  Group(Teuchos::RefCountPtr<LOCA::GlobalData> globalData,
114  N_NLS_NOX::SharedSystem& s, N_LOA_Loader& l, N_IO_OutputMgr& o,
116 
117  //! Copy Constructor
118  Group(const Group& source, NOX::CopyType type = NOX::DeepCopy);
119 
120  //! Destructor
121  ~Group();
122 
123  //! Assignment Operator
124  NOX::Abstract::Group& operator=(const NOX::Abstract::Group& source);
125 
126  //! Assignment Operator
128 
129  //! Assignment Operator
130  LOCA::Abstract::Group& operator=(const LOCA::Abstract::Group& source);
131 
132  //! Assignment Operator
134 
135  //! Special LOCA assignment operator
136  void copy (const NOX::Abstract::Group &source);
137 
138  //! Cloning function
139  Teuchos::RefCountPtr<NOX::Abstract::Group>
140  clone(NOX::CopyType type = NOX::DeepCopy) const;
141 
142  //! Overloaded function evluation routine
143  NOX::Abstract::Group::ReturnType computeF();
144 
145  //! Overloaded Jacobian evaluation routine
146  NOX::Abstract::Group::ReturnType computeJacobian();
147 
148  void setParams(const LOCA::ParameterVector& p);
149 
150  const LOCA::ParameterVector& getParams() const;
151 
152  void setParam(int paramID, double value);
153 
154  double getParam(int paramID) const;
155 
156  void setParam(std::string paramID, double value);
157 
158  double getParam(std::string paramID) const;
159 
160  void setScaleVec(const NOX::Abstract::Vector& s);
161 
162  const NOX::Abstract::Vector& getScaleVec() const;
163 
164  NOX::Abstract::Group::ReturnType
165  augmentJacobianForHomotopy(double conParamValue);
166 
167  void printSolution (const double conParam) const;
168 
169  void printSolution (const NOX::Abstract::Vector &x,
170  const double conParam) const;
171 
172  void stepFailed ();
173  void stepSucceeded ();
174 
175  // Pseudo Transient methods
176  void setAugmentLinearSystem(bool enable,
177  const Teuchos::RefCountPtr<N_NLS_NOX::AugmentLinSys>& ls);
178 
179  // Continuation flag accessors
180  void setNonContinuationFlag (bool value);
181  bool getNonContinuationFlag ();
182 
183  // dcop restart functions
184  void setOutputLinear (Xyce::NodeNamePairMap * op,
185  Xyce::NodeNamePairMap * allNodes
186 #ifdef Xyce_PARALLEL_MPI
187  , N_PDS_Comm * pdsCommPtr);
188 #else
189  );
190 #endif
191 
192 private:
193 
194  // dcop restart data.
197  std::map<int, double> oldSol_;
198  Xyce::NodeNamePairMap *op_;
199  Xyce::NodeNamePairMap *allNodes_;
200 #ifdef Xyce_PARALLEL_MPI
201  N_PDS_Comm * pdsCommPtr_;
202 #endif
203 
204  // dcop restart function
205  void outputLinearSystem_ (N_LAS_Matrix* jacobian,
206  N_LAS_Vector* solution,
207  N_LAS_Vector* residual_vector);
208 
209  //! Keep a reference to the loader to set parameters.
210  N_LOA_Loader& loader;
211 
212  //! For output to a file we need xyce's output manager.
213  N_IO_OutputMgr& outputMgr;
214 
215  //! need xyce's time integration manager.
217 
218  //! Parameter vector container
219  LOCA::ParameterVector params;
220 
221  //! Utilities for computing derivatives
222  LOCA::DerivUtils derivUtils;
223 
224  //! Temporary vector used for homotopy calculation
225  N_LAS_Vector* tmpVectorPtr;
226 
227  //! LOCA Scaling Vector
228  const NOX::Abstract::Vector* scalingVecPtr;
229 
230  // Objects for Pseudo transient continuation
232  Teuchos::RefCountPtr<N_NLS_NOX::AugmentLinSys> augmentLSStrategy_;
233 
234  // Flag to indicate if this is a traditional newton solve or not.
236 
237 }; // class N_NLS_LOCA::Group
238 } // namespace N_NLS_LOCA
239 
240 #endif // Xyce_N_NLS_LOCA_Group_h
241