11 #ifndef __Panzer_ModelEvaluator_impl_hpp__
12 #define __Panzer_ModelEvaluator_impl_hpp__
14 #include "Teuchos_DefaultComm.hpp"
15 #include "Teuchos_ArrayRCP.hpp"
17 #include "PanzerDiscFE_config.hpp"
34 #include "Thyra_TpetraThyraWrappers.hpp"
35 #include "Thyra_SpmdVectorBase.hpp"
36 #include "Thyra_DefaultSpmdVector.hpp"
37 #include "Thyra_DefaultSpmdVectorSpace.hpp"
38 #include "Thyra_DefaultMultiVectorProductVectorSpace.hpp"
39 #include "Thyra_DefaultMultiVectorProductVector.hpp"
40 #include "Thyra_MultiVectorStdOps.hpp"
41 #include "Thyra_VectorStdOps.hpp"
44 #include "Thyra_ProductVectorBase.hpp"
45 #include "Thyra_BlockedLinearOpBase.hpp"
46 #include "Thyra_TpetraVector.hpp"
47 #include "Thyra_TpetraLinearOp.hpp"
48 #include "Tpetra_CrsMatrix.hpp"
52 template<
typename Scalar>
61 bool build_transient_support,
64 , num_me_parameters_(0)
66 , fd_perturb_size_(1e-7)
67 , require_in_args_refresh_(true)
68 , require_out_args_refresh_(true)
69 , responseLibrary_(rLibrary)
70 , global_data_(global_data)
71 , build_transient_support_(build_transient_support)
73 , solverFactory_(solverFactory)
74 , oneTimeDirichletBeta_on_(false)
75 , oneTimeDirichletBeta_(0.0)
76 , build_volume_field_managers_(true)
77 , build_bc_field_managers_(true)
78 , active_evaluation_types_(Sacado::mpl::size<panzer::
Traits::EvalTypes>::value, true)
79 , write_matrix_count_(0)
83 using Teuchos::rcp_dynamic_cast;
86 using Thyra::createMember;
91 ae_tm_.buildObjects(builder);
100 x_space_ = tof->getThyraDomainSpace();
101 f_space_ = tof->getThyraRangeSpace();
106 for(std::size_t i=0;i<p_names.size();i++)
114 template<
typename Scalar>
119 bool build_transient_support,
double t_init)
121 , num_me_parameters_(0)
123 , fd_perturb_size_(1e-7)
124 , require_in_args_refresh_(true)
125 , require_out_args_refresh_(true)
126 , global_data_(global_data)
127 , build_transient_support_(build_transient_support)
129 , solverFactory_(solverFactory)
130 , oneTimeDirichletBeta_on_(false)
131 , oneTimeDirichletBeta_(0.0)
132 , build_volume_field_managers_(true)
133 , build_bc_field_managers_(true)
134 , active_evaluation_types_(Sacado::mpl::size<panzer::
Traits::EvalTypes>::value, true)
135 , write_matrix_count_(0)
138 using Teuchos::rcp_dynamic_cast;
149 x_space_ = tof->getThyraDomainSpace();
150 f_space_ = tof->getThyraRangeSpace();
160 template<
typename Scalar>
169 template<
typename Scalar>
177 template<
typename Scalar>
184 template<
typename Scalar>
189 "panzer::ModelEvaluator::get_p_names: Requested parameter index out of range.");
191 if (i < Teuchos::as<int>(parameters_.size()))
192 return parameters_[i]->names;
193 else if (i < Teuchos::as<int>(parameters_.size()+tangent_space_.size())) {
195 int param_index = i-parameters_.size();
196 std::ostringstream ss;
197 ss <<
"TANGENT VECTOR: " << param_index;
198 names->push_back(ss.str());
201 else if (build_transient_support_ && i < Teuchos::as<int>(parameters_.size()+2*tangent_space_.size())) {
203 int param_index = i-parameters_.size()-tangent_space_.size();
204 std::ostringstream ss;
205 ss <<
"TIME DERIVATIVE TANGENT VECTOR: " << param_index;
206 names->push_back(ss.str());
210 return Teuchos::null;
213 template<
typename Scalar>
218 "panzer::ModelEvaluator::get_p_space: Requested parameter index out of range.");
220 if (i < Teuchos::as<int>(parameters_.size()))
221 return parameters_[i]->space;
222 else if (i < Teuchos::as<int>(parameters_.size()+tangent_space_.size()))
223 return tangent_space_[i-parameters_.size()];
224 else if (build_transient_support_ && i < Teuchos::as<int>(parameters_.size()+2*tangent_space_.size()))
225 return tangent_space_[i-parameters_.size()-tangent_space_.size()];
227 return Teuchos::null;
230 template<
typename Scalar>
235 "panzer::ModelEvaluator::get_g_names: Requested response index out of range.");
240 template<
typename Scalar>
245 static_cast<typename std::vector<Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar>
> >::size_type>(i)<responses_.size());
247 return responses_[i]->name;
250 template<
typename Scalar>
255 static_cast<typename std::vector<Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar>
> >::size_type>(i)<responses_.size());
257 return responses_[i]->space;
260 template<
typename Scalar>
261 Thyra::ModelEvaluatorBase::InArgs<Scalar>
264 return getNominalValues();
267 template<
typename Scalar>
268 Thyra::ModelEvaluatorBase::InArgs<Scalar>
272 using Teuchos::rcp_dynamic_cast;
274 if(require_in_args_refresh_) {
275 typedef Thyra::ModelEvaluatorBase MEB;
282 MEB::InArgsSetup<Scalar> nomInArgs;
283 nomInArgs = nominalValues_;
284 nomInArgs.setSupports(nominalValues_);
287 nomInArgs.set_Np(num_me_parameters_);
288 for(std::size_t p=0;p<parameters_.size();p++) {
290 nomInArgs.set_p(p,parameters_[p]->initial_value);
296 nominalValues_ = nomInArgs;
300 require_in_args_refresh_ =
false;
302 return nominalValues_;
305 template<
typename Scalar>
309 typedef Thyra::ModelEvaluatorBase MEB;
315 MEB::InArgsSetup<Scalar> nomInArgs;
316 nomInArgs.setModelEvalDescription(this->description());
317 nomInArgs.setSupports(MEB::IN_ARG_x);
319 Thyra::assign(x_nom.
ptr(),0.0);
320 nomInArgs.set_x(x_nom);
321 if(build_transient_support_) {
322 nomInArgs.setSupports(MEB::IN_ARG_x_dot,
true);
323 nomInArgs.setSupports(MEB::IN_ARG_t,
true);
324 nomInArgs.setSupports(MEB::IN_ARG_alpha,
true);
325 nomInArgs.setSupports(MEB::IN_ARG_beta,
true);
326 nomInArgs.setSupports(MEB::IN_ARG_step_size,
true);
327 nomInArgs.setSupports(MEB::IN_ARG_stage_number,
true);
330 Thyra::assign(x_dot_nom.
ptr(),0.0);
331 nomInArgs.set_x_dot(x_dot_nom);
332 nomInArgs.set_t(t_init_);
333 nomInArgs.set_alpha(0.0);
334 nomInArgs.set_beta(0.0);
336 nomInArgs.set_step_size(0.0);
337 nomInArgs.set_stage_number(1.0);
341 nomInArgs.set_Np(num_me_parameters_);
342 std::size_t v_index = 0;
343 for(std::size_t p=0;p<parameters_.size();p++) {
344 nomInArgs.set_p(p,parameters_[p]->initial_value);
345 if (!parameters_[p]->is_distributed) {
347 Thyra::assign(v_nom_x.
ptr(),0.0);
348 nomInArgs.set_p(v_index+parameters_.size(),v_nom_x);
349 if (build_transient_support_) {
351 Thyra::assign(v_nom_xdot.
ptr(),0.0);
352 nomInArgs.set_p(v_index+parameters_.size()+tangent_space_.size(),v_nom_xdot);
358 nominalValues_ = nomInArgs;
361 template <
typename Scalar>
365 build_volume_field_managers_ = value;
368 template <
typename Scalar>
372 build_bc_field_managers_ = value;
375 template <
typename Scalar>
379 const std::vector<panzer::BC> & bcs,
386 bool writeGraph,
const std::string & graphPrefix,
391 PANZER_FUNC_TIME_MONITOR_DIFF(
"panzer::ModelEvaluator::setupModel()",setupModel);
399 PANZER_FUNC_TIME_MONITOR_DIFF(
"allocate FieldManagerBuilder",allocFMB);
404 PANZER_FUNC_TIME_MONITOR_DIFF(
"fmb->setWorksetContainer()",setupWorksets);
407 if (build_volume_field_managers_) {
408 PANZER_FUNC_TIME_MONITOR_DIFF(
"fmb->setupVolumeFieldManagers()",setupVolumeFieldManagers);
411 if (build_bc_field_managers_) {
412 PANZER_FUNC_TIME_MONITOR_DIFF(
"fmb->setupBCFieldManagers()",setupBCFieldManagers);
413 fmb->
setupBCFieldManagers(bcs,physicsBlocks,eqset_factory,bc_cm_factory,bc_factory,closure_models,*lof_,user_data);
418 if (build_volume_field_managers_)
420 if (build_bc_field_managers_)
425 PANZER_FUNC_TIME_MONITOR_DIFF(
"AssemblyEngine_TemplateBuilder::buildObjects()",AETM_BuildObjects);
427 ae_tm_.buildObjects(builder);
435 PANZER_FUNC_TIME_MONITOR_DIFF(
"build response library",buildResponses);
437 responseLibrary_->initialize(wc,lof_->getRangeGlobalIndexer(),lof_);
439 buildResponses(physicsBlocks,eqset_factory,volume_cm_factory,closure_models,user_data,writeGraph,graphPrefix+
"Responses_");
440 buildDistroParamDfDp_RL(wc,physicsBlocks,bcs,eqset_factory,bc_factory,volume_cm_factory,closure_models,user_data,writeGraph,graphPrefix+
"Response_DfDp_");
441 buildDistroParamDgDp_RL(wc,physicsBlocks,bcs,eqset_factory,bc_factory,volume_cm_factory,closure_models,user_data,writeGraph,graphPrefix+
"Response_DgDp_");
444 fd_perturb_size_ = 1.0e-7;
445 if (me_params.
isParameter(
"FD Forward Sensitivities"))
446 do_fd_dfdp_ = me_params.
get<
bool>(
"FD Forward Sensitivities");
448 fd_perturb_size_ = me_params.
get<
double>(
"FD Perturbation Size");
452 template <
typename Scalar>
459 using Teuchos::rcp_dynamic_cast;
460 using Teuchos::rcp_const_cast;
461 typedef Thyra::ModelEvaluatorBase MEB;
465 ghostedContainer_ = lof_->buildGhostedLinearObjContainer();
472 bool is_transient =
false;
473 if (inArgs.supports(MEB::IN_ARG_x_dot ))
477 xContainer_ = lof_->buildReadOnlyDomainContainer();
479 xdotContainer_ = lof_->buildReadOnlyDomainContainer();
486 "ModelEvaluator was not built with transient support enabled!");
488 ae_inargs.
container_ = lof_->buildLinearObjContainer();
490 ae_inargs.
alpha = 0.0;
491 ae_inargs.
beta = 1.0;
493 if (build_transient_support_) {
494 x_dot = inArgs.get_x_dot();
495 ae_inargs.
alpha = inArgs.get_alpha();
496 ae_inargs.
beta = inArgs.get_beta();
497 ae_inargs.
time = inArgs.get_t();
499 ae_inargs.
step_size= inArgs.get_step_size();
508 int num_param_vecs = parameters_.size();
509 for (
int i=0; i<num_param_vecs; i++) {
512 if ( paramVec!=Teuchos::null && !parameters_[i]->is_distributed) {
516 rcp_dynamic_cast<
const Thyra::SpmdVectorBase<Scalar> >(paramVec,
true)->getLocalData(Teuchos::ptrFromRef(p_data));
518 for (
unsigned int j=0; j < parameters_[i]->scalar_value.size(); j++) {
519 parameters_[i]->scalar_value[j].baseValue = p_data[j];
520 parameters_[i]->scalar_value[j].family->setRealValueForAllTypes(parameters_[i]->scalar_value[j].baseValue);
523 else if ( paramVec!=Teuchos::null && parameters_[i]->is_distributed) {
526 std::string key = (*parameters_[i]->names)[0];
534 if(loc_pair_ged!=Teuchos::null) {
541 ro_ged->setOwnedVector(paramVec);
568 xContainer_->setOwnedVector(x);
573 xdotContainer_->setOwnedVector(x_dot);
583 for (
int i(0); i < num_param_vecs; ++i)
589 if (not parameters_[i]->is_distributed)
591 auto dxdp = rcp_const_cast<VectorBase<Scalar>>
592 (inArgs.get_p(vIndex + num_param_vecs));
593 if (not dxdp.is_null())
597 auto dxdpBlock = rcp_dynamic_cast<ProductVectorBase<Scalar>>(dxdp);
598 int numParams(parameters_[i]->scalar_value.size());
599 for (
int j(0); j < numParams; ++j)
601 RCP<ROVGED> dxdpContainer = lof_->buildReadOnlyDomainContainer();
602 dxdpContainer->setOwnedVector(dxdpBlock->getNonconstVectorBlock(j));
603 string name(
"X TANGENT GATHER CONTAINER: " +
604 (*parameters_[i]->names)[j]);
608 if (build_transient_support_)
612 auto dxdotdp = rcp_const_cast<VectorBase<Scalar>>
613 (inArgs.get_p(vIndex + num_param_vecs + tangent_space_.size()));
614 if (not dxdotdp.is_null())
617 rcp_dynamic_cast<ProductVectorBase<Scalar>>(dxdotdp);
618 int numParams(parameters_[i]->scalar_value.size());
619 for (
int j(0); j < numParams; ++j)
621 RCP<ROVGED> dxdotdpContainer = lof_->buildReadOnlyDomainContainer();
622 dxdotdpContainer->setOwnedVector(
623 dxdotdpBlock->getNonconstVectorBlock(j));
624 string name(
"DXDT TANGENT GATHER CONTAINER: " +
625 (*parameters_[i]->names)[j]);
638 template <
typename Scalar>
639 Thyra::ModelEvaluatorBase::OutArgs<Scalar>
642 typedef Thyra::ModelEvaluatorBase MEB;
644 if(require_out_args_refresh_) {
645 MEB::OutArgsSetup<Scalar> outArgs;
646 outArgs.setModelEvalDescription(this->description());
647 outArgs.set_Np_Ng(num_me_parameters_, responses_.size());
648 outArgs.setSupports(MEB::OUT_ARG_f);
649 outArgs.setSupports(MEB::OUT_ARG_W_op);
652 for(std::size_t i=0;i<responses_.size();i++) {
657 = responseLibrary_->getResponse<RespEvalT>(responses_[i]->name);
658 if(respJacBase!=Teuchos::null) {
664 if(resp->supportsDerivative()) {
665 outArgs.setSupports(MEB::OUT_ARG_DgDx,i,MEB::DerivativeSupport(MEB::DERIV_MV_GRADIENT_FORM));
668 for(std::size_t p=0;p<parameters_.size();p++) {
669 if(parameters_[p]->is_distributed && parameters_[p]->global_indexer!=Teuchos::null)
670 outArgs.setSupports(MEB::OUT_ARG_DgDp,i,p,MEB::DerivativeSupport(MEB::DERIV_MV_GRADIENT_FORM));
671 if(!parameters_[p]->is_distributed)
672 outArgs.setSupports(MEB::OUT_ARG_DgDp,i,p,MEB::DerivativeSupport(MEB::DERIV_MV_JACOBIAN_FORM));
679 for(std::size_t p=0;p<parameters_.size();p++) {
681 if(!parameters_[p]->is_distributed)
682 outArgs.setSupports(MEB::OUT_ARG_DfDp,p,MEB::DerivativeSupport(MEB::DERIV_MV_BY_COL));
683 else if(parameters_[p]->is_distributed && parameters_[p]->global_indexer!=Teuchos::null)
684 outArgs.setSupports(MEB::OUT_ARG_DfDp,p,MEB::DerivativeSupport(MEB::DERIV_LINEAR_OP));
687 prototypeOutArgs_ = outArgs;
691 require_out_args_refresh_ =
false;
693 return prototypeOutArgs_;
696 template <
typename Scalar>
701 PANZER_FUNC_TIME_MONITOR(
"panzer::ModelEvaluator::create_W_op");
705 return tof->getThyraMatrix();
708 template <
typename Scalar>
713 return solverFactory_;
716 template <
typename Scalar>
722 using Teuchos::rcp_dynamic_cast;
724 typedef Thyra::ModelEvaluatorBase MEB;
736 if(require_out_args_refresh_) {
737 this->createOutArgs();
746 TEUCHOS_ASSERT(prototypeOutArgs_.supports(MEB::OUT_ARG_DfDp,p).supports(MEB::DERIV_LINEAR_OP));
753 return response_jacobian->allocateJacobian();
756 TEUCHOS_ASSERT(prototypeOutArgs_.supports(MEB::OUT_ARG_DfDp,p).supports(MEB::DERIV_MV_BY_COL));
759 return Thyra::createMember(*get_f_space());
765 return Teuchos::null;
768 template <
typename Scalar>
778 return addParameter(tmp_names,tmp_values);
781 template <
typename Scalar>
788 using Teuchos::rcp_dynamic_cast;
789 using Teuchos::ptrFromRef;
793 int parameter_index = parameters_.size();
797 parameters_.push_back(param);
801 Thyra::multiVectorProductVectorSpace(x_space_, param->names->size());
802 tangent_space_.push_back(tan_space);
806 num_me_parameters_ += 2;
807 if (build_transient_support_)
808 ++num_me_parameters_;
810 require_in_args_refresh_ =
true;
811 require_out_args_refresh_ =
true;
812 this->resetDefaultBase();
814 return parameter_index;
817 template <
typename Scalar>
825 distrParamGlobalEvaluationData_.addDataObject(key,ged);
827 int parameter_index = parameters_.size();
828 parameters_.push_back(createDistributedParameter(key,vs,initial,ugi));
829 ++num_me_parameters_;
831 require_in_args_refresh_ =
true;
832 require_out_args_refresh_ =
true;
833 this->resetDefaultBase();
835 return parameter_index;
838 template <
typename Scalar>
843 nonParamGlobalEvaluationData_.addDataObject(key,ged);
846 template <
typename Scalar>
849 const std::vector<WorksetDescriptor> & wkst_desc,
855 int respIndex = addResponse(responseName,wkst_desc,*builder);
858 responses_[respIndex]->builder = builder;
864 template <
typename Scalar>
872 using Teuchos::tuple;
873 using Teuchos::rcp_dynamic_cast;
877 ghostedContainer_ = lof_->buildGhostedLinearObjContainer();
883 ae_inargs.
container_ = lof_->buildLinearObjContainer();
885 ae_inargs.
alpha = 0.0;
886 ae_inargs.
beta = 1.0;
908 Thyra::assign(thGhostedContainer->get_f_th().
ptr(),0.0);
917 thGlobalContainer->set_x_th(x);
921 = ae_tm_.template getAsObject<panzer::Traits::Residual>()->evaluateOnlyDirichletBCs(ae_inargs);
928 thGlobalContainer->get_f_th());
934 lof_->applyDirichletBCs(*counter,*result);
937 template <
typename Scalar>
940 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
944 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
947 setParameters(inArgs);
950 std::string responseName = responses_[respIndex]->name;
954 resp->setDerivative(D2gDx2);
961 setupAssemblyInArgs(inArgs,ae_inargs);
963 ae_inargs.
beta = 1.0;
965 auto deltaXContainer = lof_->buildReadOnlyDomainContainer();
966 deltaXContainer->setOwnedVector(delta_x);
984 template <
typename Scalar>
988 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
992 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
995 setParameters(inArgs);
998 std::string responseName = responses_[respIndex]->name;
1002 resp->setDerivative(D2gDxDp);
1009 setupAssemblyInArgs(inArgs,ae_inargs);
1011 ae_inargs.
beta = 1.0;
1014 auto deltaPContainer = parameters_[pIndex]->dfdp_rl->getLinearObjFactory()->buildReadOnlyDomainContainer();
1015 deltaPContainer->setOwnedVector(delta_p);
1034 template <
typename Scalar>
1038 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
1042 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
1045 setParameters(inArgs);
1050 std::string responseName = responses_[respIndex]->name;
1054 resp->setDerivative(D2gDp2);
1061 setupAssemblyInArgs(inArgs,ae_inargs);
1068 auto deltaPContainer = parameters_[pIndex]->dfdp_rl->getLinearObjFactory()->buildReadOnlyDomainContainer();
1069 deltaPContainer->setOwnedVector(delta_p);
1088 template <
typename Scalar>
1092 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
1096 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
1099 setParameters(inArgs);
1104 std::string responseName = responses_[respIndex]->name;
1108 resp->setDerivative(D2gDpDx);
1115 setupAssemblyInArgs(inArgs,ae_inargs);
1122 auto deltaXContainer = lof_->buildReadOnlyDomainContainer();
1123 deltaXContainer->setOwnedVector(delta_x);
1142 template <
typename Scalar>
1148 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
1153 using Teuchos::tuple;
1154 using Teuchos::rcp_dynamic_cast;
1156 typedef Thyra::ModelEvaluatorBase MEB;
1161 bool is_transient =
false;
1162 if (inArgs.supports(MEB::IN_ARG_x_dot ))
1167 "ModelEvaluator was not built with transient support enabled!");
1178 setupAssemblyInArgs(inArgs,ae_inargs);
1180 auto deltaXContainer = lof_->buildReadOnlyDomainContainer();
1181 deltaXContainer->setOwnedVector(delta_x);
1185 setParameters(inArgs);
1191 if(oneTimeDirichletBeta_on_) {
1195 oneTimeDirichletBeta_on_ =
false;
1205 PANZER_FUNC_TIME_MONITOR(
"panzer::ModelEvaluator::evalModel(D2fDx2)");
1209 thGlobalContainer->set_f_th(dummy_f);
1210 thGlobalContainer->set_A_th(W_out);
1213 thGhostedContainer->initializeMatrix(0.0);
1215 ae_tm_.template getAsObject<panzer::Traits::Hessian>()->evaluate(ae_inargs);
1221 thGlobalContainer->set_A_th(Teuchos::null);
1225 thGlobalContainer->set_x_th(Teuchos::null);
1226 thGlobalContainer->set_dxdt_th(Teuchos::null);
1227 thGlobalContainer->set_f_th(Teuchos::null);
1228 thGlobalContainer->set_A_th(Teuchos::null);
1240 template <
typename Scalar>
1243 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
1247 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
1252 using Teuchos::tuple;
1253 using Teuchos::rcp_dynamic_cast;
1255 typedef Thyra::ModelEvaluatorBase MEB;
1260 bool is_transient =
false;
1261 if (inArgs.supports(MEB::IN_ARG_x_dot ))
1266 "ModelEvaluator was not built with transient support enabled!");
1277 setupAssemblyInArgs(inArgs,ae_inargs);
1281 auto deltaPContainer = parameters_[pIndex]->dfdp_rl->getLinearObjFactory()->buildReadOnlyDomainContainer();
1282 deltaPContainer->setOwnedVector(delta_p);
1286 setParameters(inArgs);
1292 if(oneTimeDirichletBeta_on_) {
1296 oneTimeDirichletBeta_on_ =
false;
1306 PANZER_FUNC_TIME_MONITOR(
"panzer::ModelEvaluator::evalModel(D2fDxDp)");
1310 thGlobalContainer->set_f_th(dummy_f);
1311 thGlobalContainer->set_A_th(W_out);
1314 thGhostedContainer->initializeMatrix(0.0);
1316 ae_tm_.template getAsObject<panzer::Traits::Hessian>()->evaluate(ae_inargs);
1322 thGlobalContainer->set_A_th(Teuchos::null);
1326 thGlobalContainer->set_x_th(Teuchos::null);
1327 thGlobalContainer->set_dxdt_th(Teuchos::null);
1328 thGlobalContainer->set_f_th(Teuchos::null);
1329 thGlobalContainer->set_A_th(Teuchos::null);
1342 template <
typename Scalar>
1345 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
1349 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
1351 using Teuchos::rcp_dynamic_cast;
1352 using Teuchos::null;
1366 response_hessian->setHessian(D2fDpDx);
1371 setupAssemblyInArgs(inArgs,ae_inargs);
1373 auto deltaXContainer = lof_->buildReadOnlyDomainContainer();
1374 deltaXContainer->setOwnedVector(delta_x);
1393 template <
typename Scalar>
1396 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
1400 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
1402 using Teuchos::rcp_dynamic_cast;
1403 using Teuchos::null;
1417 response_hessian->setHessian(D2fDp2);
1422 setupAssemblyInArgs(inArgs,ae_inargs);
1424 auto deltaPContainer = parameters_[pIndex]->dfdp_rl->getLinearObjFactory()->buildReadOnlyDomainContainer();
1425 deltaPContainer->setOwnedVector(delta_p);
1444 template <
typename Scalar>
1447 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
1449 evalModelImpl_basic(inArgs,outArgs);
1452 if(required_basic_g(outArgs))
1453 evalModelImpl_basic_g(inArgs,outArgs);
1456 if(required_basic_dgdx(outArgs))
1457 evalModelImpl_basic_dgdx(inArgs,outArgs);
1460 if(required_basic_dgdp_scalar(outArgs))
1461 evalModelImpl_basic_dgdp_scalar(inArgs,outArgs);
1464 if(required_basic_dgdp_distro(outArgs))
1465 evalModelImpl_basic_dgdp_distro(inArgs,outArgs);
1467 if(required_basic_dfdp_scalar(outArgs)) {
1469 evalModelImpl_basic_dfdp_scalar_fd(inArgs,outArgs);
1471 evalModelImpl_basic_dfdp_scalar(inArgs,outArgs);
1474 if(required_basic_dfdp_distro(outArgs))
1475 evalModelImpl_basic_dfdp_distro(inArgs,outArgs);
1478 template <
typename Scalar>
1481 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
1486 using Teuchos::tuple;
1487 using Teuchos::rcp_dynamic_cast;
1489 typedef Thyra::ModelEvaluatorBase MEB;
1494 bool is_transient =
false;
1495 if (inArgs.supports(MEB::IN_ARG_x_dot ))
1500 "ModelEvaluator was not built with transient support enabled!");
1517 setupAssemblyInArgs(inArgs,ae_inargs);
1520 setParameters(inArgs);
1526 if(oneTimeDirichletBeta_on_) {
1530 oneTimeDirichletBeta_on_ =
false;
1540 PANZER_FUNC_TIME_MONITOR(
"panzer::ModelEvaluator::evalModel(f and J)");
1546 thGlobalContainer->set_f_th(f_out);
1547 thGlobalContainer->set_A_th(W_out);
1550 Thyra::assign(thGhostedContainer->get_f_th().ptr(),0.0);
1551 thGhostedContainer->initializeMatrix(0.0);
1553 ae_tm_.template getAsObject<panzer::Traits::Jacobian>()->evaluate(ae_inargs);
1557 PANZER_FUNC_TIME_MONITOR(
"panzer::ModelEvaluator::evalModel(f)");
1562 thGlobalContainer->set_f_th(f_out);
1565 Thyra::assign(thGhostedContainer->get_f_th().ptr(),0.0);
1567 ae_tm_.template getAsObject<panzer::Traits::Residual>()->evaluate(ae_inargs);
1571 PANZER_FUNC_TIME_MONITOR(
"panzer::ModelEvaluator::evalModel(J)");
1578 thGlobalContainer->set_f_th(dummy_f);
1579 thGlobalContainer->set_A_th(W_out);
1582 thGhostedContainer->initializeMatrix(0.0);
1584 ae_tm_.template getAsObject<panzer::Traits::Jacobian>()->evaluate(ae_inargs);
1590 thGlobalContainer->set_A_th(Teuchos::null);
1594 thGlobalContainer->set_x_th(Teuchos::null);
1595 thGlobalContainer->set_dxdt_th(Teuchos::null);
1596 thGlobalContainer->set_f_th(Teuchos::null);
1597 thGlobalContainer->set_A_th(Teuchos::null);
1602 const bool writeToFile =
false;
1603 if (writeToFile &&
nonnull(W_out)) {
1605 if (check_blocked) {
1606 const int numBlocks = check_blocked->productDomain()->numBlocks();
1607 const int rangeBlocks = check_blocked->productRange()->numBlocks();
1609 for (
int row=0; row < numBlocks; ++row) {
1610 for (
int col=0; col < numBlocks; ++col) {
1611 using LO = panzer::LocalOrdinal;
1612 using GO = panzer::GlobalOrdinal;
1614 const auto thyraTpetraOperator = Teuchos::rcp_dynamic_cast<::Thyra::TpetraLinearOp<double,LO,GO,NodeT>>(check_blocked->getNonconstBlock(row,col),
true);
1615 const auto tpetraCrsMatrix = Teuchos::rcp_dynamic_cast<Tpetra::CrsMatrix<double,LO,GO,NodeT>>(thyraTpetraOperator->getTpetraOperator(),
true);
1616 tpetraCrsMatrix->print(std::cout);
1617 std::stringstream ss;
1618 ss <<
"W_out_" << write_matrix_count_ <<
".rank_" << tpetraCrsMatrix->getMap()->getComm()->getRank() <<
".block_" << row <<
"_" << col <<
".txt";
1619 std::fstream fs(ss.str().c_str(),std::fstream::out|std::fstream::trunc);
1627 using LO = panzer::LocalOrdinal;
1628 using GO = panzer::GlobalOrdinal;
1630 const auto thyraTpetraOperator = Teuchos::rcp_dynamic_cast<::Thyra::TpetraLinearOp<double,LO,GO,NodeT>>(W_out,
true);
1631 const auto tpetraCrsMatrix = Teuchos::rcp_dynamic_cast<Tpetra::CrsMatrix<double,LO,GO,NodeT>>(thyraTpetraOperator->getTpetraOperator(),
true);
1632 tpetraCrsMatrix->print(std::cout);
1633 std::stringstream ss;
1634 ss <<
"W_out_" << write_matrix_count_ <<
".rank_" << tpetraCrsMatrix->getMap()->getComm()->getRank() <<
".txt";
1635 std::fstream fs(ss.str().c_str(),std::fstream::out|std::fstream::trunc);
1640 ++write_matrix_count_;
1645 template <
typename Scalar>
1648 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
1657 setupAssemblyInArgs(inArgs,ae_inargs);
1660 setParameters(inArgs);
1662 for(std::size_t i=0;i<responses_.size();i++) {
1664 if(vec!=Teuchos::null) {
1665 std::string responseName = responses_[i]->name;
1669 resp->setVector(vec);
1681 template <
typename Scalar>
1685 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
1687 typedef Thyra::ModelEvaluatorBase MEB;
1693 setParameters(inArgs);
1695 for(std::size_t i=0;i<responses_.size();i++) {
1697 MEB::Derivative<Scalar> deriv = outArgs.get_DgDx(i);
1703 if(vec!=Teuchos::null) {
1705 std::string responseName = responses_[i]->name;
1709 resp->setDerivative(vec);
1717 setupAssemblyInArgs(inArgs,ae_inargs);
1727 template <
typename Scalar>
1731 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
1735 using Teuchos::rcp_dynamic_cast;
1737 typedef Thyra::ModelEvaluatorBase MEB;
1743 std::vector<std::string> activeParameterNames;
1744 std::vector<int> activeParameters;
1745 int totalParameterCount = 0;
1746 for(std::size_t j=0; j<parameters_.size(); j++) {
1749 if(parameters_[j]->is_distributed)
1752 bool is_active =
false;
1753 for(std::size_t i=0;i<responses_.size(); i++) {
1755 MEB::Derivative<Scalar> deriv = outArgs.get_DgDp(i,j);
1760 if(vec!=Teuchos::null) {
1762 std::string responseName = responses_[i]->name;
1768 resp->setVector(vec);
1775 for (std::size_t k=0; k<parameters_[j]->scalar_value.size(); k++) {
1776 std::string name =
"PARAMETER_SENSITIVIES: "+(*parameters_[j]->names)[k];
1777 activeParameterNames.push_back(name);
1778 totalParameterCount++;
1780 activeParameters.push_back(j);
1786 setupAssemblyInArgs(inArgs,ae_inargs);
1795 for (std::size_t ap=0; ap<activeParameters.size(); ++ap) {
1796 const int j = activeParameters[ap];
1797 for (
unsigned int k=0; k < parameters_[j]->scalar_value.size(); k++) {
1799 p.fastAccessDx(paramIndex) = 1.0;
1800 parameters_[j]->scalar_value[k].family->template setValue<panzer::Traits::Tangent>(p);
1809 if(totalParameterCount>0) {
1815 template <
typename Scalar>
1819 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
1821 typedef Thyra::ModelEvaluatorBase MEB;
1830 for(std::size_t p=0;p<parameters_.size();p++) {
1834 if(!parameters_[p]->is_distributed)
1839 for(std::size_t r=0;r<responses_.size();r++) {
1841 MEB::Derivative<Scalar> deriv = outArgs.get_DgDp(r,p);
1847 if(vec!=Teuchos::null) {
1850 std::string responseName = responses_[r]->name;
1855 resp->setDerivative(vec);
1862 setupAssemblyInArgs(inArgs,ae_inargs);
1874 template <
typename Scalar>
1878 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
1881 using Teuchos::rcp_dynamic_cast;
1883 typedef Thyra::ModelEvaluatorBase MEB;
1891 setupAssemblyInArgs(inArgs,ae_inargs);
1897 std::vector<std::string> activeParameters;
1899 int totalParameterCount = 0;
1900 for(std::size_t i=0; i < parameters_.size(); i++) {
1902 if(parameters_[i]->is_distributed)
1906 MEB::Derivative<Scalar> deriv = outArgs.get_DfDp(i);
1912 TEUCHOS_ASSERT(mVec->domain()->dim()==Teuchos::as<int>(parameters_[i]->scalar_value.size()));
1914 for (std::size_t j=0; j < parameters_[i]->scalar_value.size(); j++) {
1925 thGlobalContainer->set_f_th(vec);
1928 std::string name =
"PARAMETER_SENSITIVIES: "+(*parameters_[i]->names)[j];
1932 activeParameters.push_back(name);
1933 totalParameterCount++;
1950 for(std::size_t i=0; i < parameters_.size(); i++) {
1952 if(parameters_[i]->is_distributed)
1956 MEB::Derivative<Scalar> deriv = outArgs.get_DfDp(i);
1957 if(deriv.isEmpty()) {
1959 for (
unsigned int j=0; j < parameters_[i]->scalar_value.size(); j++) {
1961 parameters_[i]->scalar_value[j].baseValue);
1962 parameters_[i]->scalar_value[j].family->template setValue<panzer::Traits::Tangent>(p);
1968 for (
unsigned int j=0; j < parameters_[i]->scalar_value.size(); j++) {
1970 parameters_[i]->scalar_value[j].baseValue);
1971 p.fastAccessDx(paramIndex) = 1.0;
1972 parameters_[i]->scalar_value[j].family->template setValue<panzer::Traits::Tangent>(p);
1984 if(totalParameterCount>0) {
1985 PANZER_FUNC_TIME_MONITOR(
"panzer::ModelEvaluator::evalModel(df/dp)");
1990 template <
typename Scalar>
1994 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
1996 PANZER_FUNC_TIME_MONITOR(
"panzer::ModelEvaluator::evalModel(df/dp)");
1999 using Teuchos::rcp_dynamic_cast;
2001 typedef Thyra::ModelEvaluatorBase MEB;
2008 MEB::OutArgs<Scalar> outArgs_base = this->createOutArgs();
2009 if (outArgs.get_f() == Teuchos::null)
2010 outArgs_base.set_f(Thyra::createMember(this->get_f_space()));
2012 outArgs_base.set_f(outArgs.get_f());
2013 outArgs_base.set_W_op(outArgs.get_W_op());
2014 this->evalModel(inArgs, outArgs_base);
2018 if (inArgs.supports(MEB::IN_ARG_x_dot))
2019 x_dot = inArgs.get_x_dot();
2023 MEB::OutArgs<Scalar> outArgs_fd = this->createOutArgs();
2024 outArgs_fd.set_f(fd);
2028 if (x_dot != Teuchos::null)
2029 xd_dot = Thyra::createMember(this->get_x_space());
2030 MEB::InArgs<Scalar> inArgs_fd = this->createInArgs();
2031 inArgs_fd.setArgs(inArgs);
2032 inArgs_fd.set_x(xd);
2033 if (x_dot != Teuchos::null)
2034 inArgs_fd.set_x_dot(xd_dot);
2036 const double h = fd_perturb_size_;
2037 for(std::size_t i=0; i < parameters_.size(); i++) {
2040 if(parameters_[i]->is_distributed)
2044 MEB::Derivative<Scalar> deriv = outArgs.get_DfDp(i);
2050 TEUCHOS_ASSERT(dfdp->domain()->dim()==Teuchos::as<int>(parameters_[i]->scalar_value.size()));
2056 rcp_dynamic_cast<
const Thyra::DefaultMultiVectorProductVector<Scalar> >(dx_v,
true)->
getMultiVector();
2059 if (x_dot != Teuchos::null) {
2060 dx_dot_v =inArgs.get_p(i+parameters_.size()+tangent_space_.size());
2062 rcp_dynamic_cast<
const Thyra::DefaultMultiVectorProductVector<Scalar> >(dx_dot_v,
true)->
getMultiVector();
2067 inArgs_fd.set_p(i,pd);
2069 for (std::size_t j=0; j < parameters_[i]->scalar_value.size(); j++) {
2072 Thyra::copy(*p, pd.
ptr());
2073 Thyra::set_ele(j, Thyra::get_ele(*p,j)+h, pd.
ptr());
2076 Thyra::V_VpStV(xd.
ptr(), *x, h, *(dx)->col(j));
2077 if (x_dot != Teuchos::null)
2078 Thyra::V_VpStV(xd_dot.
ptr(), *x_dot, h, *(dx_dot)->col(j));
2081 Thyra::assign(fd.
ptr(), 0.0);
2082 this->evalModel(inArgs_fd, outArgs_fd);
2085 Thyra::V_StVpStV(dfdp->col(j).
ptr(), 1.0/h, *fd, -1.0/h, *f);
2088 parameters_[i]->scalar_value[j].family->setRealValueForAllTypes(Thyra::get_ele(*p,j));
2094 template <
typename Scalar>
2098 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
2101 using Teuchos::rcp_dynamic_cast;
2102 using Teuchos::null;
2104 typedef Thyra::ModelEvaluatorBase MEB;
2112 for(std::size_t p=0;p<parameters_.size();p++) {
2116 if(!parameters_[p]->is_distributed)
2121 if(parameters_[p]->dfdp_rl==null)
2125 MEB::Derivative<Scalar> deriv = outArgs.get_DfDp(p);
2134 response_jacobian->setJacobian(deriv.getLinearOp());
2139 setupAssemblyInArgs(inArgs,ae_inargs);
2150 template <
typename Scalar>
2155 bool activeGArgs =
false;
2156 for(
int i=0;i<outArgs.Ng();i++)
2157 activeGArgs |= (outArgs.get_g(i)!=Teuchos::null);
2159 return activeGArgs | required_basic_dgdx(outArgs);
2162 template <
typename Scalar>
2166 typedef Thyra::ModelEvaluatorBase MEB;
2169 bool activeGArgs =
false;
2170 for(
int i=0;i<outArgs.Ng();i++) {
2172 if(outArgs.supports(MEB::OUT_ARG_DgDx,i).none())
2176 activeGArgs |= (!outArgs.get_DgDx(i).isEmpty());
2182 template <
typename Scalar>
2186 typedef Thyra::ModelEvaluatorBase MEB;
2189 bool activeGArgs =
false;
2190 for(
int i=0;i<outArgs.Ng();i++) {
2191 for(
int p=0;p<Teuchos::as<int>(parameters_.size());p++) {
2194 if(parameters_[p]->is_distributed)
2198 if(outArgs.supports(MEB::OUT_ARG_DgDp,i,p).none())
2201 activeGArgs |= (!outArgs.get_DgDp(i,p).isEmpty());
2208 template <
typename Scalar>
2212 typedef Thyra::ModelEvaluatorBase MEB;
2215 bool activeGArgs =
false;
2216 for(
int i=0;i<outArgs.Ng();i++) {
2217 for(
int p=0;p<Teuchos::as<int>(parameters_.size());p++) {
2220 if(!parameters_[p]->is_distributed)
2224 if(outArgs.supports(MEB::OUT_ARG_DgDp,i,p).none())
2227 activeGArgs |= (!outArgs.get_DgDp(i,p).isEmpty());
2234 template <
typename Scalar>
2238 typedef Thyra::ModelEvaluatorBase MEB;
2241 bool activeFPArgs =
false;
2242 for(
int i=0;i<Teuchos::as<int>(parameters_.size());i++) {
2245 if(parameters_[i]->is_distributed)
2249 if(outArgs.supports(MEB::OUT_ARG_DfDp,i).none())
2253 activeFPArgs |= (!outArgs.get_DfDp(i).isEmpty());
2256 return activeFPArgs;
2259 template <
typename Scalar>
2263 typedef Thyra::ModelEvaluatorBase MEB;
2266 bool activeFPArgs =
false;
2267 for(
int i=0;i<Teuchos::as<int>(parameters_.size());i++) {
2270 if(!parameters_[i]->is_distributed)
2274 if(outArgs.supports(MEB::OUT_ARG_DfDp,i).none())
2278 activeFPArgs |= (!outArgs.get_DfDp(i).isEmpty());
2281 return activeFPArgs;
2284 template <
typename Scalar>
2289 const std::vector<panzer::BC> & bcs,
2295 const bool write_graphviz_file,
2296 const std::string& graphviz_file_prefix)
2300 using Teuchos::null;
2306 for(std::size_t p=0;p<parameters_.size();p++) {
2309 if(!parameters_[p]->is_distributed)
2314 if(parameters_[p]->global_indexer==null)
2320 parameters_[p]->global_indexer);
2326 rLibrary->buildResidualResponseEvaluators(physicsBlocks,eqset_factory,bcs,bc_factory,
2327 cm_factory,closure_models,user_data,
2328 write_graphviz_file,graphviz_file_prefix);
2331 parameters_[p]->dfdp_rl = rLibrary;
2335 template <
typename Scalar>
2340 const std::vector<panzer::BC>& ,
2346 const bool write_graphviz_file,
2347 const std::string& graphviz_file_prefix)
2351 using Teuchos::null;
2357 for(std::size_t p=0;p<parameters_.size();p++) {
2360 if(!parameters_[p]->is_distributed)
2365 if(parameters_[p]->global_indexer==null)
2379 for(std::size_t r=0;r<responses_.size();r++) {
2381 if(responses_[r]->builder==Teuchos::null)
2386 responses_[r]->builder->setDerivativeInformation(param_lof);
2389 rLibrary->addResponse(responses_[r]->name,
2390 responses_[r]->wkst_desc,
2391 *responses_[r]->builder);
2394 rLibrary->buildResponseEvaluators(physicsBlocks,eqset_factory,
2395 cm_factory,closure_models,user_data,
2396 write_graphviz_file,graphviz_file_prefix);
2399 parameters_[p]->dgdp_rl = rLibrary;
2403 template <
typename Scalar>
2407 oneTimeDirichletBeta_on_ =
true;
2408 oneTimeDirichletBeta_ = beta;
2411 template <
typename Scalar>
2419 using Teuchos::rcp_dynamic_cast;
2420 using Teuchos::ptrFromRef;
2434 paramObj->is_distributed =
false;
2437 for(
int i=0;i<in_names.
size();i++)
2445 Thyra::locallyReplicatedDefaultSpmdVectorSpace<Scalar>(
2452 vec->getNonconstLocalData(ptrFromRef(data));
2453 for (
unsigned int i=0; i < paramObj->scalar_value.size(); i++)
2454 data[i] = in_values[i];
2456 paramObj->initial_value = initial_value;
2461 template <
typename Scalar>
2474 paramObj->is_distributed =
true;
2476 paramObj->names->push_back(key);
2477 paramObj->space = vs;
2478 paramObj->initial_value = initial;
2480 paramObj->global_indexer = ugi;
2485 template <
typename Scalar>
2490 for(std::size_t i=0; i < parameters_.size(); i++) {
2493 if(parameters_[i]->is_distributed)
2498 if (p != Teuchos::null) {
2499 for (
unsigned int j=0; j < parameters_[i]->scalar_value.size(); j++) {
2500 parameters_[i]->scalar_value[j].family->setRealValueForAllTypes(Thyra::get_ele(*p,j));
2507 template <
typename Scalar>
2512 for(std::size_t i=0; i < parameters_.size(); i++) {
2515 if(parameters_[i]->is_distributed)
2519 for (
unsigned int j=0; j < parameters_[i]->scalar_value.size(); j++) {
2520 parameters_[i]->scalar_value[j].family->setRealValueForAllTypes(Thyra::get_ele(*(parameters_[i]->initial_value),j));
2526 #endif // __Panzer_ModelEvaluator_impl_hpp__
Teuchos::RCP< const LinearObjFactory< panzer::Traits > > cloneWithNewDomain(const LinearObjFactory< panzer::Traits > &lof, const Teuchos::RCP< const GlobalIndexer > &dUgi)
Clone a linear object factory, but using a different domain.
Interface for constructing a BCStrategy_TemplateManager.
void setupVolumeFieldManagers(const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &cm_factory, const Teuchos::ParameterList &closure_models, const LinearObjFactory< panzer::Traits > &lo_factory, const Teuchos::ParameterList &user_data)
Allocates and initializes an equation set template manager.
bool evaluate_transient_terms
virtual void evalModelImpl_basic_dgdp_distro(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) 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
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)
void addResponsesToInArgs(panzer::AssemblyEngineInArgs &input_args) const
int addFlexibleResponse(const std::string &responseName, const std::vector< WorksetDescriptor > &wkst_desc, const Teuchos::RCP< ResponseMESupportBuilderBase > &builder)
T & get(const std::string &name, T def_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
bool is_null(const std::shared_ptr< T > &p)
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
void writeVolumeGraphvizDependencyFiles(std::string filename_prefix, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks) const
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_f_space() const override
#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="")
Teuchos::RCP< LinearObjContainer > getGlobalLOC() const
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)
Thyra::ModelEvaluatorBase::InArgs< Scalar > createInArgs() const override
void writeBCGraphvizDependencyFiles(std::string filename_prefix) const
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
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
Teuchos::RCP< panzer::LinearObjContainer > ghostedContainer_
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< Epetra_MultiVector > getMultiVector(const std::string &modelEvalDescription, const ModelEvaluator::Derivative &deriv, const std::string &derivName, const ModelEvaluator::EDerivativeMultiVectorOrientation mvOrientation)
std::vector< double > gather_seeds
const std::string & get_g_name(int i) const
Teuchos::RCP< Thyra::LinearOpBase< Scalar > > create_W_op() const override
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > x_space_
void setParameters(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs) const
void evaluate(const panzer::AssemblyEngineInArgs &input_args)
Teuchos::RCP< LinearObjContainer > getGhostedLOC() const
Teuchos::RCP< panzer::LinearObjContainer > container_
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
void addGlobalEvaluationData(const std::string &key, const Teuchos::RCP< GlobalEvaluationData > &ged)
void setWorksetContainer(const Teuchos::RCP< WorksetContainer > &wc)
bool isParameter(const std::string &name) const
Teuchos::RCP< const Thyra::LinearOpWithSolveFactoryBase< Scalar > > get_W_factory() const override
PHX::MDField< ScalarT, panzer::Cell, panzer::IP > result
A field that will be used to build up the result of the integral we're performing.
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
Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > lof_
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > get_p_space(int i) const override
bool required_basic_dgdp_scalar(const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
Are their required responses in the out args? DgDp.
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 setDerivativeInformation(const Teuchos::RCP< const panzer::LinearObjFactory< panzer::Traits > > &linearObjFactory)=0
Teuchos::RCP< ResponseBase > getResponse(const std::string &responseName) const
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
bool nonnull(const boost::shared_ptr< T > &p)
void push_back(const value_type &x)
std::string first_sensitivities_name
bool apply_dirichlet_beta
Teuchos::RCP< panzer::ResponseLibrary< panzer::Traits > > responseLibrary_
std::string second_sensitivities_name
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.
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
void setupBCFieldManagers(const std::vector< panzer::BC > &bcs, const std::vector< Teuchos::RCP< panzer::PhysicsBlock > > &physicsBlocks, const panzer::EquationSetFactory &eqset_factory, const panzer::ClosureModelFactory_TemplateManager< panzer::Traits > &cm_factory, const panzer::BCStrategyFactory &bc_factory, const Teuchos::ParameterList &closure_models, const LinearObjFactory< panzer::Traits > &lo_factory, const Teuchos::ParameterList &user_data)
void applyDirichletBCs(const Teuchos::RCP< Thyra::VectorBase< Scalar > > &x, const Teuchos::RCP< Thyra::VectorBase< Scalar > > &f) const
#define TEUCHOS_ASSERT(assertion_test)
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...
Tpetra::KokkosCompat::KokkosDeviceWrapperNode< PHX::Device > TpetraNodeType
void registerScalarParameter(const std::string name, panzer::ParamLib &pl, double realValue)
void setActiveEvaluationTypes(const std::vector< bool > &aet)
Set a vector of active evaluation types to allocate.
virtual void evalModelImpl_basic_dgdp_scalar(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
void buildBCFieldManagers(const bool value)
int addParameter(const std::string &name, const Scalar &initial)