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;
144 const std::vector<panzer::BC> & bcs,
151 bool writeGraph=
false,
const std::string & graphPrefix=
"",
165 int addParameter(
const std::string & name,
const Scalar & initial);
230 const std::vector<WorksetDescriptor> & wkst_desc,
248 template <
typename ResponseEvaluatorFactory_BuilderT>
250 const std::vector<WorksetDescriptor> & wkst_desc,
251 const ResponseEvaluatorFactory_BuilderT & builder);
262 const bool write_graphviz_file=
false,
263 const std::string& graphviz_file_prefix=
"")
264 {
responseLibrary_->buildResponseEvaluators(physicsBlocks,eqset_factory,cm_factory,closure_models,user_data,write_graphviz_file,graphviz_file_prefix);
267 this->resetDefaultBase();
269 typedef Thyra::ModelEvaluatorBase MEB;
270 MEB::OutArgsSetup<Scalar> outArgs;
271 outArgs.setModelEvalDescription(this->description());
273 outArgs.setSupports(MEB::OUT_ARG_f);
274 outArgs.setSupports(MEB::OUT_ARG_W_op);
285 const bool write_graphviz_file=
false,
286 const std::string& graphviz_file_prefix=
"")
287 {
responseLibrary_->buildResponseEvaluators(physicsBlocks,cm_factory,closure_models,user_data,write_graphviz_file,graphviz_file_prefix);
290 this->resetDefaultBase();
292 typedef Thyra::ModelEvaluatorBase MEB;
293 MEB::OutArgsSetup<Scalar> outArgs;
294 outArgs.setModelEvalDescription(this->description());
296 outArgs.setSupports(MEB::OUT_ARG_f);
297 outArgs.setSupports(MEB::OUT_ARG_W_op);
308 const std::vector<panzer::BC> & bcs,
314 const bool write_graphviz_file=
false,
315 const std::string& graphviz_file_prefix=
"");
326 const std::vector<panzer::BC> & bcs,
332 const bool write_graphviz_file=
false,
333 const std::string& graphviz_file_prefix=
"");
374 for (
int i=0; i<index; i++) {
385 for (
int i=0; i<index; i++) {
406 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
420 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
434 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
448 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
459 void evalModel_D2fDx2(
const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
472 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
485 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
498 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
511 virtual void evalModelImpl(
const Thyra::ModelEvaluatorBase::InArgs<Scalar> &inArgs,
512 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const override;
518 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const;
522 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const;
530 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const;
538 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;
573 bool required_basic_g(
const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const;
594 void setParameters(
const Thyra::ModelEvaluatorBase::InArgs<Scalar> &inArgs)
const;
687 template<
typename Scalar>
688 template <
typename ResponseEvaluatorFactory_BuilderT>
691 const std::vector<WorksetDescriptor> & wkst_desc,
692 const ResponseEvaluatorFactory_BuilderT & builder)
699 "panzer::ModelEvaluator::addResponse: Response with name \"" << responseName <<
"\" "
700 "cannot be added to the model evaluator because evalModel has already been called!");
703 responseLibrary_->addResponse(responseName,wkst_desc,builder);
708 "panzer::ModelEvaluator::addResponse: Response with name \"" << responseName <<
"\" "
709 "has already been added to the model evaluator!");
719 "panzer::ModelEvaluator::addResponse: Response with name \"" << responseName <<
"\" "
720 "has no residual type! Not sure what is going on!");
725 TEUCHOS_TEST_FOR_EXCEPTION(resp==Teuchos::null,std::logic_error,
726 "panzer::ModelEvaluator::addResponse: Response with name \"" << responseName <<
"\" "
727 "resulted in bad cast to panzer::ResponseMESupportBase, the type of the response is incompatible!");
731 respObject->space = vs;
734 resp->setVector(Thyra::createMember(vs));
739 if(respJacBase!=Teuchos::null) {
746 "panzer::ModelEvaluator::addResponse: Response with name \"" << responseName <<
747 "\" resulted in bad cast to panzer::ResponseMESupportBase<Jacobian>, the type "
748 "of the response is incompatible!");
751 if(resp->supportsDerivative())
752 resp->setDerivative(resp->buildDerivative());
755 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
758 if(respHesBase!=Teuchos::null) {
765 "panzer::ModelEvaluator::addResponse: Response with name \"" << responseName <<
766 "\" resulted in bad cast to panzer::ResponseMESupportBase<Hessian>, the type "
767 "of the response is incompatible!");
770 if(resp->supportsDerivative())
771 resp->setDerivative(resp->buildDerivative());
775 respObject->name = responseName;
776 respObject->wkst_desc = wkst_desc;
778 responses_.push_back(respObject);
780 require_in_args_refresh_ =
true;
781 require_out_args_refresh_ =
true;
782 this->resetDefaultBase();
784 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
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
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
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 UniqueGlobalIndexerBase > &ugi) const
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
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
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...
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 UniqueGlobalIndexerBase > global_indexer
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)
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
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
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 UniqueGlobalIndexerBase > &ugi=Teuchos::null)
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_
int addParameter(const std::string &name, const Scalar &initial)