Debian Codegraph @

packages/nox/test/epetra/LOCA_Brusselator_xyzt/Problem_Interface.C

raw
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 // ---------- Includes ----------
11 #include <iostream>
12 #include "Problem_Interface.H"
13
14 // ---------- User Defined Includes ----------
15 #include "Brusselator.H"
16 #include "Epetra_CrsMatrix.h"
17 #ifdef HAVE_NOX_EPETRAEXT
18 #include "EpetraExt_MatrixMatrix.h"
19 #endif
20
21 //-----------------------------------------------------------------------------
22 Problem_Interface::Problem_Interface(Brusselator& Problem) :
23 problem(Problem),
24 conStep(0),
25 timeStep(1)
26 { }
27
28 Problem_Interface::~Problem_Interface()
29 { }
30
31 bool Problem_Interface::computeF(const Epetra_Vector& x, Epetra_Vector& FVec,
32 NOX::Epetra::Interface::Required::FillType fillType)
33 {
34 return problem.evaluate(fillType, &x, &FVec, NULL, 0.0, 0.0);
35 }
36
37 bool Problem_Interface::computeJacobian(const Epetra_Vector& x,
38 Epetra_Operator& Jac)
39 {
40 return problem.evaluate(NOX::Epetra::Interface::Required::Jac, &x, 0, 0, 1.0, 0.0);
41 }
42
43 void Problem_Interface::setParameters(const LOCA::ParameterVector& params)
44 {
45 problem.setParameters( params.getValue("alpha"), params.getValue("beta") );
46 }
47
48 void Problem_Interface::printSolution(const Epetra_Vector& x, double conParam)
49 {
50 /*
51 if (timeStep==1)
52 std::cout << "Writing solution at continuation step " << conStep
53 << " for parameter = " << conParam << std::endl;
54 char file_name[25];
55 FILE *ifp;
56 Epetra_Vector& xMesh = problem.getMesh();
57 int NumMyNodes = xMesh.Map().NumMyElements();
58 (void) sprintf(file_name, "output.p%02d_t%03d_s%03d", xMesh.Comm().MyPID(),
59 timeStep, conStep);
60 ifp = fopen(file_name, "w");
61 for (int i=0; i<NumMyNodes; i++)
62 fprintf(ifp, "%d %E %E %E\n", xMesh.Map().MinMyGID()+i, xMesh[i],
63 x[2*i], x[2*i+1]);
64 fclose(ifp);
65 timeStep++; //for time integration runs
66 */
67 }
68
69 void Problem_Interface::dataForPrintSolution(const int conStep_,
70 const int timeStep_, const int numTimeSteps_)
71 {
72 conStep = conStep_; // Zero based
73 timeStep = timeStep_ + 1; // One based
74 }
75
76 bool Problem_Interface::computePrecMatrix(const Epetra_Vector& x, Epetra_RowMatrix& M)
77 {
78 std::cout << "ERROR: Problem_Interface::preconditionVector() - Use Explicit Jacobian only for this test problem!" << std::endl;
79 throw 1;
80 }
81
82 bool Problem_Interface::computePreconditioner(const Epetra_Vector& x,
83 Epetra_Operator& Prec,
84 Teuchos::ParameterList* p)
85 {
86 std::cout << "ERROR: Problem_Interface::preconditionVector() - Use Explicit Jacobian only for this test problem!" << std::endl;
87 throw 1;
88 }
89
90 bool Problem_Interface::computeMassMatrix(const Epetra_Vector& x)
91 {
92 return problem.evaluate(NOX::Epetra::Interface::Required::Jac, &x, 0, 0, 0.0, 1.0);
93 }
94
95 bool Problem_Interface::computeShiftedMatrix(double alpha, double beta,
96 const Epetra_Vector& x, Epetra_Operator& shMat)
97 {
98 return problem.evaluate(NOX::Epetra::Interface::Required::Jac, &x, 0, 0, alpha, beta);
99 }
100
101 void Problem_Interface::setXdot(const Epetra_Vector& xDot, const double time_)
102 {
103 problem.setxDot(xDot);
104
105 // Can set time for nonautonomous systems
106 }
107 //-----------------------------------------------------------------------------
108