// @HEADER // ***************************************************************************** // Piro: Strategy package for embedded analysis capabilitites // // Copyright 2010 NTESS and the Piro contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef MOCKMODELEVAL_B_TPETRA_2_PARAMETERS_H #define MOCKMODELEVAL_B_TPETRA_2_PARAMETERS_H #include "Teuchos_Assert.hpp" #include "Teuchos_RCP.hpp" #include "Thyra_ModelEvaluatorDefaultBase.hpp" #include "Tpetra_MultiVector.hpp" #include "Tpetra_CrsMatrix.hpp" #include "Thyra_TpetraThyraWrappers.hpp" #include "MatrixBased_LOWS.hpp" using LO = Tpetra::Map<>::local_ordinal_type; using GO = Tpetra::Map<>::global_ordinal_type; typedef Tpetra::Map Tpetra_Map; typedef Tpetra::Vector Tpetra_Vector; typedef Tpetra::MultiVector Tpetra_MultiVector; typedef Tpetra::Operator Tpetra_Operator; typedef Tpetra::CrsGraph Tpetra_CrsGraph; typedef Tpetra::CrsMatrix Tpetra_CrsMatrix; typedef Thyra::TpetraOperatorVectorExtraction< double, LO, GO> ConverterT; /** \brief Concrete Tpetra-based Model Evaluator * * Concrete model evaluator for the solution of the following PDE-Constrained problem: * * find (p_0,p_1) that minimizes * g = 0.5*(p0-6)^2 + 0.5*c*(p1-4)^2 + 0.5*(p0+p1-10)^2 * subject to: * f_i = x_i = 0 * * solution is p = (6,4). */ class MockModelEval_B_Tpetra_2_parameters : public Thyra::ModelEvaluatorDefaultBase { public: /** \name Constructors/initializers */ //@{ /** \brief Takes the number of elements in the discretization . */ MockModelEval_B_Tpetra_2_parameters(const Teuchos::RCP > appComm, bool adjoint = false, const Teuchos::RCP& problemList = Teuchos::null, bool hessianSupport = false); //@} ~MockModelEval_B_Tpetra_2_parameters(); /** \name Overridden from EpetraExt::ModelEvaluator . */ //@{ /** \brief . */ Thyra::ModelEvaluatorBase::InArgs getNominalValues() const; /** \brief . */ Thyra::ModelEvaluatorBase::InArgs getLowerBounds() const; /** \brief . */ Thyra::ModelEvaluatorBase::InArgs getUpperBounds() const; /** \brief . */ Teuchos::RCP> create_W_op() const; /** \brief . */ Teuchos::RCP> create_W_prec() const; /** \brief . */ Teuchos::RCP> get_W_factory() const; /** \brief . */ Teuchos::RCP> create_hess_g_pp( int j, int l1, int l2 ) const; /** \brief . */ Thyra::ModelEvaluatorBase::InArgs createInArgs() const; /** \brief . */ void reportFinalPoint( const Thyra::ModelEvaluatorBase::InArgs& finalPoint, const bool wasSolved); /** \brief . */ Teuchos::RCP> get_x_space() const; /** \brief . */ Teuchos::RCP> get_f_space() const; /** \brief . */ Teuchos::RCP> get_p_space(int l) const; /** \brief . */ Teuchos::RCP> get_g_space(int j) const; /** \brief . */ Teuchos::RCP > get_p_names(int l) const; /** \brief . */ Teuchos::ArrayView get_g_names(int j) const { TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "not implemented"); } //@} protected: //@{ /** \brief . */ Thyra::ModelEvaluatorBase::OutArgs createOutArgsImpl() const; /** \brief . */ void evalModelImpl( const Thyra::ModelEvaluatorBase::InArgs& inArgs, const Thyra::ModelEvaluatorBase::OutArgs& outArgs) const; //@} private: /** \brief . */ Thyra::ModelEvaluatorBase::InArgs createInArgsImpl() const; //These are set in the constructor and used in evalModel Teuchos::RCP x_map; Teuchos::RCP p_map; Teuchos::RCP g_map; Teuchos::RCP crs_graph; Teuchos::RCP hess_crs_graph; Teuchos::RCP > comm; Teuchos::RCP p_vec_0; Teuchos::RCP p_vec_1; Teuchos::RCP x_vec; Teuchos::RCP x_dot_vec; //! Cached nominal values and lower/upper bounds Thyra::ModelEvaluatorBase::InArgs nominalValues; Thyra::ModelEvaluatorBase::InArgs lowerBounds; Thyra::ModelEvaluatorBase::InArgs upperBounds; //whether hessian is supported bool hessSupport; //Problem parameter list Teuchos::RCP probList_; }; #endif // MOCKMODELEVAL_B_TPETRA_2_PARAMETERS_H