// @HEADER // ***************************************************************************** // NOX: An Object-Oriented Nonlinear Solver Package // // Copyright 2002 NTESS and the NOX contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef NOX_TPETRA_ME_1DFEM_DECL_HPP #define NOX_TPETRA_ME_1DFEM_DECL_HPP #include "Thyra_StateFuncModelEvaluatorBase.hpp" #include "Tpetra_Map.hpp" #include "Tpetra_Vector.hpp" #include "Tpetra_Import.hpp" #include "Tpetra_CrsGraph.hpp" #include "Tpetra_CrsMatrix.hpp" #include "Teuchos_TimeMonitor.hpp" template class EvaluatorTpetra1DFEM; /** \brief Nonmember constuctor. * * \relates EvaluatorTpetra1DFEM */ template Teuchos::RCP > evaluatorTpetra1DFEM(const Teuchos::RCP >& comm, const Tpetra::global_size_t numGlobalElements, const Scalar zMin, const Scalar zMax); /** \brief 1D Finite Element model for nonlinear heat conduction * * The equation modeled is: \verbatim d2T --- - k * T**2 = 0 dz2 subject to: T = p(4), defaults to 1.0 @ z = zMin T' = 0.0 @ z = zMax k = p(2), defaults to 1.0 (independent parameter) For LOCA testing, parameters and responses are used to evaluate a contraint equation. The parameter k is the unknown variable used to enforce the response. We add in dummy responses for unit testing correct offsets in LOCA parameter handling code.: p(0) is a dummy parameter (throws if queried) p(1) is a dummy parameter (throws if queried) p(2) is a constant "k" multiplier on the source term p(3) is a dummy parameter (throws if queried) p(4) is the Dirichlet BC temperature value for left side node "T_left" g(0) is a dummy response (throws if queried) g(1) is a dummy response (throws if queried) g(2) is a dummy response (throws if queried) g(3) is a dummy response (throws if queried) g(4) = T(zMax) - 2.0 g(5) is a dummy response (throws if queried) g(6) = 2.0 * T(zMin) - T(zMax) \endverbatim * The Matrix W = d(f)/d(x) is implemented as a * Thyra::LinearOpBase object and the class * Thyra::DefaultSerialDenseLinearOpWithSolveFactory is used to * create the linear solver. */ template class EvaluatorTpetra1DFEM : public ::Thyra::ModelEvaluator { public: // Public typedefs typedef Scalar scalar_type; typedef LO local_ordinal_type; typedef GO global_ordinal_type; typedef Node node_type; typedef Tpetra::Map tpetra_map; typedef Tpetra::CrsGraph tpetra_graph; typedef Tpetra::CrsMatrix tpetra_matrix; typedef Tpetra::Vector tpetra_vec; typedef ::Thyra::VectorBase thyra_vec; typedef ::Thyra::MultiVectorBase thyra_mvec; typedef ::Thyra::VectorSpaceBase thyra_vec_space; typedef ::Thyra::LinearOpBase thyra_op; typedef ::Thyra::PreconditionerBase thyra_prec; // Constructor EvaluatorTpetra1DFEM(const Teuchos::RCP >& comm, const Tpetra::global_size_t numGlobalElements, const Scalar zMin, const Scalar zMax); /** \name Initializers/Accessors */ //@{ /** \brief . */ void set_x0(const Teuchos::ArrayView &x0); /** \brief . */ void setShowGetInvalidArgs(bool showGetInvalidArg); void set_W_factory(const Teuchos::RCP >& W_factory); //@} /** \name Public functions overridden from ModelEvaulator. */ //@{ Teuchos::RCP get_x_space() const; Teuchos::RCP get_f_space() const; ::Thyra::ModelEvaluatorBase::InArgs getNominalValues() const; Teuchos::RCP create_W_op() const; Teuchos::RCP > get_W_factory() const; ::Thyra::ModelEvaluatorBase::InArgs createInArgs() const; Teuchos::RCP create_W_prec() const; // These are for constraint solver support int Np () const; int Ng () const; ::Thyra::ModelEvaluatorBase::OutArgs createOutArgs() const; Teuchos::RCP > get_p_space(int l) const; Teuchos::RCP > get_p_names(int l) const; Teuchos::RCP > get_g_space(int j) const; Teuchos::ArrayView get_g_names(int j) const; Teuchos::RCP<::Thyra::LinearOpBase> create_DfDp_op(int l) const; Teuchos::RCP<::Thyra::LinearOpBase > create_DgDx_op(int j) const; Teuchos::RCP<::Thyra::LinearOpBase > create_DgDx_dot_op(int j) const; Teuchos::RCP<::Thyra::LinearOpBase > create_DgDp_op( int j, int l ) const; void evalModel(const ::Thyra::ModelEvaluatorBase::InArgs &inArgs, const ::Thyra::ModelEvaluatorBase::OutArgs &outArgs) const; // Dummy Teuchos::RCP get_f_multiplier_space() const{return Teuchos::null;} Teuchos::RCP get_g_multiplier_space(int j) const{return Teuchos::null;} ::Thyra::ModelEvaluatorBase::InArgs getLowerBounds() const{return prototypeInArgs_;} ::Thyra::ModelEvaluatorBase::InArgs getUpperBounds() const{return prototypeInArgs_;} Teuchos::RCP<::Thyra::LinearOpWithSolveBase> create_W() const{return Teuchos::null;} Teuchos::RCP<::Thyra::LinearOpBase> create_hess_f_xx() const{return Teuchos::null;} Teuchos::RCP<::Thyra::LinearOpBase> create_hess_f_xp(int l) const{return Teuchos::null;} Teuchos::RCP<::Thyra::LinearOpBase> create_hess_f_pp( int l1, int l2 ) const{return Teuchos::null;} Teuchos::RCP<::Thyra::LinearOpBase> create_hess_g_xx(int j) const{return Teuchos::null;} Teuchos::RCP<::Thyra::LinearOpBase> create_hess_g_xp( int j, int l ) const{return Teuchos::null;} Teuchos::RCP<::Thyra::LinearOpBase> create_hess_g_pp( int j, int l1, int l2 ) const{return Teuchos::null;} void reportFinalPoint (const ::Thyra::ModelEvaluatorBase::InArgs &finalPoint, const bool wasSolved); //@} std::pair get_p_index(const std::string& p_name) const; std::pair get_g_index(const std::string& g_name) const; private: /** Allocates and returns the Jacobian matrix graph */ virtual Teuchos::RCP createGraph(); private: // data members const Teuchos::RCP > comm_; const Tpetra::global_size_t numGlobalElements_; const Scalar zMin_; const Scalar zMax_; const int Np_; // Number of parameters const int Ng_; // Number of responses const bool printDebug_; Teuchos::RCP xSpace_; Teuchos::RCP xOwnedMap_; Teuchos::RCP xGhostedMap_; Teuchos::RCP > importer_; Teuchos::RCP fSpace_; Teuchos::RCP fOwnedMap_; Teuchos::RCP W_graph_; Teuchos::RCP > W_factory_; Teuchos::RCP nodeCoordinates_; mutable Teuchos::RCP uPtr_; mutable Teuchos::RCP xPtr_; mutable Teuchos::RCP J_diagonal_; ::Thyra::ModelEvaluatorBase::InArgs nominalValues_; Teuchos::RCP x0_; bool showGetInvalidArg_; ::Thyra::ModelEvaluatorBase::InArgs prototypeInArgs_; ::Thyra::ModelEvaluatorBase::OutArgs prototypeOutArgs_; mutable Teuchos::RCP residTimer_; mutable Teuchos::RCP jacTimer_; // Optional parameter and response support for LOCA std::vector>> pNames_; std::vector> gNames_; Teuchos::RCP pMap_; // locally replicated scalar Teuchos::RCP pSpace_; Teuchos::RCP p2_; // k value in equation Teuchos::RCP p4_; // T_left value in equation Dirichlet BC Teuchos::RCP gMap_; // locally replicated scalar Teuchos::RCP gSpace_; Teuchos::RCP dgdpMap_; // locally replicated dense matrix Teuchos::RCP dgdpSpace_; std::unordered_map> p_name_to_index_; std::unordered_map> g_name_to_index_; }; //================================================================== #include "ME_Tpetra_1DFEM_def.hpp" //================================================================== #endif