| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// LOCA: Library of Continuation Algorithms Package |
| 4 |
// |
| 5 |
// Copyright 2001-2005 NTESS and the LOCA contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
#include "LOCAInterface.H" |
| 11 |
|
| 12 |
LOCAInterface:: |
| 13 |
LOCAInterface( Teuchos::RCP <ProblemLOCAPrototype> & aProblem , |
| 14 |
Teuchos::RCP <ContinuationManager> aContinuationManager): |
| 15 |
continuationManager(aContinuationManager), |
| 16 |
problem(aProblem), |
| 17 |
t(0.0) |
| 18 |
{ |
| 19 |
} |
| 20 |
|
| 21 |
LOCAInterface:: |
| 22 |
~LOCAInterface() |
| 23 |
{ |
| 24 |
} |
| 25 |
|
| 26 |
bool LOCAInterface:: |
| 27 |
computeF(const Epetra_Vector& x, Epetra_Vector& f, |
| 28 |
const NOX::Epetra::Interface::Required::FillType /* F */) |
| 29 |
{ |
| 30 |
problem->ComputeF(x,f); |
| 31 |
return true; |
| 32 |
} |
| 33 |
|
| 34 |
bool LOCAInterface:: |
| 35 |
computeJacobian(const Epetra_Vector& x, Epetra_Operator& /* Jac */) |
| 36 |
{ |
| 37 |
problem->ComputeJacF(x); |
| 38 |
return true; |
| 39 |
} |
| 40 |
|
| 41 |
void LOCAInterface:: |
| 42 |
setParameters(const LOCA::ParameterVector& params) |
| 43 |
{ |
| 44 |
// Setting the continuable parameters |
| 45 |
for(int i = 0; i < params.length(); i++ ) { |
| 46 |
problem->SetContinuableParameter(params.getLabel(i), params.getValue(i)); |
| 47 |
} |
| 48 |
|
| 49 |
return; |
| 50 |
} |
| 51 |
|
| 52 |
void LOCAInterface:: |
| 53 |
printSolution (const Epetra_Vector &x, const double /* conParam */) |
| 54 |
{ |
| 55 |
|
| 56 |
// Printing a Solution file **************************************** |
| 57 |
if ( continuationManager->GetSolutionFileAttribute() == |
| 58 |
ContinuationManager::Print) |
| 59 |
{ |
| 60 |
// Setting the parameters to be printed in the solution file |
| 61 |
problem->SetSolutionFileParameters(x); |
| 62 |
|
| 63 |
// Getting the solution parameter list |
| 64 |
Teuchos::RCP <Teuchos::ParameterList> solutionFileParams = |
| 65 |
problem->GetSolutionFileParameters(); |
| 66 |
|
| 67 |
// Retrieving the file name from the continuation Manager |
| 68 |
std::string solutionFileName = continuationManager->GetSolutionFileName(); |
| 69 |
|
| 70 |
// Printing a Solution File |
| 71 |
problem->PrintSolutionFile(solutionFileName,x,*solutionFileParams); |
| 72 |
} |
| 73 |
|
| 74 |
// Printing a continuation step in the continuation file *********** |
| 75 |
|
| 76 |
// Setting the parameters to be printed in the continuation file |
| 77 |
problem->SetContinuationFileParameters(x); |
| 78 |
|
| 79 |
// Getting the continuation file parameter list |
| 80 |
Teuchos::RCP <Teuchos::ParameterList> continuationFileParams = |
| 81 |
problem->GetContinuationFileParameters(); |
| 82 |
|
| 83 |
// Getting the continuation file name from the Continuation manager |
| 84 |
std::string continuationFileName = continuationManager->GetContinuationFileName(); |
| 85 |
|
| 86 |
// Getting the step id from the continuation manager |
| 87 |
int stepId = continuationManager->GetStepID(); |
| 88 |
|
| 89 |
// Updating the continuation file |
| 90 |
problem->UpdateContinuationFile(continuationFileName,stepId,*continuationFileParams); |
| 91 |
|
| 92 |
return; |
| 93 |
} |
| 94 |
|
| 95 |
bool LOCAInterface:: |
| 96 |
computeShiftedMatrix (double alpha, double /* beta */, |
| 97 |
const Epetra_Vector &x, Epetra_Operator &/* A */) |
| 98 |
{ |
| 99 |
|
| 100 |
std::cout << " AGS HACK -- LOCAInterface::computeShiftedMatrix RETURNS JACOBIAN!!! " << std::endl; |
| 101 |
problem->ComputeJacF(x); |
| 102 |
problem->GetJacF()->Scale(alpha); |
| 103 |
|
| 104 |
// Need to add beta * I for ODEs of the form: u_dot = f(u) |
| 105 |
|
| 106 |
//problem->ComputeShiftedJacobian(alpha,beta); |
| 107 |
return true; |
| 108 |
} |
| 109 |
|
| 110 |
void LOCAInterface::setXdot(const Epetra_Vector& /* xdot */, const double time) { |
| 111 |
// current problem does not depend on xdot or t |
| 112 |
t = time; |
| 113 |
} |