// @HEADER // ***************************************************************************** // NOX: An Object-Oriented Nonlinear Solver Package // // Copyright 2002 NTESS and the NOX contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER // Finite Element Problem Class /* Provides function (F) and Jacobian evaluations for the following equation * via a 1D linear finite element discretization with Epetra objects. * * d2u * --- - k * u**2 = 0 * dx2 * * subject to @ x=0, u=1 */ #ifndef TEST_EPETRA_1DFEM_INTERFACE_EPETRANEW_H #define TEST_EPETRA_1DFEM_INTERFACE_EPETRANEW_H #include "NOX_Epetra_Interface_Required.H" // base class #include "NOX_Epetra_Interface_Jacobian.H" // base class #include "NOX_Epetra_Interface_Preconditioner.H" // base class #include "Teuchos_RCP.hpp" // Forward Declarations class Epetra_Comm; class Epetra_Map; class Epetra_Vector; class Epetra_Import; class Epetra_Operator; class Epetra_CrsGraph; class Epetra_RowMatrix; class Epetra_CrsMatrix; namespace NOX { namespace Parameter { class List; } } // Finite Element Problem Class class Interface : public NOX::Epetra::Interface::Required, public NOX::Epetra::Interface::Jacobian, public NOX::Epetra::Interface::Preconditioner { public: // Constructor Interface(int NumGlobalElements, Epetra_Comm& Comm, double xmin = 0.0, double xmax = 1.0 ); // Destructor virtual ~Interface(); virtual bool computeF(const Epetra_Vector& x, Epetra_Vector& FVec, FillType fillType = Residual); virtual bool computeJacobian(const Epetra_Vector& x, Epetra_Operator& Jac); virtual bool computePreconditioner(const Epetra_Vector& x, Epetra_Operator& Prec, Teuchos::ParameterList* precParams = 0); // Return a reference to the Epetra_Vector with the initial guess // that is generated by the Interface class. Teuchos::RCP getSolution(); // Return a reference to the Epetra_Vector holding the mesh data Teuchos::RCP getMesh(); // Return a reference to the Epetra_CrsMatrix with the Jacobian // that is generated by the Interface class. Teuchos::RCP getJacobian(); // Set PDE factor bool setPDEfactor(double value) { factor = value; return true; }; protected: // Evaluates the function (F) and/or the Jacobian using the solution // values in solnVector. virtual bool evaluate(FillType f, const Epetra_Vector *solnVector, Epetra_Vector *rhsVector, Epetra_RowMatrix *matrix); // Inserts the global column indices into the Graph virtual bool createGraph(); // Set initial condition for solution vector virtual bool initializeSoln(); protected: enum TargetObjectType {FUNCTION, JACOBIAN}; int NumGlobalElements; // Total Number of elements int NumMyElements; // Number of elements owned by this process int MyPID; // Process number int NumProc; // Total number of processes double xmin; double xmax; double factor; // PDE factor Epetra_Comm* Comm; Epetra_Map* StandardMap; Epetra_Map* OverlapMap; Epetra_Import* Importer; Teuchos::RCP initialSolution; Epetra_Vector* rhs; Epetra_CrsGraph* Graph; Teuchos::RCP jacobian; Teuchos::RCP xptr; }; //================================================================== // Finite Element Basis Object class Basis { public: // Constructor Basis(); // Destructor ~Basis(); // Calculates the values of u and x at the specified gauss point void computeBasis(int gp, double *x, double *u, double *uold = 0); public: // Variables that are calculated at the gauss point double *phi, *dphide; double uu, xx, duu, eta, wt; double dx; // These are only needed for transient double uuold, duuold; }; #endif