// @HEADER // ***************************************************************************** // Panzer: A partial differential equation assembly // engine for strongly coupled complex multiphysics systems // // Copyright 2011 NTESS and the Panzer contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef __Panzer_ResponseEvaluatorFactory_ExtremeValue_hpp__ #define __Panzer_ResponseEvaluatorFactory_ExtremeValue_hpp__ #include #include "PanzerDiscFE_config.hpp" #include "Panzer_PhysicsBlock.hpp" #include "Panzer_BC.hpp" #include "Panzer_Traits.hpp" #include "Panzer_ResponseEvaluatorFactory.hpp" #include "Panzer_LinearObjFactory.hpp" #include "Panzer_ResponseMESupportBuilderBase.hpp" #include namespace panzer { /** This class defines a response based on a functional. */ template class ResponseEvaluatorFactory_ExtremeValue : public ResponseEvaluatorFactory { public: ResponseEvaluatorFactory_ExtremeValue(MPI_Comm comm, int cubatureDegree=1, bool requiresCellReduction=true, bool useMax=true, const std::string & quadPointField="", const Teuchos::RCP > & linearObjFactory=Teuchos::null, const Teuchos::RCP & globalIndexer=Teuchos::null, bool applyDirichletToDerivative=false, std::string in_prefix="") : comm_(comm), cubatureDegree_(cubatureDegree), requiresCellExtreme_(requiresCellReduction), useMax_(useMax) , quadPointField_(quadPointField), linearObjFactory_(linearObjFactory), globalIndexer_(globalIndexer) , applyDirichletToDerivative_(applyDirichletToDerivative) , prefix_(in_prefix) { TEUCHOS_ASSERT((linearObjFactory==Teuchos::null && globalIndexer==Teuchos::null) || (linearObjFactory!=Teuchos::null && globalIndexer!=Teuchos::null)); } virtual ~ResponseEvaluatorFactory_ExtremeValue() {} /** Build the response object used by this factory. This object * assumes the role of the scatter target and will be accessible * by all the evaluators in the field managers. * * \param[in] responseName Name of response to be built. This * name will be used for looking up * the response in the GlobalEvaluationDataContainer * object. */ virtual Teuchos::RCP buildResponseObject(const std::string & responseName) const; virtual Teuchos::RCP buildResponseObject(const std::string & responseName, const std::vector & /* wkstDesc */) const { return buildResponseObject(responseName); } /** Build and register evaluators for a response on a particular physics * block. * * \param[in] responseName The name of the response to be constructed * by these evaluators. * \param[in,out] fm Field manager to be fuild with the evaluators. * \param[in] physicsBlock What physics block is being used for constructing * the evaluators * \param[in] user_data The user data parameter list, this stores things * that the user may find useful. */ virtual void buildAndRegisterEvaluators(const std::string & responseName, PHX::FieldManager & fm, const panzer::PhysicsBlock & physicsBlock, const Teuchos::ParameterList & user_data) const; /** Is this evaluation type supported by the factory. This is used to determine cases * where a response may support a particular evaluation type, however at runtime the user * decides not to enable the (say) Jacobian evaluation of this response. * * Note that use of this mechanism is complementary to having the builder return * Teuchos::null for a particular evaluation type. */ virtual bool typeSupported() const; protected: //! Accessor method for Cubature degree (can be used by sub classes) int getCubatureDegree() const { return cubatureDegree_; } private: MPI_Comm comm_; int cubatureDegree_; bool requiresCellExtreme_; bool useMax_; std::string quadPointField_; Teuchos::RCP > linearObjFactory_; Teuchos::RCP globalIndexer_; bool applyDirichletToDerivative_; std::string prefix_; }; template struct ExtremeValueResponse_Builder : public ResponseMESupportBuilderBase { MPI_Comm comm; int cubatureDegree; bool requiresCellExtreme; bool useMax; std::string quadPointField; bool applyDirichletToDerivative; // if this is set to true, then the dirichlet values will be zerod out in // the DgDx vector std::string prefix; ExtremeValueResponse_Builder() : applyDirichletToDerivative(false) {} virtual ~ExtremeValueResponse_Builder() {} void setDerivativeInformation(const Teuchos::RCP > & in_linearObjFactory, const Teuchos::RCP & in_globalIndexer) { linearObjFactory = in_linearObjFactory; globalIndexer = in_globalIndexer; TEUCHOS_ASSERT((linearObjFactory==Teuchos::null && globalIndexer==Teuchos::null) || (linearObjFactory!=Teuchos::null && globalIndexer!=Teuchos::null)); } virtual void setDerivativeInformation(const Teuchos::RCP > & in_linearObjFactory) { using Teuchos::rcp_dynamic_cast; setDerivativeInformation(in_linearObjFactory, rcp_dynamic_cast(in_linearObjFactory->getDomainGlobalIndexer(),true)); } template Teuchos::RCP build() const { return Teuchos::rcp(new ResponseEvaluatorFactory_ExtremeValue(comm,cubatureDegree,requiresCellExtreme,useMax,quadPointField, linearObjFactory,globalIndexer,applyDirichletToDerivative,prefix)); } virtual Teuchos::RCP buildValueFactory() const { return build(); } virtual Teuchos::RCP buildDerivativeFactory() const { return build(); } virtual Teuchos::RCP buildTangentFactory() const { return build(); } #ifdef Panzer_BUILD_HESSIAN_SUPPORT /** Using a panzer::Tangent evaluation type build the REFB for this * response. */ virtual Teuchos::RCP buildHessianFactory() const { return build(); } #endif private: Teuchos::RCP > linearObjFactory; Teuchos::RCP globalIndexer; }; } #include "Panzer_ResponseEvaluatorFactory_ExtremeValue_impl.hpp" #endif