// @HEADER // ***************************************************************************** // Piro: Strategy package for embedded analysis capabilitites // // Copyright 2010 NTESS and the Piro contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef PIRO_EPETRA_NOXSOLVER_H #define PIRO_EPETRA_NOXSOLVER_H #include #include "NOX.H" #include "NOX_Epetra.H" #include "Epetra_Vector.h" #include "Epetra_LocalMap.h" #include "NOX_Epetra_ModelEvaluatorInterface.H" #include "NOX_Epetra_LinearSystem_Stratimikos.H" #include #include #include "LOCA_GlobalData.H" #include "LOCA_Epetra_TransposeLinearSystem_AbstractStrategy.H" #ifdef HAVE_MPI #include "Epetra_MpiComm.h" #else #include "Epetra_SerialComm.h" #endif #include "EpetraExt_ModelEvaluator.h" namespace Piro { namespace Epetra { /** \brief Epetra-based Model Evaluator for NOX solves * \ingroup Piro_Epetra_solver_grp * */ class NOXSolver : public EpetraExt::ModelEvaluator { public: /** \name Constructors/initializers */ //@{ /** \brief Takes the number of elements in the discretization . */ NOXSolver(Teuchos::RCP piroParams, Teuchos::RCP model, Teuchos::RCP observer = Teuchos::null, Teuchos::RCP interface = Teuchos::null, Teuchos::RCP linsys = Teuchos::null ); //@} ~NOXSolver(); /** \name Overridden from EpetraExt::ModelEvaluator . */ //@{ Teuchos::RCP get_g_map(int j) const; /** \brief . */ Teuchos::RCP get_p_init(int l) const; /** \brief . */ Teuchos::RCP get_p_lower_bounds(int l) const; /** \brief . */ Teuchos::RCP get_p_upper_bounds(int l) const; /** \brief . */ Teuchos::RCP create_DgDp_op( int j, int l ) const; /** \brief . */ EpetraExt::ModelEvaluator::InArgs createInArgs() const; /** \brief . */ EpetraExt::ModelEvaluator::OutArgs createOutArgs() const; /** \brief . */ void evalModel( const InArgs& inArgs, const OutArgs& outArgs ) const; private: /** \brief . */ Teuchos::RCP get_x_map() const; /** \brief . */ Teuchos::RCP get_f_map() const; /** \brief . */ Teuchos::RCP get_x_init() const; /** \brief . */ Teuchos::RCP get_p_map(int l) const; /** \brief . */ void setProblemParamDefaults(Teuchos::ParameterList* piroParams_); /** \brief . */ void setSolverParamDefaults(Teuchos::ParameterList* piroParams_); //@} void resetCounters(); private: //These are set in the constructor and used in evalModel mutable Teuchos::RCP piroParams; Teuchos::RCP model; Teuchos::RCP observer; NOX::Utils utils; Teuchos::RCP linsys; Teuchos::RCP solver; Teuchos::RCP currentSolution; Teuchos::RCP interface; int num_p; int num_g; Teuchos::RCP grp; Teuchos::RCP globalData; Teuchos::RCP tls_strategy; bool writeOnlyConvergedSol; bool exitUponFailedNOXSolve; //Store current iteration of Analysis solver mutable int current_iteration; enum DerivativeLayout { OP, COL, ROW }; mutable int totalNewtonIters; mutable int totalKrylovIters; mutable int stepNum; }; } } #endif