Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_NLS_NOX_AugmentLinSys_PseudoTransient.C
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_AugmentLinSys_PseudoTransient.C,v $
27 //
28 // Purpose : Algorithm for augmenting the Jacobian for pseudo
29 // transient solves.
30 //
31 // Special Notes :
32 //
33 // Creator : Roger Pawlowski, SNL 9233
34 //
35 // Creation Date : 03/07/06
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.8 $
41 //
42 // Revision Date : $Date: 2014/02/24 23:49:25 $
43 //
44 // Current Owner : $Author: tvrusso $
45 //-------------------------------------------------------------------------
46 
47 #include <Xyce_config.h>
48 
49 
50 // ---------- Standard Includes ----------
51 
52 // ---------- Xyce Includes ----------
53 
54 #include "N_LAS_Vector.h"
55 #include "N_LAS_Matrix.h"
56 #include "Epetra_MapColoring.h"
58 
59 
60 //-----------------------------------------------------------------------------
61 // Function : N_NLS_NOX::AugmentLinSysPseudoTransient::AugmentLinSysPseudoTransient
62 // Purpose : constructor
63 // Special Notes :
64 // Scope : public
65 // Creator : Roger Pawlowski, SNL 9233
66 // Creation Date :
67 //-----------------------------------------------------------------------------
69  (const Teuchos::RefCountPtr<Epetra_MapColoring>&
70  color_map,
71  N_LAS_Vector* cloneVector,
72  bool useVoltageScaleFactor,
73  double voltageScaleFactor)
74 {
75  use_voltage_scale_factor_ = useVoltageScaleFactor;
76  voltage_scale_factor_ = voltageScaleFactor;
77  color_map_ = color_map;
78  tmp_vector_ptr_ = new N_LAS_Vector(*cloneVector);
79 }
80 
81 //-----------------------------------------------------------------------------
82 // Function : N_NLS_NOX::AugmentLinSysPseudoTransient::~AugmentLinSysPseudoTransient
83 // Purpose : destructor
84 // Special Notes :
85 // Scope : public
86 // Creator : Roger Pawlowski, SNL 9233
87 // Creation Date :
88 //-----------------------------------------------------------------------------
90 {
91  delete tmp_vector_ptr_;
92 }
93 
94 
95 //-----------------------------------------------------------------------------
96 // Function : N_NLS_NOX::AugmentLinSysPseudoTransient::setProgressVariable
97 // Purpose :
98 // Special Notes :
99 // Scope : public
100 // Creator : Roger Pawlowski, SNL 9233
101 // Creation Date :
102 //-----------------------------------------------------------------------------
104  (double time_step_size)
105 {
106  time_step_size_ = time_step_size;
107 }
108 
109 //-----------------------------------------------------------------------------
110 // Function : N_NLS_NOX::AugmentLinSysPseudoTransient::augmentResidual
111 // Purpose :
112 // Special Notes : no-op for pseudo-transient.
113 // Scope : public
114 // Creator : Roger Pawlowski, SNL 9233
115 // Creation Date :
116 //-----------------------------------------------------------------------------
118  (const N_LAS_Vector * solution, N_LAS_Vector * residual_vector)
119 {
120  // Nothing to do for pseudo transient!!
121 }
122 
123 //-----------------------------------------------------------------------------
124 // Function : N_NLS_NOX::AugmentLinSysPseudoTransient::augmentJacobian
125 // Purpose :
126 // Special Notes :
127 // Scope : public
128 // Creator : Roger Pawlowski, SNL 9233
129 // Creation Date :
130 //-----------------------------------------------------------------------------
132  (N_LAS_Matrix * jacobian)
133 {
134  //cout << "Augmenting Jacobian for Pseudo Transient" << endl;
135  //cout << "Pseudo Trans Step Size = " << pseudoTransientTimeStep_ << endl;
136 
137  //color_map_->Print(cout);
138 
139  //jacobian->printPetraObject();
140 
141  //jacobian->scale(conParamValue);
142 
143  jacobian->getDiagonal(*tmp_vector_ptr_);
144 
145  //tmp_vector_ptr_->printPetraObject();
146 
147  double value = 1.0 / time_step_size_;
148 
149  //cout << "Pseudo Transient Time Step Size = " << time_step_size_ << endl;
150 
151  if (!use_voltage_scale_factor_)
152  {
153  tmp_vector_ptr_->addScalar(value);
154  }
155  else
156  {
157  for (std::size_t i = 0; i < tmp_vector_ptr_->localLength(); ++i)
158  {
159  if ( (*color_map_)[i] == 0)
160  {
161  (*tmp_vector_ptr_)[i] += value * voltage_scale_factor_;
162  }
163  else
164  {
165  (*tmp_vector_ptr_)[i] += value;
166  }
167  }
168  //RPP Might need to export local values for tmp_vector_ptr_ here
169  //for parallel.
170  }
171 
172  jacobian->replaceDiagonal(*tmp_vector_ptr_);
173 
174  //jacobian->printPetraObject();
175 
176  //cout << "Time step size = " << time_step_size_ << endl;
177 
178  //if (use_voltage_scale_factor_)
179  //cout << "Voltage scale factor = " << voltage_scale_factor_ << endl;
180 }
181