43 #ifndef __Panzer_ModelEvaluator_impl_hpp__
44 #define __Panzer_ModelEvaluator_impl_hpp__
46 #include "Teuchos_DefaultComm.hpp"
47 #include "Teuchos_ArrayRCP.hpp"
49 #include "PanzerDiscFE_config.hpp"
67 #include "Thyra_TpetraThyraWrappers.hpp"
68 #include "Thyra_SpmdVectorBase.hpp"
69 #include "Thyra_DefaultSpmdVector.hpp"
70 #include "Thyra_DefaultSpmdVectorSpace.hpp"
71 #include "Thyra_DefaultMultiVectorProductVectorSpace.hpp"
72 #include "Thyra_DefaultMultiVectorProductVector.hpp"
73 #include "Thyra_MultiVectorStdOps.hpp"
74 #include "Thyra_VectorStdOps.hpp"
76 #include "Tpetra_CrsMatrix.hpp"
80 template<
typename Scalar>
89 bool build_transient_support,
92 , num_me_parameters_(0)
94 , fd_perturb_size_(1e-7)
95 , require_in_args_refresh_(true)
96 , require_out_args_refresh_(true)
97 , responseLibrary_(rLibrary)
98 , global_data_(global_data)
99 , build_transient_support_(build_transient_support)
101 , solverFactory_(solverFactory)
102 , oneTimeDirichletBeta_on_(false)
103 , oneTimeDirichletBeta_(0.0)
107 using Teuchos::rcp_dynamic_cast;
108 using Teuchos::tuple;
110 using Thyra::createMember;
115 ae_tm_.buildObjects(builder);
124 x_space_ = tof->getThyraDomainSpace();
125 f_space_ = tof->getThyraRangeSpace();
130 for(std::size_t i=0;i<p_names.size();i++)
138 template<
typename Scalar>
143 bool build_transient_support,
double t_init)
145 , num_me_parameters_(0)
147 , fd_perturb_size_(1e-7)
148 , require_in_args_refresh_(true)
149 , require_out_args_refresh_(true)
150 , global_data_(global_data)
151 , build_transient_support_(build_transient_support)
153 , solverFactory_(solverFactory)
154 , oneTimeDirichletBeta_on_(false)
155 , oneTimeDirichletBeta_(0.0)
158 using Teuchos::rcp_dynamic_cast;
169 x_space_ = tof->getThyraDomainSpace();
170 f_space_ = tof->getThyraRangeSpace();
180 template<
typename Scalar>
189 template<
typename Scalar>
197 template<
typename Scalar>
204 template<
typename Scalar>
209 "panzer::ModelEvaluator::get_p_names: Requested parameter index out of range.");
211 if (i < Teuchos::as<int>(parameters_.size()))
212 return parameters_[i]->names;
213 else if (i < Teuchos::as<int>(parameters_.size()+tangent_space_.size())) {
215 int param_index = i-parameters_.size();
216 std::ostringstream ss;
217 ss <<
"TANGENT VECTOR: " << param_index;
218 names->push_back(ss.str());
221 else if (build_transient_support_ && i < Teuchos::as<int>(parameters_.size()+2*tangent_space_.size())) {
223 int param_index = i-parameters_.size()-tangent_space_.size();
224 std::ostringstream ss;
225 ss <<
"TIME DERIVATIVE TANGENT VECTOR: " << param_index;
226 names->push_back(ss.str());
230 return Teuchos::null;
233 template<
typename Scalar>
238 "panzer::ModelEvaluator::get_p_space: Requested parameter index out of range.");
240 if (i < Teuchos::as<int>(parameters_.size()))
241 return parameters_[i]->space;
242 else if (i < Teuchos::as<int>(parameters_.size()+tangent_space_.size()))
243 return tangent_space_[i-parameters_.size()];
244 else if (build_transient_support_ && i < Teuchos::as<int>(parameters_.size()+2*tangent_space_.size()))
245 return tangent_space_[i-parameters_.size()-tangent_space_.size()];
247 return Teuchos::null;
250 template<
typename Scalar>
255 "panzer::ModelEvaluator::get_g_names: Requested response index out of range.");
260 template<
typename Scalar>
265 static_cast<typename std::vector<Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar>
> >::size_type>(i)<responses_.size());
267 return responses_[i]->name;
270 template<
typename Scalar>
275 static_cast<typename std::vector<Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar>
> >::size_type>(i)<responses_.size());
277 return responses_[i]->space;
280 template<
typename Scalar>
281 Thyra::ModelEvaluatorBase::InArgs<Scalar>
284 return getNominalValues();
287 template<
typename Scalar>
288 Thyra::ModelEvaluatorBase::InArgs<Scalar>
292 using Teuchos::rcp_dynamic_cast;
294 if(require_in_args_refresh_) {
295 typedef Thyra::ModelEvaluatorBase MEB;
302 MEB::InArgsSetup<Scalar> nomInArgs;
303 nomInArgs = nominalValues_;
304 nomInArgs.setSupports(nominalValues_);
307 nomInArgs.set_Np(num_me_parameters_);
308 for(std::size_t p=0;p<parameters_.size();p++) {
310 nomInArgs.set_p(p,parameters_[p]->initial_value);
316 nominalValues_ = nomInArgs;
320 require_in_args_refresh_ =
false;
322 return nominalValues_;
325 template<
typename Scalar>
329 typedef Thyra::ModelEvaluatorBase MEB;
335 MEB::InArgsSetup<Scalar> nomInArgs;
336 nomInArgs.setModelEvalDescription(this->description());
337 nomInArgs.setSupports(MEB::IN_ARG_x);
339 Thyra::assign(x_nom.
ptr(),0.0);
340 nomInArgs.set_x(x_nom);
341 if(build_transient_support_) {
342 nomInArgs.setSupports(MEB::IN_ARG_x_dot,
true);
343 nomInArgs.setSupports(MEB::IN_ARG_t,
true);
344 nomInArgs.setSupports(MEB::IN_ARG_alpha,
true);
345 nomInArgs.setSupports(MEB::IN_ARG_beta,
true);
346 nomInArgs.setSupports(MEB::IN_ARG_step_size,
true);
347 nomInArgs.setSupports(MEB::IN_ARG_stage_number,
true);
350 Thyra::assign(x_dot_nom.
ptr(),0.0);
351 nomInArgs.set_x_dot(x_dot_nom);
352 nomInArgs.set_t(t_init_);
353 nomInArgs.set_alpha(0.0);
354 nomInArgs.set_beta(0.0);
356 nomInArgs.set_step_size(0.0);
357 nomInArgs.set_stage_number(1.0);
361 nomInArgs.set_Np(num_me_parameters_);
362 std::size_t v_index = 0;
363 for(std::size_t p=0;p<parameters_.size();p++) {
364 nomInArgs.set_p(p,parameters_[p]->initial_value);
365 if (!parameters_[p]->is_distributed) {
367 Thyra::assign(v_nom_x.
ptr(),0.0);
368 nomInArgs.set_p(v_index+parameters_.size(),v_nom_x);
369 if (build_transient_support_) {
371 Thyra::assign(v_nom_xdot.
ptr(),0.0);
372 nomInArgs.set_p(v_index+parameters_.size()+tangent_space_.size(),v_nom_xdot);
378 nominalValues_ = nomInArgs;
381 template <
typename Scalar>
385 const std::vector<panzer::BC> & bcs,
392 bool writeGraph,
const std::string & graphPrefix,
405 fmb->
setupBCFieldManagers(bcs,physicsBlocks,eqset_factory,bc_cm_factory,bc_factory,closure_models,*lof_,user_data);
414 ae_tm_.buildObjects(builder);
420 responseLibrary_->initialize(wc,lof_->getRangeGlobalIndexer(),lof_);
422 buildResponses(physicsBlocks,eqset_factory,volume_cm_factory,closure_models,user_data,writeGraph,graphPrefix+
"Responses_");
423 buildDistroParamDfDp_RL(wc,physicsBlocks,bcs,eqset_factory,bc_factory,volume_cm_factory,closure_models,user_data,writeGraph,graphPrefix+
"Response_DfDp_");
424 buildDistroParamDgDp_RL(wc,physicsBlocks,bcs,eqset_factory,bc_factory,volume_cm_factory,closure_models,user_data,writeGraph,graphPrefix+
"Response_DgDp_");
427 fd_perturb_size_ = 1.0e-7;
428 if (me_params.
isParameter(
"FD Forward Sensitivities"))
429 do_fd_dfdp_ = me_params.
get<
bool>(
"FD Forward Sensitivities");
431 fd_perturb_size_ = me_params.
get<
double>(
"FD Perturbation Size");
434 template <
typename Scalar>
441 using Teuchos::rcp_dynamic_cast;
442 using Teuchos::rcp_const_cast;
443 typedef Thyra::ModelEvaluatorBase MEB;
447 ghostedContainer_ = lof_->buildGhostedLinearObjContainer();
454 bool is_transient =
false;
455 if (inArgs.supports(MEB::IN_ARG_x_dot ))
459 xContainer_ = lof_->buildReadOnlyDomainContainer();
461 xdotContainer_ = lof_->buildReadOnlyDomainContainer();
468 "ModelEvaluator was not built with transient support enabled!");
470 ae_inargs.
container_ = lof_->buildLinearObjContainer();
472 ae_inargs.
alpha = 0.0;
473 ae_inargs.
beta = 1.0;
475 if (build_transient_support_) {
476 x_dot = inArgs.get_x_dot();
477 ae_inargs.
alpha = inArgs.get_alpha();
478 ae_inargs.
beta = inArgs.get_beta();
479 ae_inargs.
time = inArgs.get_t();
481 ae_inargs.
step_size= inArgs.get_step_size();
490 int num_param_vecs = parameters_.size();
491 for (
int i=0; i<num_param_vecs; i++) {
494 if ( paramVec!=Teuchos::null && !parameters_[i]->is_distributed) {
498 rcp_dynamic_cast<
const Thyra::SpmdVectorBase<Scalar> >(paramVec,
true)->getLocalData(Teuchos::ptrFromRef(p_data));
500 for (
unsigned int j=0; j < parameters_[i]->scalar_value.size(); j++) {
501 parameters_[i]->scalar_value[j].baseValue = p_data[j];
502 parameters_[i]->scalar_value[j].family->setRealValueForAllTypes(parameters_[i]->scalar_value[j].baseValue);
505 else if ( paramVec!=Teuchos::null && parameters_[i]->is_distributed) {
508 std::string key = (*parameters_[i]->names)[0];
516 if(loc_pair_ged!=Teuchos::null) {
523 ro_ged->setOwnedVector(paramVec);
550 xContainer_->setOwnedVector(x);
555 xdotContainer_->setOwnedVector(x_dot);
565 for (
int i(0); i < num_param_vecs; ++i)
571 if (not parameters_[i]->is_distributed)
573 auto dxdp = rcp_const_cast<VectorBase<Scalar>>
574 (inArgs.get_p(vIndex + num_param_vecs));
575 if (not dxdp.is_null())
579 auto dxdpBlock = rcp_dynamic_cast<ProductVectorBase<Scalar>>(dxdp);
580 int numParams(parameters_[i]->scalar_value.size());
581 for (
int j(0); j < numParams; ++j)
583 RCP<ROVGED> dxdpContainer = lof_->buildReadOnlyDomainContainer();
584 dxdpContainer->setOwnedVector(dxdpBlock->getNonconstVectorBlock(j));
585 string name(
"X TANGENT GATHER CONTAINER: " +
586 (*parameters_[i]->names)[j]);
590 if (build_transient_support_)
594 auto dxdotdp = rcp_const_cast<VectorBase<Scalar>>
595 (inArgs.get_p(vIndex + num_param_vecs + tangent_space_.size()));
596 if (not dxdotdp.is_null())
599 rcp_dynamic_cast<ProductVectorBase<Scalar>>(dxdotdp);
600 int numParams(parameters_[i]->scalar_value.size());
601 for (
int j(0); j < numParams; ++j)
603 RCP<ROVGED> dxdotdpContainer = lof_->buildReadOnlyDomainContainer();
604 dxdotdpContainer->setOwnedVector(
605 dxdotdpBlock->getNonconstVectorBlock(j));
606 string name(
"DXDT TANGENT GATHER CONTAINER: " +
607 (*parameters_[i]->names)[j]);
620 template <
typename Scalar>
621 Thyra::ModelEvaluatorBase::OutArgs<Scalar>
624 typedef Thyra::ModelEvaluatorBase MEB;
626 if(require_out_args_refresh_) {
627 MEB::OutArgsSetup<Scalar> outArgs;
628 outArgs.setModelEvalDescription(this->description());
629 outArgs.set_Np_Ng(num_me_parameters_, responses_.size());
630 outArgs.setSupports(MEB::OUT_ARG_f);
631 outArgs.setSupports(MEB::OUT_ARG_W_op);
634 for(std::size_t i=0;i<responses_.size();i++) {
639 = responseLibrary_->getResponse<RespEvalT>(responses_[i]->name);
640 if(respJacBase!=Teuchos::null) {
646 if(resp->supportsDerivative()) {
647 outArgs.setSupports(MEB::OUT_ARG_DgDx,i,MEB::DerivativeSupport(MEB::DERIV_MV_GRADIENT_FORM));
650 for(std::size_t p=0;p<parameters_.size();p++) {
651 if(parameters_[p]->is_distributed && parameters_[p]->global_indexer!=Teuchos::null)
652 outArgs.setSupports(MEB::OUT_ARG_DgDp,i,p,MEB::DerivativeSupport(MEB::DERIV_MV_GRADIENT_FORM));
653 if(!parameters_[p]->is_distributed)
654 outArgs.setSupports(MEB::OUT_ARG_DgDp,i,p,MEB::DerivativeSupport(MEB::DERIV_MV_JACOBIAN_FORM));
661 for(std::size_t p=0;p<parameters_.size();p++) {
663 if(!parameters_[p]->is_distributed)
664 outArgs.setSupports(MEB::OUT_ARG_DfDp,p,MEB::DerivativeSupport(MEB::DERIV_MV_BY_COL));
665 else if(parameters_[p]->is_distributed && parameters_[p]->global_indexer!=Teuchos::null)
666 outArgs.setSupports(MEB::OUT_ARG_DfDp,p,MEB::DerivativeSupport(MEB::DERIV_LINEAR_OP));
669 prototypeOutArgs_ = outArgs;
673 require_out_args_refresh_ =
false;
675 return prototypeOutArgs_;
678 template <
typename Scalar>
686 return tof->getThyraMatrix();
689 template <
typename Scalar>
694 return solverFactory_;
697 template <
typename Scalar>
703 using Teuchos::rcp_dynamic_cast;
705 typedef Thyra::ModelEvaluatorBase MEB;
717 if(require_out_args_refresh_) {
718 this->createOutArgs();
727 TEUCHOS_ASSERT(prototypeOutArgs_.supports(MEB::OUT_ARG_DfDp,p).supports(MEB::DERIV_LINEAR_OP));
734 return response_jacobian->allocateJacobian();
737 TEUCHOS_ASSERT(prototypeOutArgs_.supports(MEB::OUT_ARG_DfDp,p).supports(MEB::DERIV_MV_BY_COL));
740 return Thyra::createMember(*get_f_space());
746 return Teuchos::null;
749 template <
typename Scalar>
759 return addParameter(tmp_names,tmp_values);
762 template <
typename Scalar>
769 using Teuchos::rcp_dynamic_cast;
770 using Teuchos::ptrFromRef;
774 int parameter_index = parameters_.size();
778 parameters_.push_back(param);
782 Thyra::multiVectorProductVectorSpace(x_space_, param->names->size());
783 tangent_space_.push_back(tan_space);
787 num_me_parameters_ += 2;
788 if (build_transient_support_)
789 ++num_me_parameters_;
791 require_in_args_refresh_ =
true;
792 require_out_args_refresh_ =
true;
793 this->resetDefaultBase();
795 return parameter_index;
798 template <
typename Scalar>
806 distrParamGlobalEvaluationData_.addDataObject(key,ged);
808 int parameter_index = parameters_.size();
809 parameters_.push_back(createDistributedParameter(key,vs,initial,ugi));
810 ++num_me_parameters_;
812 require_in_args_refresh_ =
true;
813 require_out_args_refresh_ =
true;
814 this->resetDefaultBase();
816 return parameter_index;
819 template <
typename Scalar>
824 nonParamGlobalEvaluationData_.addDataObject(key,ged);
827 template <
typename Scalar>
830 const std::vector<WorksetDescriptor> & wkst_desc,
836 int respIndex = addResponse(responseName,wkst_desc,*builder);
839 responses_[respIndex]->builder = builder;
845 template <
typename Scalar>
853 using Teuchos::tuple;
854 using Teuchos::rcp_dynamic_cast;
858 ghostedContainer_ = lof_->buildGhostedLinearObjContainer();
864 ae_inargs.
container_ = lof_->buildLinearObjContainer();
866 ae_inargs.
alpha = 0.0;
867 ae_inargs.
beta = 1.0;
889 Thyra::assign(thGhostedContainer->get_f_th().
ptr(),0.0);
898 thGlobalContainer->set_x_th(x);
902 = ae_tm_.template getAsObject<panzer::Traits::Residual>()->evaluateOnlyDirichletBCs(ae_inargs);
909 thGlobalContainer->get_f_th());
915 lof_->applyDirichletBCs(*counter,*result);
918 template <
typename Scalar>
921 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
925 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
928 setParameters(inArgs);
931 std::string responseName = responses_[respIndex]->name;
935 resp->setDerivative(D2gDx2);
942 setupAssemblyInArgs(inArgs,ae_inargs);
944 ae_inargs.
beta = 1.0;
946 auto deltaXContainer = lof_->buildReadOnlyDomainContainer();
947 deltaXContainer->setOwnedVector(delta_x);
965 template <
typename Scalar>
969 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
973 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
976 setParameters(inArgs);
979 std::string responseName = responses_[respIndex]->name;
983 resp->setDerivative(D2gDxDp);
990 setupAssemblyInArgs(inArgs,ae_inargs);
992 ae_inargs.
beta = 1.0;
995 auto deltaPContainer = parameters_[pIndex]->dfdp_rl->getLinearObjFactory()->buildReadOnlyDomainContainer();
996 deltaPContainer->setOwnedVector(delta_p);
1015 template <
typename Scalar>
1019 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
1023 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
1026 setParameters(inArgs);
1031 std::string responseName = responses_[respIndex]->name;
1035 resp->setDerivative(D2gDp2);
1042 setupAssemblyInArgs(inArgs,ae_inargs);
1049 auto deltaPContainer = parameters_[pIndex]->dfdp_rl->getLinearObjFactory()->buildReadOnlyDomainContainer();
1050 deltaPContainer->setOwnedVector(delta_p);
1069 template <
typename Scalar>
1073 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
1077 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
1080 setParameters(inArgs);
1085 std::string responseName = responses_[respIndex]->name;
1089 resp->setDerivative(D2gDpDx);
1096 setupAssemblyInArgs(inArgs,ae_inargs);
1103 auto deltaXContainer = lof_->buildReadOnlyDomainContainer();
1104 deltaXContainer->setOwnedVector(delta_x);
1123 template <
typename Scalar>
1129 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
1134 using Teuchos::tuple;
1135 using Teuchos::rcp_dynamic_cast;
1137 typedef Thyra::ModelEvaluatorBase MEB;
1142 bool is_transient =
false;
1143 if (inArgs.supports(MEB::IN_ARG_x_dot ))
1148 "ModelEvaluator was not built with transient support enabled!");
1159 setupAssemblyInArgs(inArgs,ae_inargs);
1161 auto deltaXContainer = lof_->buildReadOnlyDomainContainer();
1162 deltaXContainer->setOwnedVector(delta_x);
1166 setParameters(inArgs);
1172 if(oneTimeDirichletBeta_on_) {
1176 oneTimeDirichletBeta_on_ =
false;
1186 PANZER_FUNC_TIME_MONITOR(
"panzer::ModelEvaluator::evalModel(D2fDx2)");
1190 thGlobalContainer->set_f_th(dummy_f);
1191 thGlobalContainer->set_A_th(W_out);
1194 thGhostedContainer->initializeMatrix(0.0);
1196 ae_tm_.template getAsObject<panzer::Traits::Hessian>()->evaluate(ae_inargs);
1202 thGlobalContainer->set_A_th(Teuchos::null);
1208 thGlobalContainer->set_x_th(Teuchos::null);
1209 thGlobalContainer->set_dxdt_th(Teuchos::null);
1210 thGlobalContainer->set_f_th(Teuchos::null);
1211 thGlobalContainer->set_A_th(Teuchos::null);
1223 template <
typename Scalar>
1226 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
1230 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
1235 using Teuchos::tuple;
1236 using Teuchos::rcp_dynamic_cast;
1238 typedef Thyra::ModelEvaluatorBase MEB;
1243 bool is_transient =
false;
1244 if (inArgs.supports(MEB::IN_ARG_x_dot ))
1249 "ModelEvaluator was not built with transient support enabled!");
1260 setupAssemblyInArgs(inArgs,ae_inargs);
1264 auto deltaPContainer = parameters_[pIndex]->dfdp_rl->getLinearObjFactory()->buildReadOnlyDomainContainer();
1265 deltaPContainer->setOwnedVector(delta_p);
1269 setParameters(inArgs);
1275 if(oneTimeDirichletBeta_on_) {
1279 oneTimeDirichletBeta_on_ =
false;
1289 PANZER_FUNC_TIME_MONITOR(
"panzer::ModelEvaluator::evalModel(D2fDxDp)");
1293 thGlobalContainer->set_f_th(dummy_f);
1294 thGlobalContainer->set_A_th(W_out);
1297 thGhostedContainer->initializeMatrix(0.0);
1299 ae_tm_.template getAsObject<panzer::Traits::Hessian>()->evaluate(ae_inargs);
1305 thGlobalContainer->set_A_th(Teuchos::null);
1311 thGlobalContainer->set_x_th(Teuchos::null);
1312 thGlobalContainer->set_dxdt_th(Teuchos::null);
1313 thGlobalContainer->set_f_th(Teuchos::null);
1314 thGlobalContainer->set_A_th(Teuchos::null);
1327 template <
typename Scalar>
1330 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
1334 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
1336 using Teuchos::rcp_dynamic_cast;
1337 using Teuchos::null;
1351 response_hessian->setHessian(D2fDpDx);
1356 setupAssemblyInArgs(inArgs,ae_inargs);
1358 auto deltaXContainer = lof_->buildReadOnlyDomainContainer();
1359 deltaXContainer->setOwnedVector(delta_x);
1378 template <
typename Scalar>
1381 const Thyra::ModelEvaluatorBase::InArgs<Scalar> & inArgs,
1385 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
1387 using Teuchos::rcp_dynamic_cast;
1388 using Teuchos::null;
1402 response_hessian->setHessian(D2fDp2);
1407 setupAssemblyInArgs(inArgs,ae_inargs);
1409 auto deltaPContainer = parameters_[pIndex]->dfdp_rl->getLinearObjFactory()->buildReadOnlyDomainContainer();
1410 deltaPContainer->setOwnedVector(delta_p);
1429 template <
typename Scalar>
1432 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
1434 evalModelImpl_basic(inArgs,outArgs);
1437 if(required_basic_g(outArgs))
1438 evalModelImpl_basic_g(inArgs,outArgs);
1441 if(required_basic_dgdx(outArgs))
1442 evalModelImpl_basic_dgdx(inArgs,outArgs);
1445 if(required_basic_dgdp_scalar(outArgs))
1446 evalModelImpl_basic_dgdp_scalar(inArgs,outArgs);
1449 if(required_basic_dgdp_distro(outArgs))
1450 evalModelImpl_basic_dgdp_distro(inArgs,outArgs);
1452 if(required_basic_dfdp_scalar(outArgs)) {
1454 evalModelImpl_basic_dfdp_scalar_fd(inArgs,outArgs);
1456 evalModelImpl_basic_dfdp_scalar(inArgs,outArgs);
1459 if(required_basic_dfdp_distro(outArgs))
1460 evalModelImpl_basic_dfdp_distro(inArgs,outArgs);
1463 template <
typename Scalar>
1466 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
1471 using Teuchos::tuple;
1472 using Teuchos::rcp_dynamic_cast;
1474 typedef Thyra::ModelEvaluatorBase MEB;
1479 bool is_transient =
false;
1480 if (inArgs.supports(MEB::IN_ARG_x_dot ))
1485 "ModelEvaluator was not built with transient support enabled!");
1502 setupAssemblyInArgs(inArgs,ae_inargs);
1505 setParameters(inArgs);
1511 if(oneTimeDirichletBeta_on_) {
1515 oneTimeDirichletBeta_on_ =
false;
1525 PANZER_FUNC_TIME_MONITOR(
"panzer::ModelEvaluator::evalModel(f and J)");
1531 thGlobalContainer->set_f_th(f_out);
1532 thGlobalContainer->set_A_th(W_out);
1535 Thyra::assign(thGhostedContainer->get_f_th().ptr(),0.0);
1536 thGhostedContainer->initializeMatrix(0.0);
1538 ae_tm_.template getAsObject<panzer::Traits::Jacobian>()->evaluate(ae_inargs);
1542 PANZER_FUNC_TIME_MONITOR(
"panzer::ModelEvaluator::evalModel(f)");
1547 thGlobalContainer->set_f_th(f_out);
1550 Thyra::assign(thGhostedContainer->get_f_th().ptr(),0.0);
1552 ae_tm_.template getAsObject<panzer::Traits::Residual>()->evaluate(ae_inargs);
1556 PANZER_FUNC_TIME_MONITOR(
"panzer::ModelEvaluator::evalModel(J)");
1563 thGlobalContainer->set_f_th(dummy_f);
1564 thGlobalContainer->set_A_th(W_out);
1567 thGhostedContainer->initializeMatrix(0.0);
1569 ae_tm_.template getAsObject<panzer::Traits::Jacobian>()->evaluate(ae_inargs);
1575 thGlobalContainer->set_A_th(Teuchos::null);
1581 thGlobalContainer->set_x_th(Teuchos::null);
1582 thGlobalContainer->set_dxdt_th(Teuchos::null);
1583 thGlobalContainer->set_f_th(Teuchos::null);
1584 thGlobalContainer->set_A_th(Teuchos::null);
1590 template <
typename Scalar>
1593 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
1602 setupAssemblyInArgs(inArgs,ae_inargs);
1605 setParameters(inArgs);
1607 for(std::size_t i=0;i<responses_.size();i++) {
1609 if(vec!=Teuchos::null) {
1610 std::string responseName = responses_[i]->name;
1614 resp->setVector(vec);
1626 template <
typename Scalar>
1630 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
1632 typedef Thyra::ModelEvaluatorBase MEB;
1638 setParameters(inArgs);
1640 for(std::size_t i=0;i<responses_.size();i++) {
1642 MEB::Derivative<Scalar> deriv = outArgs.get_DgDx(i);
1648 if(vec!=Teuchos::null) {
1650 std::string responseName = responses_[i]->name;
1654 resp->setDerivative(vec);
1662 setupAssemblyInArgs(inArgs,ae_inargs);
1672 template <
typename Scalar>
1676 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
1680 using Teuchos::rcp_dynamic_cast;
1682 typedef Thyra::ModelEvaluatorBase MEB;
1688 std::vector<std::string> activeParameterNames;
1689 std::vector<int> activeParameters;
1690 int totalParameterCount = 0;
1691 for(std::size_t j=0; j<parameters_.size(); j++) {
1694 if(parameters_[j]->is_distributed)
1697 bool is_active =
false;
1698 for(std::size_t i=0;i<responses_.size(); i++) {
1700 MEB::Derivative<Scalar> deriv = outArgs.get_DgDp(i,j);
1705 if(vec!=Teuchos::null) {
1707 std::string responseName = responses_[i]->name;
1711 resp->setVector(vec);
1717 for (std::size_t k=0; k<parameters_[j]->scalar_value.size(); k++) {
1718 std::string name =
"PARAMETER_SENSITIVIES: "+(*parameters_[j]->names)[k];
1719 activeParameterNames.push_back(name);
1720 totalParameterCount++;
1722 activeParameters.push_back(j);
1728 setupAssemblyInArgs(inArgs,ae_inargs);
1737 for (std::size_t ap=0; ap<activeParameters.size(); ++ap) {
1738 const int j = activeParameters[ap];
1739 for (
unsigned int k=0; k < parameters_[j]->scalar_value.size(); k++) {
1741 p.fastAccessDx(paramIndex) = 1.0;
1742 parameters_[j]->scalar_value[k].family->template setValue<panzer::Traits::Tangent>(p);
1751 if(totalParameterCount>0) {
1757 template <
typename Scalar>
1761 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
1763 typedef Thyra::ModelEvaluatorBase MEB;
1772 for(std::size_t p=0;p<parameters_.size();p++) {
1776 if(!parameters_[p]->is_distributed)
1781 for(std::size_t r=0;r<responses_.size();r++) {
1783 MEB::Derivative<Scalar> deriv = outArgs.get_DgDp(r,p);
1789 if(vec!=Teuchos::null) {
1792 std::string responseName = responses_[r]->name;
1797 resp->setDerivative(vec);
1804 setupAssemblyInArgs(inArgs,ae_inargs);
1816 template <
typename Scalar>
1820 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
1823 using Teuchos::rcp_dynamic_cast;
1825 typedef Thyra::ModelEvaluatorBase MEB;
1833 setupAssemblyInArgs(inArgs,ae_inargs);
1839 std::vector<std::string> activeParameters;
1841 int totalParameterCount = 0;
1842 for(std::size_t i=0; i < parameters_.size(); i++) {
1844 if(parameters_[i]->is_distributed)
1848 MEB::Derivative<Scalar> deriv = outArgs.get_DfDp(i);
1854 TEUCHOS_ASSERT(mVec->domain()->dim()==Teuchos::as<int>(parameters_[i]->scalar_value.size()));
1856 for (std::size_t j=0; j < parameters_[i]->scalar_value.size(); j++) {
1867 thGlobalContainer->set_f_th(vec);
1870 std::string name =
"PARAMETER_SENSITIVIES: "+(*parameters_[i]->names)[j];
1874 activeParameters.push_back(name);
1875 totalParameterCount++;
1892 for(std::size_t i=0; i < parameters_.size(); i++) {
1894 if(parameters_[i]->is_distributed)
1898 MEB::Derivative<Scalar> deriv = outArgs.get_DfDp(i);
1899 if(deriv.isEmpty()) {
1901 for (
unsigned int j=0; j < parameters_[i]->scalar_value.size(); j++) {
1903 parameters_[i]->scalar_value[j].baseValue);
1904 parameters_[i]->scalar_value[j].family->template setValue<panzer::Traits::Tangent>(p);
1910 for (
unsigned int j=0; j < parameters_[i]->scalar_value.size(); j++) {
1912 parameters_[i]->scalar_value[j].baseValue);
1913 p.fastAccessDx(paramIndex) = 1.0;
1914 parameters_[i]->scalar_value[j].family->template setValue<panzer::Traits::Tangent>(p);
1926 if(totalParameterCount>0) {
1927 PANZER_FUNC_TIME_MONITOR(
"panzer::ModelEvaluator::evalModel(df/dp)");
1932 template <
typename Scalar>
1936 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
1938 PANZER_FUNC_TIME_MONITOR(
"panzer::ModelEvaluator::evalModel(df/dp)");
1941 using Teuchos::rcp_dynamic_cast;
1943 typedef Thyra::ModelEvaluatorBase MEB;
1950 MEB::OutArgs<Scalar> outArgs_base = this->createOutArgs();
1951 if (outArgs.get_f() == Teuchos::null)
1952 outArgs_base.set_f(Thyra::createMember(this->get_f_space()));
1954 outArgs_base.set_f(outArgs.get_f());
1955 outArgs_base.set_W_op(outArgs.get_W_op());
1956 this->evalModel(inArgs, outArgs_base);
1960 if (inArgs.supports(MEB::IN_ARG_x_dot))
1961 x_dot = inArgs.get_x_dot();
1965 MEB::OutArgs<Scalar> outArgs_fd = this->createOutArgs();
1966 outArgs_fd.set_f(fd);
1970 if (x_dot != Teuchos::null)
1971 xd_dot = Thyra::createMember(this->get_x_space());
1972 MEB::InArgs<Scalar> inArgs_fd = this->createInArgs();
1973 inArgs_fd.setArgs(inArgs);
1974 inArgs_fd.set_x(xd);
1975 if (x_dot != Teuchos::null)
1976 inArgs_fd.set_x_dot(xd_dot);
1978 const double h = fd_perturb_size_;
1979 for(std::size_t i=0; i < parameters_.size(); i++) {
1982 if(parameters_[i]->is_distributed)
1986 MEB::Derivative<Scalar> deriv = outArgs.get_DfDp(i);
1992 TEUCHOS_ASSERT(dfdp->domain()->dim()==Teuchos::as<int>(parameters_[i]->scalar_value.size()));
1998 rcp_dynamic_cast<
const Thyra::DefaultMultiVectorProductVector<Scalar> >(dx_v,
true)->
getMultiVector();
2001 if (x_dot != Teuchos::null) {
2002 dx_dot_v =inArgs.get_p(i+parameters_.size()+tangent_space_.size());
2004 rcp_dynamic_cast<
const Thyra::DefaultMultiVectorProductVector<Scalar> >(dx_dot_v,
true)->
getMultiVector();
2009 inArgs_fd.set_p(i,pd);
2011 for (std::size_t j=0; j < parameters_[i]->scalar_value.size(); j++) {
2014 Thyra::copy(*p, pd.
ptr());
2015 Thyra::set_ele(j, Thyra::get_ele(*p,j)+h, pd.
ptr());
2018 Thyra::V_VpStV(xd.
ptr(), *x, h, *(dx)->col(j));
2019 if (x_dot != Teuchos::null)
2020 Thyra::V_VpStV(xd_dot.
ptr(), *x_dot, h, *(dx_dot)->col(j));
2023 Thyra::assign(fd.
ptr(), 0.0);
2024 this->evalModel(inArgs_fd, outArgs_fd);
2027 Thyra::V_StVpStV(dfdp->col(j).
ptr(), 1.0/h, *fd, -1.0/h, *f);
2030 parameters_[i]->scalar_value[j].family->setRealValueForAllTypes(Thyra::get_ele(*p,j));
2036 template <
typename Scalar>
2040 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs)
const
2043 using Teuchos::rcp_dynamic_cast;
2044 using Teuchos::null;
2046 typedef Thyra::ModelEvaluatorBase MEB;
2054 for(std::size_t p=0;p<parameters_.size();p++) {
2058 if(!parameters_[p]->is_distributed)
2063 if(parameters_[p]->dfdp_rl==null)
2067 MEB::Derivative<Scalar> deriv = outArgs.get_DfDp(p);
2076 response_jacobian->setJacobian(deriv.getLinearOp());
2081 setupAssemblyInArgs(inArgs,ae_inargs);
2092 template <
typename Scalar>
2097 bool activeGArgs =
false;
2098 for(
int i=0;i<outArgs.Ng();i++)
2099 activeGArgs |= (outArgs.get_g(i)!=Teuchos::null);
2101 return activeGArgs | required_basic_dgdx(outArgs);
2104 template <
typename Scalar>
2108 typedef Thyra::ModelEvaluatorBase MEB;
2111 bool activeGArgs =
false;
2112 for(
int i=0;i<outArgs.Ng();i++) {
2114 if(outArgs.supports(MEB::OUT_ARG_DgDx,i).none())
2118 activeGArgs |= (!outArgs.get_DgDx(i).isEmpty());
2124 template <
typename Scalar>
2128 typedef Thyra::ModelEvaluatorBase MEB;
2131 bool activeGArgs =
false;
2132 for(
int i=0;i<outArgs.Ng();i++) {
2133 for(
int p=0;p<Teuchos::as<int>(parameters_.size());p++) {
2136 if(parameters_[p]->is_distributed)
2140 if(outArgs.supports(MEB::OUT_ARG_DgDp,i,p).none())
2143 activeGArgs |= (!outArgs.get_DgDp(i,p).isEmpty());
2150 template <
typename Scalar>
2154 typedef Thyra::ModelEvaluatorBase MEB;
2157 bool activeGArgs =
false;
2158 for(
int i=0;i<outArgs.Ng();i++) {
2159 for(
int p=0;p<Teuchos::as<int>(parameters_.size());p++) {
2162 if(!parameters_[p]->is_distributed)
2166 if(outArgs.supports(MEB::OUT_ARG_DgDp,i,p).none())
2169 activeGArgs |= (!outArgs.get_DgDp(i,p).isEmpty());
2176 template <
typename Scalar>
2180 typedef Thyra::ModelEvaluatorBase MEB;
2183 bool activeFPArgs =
false;
2184 for(
int i=0;i<Teuchos::as<int>(parameters_.size());i++) {
2187 if(parameters_[i]->is_distributed)
2191 if(outArgs.supports(MEB::OUT_ARG_DfDp,i).none())
2195 activeFPArgs |= (!outArgs.get_DfDp(i).isEmpty());
2198 return activeFPArgs;
2201 template <
typename Scalar>
2205 typedef Thyra::ModelEvaluatorBase MEB;
2208 bool activeFPArgs =
false;
2209 for(
int i=0;i<Teuchos::as<int>(parameters_.size());i++) {
2212 if(!parameters_[i]->is_distributed)
2216 if(outArgs.supports(MEB::OUT_ARG_DfDp,i).none())
2220 activeFPArgs |= (!outArgs.get_DfDp(i).isEmpty());
2223 return activeFPArgs;
2226 template <
typename Scalar>
2231 const std::vector<panzer::BC> & bcs,
2237 const bool write_graphviz_file,
2238 const std::string& graphviz_file_prefix)
2242 using Teuchos::null;
2248 for(std::size_t p=0;p<parameters_.size();p++) {
2251 if(!parameters_[p]->is_distributed)
2256 if(parameters_[p]->global_indexer==null)
2262 parameters_[p]->global_indexer);
2268 rLibrary->buildResidualResponseEvaluators(physicsBlocks,eqset_factory,bcs,bc_factory,
2269 cm_factory,closure_models,user_data,
2270 write_graphviz_file,graphviz_file_prefix);
2273 parameters_[p]->dfdp_rl = rLibrary;
2277 template <
typename Scalar>
2282 const std::vector<panzer::BC>& ,
2288 const bool write_graphviz_file,
2289 const std::string& graphviz_file_prefix)
2293 using Teuchos::null;
2299 for(std::size_t p=0;p<parameters_.size();p++) {
2302 if(!parameters_[p]->is_distributed)
2307 if(parameters_[p]->global_indexer==null)
2321 for(std::size_t r=0;r<responses_.size();r++) {
2323 if(responses_[r]->builder==Teuchos::null)
2328 responses_[r]->builder->setDerivativeInformation(param_lof);
2331 rLibrary->addResponse(responses_[r]->name,
2332 responses_[r]->wkst_desc,
2333 *responses_[r]->builder);
2336 rLibrary->buildResponseEvaluators(physicsBlocks,eqset_factory,
2337 cm_factory,closure_models,user_data,
2338 write_graphviz_file,graphviz_file_prefix);
2341 parameters_[p]->dgdp_rl = rLibrary;
2345 template <
typename Scalar>
2349 oneTimeDirichletBeta_on_ =
true;
2350 oneTimeDirichletBeta_ = beta;
2353 template <
typename Scalar>
2361 using Teuchos::rcp_dynamic_cast;
2362 using Teuchos::ptrFromRef;
2376 paramObj->is_distributed =
false;
2379 for(
int i=0;i<in_names.
size();i++)
2387 Thyra::locallyReplicatedDefaultSpmdVectorSpace<Scalar>(
2394 vec->getNonconstLocalData(ptrFromRef(data));
2395 for (
unsigned int i=0; i < paramObj->scalar_value.size(); i++)
2396 data[i] = in_values[i];
2398 paramObj->initial_value = initial_value;
2403 template <
typename Scalar>
2416 paramObj->is_distributed =
true;
2418 paramObj->names->push_back(key);
2419 paramObj->space = vs;
2420 paramObj->initial_value = initial;
2422 paramObj->global_indexer = ugi;
2427 template <
typename Scalar>
2432 for(std::size_t i=0; i < parameters_.size(); i++) {
2435 if(parameters_[i]->is_distributed)
2440 if (p != Teuchos::null) {
2441 for (
unsigned int j=0; j < parameters_[i]->scalar_value.size(); j++) {
2442 parameters_[i]->scalar_value[j].family->setRealValueForAllTypes(Thyra::get_ele(*p,j));
2449 template <
typename Scalar>
2454 for(std::size_t i=0; i < parameters_.size(); i++) {
2457 if(parameters_[i]->is_distributed)
2461 for (
unsigned int j=0; j < parameters_[i]->scalar_value.size(); j++) {
2462 parameters_[i]->scalar_value[j].family->setRealValueForAllTypes(Thyra::get_ele(*(parameters_[i]->initial_value),j));
2468 #endif // __Panzer_ModelEvaluator_impl_hpp__
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
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
void addResponsesToInArgs(panzer::AssemblyEngineInArgs &input_args) 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
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
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?
Teuchos::RCP< const LinearObjFactory< panzer::Traits > > cloneWithNewDomain(const LinearObjFactory< panzer::Traits > &lof, const Teuchos::RCP< const UniqueGlobalIndexerBase > &dUgi)
Clone a linear object factory, but using a different domain.
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)
Teuchos::RCP< const UniqueGlobalIndexerBase > global_indexer
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< 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
void push_back(const value_type &x)
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)
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...
void registerScalarParameter(const std::string name, panzer::ParamLib &pl, double realValue)
virtual void evalModelImpl_basic_dgdp_scalar(const Thyra::ModelEvaluatorBase::InArgs< Scalar > &inArgs, const Thyra::ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const
int addParameter(const std::string &name, const Scalar &initial)