43 #ifndef PANZER_MODEL_EVALUATOR_DECL_HPP
44 #define PANZER_MODEL_EVALUATOR_DECL_HPP
46 #include "PanzerDiscFE_config.hpp"
57 #include "Teuchos_AbstractFactory.hpp"
59 #include "Thyra_VectorBase.hpp"
60 #include "Thyra_VectorSpaceBase.hpp"
61 #include "Thyra_StateFuncModelEvaluatorBase.hpp"
62 #include "Thyra_LinearOpWithSolveFactoryBase.hpp"
68 class FieldManagerBuilder;
69 template<
typename>
class LinearObjFactory;
72 template<
typename Scalar>
74 :
public Thyra::StateFuncModelEvaluatorBase<Scalar>
90 bool build_transient_support,
double t_init);
95 bool build_transient_support,
double t_init);
136 Thyra::ModelEvaluatorBase::InArgs<Scalar>
createInArgs()
const override;
138 Thyra::ModelEvaluatorBase::InArgs<Scalar>
getNominalValues()
const override;
146 template<
typename EvalT>
149 ae_tm_.template disableType<EvalT>();
150 auto idx = Sacado::mpl::find<panzer::Traits::EvalTypes,EvalT>::value;
168 const std::vector<panzer::BC> & bcs,
175 bool writeGraph=
false,
const std::string & graphPrefix=
"",
189 int addParameter(
const std::string & name,
const Scalar & initial);
254 const std::vector<WorksetDescriptor> & wkst_desc,
272 template <
typename ResponseEvaluatorFactory_BuilderT>
274 const std::vector<WorksetDescriptor> & wkst_desc,
275 const ResponseEvaluatorFactory_BuilderT & builder);
286 const bool write_graphviz_file=
false,
287 const std::string& graphviz_file_prefix=
"")
288 {
responseLibrary_->buildResponseEvaluators(physicsBlocks,eqset_factory,cm_factory,closure_models,user_data,write_graphviz_file,graphviz_file_prefix);
291 this->resetDefaultBase();
293 typedef Thyra::ModelEvaluatorBase MEB;
294 MEB::OutArgsSetup<Scalar> outArgs;
295 outArgs.setModelEvalDescription(this->description());
297 outArgs.setSupports(MEB::OUT_ARG_f);
298 outArgs.setSupports(MEB::OUT_ARG_W_op);
309 const bool write_graphviz_file=
false,
310 const std::string& graphviz_file_prefix=
"")
311 {
responseLibrary_->buildResponseEvaluators(physicsBlocks,cm_factory,closure_models,user_data,write_graphviz_file,graphviz_file_prefix);
314 this->resetDefaultBase();
316 typedef Thyra::ModelEvaluatorBase MEB;
317 MEB::OutArgsSetup<Scalar> outArgs;
318 outArgs.setModelEvalDescription(this->description());
320 outArgs.setSupports(MEB::OUT_ARG_f);
321 outArgs.setSupports(MEB::OUT_ARG_W_op);
332 const std::vector<panzer::BC> & bcs,
338 const bool write_graphviz_file=
false,
339 const std::string& graphviz_file_prefix=
"");
350 const std::vector<panzer::BC> & bcs,
356 const bool write_graphviz_file=
false,
357 const std::string& graphviz_file_prefix=
"");
398 for (
int i=0; i<index; i++) {
409 for (
int i=0; i<index; i++) {
430 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
444 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
458 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
472 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
483 void evalModel_D2fDx2(
const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
496 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
509 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
522 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
535 virtual void evalModelImpl(
const Thyra::ModelEvaluatorBase::InArgs<Scalar> &inArgs,
536 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const override;
542 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const;
546 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const;
554 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const;
562 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const;
570 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const;
578 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const;
586 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const;
594 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const;
597 bool required_basic_g(
const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const;
618 void setParameters(
const Thyra::ModelEvaluatorBase::InArgs<Scalar> &inArgs)
const;
715 template<
typename Scalar>
716 template <
typename ResponseEvaluatorFactory_BuilderT>
719 const std::vector<WorksetDescriptor> & wkst_desc,
720 const ResponseEvaluatorFactory_BuilderT & builder)
727 "panzer::ModelEvaluator::addResponse: Response with name \"" << responseName <<
"\" "
728 "cannot be added to the model evaluator because evalModel has already been called!");
731 responseLibrary_->addResponse(responseName,wkst_desc,builder);
736 "panzer::ModelEvaluator::addResponse: Response with name \"" << responseName <<
"\" "
737 "has already been added to the model evaluator!");
747 "panzer::ModelEvaluator::addResponse: Response with name \"" << responseName <<
"\" "
748 "has no residual type! Not sure what is going on!");
753 TEUCHOS_TEST_FOR_EXCEPTION(resp==Teuchos::null,std::logic_error,
754 "panzer::ModelEvaluator::addResponse: Response with name \"" << responseName <<
"\" "
755 "resulted in bad cast to panzer::ResponseMESupportBase, the type of the response is incompatible!");
759 respObject->space = vs;
762 resp->setVector(Thyra::createMember(vs));
767 if(respJacBase!=Teuchos::null) {
774 "panzer::ModelEvaluator::addResponse: Response with name \"" << responseName <<
775 "\" resulted in bad cast to panzer::ResponseMESupportBase<Jacobian>, the type "
776 "of the response is incompatible!");
779 if(resp->supportsDerivative())
780 resp->setDerivative(resp->buildDerivative());
783 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
786 if(respHesBase!=Teuchos::null) {
793 "panzer::ModelEvaluator::addResponse: Response with name \"" << responseName <<
794 "\" resulted in bad cast to panzer::ResponseMESupportBase<Hessian>, the type "
795 "of the response is incompatible!");
798 if(resp->supportsDerivative())
799 resp->setDerivative(resp->buildDerivative());
803 respObject->name = responseName;
804 respObject->wkst_desc = wkst_desc;
806 responses_.push_back(respObject);
808 require_in_args_refresh_ =
true;
809 require_out_args_refresh_ =
true;
810 this->resetDefaultBase();
812 return responses_.size()-1;
panzer::AssemblyEngine_TemplateManager< panzer::Traits > getAssemblyEngineTemplateManager() const
return a copy of the model evaluators template manager, this is shallow class so pass by value ...
Interface for constructing a BCStrategy_TemplateManager.
std::vector< WorksetDescriptor > wkst_desc
bool require_out_args_refresh_
Allocates and initializes an equation set template manager.
virtual void evalModelImpl_basic_dgdp_distro(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
bool build_volume_field_managers_
Teuchos::RCP< const Thyra::VectorBase< Scalar > > get_parameter_vector(int index) const
Teuchos::RCP< const Teuchos::Array< std::string > > get_p_names(int i) const override
Teuchos::RCP< panzer::ResponseLibrary< panzer::Traits > > dfdp_rl
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_x_space() const override
Teuchos::RCP< const GlobalIndexer > global_indexer
std::vector< Teuchos::RCP< ParameterObject > > parameters_
void evalModel_D2gDp2(int rIndex, int pIndex, const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Teuchos::RCP< const Thyra::VectorBase< Scalar > > &delta_x, const Teuchos::RCP< Thyra::VectorBase< Scalar > > &D2gDp2) const
void initializeNominalValues() const
Initialize the nominal values with good starting conditions.
void resetParameters() const
int addDistributedParameter(const std::string &name, const Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > &vs, const Teuchos::RCP< GlobalEvaluationData > &ged, const Teuchos::RCP< const Thyra::VectorBase< Scalar > > &initial, const Teuchos::RCP< const GlobalIndexer > &ugi=Teuchos::null)
GlobalEvaluationDataContainer nonParamGlobalEvaluationData_
bool build_transient_support_
int addFlexibleResponse(const std::string &responseName, const std::vector< WorksetDescriptor > &wkst_desc, const Teuchos::RCP< ResponseMESupportBuilderBase > &builder)
SearchName(const std::string &n)
Teuchos::RCP< const Thyra::VectorBase< Scalar > > initial_value
void evalModel_D2gDx2(int rIndex, const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Teuchos::RCP< const Thyra::VectorBase< Scalar > > &delta_x, const Teuchos::RCP< Thyra::VectorBase< Scalar > > &D2gDx2) const
void evalModel_D2fDp2(int pIndex, const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Teuchos::RCP< const Thyra::VectorBase< Scalar > > &delta_x, const Teuchos::RCP< Thyra::LinearOpBase< Scalar > > &D2fDp2) const
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_f_space() const override
Thyra::ModelEvaluatorBase::InArgs< Scalar > prototypeInArgs_
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > space
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Teuchos::RCP< ParameterObject > createScalarParameter(const Teuchos::Array< std::string > &names, const Teuchos::Array< Scalar > &in_values) const
panzer::AssemblyEngine_TemplateManager< panzer::Traits > ae_tm_
void buildDistroParamDgDp_RL(const Teuchos::RCP< panzer::WorksetContainer > &wc, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const std::vector< panzer::BC > &bcs, const panzer::EquationSetFactory &eqset_factory, const panzer::BCStrategyFactory &bc_factory, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &cm_factory, const Teuchos::ParameterList &closure_models, const Teuchos::ParameterList &user_data, const bool write_graphviz_file=false, const std::string &graphviz_file_prefix="")
std::vector< Teuchos::RCP< ResponseObject > > responses_
Teuchos::RCP< Thyra::LinearOpBase< Scalar > > create_DfDp_op(int i) const override
void evalModel_D2fDxDp(int pIndex, const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Teuchos::RCP< const Thyra::VectorBase< Scalar > > &delta_p, const Teuchos::RCP< Thyra::LinearOpBase< Scalar > > &D2fDxDp) const
void setupAssemblyInArgs(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, panzer::AssemblyEngineInArgs &ae_inargs) const
void buildVolumeFieldManagers(const bool value)
Teuchos::RCP< Teuchos::Array< std::string > > names
Thyra::ModelEvaluatorBase::InArgs< Scalar > createInArgs() const override
Teuchos::RCP< panzer::GlobalData > global_data_
void evalModel_D2gDpDx(int rIndex, int pIndex, const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Teuchos::RCP< const Thyra::VectorBase< Scalar > > &delta_x, const Teuchos::RCP< Thyra::VectorBase< Scalar > > &D2gDpDx) const
panzer::ParamVec scalar_value
void disableEvaluationType()
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_g_space(int i) const override
void setOneTimeDirichletBeta(const Scalar &beta) const
virtual void evalModelImpl_basic(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
Evaluate a simple model, meaning a residual and a jacobian, no fancy stochastic galerkin or multipoin...
std::vector< bool > active_evaluation_types_
void evalModel_D2fDx2(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Teuchos::RCP< const Thyra::VectorBase< Scalar > > &delta_x, const Teuchos::RCP< Thyra::LinearOpBase< Scalar > > &D2fDx2) const
bool required_basic_g(const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
Does this set of out args require a simple response?
Sacado::ScalarParameterVector< panzer::EvaluationTraits > ParamVec
virtual void evalModelImpl_basic_dgdx(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
bool required_basic_dgdp_distro(const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
Are their required responses in the out args? DgDp.
Teuchos::RCP< panzer::ResponseLibrary< panzer::Traits > > dgdp_rl
const std::string & get_g_name(int i) const
bool operator()(const Teuchos::RCP< ResponseObject > &ro)
Teuchos::RCP< Thyra::LinearOpBase< Scalar > > create_W_op() const override
int addResponse(const std::string &responseName, const std::vector< WorksetDescriptor > &wkst_desc, const ResponseEvaluatorFactory_BuilderT &builder)
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > x_space_
void setParameters(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs) const
int getXTangentVectorIndex(const int index) const
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > f_space_
Teuchos::ArrayView< const std::string > get_g_names(int i) const override
Thyra::ModelEvaluatorBase::OutArgs< Scalar > createOutArgsImpl() const override
Teuchos::RCP< panzer::ResponseLibrary< panzer::Traits > > getResponseLibrary() const
Teuchos::RCP< const Thyra::LinearOpWithSolveFactoryBase< Scalar > > get_W_factory() const override
bool require_in_args_refresh_
virtual void evalModelImpl_basic_g(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
Construct a simple response dicatated by this set of out args.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< ParameterObject > createDistributedParameter(const std::string &key, const Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > &vs, const Teuchos::RCP< const Thyra::VectorBase< Scalar > > &initial, const Teuchos::RCP< const GlobalIndexer > &ugi) const
GlobalEvaluationDataContainer distrParamGlobalEvaluationData_
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > space
Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > lof_
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_p_space(int i) const override
void buildResponses(const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &cm_factory, const Teuchos::ParameterList &closure_models, const Teuchos::ParameterList &user_data, const bool write_graphviz_file=false, const std::string &graphviz_file_prefix="")
bool required_basic_dgdp_scalar(const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
Are their required responses in the out args? DgDp.
Thyra::ModelEvaluatorBase::OutArgs< Scalar > prototypeOutArgs_
std::vector< Teuchos::RCP< Thyra::VectorSpaceBase< double > > > tangent_space_
Teuchos::RCP< const Thyra::LinearOpWithSolveFactoryBase< Scalar > > solverFactory_
bool required_basic_dgdx(const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
Are their required responses in the out args? DgDx.
virtual void evalModelImpl(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const override
bool build_bc_field_managers_
virtual void evalModelImpl_basic_dfdp_distro(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
virtual void evalModelImpl_basic_dfdp_scalar(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
void buildDistroParamDfDp_RL(const Teuchos::RCP< panzer::WorksetContainer > &wc, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const std::vector< panzer::BC > &bcs, const panzer::EquationSetFactory &eqset_factory, const panzer::BCStrategyFactory &bc_factory, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &cm_factory, const Teuchos::ParameterList &closure_models, const Teuchos::ParameterList &user_data, const bool write_graphviz_file=false, const std::string &graphviz_file_prefix="")
void setupModel(const Teuchos::RCP< panzer::WorksetContainer > &wc, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const std::vector< panzer::BC > &bcs, const panzer::EquationSetFactory &eqset_factory, const panzer::BCStrategyFactory &bc_factory, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &volume_cm_factory, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &bc_cm_factory, const Teuchos::ParameterList &closure_models, const Teuchos::ParameterList &user_data, bool writeGraph=false, const std::string &graphPrefix="", const Teuchos::ParameterList &me_params=Teuchos::ParameterList())
virtual void evalModelImpl_basic_dfdp_scalar_fd(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
Thyra::ModelEvaluatorBase::InArgs< Scalar > getNominalValues() const override
Teuchos::RCP< ResponseMESupportBuilderBase > builder
Teuchos::RCP< panzer::LinearObjContainer > ghostedContainer_
void buildResponses(const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const panzer::EquationSetFactory &eqset_factory, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &cm_factory, const Teuchos::ParameterList &closure_models, const Teuchos::ParameterList &user_data, const bool write_graphviz_file=false, const std::string &graphviz_file_prefix="")
Teuchos::RCP< panzer::ResponseLibrary< panzer::Traits > > responseLibrary_
void addNonParameterGlobalEvaluationData(const std::string &name, const Teuchos::RCP< GlobalEvaluationData > &ged)
bool required_basic_dfdp_scalar(const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
Are derivatives of the residual with respect to the scalar parameters in the out args? DfDp.
Teuchos::RCP< ReadOnlyVector_GlobalEvaluationData > xdotContainer_
void evalModel_D2fDpDx(int pIndex, const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Teuchos::RCP< const Thyra::VectorBase< Scalar > > &delta_x, const Teuchos::RCP< Thyra::LinearOpBase< Scalar > > &D2fDpDx) const
void evalModel_D2gDxDp(int rIndex, int pIndex, const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Teuchos::RCP< const Thyra::VectorBase< Scalar > > &delta_p, const Teuchos::RCP< Thyra::VectorBase< Scalar > > &D2gDxDp) const
Thyra::ModelEvaluatorBase::InArgs< Scalar > nominalValues_
void applyDirichletBCs(const Teuchos::RCP< Thyra::VectorBase< Scalar > > &x, const Teuchos::RCP< Thyra::VectorBase< Scalar > > &f) const
Scalar oneTimeDirichletBeta_
bool required_basic_dfdp_distro(const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
Are derivatives of the residual with respect to the distributed parameters in the out args...
int getXDotTangentVectorIndex(const int index) const
virtual void evalModelImpl_basic_dgdp_scalar(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
bool oneTimeDirichletBeta_on_
Teuchos::RCP< ReadOnlyVector_GlobalEvaluationData > xContainer_
void buildBCFieldManagers(const bool value)
int addParameter(const std::string &name, const Scalar &initial)