| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// NOX: An Object-Oriented Nonlinear Solver Package |
| 4 |
// |
| 5 |
// Copyright 2002 NTESS and the NOX contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
// ---------- Includes ---------- |
| 11 |
#include <iostream> |
| 12 |
#include "Problem_Interface.H" |
| 13 |
#include "NOX_Epetra_FiniteDifferenceColoringWithUpdate.H" |
| 14 |
#include "EpetraExt_RowMatrixOut.h" |
| 15 |
// ---------- User Defined Includes ---------- |
| 16 |
#include "FiniteElementProblem.H" |
| 17 |
|
| 18 |
//----------------------------------------------------------------------------- |
| 19 |
Problem_Interface::Problem_Interface(FiniteElementProblem& Problem) : |
| 20 |
problem(Problem) |
| 21 |
{ } |
| 22 |
|
| 23 |
Problem_Interface::~Problem_Interface() |
| 24 |
{ } |
| 25 |
|
| 26 |
bool Problem_Interface::computeF(const Epetra_Vector& x, Epetra_Vector& FVec, FillType flag) |
| 27 |
{ |
| 28 |
return problem.evaluate(FiniteElementProblem::F_ONLY, &x, &FVec, NULL, flag); |
| 29 |
} |
| 30 |
|
| 31 |
bool Problem_Interface::computeJacobian(const Epetra_Vector& x, Epetra_Operator& Jac) |
| 32 |
{ |
| 33 |
NOX::Epetra::FiniteDifferenceColoring* fdcJac = 0; |
| 34 |
NOX::Epetra::FiniteDifferenceColoringWithUpdate* fdcJac2 = 0; |
| 35 |
|
| 36 |
fdcJac = dynamic_cast<NOX::Epetra::FiniteDifferenceColoring*>(&Jac); |
| 37 |
if (fdcJac == 0) { |
| 38 |
fdcJac2 = dynamic_cast<NOX::Epetra::FiniteDifferenceColoringWithUpdate*>(&Jac); |
| 39 |
if(fdcJac2==0){ |
| 40 |
std::cout << "Error: Problem_Interface::computeJacobian() - " |
| 41 |
<< "Jacobian operator is not a NOX::Epetra::FiniteDifferenceColoring " |
| 42 |
<< "or NOX::Epetra::FiniteDifferenceColoringWithUpdate " |
| 43 |
<< "object!" << std::endl; |
| 44 |
throw "Problem_Interface Error"; |
| 45 |
} |
| 46 |
else{ |
| 47 |
fdcJac2->computeJacobian(x); |
| 48 |
} |
| 49 |
} |
| 50 |
else{ |
| 51 |
fdcJac->computeJacobian(x); |
| 52 |
} |
| 53 |
|
| 54 |
return true; |
| 55 |
} |
| 56 |
|
| 57 |
bool Problem_Interface::computePreconditioner(const Epetra_Vector& x, Epetra_Operator& M, Teuchos::ParameterList* precParams) |
| 58 |
{ |
| 59 |
std::cout << "ERROR: Problem_Interface::preconditionVector() - Use Explicit Jaciban only for this test problem!" << std::endl; |
| 60 |
throw 1; |
| 61 |
} |
| 62 |
//----------------------------------------------------------------------------- |
| 63 |
|