11 #ifndef PANZER_MODEL_EVALUATOR_DECL_HPP
12 #define PANZER_MODEL_EVALUATOR_DECL_HPP
14 #include "PanzerDiscFE_config.hpp"
25 #include "Teuchos_AbstractFactory.hpp"
27 #include "Thyra_VectorBase.hpp"
28 #include "Thyra_VectorSpaceBase.hpp"
29 #include "Thyra_StateFuncModelEvaluatorBase.hpp"
30 #include "Thyra_LinearOpWithSolveFactoryBase.hpp"
36 class FieldManagerBuilder;
37 template<
typename>
class LinearObjFactory;
40 template<
typename Scalar>
42 :
public Thyra::StateFuncModelEvaluatorBase<Scalar>
58 bool build_transient_support,
double t_init);
63 bool build_transient_support,
double t_init);
104 Thyra::ModelEvaluatorBase::InArgs<Scalar>
createInArgs()
const override;
106 Thyra::ModelEvaluatorBase::InArgs<Scalar>
getNominalValues()
const override;
114 template<
typename EvalT>
117 ae_tm_.template disableType<EvalT>();
118 auto idx = Sacado::mpl::find<panzer::Traits::EvalTypes,EvalT>::value;
136 const std::vector<panzer::BC> & bcs,
143 bool writeGraph=
false,
const std::string & graphPrefix=
"",
157 int addParameter(
const std::string & name,
const Scalar & initial);
222 const std::vector<WorksetDescriptor> & wkst_desc,
240 template <
typename ResponseEvaluatorFactory_BuilderT>
242 const std::vector<WorksetDescriptor> & wkst_desc,
243 const ResponseEvaluatorFactory_BuilderT & builder);
254 const bool write_graphviz_file=
false,
255 const std::string& graphviz_file_prefix=
"")
256 {
responseLibrary_->buildResponseEvaluators(physicsBlocks,eqset_factory,cm_factory,closure_models,user_data,write_graphviz_file,graphviz_file_prefix);
259 this->resetDefaultBase();
261 typedef Thyra::ModelEvaluatorBase MEB;
262 MEB::OutArgsSetup<Scalar> outArgs;
263 outArgs.setModelEvalDescription(this->description());
265 outArgs.setSupports(MEB::OUT_ARG_f);
266 outArgs.setSupports(MEB::OUT_ARG_W_op);
277 const bool write_graphviz_file=
false,
278 const std::string& graphviz_file_prefix=
"")
279 {
responseLibrary_->buildResponseEvaluators(physicsBlocks,cm_factory,closure_models,user_data,write_graphviz_file,graphviz_file_prefix);
282 this->resetDefaultBase();
284 typedef Thyra::ModelEvaluatorBase MEB;
285 MEB::OutArgsSetup<Scalar> outArgs;
286 outArgs.setModelEvalDescription(this->description());
288 outArgs.setSupports(MEB::OUT_ARG_f);
289 outArgs.setSupports(MEB::OUT_ARG_W_op);
300 const std::vector<panzer::BC> & bcs,
306 const bool write_graphviz_file=
false,
307 const std::string& graphviz_file_prefix=
"");
318 const std::vector<panzer::BC> & bcs,
324 const bool write_graphviz_file=
false,
325 const std::string& graphviz_file_prefix=
"");
366 for (
int i=0; i<index; i++) {
377 for (
int i=0; i<index; i++) {
398 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
412 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
426 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
440 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
451 void evalModel_D2fDx2(
const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
464 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
477 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
490 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
503 virtual void evalModelImpl(
const Thyra::ModelEvaluatorBase::InArgs<Scalar> &inArgs,
504 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const override;
510 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const;
514 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;
565 bool required_basic_g(
const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const;
586 void setParameters(
const Thyra::ModelEvaluatorBase::InArgs<Scalar> &inArgs)
const;
685 template<
typename Scalar>
686 template <
typename ResponseEvaluatorFactory_BuilderT>
689 const std::vector<WorksetDescriptor> & wkst_desc,
690 const ResponseEvaluatorFactory_BuilderT & builder)
697 "panzer::ModelEvaluator::addResponse: Response with name \"" << responseName <<
"\" "
698 "cannot be added to the model evaluator because evalModel has already been called!");
701 responseLibrary_->addResponse(responseName,wkst_desc,builder);
706 "panzer::ModelEvaluator::addResponse: Response with name \"" << responseName <<
"\" "
707 "has already been added to the model evaluator!");
717 "panzer::ModelEvaluator::addResponse: Response with name \"" << responseName <<
"\" "
718 "has no residual type! Not sure what is going on!");
723 TEUCHOS_TEST_FOR_EXCEPTION(resp==Teuchos::null,std::logic_error,
724 "panzer::ModelEvaluator::addResponse: Response with name \"" << responseName <<
"\" "
725 "resulted in bad cast to panzer::ResponseMESupportBase, the type of the response is incompatible!");
729 respObject->space = vs;
732 resp->setVector(Thyra::createMember(vs));
737 if(respJacBase!=Teuchos::null) {
744 "panzer::ModelEvaluator::addResponse: Response with name \"" << responseName <<
745 "\" resulted in bad cast to panzer::ResponseMESupportBase<Jacobian>, the type "
746 "of the response is incompatible!");
749 if(resp->supportsDerivative())
750 resp->setDerivative(resp->buildDerivative());
753 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
756 if(respHesBase!=Teuchos::null) {
763 "panzer::ModelEvaluator::addResponse: Response with name \"" << responseName <<
764 "\" resulted in bad cast to panzer::ResponseMESupportBase<Hessian>, the type "
765 "of the response is incompatible!");
768 if(resp->supportsDerivative())
769 resp->setDerivative(resp->buildDerivative());
773 respObject->name = responseName;
774 respObject->wkst_desc = wkst_desc;
776 responses_.push_back(respObject);
778 require_in_args_refresh_ =
true;
779 require_out_args_refresh_ =
true;
780 this->resetDefaultBase();
782 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)
unsigned long long write_matrix_count_