Debian Codegraph @

packages/nox/examples/epetra/NOX_1DFEMNonlinear/Problem_Interface.C

raw
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
14 // ---------- User Defined Includes ----------
15 #include "FiniteElementProblem.H"
16
17 //-----------------------------------------------------------------------------
18 Problem_Interface::Problem_Interface(FiniteElementProblem& Problem) :
19 problem(Problem)
20 { }
21
22 Problem_Interface::~Problem_Interface()
23 { }
24
25 bool Problem_Interface::computeF(const Epetra_Vector& x, Epetra_Vector& FVec, const FillType flag)
26 {
27 return problem.evaluate(F_ONLY, &x, &FVec, NULL);
28 }
29
30 bool Problem_Interface::computeJacobian(const Epetra_Vector& x, Epetra_Operator& Jac)
31 {
32 Epetra_RowMatrix* Jacobian = dynamic_cast<Epetra_RowMatrix*>(&Jac);
33 if (Jacobian == NULL) {
34 std::cout << "ERROR: Problem_Interface::computeJacobian() - The supplied"
35 << "Epetra_Operator is NOT an Epetra_RowMatrix!" << std::endl;
36 throw;
37 }
38 return problem.evaluate(MATRIX_ONLY, &x, NULL, Jacobian);
39 }
40
41 bool Problem_Interface::computePrecMatrix(const Epetra_Vector& x, Epetra_RowMatrix& M)
42 {
43 Epetra_RowMatrix* precMatrix = dynamic_cast<Epetra_RowMatrix*>(&M);
44 if (precMatrix == NULL) {
45 std::cout << "ERROR: Problem_Interface::computePreconditioner() - The supplied"
46 << "Epetra_Operator is NOT an Epetra_RowMatrix!" << std::endl;
47 throw;
48 }
49 return problem.evaluate(MATRIX_ONLY, &x, NULL, precMatrix);
50 }
51 bool Problem_Interface::computePreconditioner(const Epetra_Vector& x, Epetra_Operator& M, Teuchos::ParameterList* precParams)
52 {
53 std::cout << "ERROR: Problem_Interface::preconditionVector() - Use Explicit Jaciban only for this test problem!" << std::endl;
54 throw 1;
55 }
56 //-----------------------------------------------------------------------------
57