Debian Codegraph @

packages/trilinoscouplings/examples/ml/NonlinML/Problem_Interface.cpp

raw
1 // @HEADER
2 // *****************************************************************************
3 // Trilinos: An Object-Oriented Solver Framework
4 //
5 // Copyright 2001-2024 NTESS and the Trilinos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9
10 // ml objects
11 #include "ml_common.h"
12 #include "TrilinosCouplings_config.h"
13
14 #if defined(HAVE_ML_NOX) && defined(HAVE_ML_EPETRA) && defined(HAVE_ML_AZTECOO) && defined(HAVE_ML_TEUCHOS) && defined(HAVE_ML_IFPACK) && defined(HAVE_ML_AMESOS) && defined(HAVE_ML_EPETRAEXT)
15
16 // ---------- Includes ----------
17 #include <iostream>
18 #include "Problem_Interface.H"
19
20 // ---------- User Defined Includes ----------
21 #include "FiniteElementProblem.H"
22
23 //-----------------------------------------------------------------------------
24 Problem_Interface::Problem_Interface(FiniteElementProblem& Problem) :
25 problem(Problem)
26 {
27 type_ = "Problem_Interface";
28 return;
29 }
30
31 Problem_Interface::~Problem_Interface()
32 { }
33
34 bool Problem_Interface::computeF(const Epetra_Vector& x, Epetra_Vector& FVec, FillType flag)
35 {
36 double t0 = GetClock();
37 bool ok = problem.evaluate(F_ONLY, &x, &FVec, NULL);
38 double t1 = GetClock();
39 ncalls_computeF_++;
40 t_ += (t1-t0);
41 return ok;
42 }
43
44 bool Problem_Interface::computeJacobian(const Epetra_Vector& x, Epetra_Operator& Jac)
45 {
46 Epetra_RowMatrix* Jacobian = dynamic_cast<Epetra_RowMatrix*>(&Jac);
47 if (Jacobian == NULL) {
48 std::cout << "ERROR: Problem_Interface::computeJacobian() - The supplied"
49 << "Epetra_Operator is NOT an Epetra_RowMatrix!" << std::endl;
50 throw -1;
51 }
52 return problem.evaluate(MATRIX_ONLY, &x, NULL, Jacobian);
53 }
54
55 //-----------------------------------------------------------------------------
56 #endif // defined(HAVE_ML_EPETRA) && defined(HAVE_ML_AZTECOO)
57