Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_ANP_OutputMgrAdapter.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_ANP_OutputMgrAdapter.C,v $
27 //
28 // Purpose :
29 //
30 // Special Notes :
31 //
32 // Creator : Richard Schiek, SNL, Electrical and Microsystem Modeling
33 //
34 // Creation Date : 01/24/08
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.20.2.2 $
40 //
41 // Revision Date : $Date: 2014/08/25 20:12:48 $
42 //
43 // Current Owner : $Author: dgbaur $
44 //-----------------------------------------------------------------------------
45 #include <Xyce_config.h>
46 
47 #include <N_ANP_OutputMgrAdapter.h>
48 #include <N_IO_OutputMgr.h>
49 #include <N_IO_FourierMgr.h>
50 #include <N_IO_MeasureManager.h>
51 #include <N_IO_OutputROM.h>
52 #include <N_IO_OutputMOR.h>
53 #include <N_IO_OutputResults.h>
54 #include <N_IO_OutputResponse.h>
55 
56 namespace Xyce {
57 namespace Analysis {
58 
59 //-----------------------------------------------------------------------------
60 // Function : OutputMgrAdapter::OutputMgrAdapter( )
61 // Purpose : constructor
62 // Special Notes :
63 // Scope : public
64 // Creator :
65 // Creation Date :
66 //-----------------------------------------------------------------------------
68  Parallel::Machine comm,
69  Util::Notifier<StepEvent> & step_notifier)
70  : Util::ListenerAutoSubscribe<StepEvent>(step_notifier),
71  comm_(comm),
72  outputManager_(0),
73  measureManager_(0),
74  fourierManager_(0),
75  outputMOR_(0),
76  outputResults_(0),
77  outputResponse_(0),
78  emptyParamVector_(),
79  stepParamVector_(&emptyParamVector_),
80  dcParamVector_(),
81  stepAnalysisStepNumber_(0),
82  stepAnalysisMaxSteps_(0),
83  dcAnalysisStepNumber_(0),
84  dcAnalysisMaxSteps_(0)
85 {}
86 
88 {
89  delete outputMOR_;
90  delete outputResults_;
91 }
92 
93 
94 void
96  const StepEvent & event)
97 {
98  if (event.state_ == StepEvent::STEP_STARTED)
99  stepAnalysisStepNumber_ = event.count_;
100  else if (event.state_ == StepEvent::INITIALIZE)
101  stepAnalysisMaxSteps_ = event.count_;
102 }
103 
104 
105 void OutputMgrAdapter::addOutputResults(const Util::OptionBlock & option_block)
106 {
107  if (!outputResults_)
108  outputResults_ = new IO::OutputResults(outputManager_->getNetListFilename());
109 
110  outputResults_->addResultParams(option_block);
111 }
112 
113 void OutputMgrAdapter::addOutputResponse(const Util::OptionBlock & option_block)
114 {
115  if (!outputResponse_)
116  outputResponse_ = new IO::OutputResponse(*outputManager_);
117 }
118 
119 void
121  const std::vector<SweepParam> & paramVec)
122 {
123  stepParamVector_ = &paramVec;
124 }
125 
126 void
128  const std::vector<SweepParam> & paramVec)
129 {
130  dcParamVector_ = paramVec;
131 }
132 
133 void
135  double time,
136  N_LAS_Vector & currSolutionPtr,
137  N_LAS_Vector & stateVecPtr,
138  N_LAS_Vector & storeVecPtr,
139  std::vector<double> & objectiveVec_,
140  std::vector<double> & dOdpVec_,
141  std::vector<double> & dOdpAdjVec_,
142  std::vector<double> & scaled_dOdpVec_,
143  std::vector<double> & scaled_dOdpAdjVec_,
144  bool skipPrintLineOutput)
145 {
146  outputManager_->output(
149  currSolutionPtr, stateVecPtr, storeVecPtr, objectiveVec_,
150  dOdpVec_, dOdpAdjVec_, scaled_dOdpVec_, scaled_dOdpAdjVec_,
151  skipPrintLineOutput);
152 
153  if (outputResponse_) {
154  outputResponse_->saveResponseVarValues(comm_, time, currSolutionPtr);
155  outputResponse_->send(comm_,
156  &currSolutionPtr, 0, &stateVecPtr, &storeVecPtr,
157  &objectiveVec_, &dOdpVec_, &dOdpAdjVec_, &scaled_dOdpVec_, &scaled_dOdpAdjVec_);
158  }
159 }
160 
161 void
163  int dcStepNumber,
164  N_LAS_Vector & currSolutionPtr,
165  N_LAS_Vector & stateVecPtr,
166  N_LAS_Vector & storeVecPtr,
167  std::vector<double> & objectiveVec_,
168  std::vector<double> & dOdpVec_,
169  std::vector<double> & dOdpAdjVec_,
170  std::vector<double> & scaled_dOdpVec_,
171  std::vector<double> & scaled_dOdpAdjVec_)
172 {
173  outputManager_->output(
175  dcStepNumber, dcAnalysisMaxSteps_, dcParamVector_,
176  currSolutionPtr, stateVecPtr, storeVecPtr, objectiveVec_,
177  dOdpVec_, dOdpAdjVec_, scaled_dOdpVec_, scaled_dOdpAdjVec_);
178 
179  if (outputResponse_)
180  outputResponse_->saveResponseVarValues(comm_, 0.0, currSolutionPtr);
181 }
182 
183 
184 void
186  const N_LAS_Vector & currSolutionPtr,
187  const N_LAS_Vector & currStatePtr,
188  const N_LAS_Vector & currStorePtr)
189 {
190  if (!outputResults_)
191  outputResults_ = new IO::OutputResults(outputManager_->getNetListFilename());
192 
193  outputResults_->output(comm_, *outputManager_, outputManager_->getCircuitTime(), *stepParamVector_, stepAnalysisStepNumber_, currSolutionPtr, currStatePtr, currStorePtr);
194 }
195 
196 void
198 {
199  outputManager_->steppingComplete();
200  if (outputResults_)
201  outputResults_->steppingComplete();
202 }
203 
204 void
206 {
207  outputManager_->finishOutput();
208 }
209 
210 bool
212  N_LAS_Vector & solnVec,
213  N_LAS_Vector & flagVec)
214 {
215  return outputManager_->setupInitialConditions(comm_, solnVec, flagVec);
216 }
217 
218 void
220  const N_LAS_Vector & solution)
221 {
222  outputManager_->outputDCOP(comm_, solution);
223 }
224 
225 
226 void
228  double time,
229  const std::vector<double> & fast_time_points,
230  const N_LAS_Vector & solution_vector)
231 {
232  outputManager_->outputMPDE(comm_, time, fast_time_points, solution_vector);
233 }
234 
235 void
237  const std::vector< double > & timePoints,
238  const std::vector< double > & freqPoints,
239  const N_LAS_BlockVector & timeDomainSolutionVec,
240  const N_LAS_BlockVector & freqDomainSolutionVecReal,
241  const N_LAS_BlockVector & freqDomainSolutionVecImaginary,
242  const N_LAS_BlockVector & timeDomainStoreVec,
243  const N_LAS_BlockVector & freqDomainStoreVecReal,
244  const N_LAS_BlockVector & freqDomainStoreVecImaginary)
245 {
246  outputManager_->outputHB(
247  comm_,
249  timePoints, freqPoints,
250  timeDomainSolutionVec, freqDomainSolutionVecReal, freqDomainSolutionVecImaginary,
251  timeDomainStoreVec, freqDomainStoreVecReal, freqDomainStoreVecImaginary);
252 }
253 
254 void
256  double freq,
257  const N_LAS_Vector & solnVecRealPtr,
258  const N_LAS_Vector & solnVecImaginaryPtr)
259 {
260  outputManager_->outputAC(comm_, freq, solnVecRealPtr, solnVecImaginaryPtr);
261 }
262 
263 void
265  bool origSys,
266  double freq,
267  const Teuchos::SerialDenseMatrix<int, std::complex<double> >& H )
268 {
269  if (!outputMOR_)
270  outputMOR_ = new IO::OutputMOR(outputManager_->getNetListFilename());
271 
272  outputMOR_->output(comm_, origSys, freq, H );
273 }
274 
275 void
277 {
278  if (!outputMOR_)
279  outputMOR_ = new IO::OutputMOR(outputManager_->getNetListFilename());
280 
281  outputMOR_->reset();
282 }
283 
284 void
286  const Teuchos::SerialDenseMatrix<int, double> & Ghat,
287  const Teuchos::SerialDenseMatrix<int, double> & Chat,
288  const Teuchos::SerialDenseMatrix<int, double> & Bhat,
289  const Teuchos::SerialDenseMatrix<int, double> & Lhat )
290 {
291  IO::outputROM(comm_, outputManager_->getNetListFilename(), Ghat, Chat, Bhat, Lhat );
292 }
293 
294 void
296  const N_LAS_Matrix & Ghat,
297  const N_LAS_Matrix & Chat,
298  const Teuchos::SerialDenseMatrix<int, double> & Bhat,
299  const Teuchos::SerialDenseMatrix<int, double> & Lhat )
300 {
301  IO::outputROM(comm_, outputManager_->getNetListFilename(), Ghat, Chat, Bhat, Lhat );
302 }
303 
304 bool
306  double & initialInterval,
307  std::vector<std::pair< double, double > > * intervalPairs) const
308 {
309  return outputManager_->getOutputIntervals( initialInterval, *intervalPairs );
310 }
311 
312 
313 void
315  const std::vector<std::string> & paramNames,
316  const std::vector<double> & paramVals,
317  N_LAS_Vector & solnVecPtr )
318 {
319  outputManager_->outputHomotopy (comm_, paramNames, paramVals, solnVecPtr);
320 }
321 
322 const Xyce::NodeNamePairMap &
324 {
325  return outputManager_->getAllNodes();
326 }
327 
328 } // namespace Analysis
329 } // namespace Xyce