10 #ifndef THYRA_DIRECTIONAL_FINITE_DIFF_CALCULATOR_DEF_HPP
11 #define THYRA_DIRECTIONAL_FINITE_DIFF_CALCULATOR_DEF_HPP
14 #include "Thyra_DirectionalFiniteDiffCalculator_decl.hpp"
15 #include "Thyra_ModelEvaluatorHelpers.hpp"
16 #include "Thyra_DetachedVectorView.hpp"
17 #include "Thyra_DetachedMultiVectorView.hpp"
18 #include "Thyra_StateFuncModelEvaluatorBase.hpp"
19 #include "Thyra_MultiVectorStdOps.hpp"
20 #include "Thyra_VectorStdOps.hpp"
21 #include "Teuchos_TimeMonitor.hpp"
22 #include "Teuchos_VerboseObjectParameterListHelpers.hpp"
28 namespace DirectionalFiniteDiffCalculatorTypes {
41 template<
class Scalar>
42 class OutArgsCreator :
public StateFuncModelEvaluatorBase<Scalar>
46 RCP<const VectorSpaceBase<Scalar> > get_x_space()
const
48 RCP<const VectorSpaceBase<Scalar> > get_f_space()
const
50 ModelEvaluatorBase::InArgs<Scalar> createInArgs()
const
52 ModelEvaluatorBase::OutArgs<Scalar> createOutArgs()
const
55 const ModelEvaluatorBase::InArgs<Scalar> &inArgs,
56 const ModelEvaluatorBase::OutArgs<Scalar> &outArgs
60 static ModelEvaluatorBase::OutArgs<Scalar> createOutArgs(
61 const ModelEvaluator<Scalar> &model,
62 const SelectedDerivatives &fdDerivatives
68 const MEB::OutArgs<Scalar> wrappedOutArgs = model.createOutArgs();
69 const int Np = wrappedOutArgs.Np(),
Ng = wrappedOutArgs.Ng();
70 MEB::OutArgsSetup<Scalar> outArgs;
72 outArgs.setModelEvalDescription(
73 "DirectionalFiniteDiffCalculator: " + model.description()
79 outArgs.set_Np_Ng(Np,Ng);
80 outArgs.setSupports(wrappedOutArgs);
84 const SelectedDerivatives::supports_DfDp_t
85 &supports_DfDp = fdDerivatives.supports_DfDp_;
87 SelectedDerivatives::supports_DfDp_t::const_iterator
88 itr = supports_DfDp.begin();
89 itr != supports_DfDp.end();
94 assert_p_space(model,l);
95 outArgs.setSupports(MEB::OUT_ARG_DfDp,l,MEB::DERIV_MV_BY_COL);
100 const SelectedDerivatives::supports_DgDp_t
101 &supports_DgDp = fdDerivatives.supports_DgDp_;
103 SelectedDerivatives::supports_DgDp_t::const_iterator
104 itr = supports_DgDp.begin();
105 itr != supports_DgDp.end();
109 const int j = itr->first;
110 const int l = itr->second;
111 assert_p_space(model,l);
112 outArgs.setSupports(MEB::OUT_ARG_DgDp,j,l,MEB::DERIV_MV_BY_COL);
121 static void assert_p_space(
const ModelEvaluator<Scalar> &model,
const int l )
124 const bool p_space_l_is_in_core = model.get_p_space(l)->hasInCoreView();
126 !p_space_l_is_in_core, std::logic_error,
127 "Error, for the model " << model.description()
128 <<
", the space p_space("<<l<<
") must be in-core so that they can"
129 " act as the domain space for the multi-vector derivative!"
146 template<
class Scalar>
147 const std::string& DirectionalFiniteDiffCalculator<Scalar>::FDMethod_name()
149 static std::string loc_FDMethod_name =
"FD Method";
150 return loc_FDMethod_name;
154 template<
class Scalar>
157 Thyra::DirectionalFiniteDiffCalculatorTypes::EFDMethodType
160 DirectionalFiniteDiffCalculator<Scalar>::fdMethodValidator()
162 static RCP<Teuchos::StringToIntegralParameterEntryValidator<EFDMethodType> >
163 loc_fdMethodValidator
166 Teuchos::tuple<std::string>(
172 ,
"order-four-central"
175 ,Teuchos::tuple<std::string>(
176 "Use O(eps) one sided finite differences (cramped bounds)"
177 ,
"Use O(eps^2) one sided finite differences (cramped bounds)"
178 ,
"Use O(eps^2) two sided central finite differences"
179 ,
"Use \"order-two-central\" when not cramped by bounds, otherwise use \"order-two\""
180 ,
"Use O(eps^4) one sided finite differences (cramped bounds)"
181 ,
"Use O(eps^4) two sided central finite differences"
182 ,
"Use \"order-four-central\" when not cramped by bounds, otherwise use \"order-four\""
184 ,Teuchos::tuple<Thyra::DirectionalFiniteDiffCalculatorTypes::EFDMethodType>(
185 Thyra::DirectionalFiniteDiffCalculatorTypes::FD_ORDER_ONE
186 ,Thyra::DirectionalFiniteDiffCalculatorTypes::FD_ORDER_TWO
187 ,Thyra::DirectionalFiniteDiffCalculatorTypes::FD_ORDER_TWO_CENTRAL
188 ,Thyra::DirectionalFiniteDiffCalculatorTypes::FD_ORDER_TWO_AUTO
189 ,Thyra::DirectionalFiniteDiffCalculatorTypes::FD_ORDER_FOUR
190 ,Thyra::DirectionalFiniteDiffCalculatorTypes::FD_ORDER_FOUR_CENTRAL
191 ,Thyra::DirectionalFiniteDiffCalculatorTypes::FD_ORDER_FOUR_AUTO
196 return loc_fdMethodValidator;
200 template<
class Scalar>
202 DirectionalFiniteDiffCalculator<Scalar>::FDMethod_default()
204 static std::string loc_FDMethod_default =
"order-one";
205 return loc_FDMethod_default;
209 template<
class Scalar>
211 DirectionalFiniteDiffCalculator<Scalar>::FDStepSelectType_name()
213 static std::string loc_FDStepSelectType_name =
"FD Step Select Type";
214 return loc_FDStepSelectType_name;
218 template<
class Scalar>
221 Thyra::DirectionalFiniteDiffCalculatorTypes::EFDStepSelectType
224 DirectionalFiniteDiffCalculator<Scalar>::fdStepSelectTypeValidator()
226 static const RCP<Teuchos::StringToIntegralParameterEntryValidator<EFDStepSelectType> >
227 loc_fdStepSelectTypeValidator
230 Teuchos::tuple<std::string>(
234 ,Teuchos::tuple<std::string>(
235 "Use absolute step size \""+FDStepLength_name()+
"\""
236 ,
"Use relative step size \""+FDStepLength_name()+
"\"*||xo||inf"
238 ,Teuchos::tuple<Thyra::DirectionalFiniteDiffCalculatorTypes::EFDStepSelectType>(
239 Thyra::DirectionalFiniteDiffCalculatorTypes::FD_STEP_ABSOLUTE
240 ,Thyra::DirectionalFiniteDiffCalculatorTypes::FD_STEP_RELATIVE
245 return loc_fdStepSelectTypeValidator;
249 template<
class Scalar>
251 DirectionalFiniteDiffCalculator<Scalar>::FDStepSelectType_default()
253 static std::string loc_FDStepSelectType_default =
"Absolute";
254 return loc_FDStepSelectType_default;
258 template<
class Scalar>
260 DirectionalFiniteDiffCalculator<Scalar>::FDStepLength_name()
262 static std::string loc_FDStepLength_name =
"FD Step Length";
263 return loc_FDStepLength_name;
267 template<
class Scalar>
269 DirectionalFiniteDiffCalculator<Scalar>::FDStepLength_default()
271 static double loc_FDStepLength_default = -1.0;
272 return loc_FDStepLength_default;
279 template<
class Scalar>
286 :fd_method_type_(fd_method_type_in)
287 ,fd_step_select_type_(fd_step_select_type_in)
288 ,fd_step_size_(fd_step_size_in)
289 ,fd_step_size_min_(fd_step_size_min_in)
296 template<
class Scalar>
303 paramList_ = paramList;
305 *paramList_, FDMethod_name(), FDMethod_default());
306 fd_step_select_type_ = fdStepSelectTypeValidator()->getIntegralValue(
307 *paramList_, FDStepSelectType_name(), FDStepSelectType_default());
308 fd_step_size_ = paramList_->get(
309 FDStepLength_name(),FDStepLength_default());
310 Teuchos::readVerboseObjectSublist(&*paramList_,
this);
314 template<
class Scalar>
322 template<
class Scalar>
327 paramList_ = Teuchos::null;
332 template<
class Scalar>
340 template<
class Scalar>
344 using Teuchos::rcp_implicit_cast;
348 pl = Teuchos::parameterList();
350 FDMethod_name(), FDMethod_default(),
351 "The method used to compute the finite differences.",
352 rcp_implicit_cast<const PEV>(fdMethodValidator())
355 FDStepSelectType_name(), FDStepSelectType_default(),
356 "Method used to select the finite difference step length.",
357 rcp_implicit_cast<const PEV>(fdStepSelectTypeValidator())
360 FDStepLength_name(), FDStepLength_default()
361 ,
"The length of the finite difference step to take.\n"
362 "A value of < 0.0 means that the step length will be determined automatically."
364 Teuchos::setupVerboseObjectSublist(&*pl);
370 template<
class Scalar>
377 return DirectionalFiniteDiffCalculatorTypes::OutArgsCreator<Scalar>::createOutArgs(
378 model, fdDerivatives );
382 template<
class Scalar>
394 THYRA_FUNC_TIME_MONITOR(
395 string(
"Thyra::DirectionalFiniteDiffCalculator<")+ST::name()+
">::calcVariations(...)"
403 namespace DFDCT = DirectionalFiniteDiffCalculatorTypes;
411 if(out.
get() && trace)
412 *out <<
"\nEntering DirectionalFiniteDiffCalculator<Scalar>::calcVariations(...)\n";
414 if(out.
get() && trace)
416 <<
"\nbasePoint=\n" << describe(bp,verbLevel)
417 <<
"\ndirections=\n" << describe(dir,verbLevel)
418 <<
"\nbaseFunctionValues=\n" << describe(bfunc,verbLevel)
423 var.
isEmpty(), std::logic_error,
424 "Error, all of the variations can not be null!"
456 switch(this->fd_method_type()) {
457 case DFDCT::FD_ORDER_ONE:
458 if(out.
get()&&trace) *out<<
"\nUsing one-sided, first-order finite differences ...\n";
460 case DFDCT::FD_ORDER_TWO:
461 if(out.
get()&&trace) *out<<
"\nUsing one-sided, second-order finite differences ...\n";
463 case DFDCT::FD_ORDER_TWO_CENTRAL:
464 if(out.
get()&&trace) *out<<
"\nUsing second-order central finite differences ...\n";
466 case DFDCT::FD_ORDER_TWO_AUTO:
467 if(out.
get()&&trace) *out<<
"\nUsing auto selection of some second-order finite difference method ...\n";
469 case DFDCT::FD_ORDER_FOUR:
470 if(out.
get()&&trace) *out<<
"\nUsing one-sided, fourth-order finite differences ...\n";
472 case DFDCT::FD_ORDER_FOUR_CENTRAL:
473 if(out.
get()&&trace) *out<<
"\nUsing fourth-order central finite differences ...\n";
475 case DFDCT::FD_ORDER_FOUR_AUTO:
476 if(out.
get()&&trace) *out<<
"\nUsing auto selection of some fourth-order finite difference method ...\n";
490 sqrt_epsilon = SMT::squareroot(SMT::eps()),
491 u_optimal_1 = sqrt_epsilon,
492 u_optimal_2 = SMT::squareroot(sqrt_epsilon),
493 u_optimal_4 = SMT::squareroot(u_optimal_2);
496 bp_norm = SMT::zero();
501 switch(this->fd_method_type()) {
502 case DFDCT::FD_ORDER_ONE:
503 uh_opt = u_optimal_1 * ( fd_step_select_type() == DFDCT::FD_STEP_ABSOLUTE ? 1.0 : bp_norm + 1.0 );
505 case DFDCT::FD_ORDER_TWO:
506 case DFDCT::FD_ORDER_TWO_CENTRAL:
507 case DFDCT::FD_ORDER_TWO_AUTO:
508 uh_opt = u_optimal_2 * ( fd_step_select_type() == DFDCT::FD_STEP_ABSOLUTE ? 1.0 : bp_norm + 1.0 );
510 case DFDCT::FD_ORDER_FOUR:
511 case DFDCT::FD_ORDER_FOUR_CENTRAL:
512 case DFDCT::FD_ORDER_FOUR_AUTO:
513 uh_opt = u_optimal_4 * ( fd_step_select_type() == DFDCT::FD_STEP_ABSOLUTE ? 1.0 : bp_norm + 1.0 );
519 if(out.
get()&&trace) *out<<
"\nDefault optimal step length uh_opt = " << uh_opt <<
" ...\n";
526 uh = this->fd_step_size();
530 else if( fd_step_select_type() == DFDCT::FD_STEP_RELATIVE )
531 uh *= (bp_norm + 1.0);
533 if(out.
get()&&trace) *out<<
"\nStep size to be used uh="<<uh<<
"\n";
547 DFDCT::EFDMethodType l_fd_method_type = this->fd_method_type();
548 switch(l_fd_method_type) {
549 case DFDCT::FD_ORDER_TWO_AUTO:
550 l_fd_method_type = DFDCT::FD_ORDER_TWO_CENTRAL;
552 case DFDCT::FD_ORDER_FOUR_AUTO:
553 l_fd_method_type = DFDCT::FD_ORDER_FOUR_CENTRAL;
563 p_saved = out->precision();
568 const int Np = var.
Np(), Ng = var.
Ng();
571 VectorPtr per_x, per_x_dot, per_x_dot_dot;
572 std::vector<VectorPtr> per_p(Np);
576 if( dir.
get_x().get() )
579 pp.set_x(bp.
get_x());
581 if( bp.
supports(MEB::IN_ARG_x_dot) ) {
583 pp.set_x_dot(per_x_dot=createMember(model.
get_x_space()));
587 if( bp.
supports(MEB::IN_ARG_x_dot_dot) ) {
589 pp.set_x_dot_dot(per_x_dot_dot=createMember(model.
get_x_space()));
593 for(
int l = 0; l < Np; ++l ) {
594 if( dir.
get_p(l).get() )
595 pp.set_p(l,per_p[l]=createMember(model.
get_p_space(l)));
597 pp.set_p(l,bp.
get_p(l));
599 if(out.
get() && trace)
601 <<
"\nperturbedPoint after initial setup (with some uninitialized vectors) =\n"
602 << describe(pp,verbLevel);
605 bool all_funcs_at_base_computed =
true;
609 if( var.
supports(MEB::OUT_ARG_f) && (f=var.
get_f()).
get() ) {
611 assign(f.ptr(),ST::zero());
612 if(!bfunc.
get_f().get()) all_funcs_at_base_computed =
false;
614 for(
int j = 0; j < Ng; ++j ) {
616 if( (g_j=var.
get_g(j)).
get() ) {
618 assign(g_j.ptr(),ST::zero());
619 if(!bfunc.
get_g(j).get()) all_funcs_at_base_computed =
false;
623 if(out.
get() && trace)
625 <<
"\nperturbedFunctions after initial setup (with some uninitialized vectors) =\n"
626 << describe(pfunc,verbLevel);
628 const int dbl_p = 15;
630 *out << std::setprecision(dbl_p);
638 switch(l_fd_method_type) {
639 case DFDCT::FD_ORDER_ONE:
643 case DFDCT::FD_ORDER_TWO:
647 case DFDCT::FD_ORDER_TWO_CENTRAL:
651 case DFDCT::FD_ORDER_FOUR:
655 case DFDCT::FD_ORDER_FOUR_CENTRAL:
662 for(
int eval_i = 1; eval_i <= num_evals; ++eval_i ) {
667 switch(l_fd_method_type) {
668 case DFDCT::FD_ORDER_ONE: {
681 case DFDCT::FD_ORDER_TWO: {
698 case DFDCT::FD_ORDER_TWO_CENTRAL: {
711 case DFDCT::FD_ORDER_FOUR: {
736 case DFDCT::FD_ORDER_FOUR_CENTRAL: {
757 case DFDCT::FD_ORDER_TWO_AUTO:
758 case DFDCT::FD_ORDER_FOUR_AUTO:
764 if(out.
get() && trace)
765 *out <<
"\neval_i="<<eval_i<<
", uh_i="<<uh_i<<
", wgt_i="<<wgt_i<<
"\n";
769 if(uh_i == ST::zero()) {
770 MEB::OutArgs<Scalar> bfuncall;
771 if(!all_funcs_at_base_computed) {
774 if( pfunc.supports(MEB::OUT_ARG_f) && pfunc.get_f().get() && !bfunc.
get_f().get() ) {
777 for(
int j = 0; j < Ng; ++j ) {
778 if( pfunc.get_g(j).get() && !bfunc.
get_g(j).get() ) {
779 bfuncall.set_g(j,createMember(model.
get_g_space(j)));
783 bfuncall.setArgs(bfunc);
789 if(out.
get() && trace)
790 *out <<
"\nSetting variations = wgt_i * basePoint ...\n";
792 if( pfunc.supports(MEB::OUT_ARG_f) && (f=var.
get_f()).
get() ) {
793 V_StV<Scalar>(f.ptr(), wgt_i, *bfuncall.get_f());
795 for(
int j = 0; j < Ng; ++j ) {
797 if( (g_j=var.
get_g(j)).
get() ) {
798 V_StV<Scalar>(g_j.ptr(), wgt_i, *bfuncall.get_g(j));
803 if(out.
get() && trace)
804 *out <<
"\nSetting perturbedPoint = basePoint + uh_i*uh*direction ...\n";
808 V_StVpV(per_x.ptr(),as<Scalar>(uh_i*uh),*dir.
get_x(),*bp.
get_x());
813 for (
int l = 0; l < Np; ++l ) {
814 if( dir.
get_p(l).get() )
815 V_StVpV(per_p[l].ptr(), as<Scalar>(uh_i*uh), *dir.
get_p(l), *bp.
get_p(l));
818 if(out.
get() && trace)
819 *out <<
"\nperturbedPoint=\n" << describe(pp,verbLevel);
821 if(out.
get() && trace)
822 *out <<
"\nCompute perturbedFunctions at perturbedPoint...\n";
824 if(out.
get() && trace)
825 *out <<
"\nperturbedFunctions=\n" << describe(pfunc,verbLevel);
829 if(out.
get() && trace)
830 *out <<
"\nComputing variations += wgt_i*perturbedfunctions ...\n";
832 if( pfunc.supports(MEB::OUT_ARG_f) && (f=pfunc.get_f()).
get() )
833 Vp_StV<Scalar>(var.
get_f().ptr(), wgt_i, *f);
834 for(
int j = 0; j < Ng; ++j ) {
836 if( (g_j=pfunc.get_g(j)).
get() )
837 Vp_StV<Scalar>(var.
get_g(j).ptr(), wgt_i, *g_j);
841 if(out.
get() && trace)
842 *out <<
"\nvariations=\n" << describe(var,verbLevel);
851 const Scalar alpha = ST::one()/(dwgt*uh);
852 if(out.
get() && trace)
854 <<
"\nComputing variations *= (1.0)/(dwgt*uh),"
855 <<
" where (1.0)/(dwgt*uh) = (1.0)/("<<dwgt<<
"*"<<uh<<
") = "<<alpha<<
" ...\n";
859 for(
int j = 0; j < Ng; ++j ) {
861 if( (g_j=var.
get_g(j)).
get() )
862 Vt_S(g_j.ptr(),alpha);
864 if(out.
get() && trace)
865 *out <<
"\nFinal variations=\n" << describe(var,verbLevel);
869 *out << std::setprecision(p_saved);
871 if(out.
get() && trace)
872 *out <<
"\nLeaving DirectionalFiniteDiffCalculator<Scalar>::calcVariations(...)\n";
877 template<
class Scalar>
889 THYRA_FUNC_TIME_MONITOR(
890 string(
"Thyra::DirectionalFiniteDiffCalculator<")+ST::name()+
">::calcDerivatives(...)"
902 if(out.
get() && trace)
903 *out <<
"\nEntering DirectionalFiniteDiffCalculator<Scalar>::calcDerivatives(...)\n";
905 if(out.
get() && trace)
907 <<
"\nbasePoint=\n" << describe(bp,verbLevel)
908 <<
"\nbaseFunctionValues=\n" << describe(bfunc,verbLevel)
914 const int Np = bp.
Np(), Ng = bfunc.
Ng();
917 MultiVectorPtr DfDp_l;
918 std::vector<MEB::DerivativeMultiVector<Scalar> > DgDp_l(Ng);
919 std::vector<VectorPtr> var_g(Ng);
920 for(
int l = 0; l < Np; ++l ) {
921 if(out.
get() && trace)
922 *out <<
"\nComputing derivatives for parameter subvector p("<<l<<
") ...\n";
927 bool hasDerivObject =
false;
930 !deriv.
supports(MEB::OUT_ARG_DfDp,l).none()
934 hasDerivObject =
true;
935 std::ostringstream name; name <<
"DfDp("<<l<<
")";
936 DfDp_l = get_mv(deriv.
get_DfDp(l),name.str(),MEB::DERIV_MV_BY_COL);
939 DfDp_l = Teuchos::null;
942 for (
int j = 0; j < Ng; ++j ) {
944 !deriv.
supports(MEB::OUT_ARG_DgDp,j,l).none()
949 hasDerivObject =
true;
950 std::ostringstream name; name <<
"DgDp("<<j<<
","<<l<<
")";
951 DgDp_l[j] = get_dmv(deriv.
get_DgDp(j,l),name.str());
952 if( DgDp_l[j].getMultiVector().get() && !var_g[j].get() )
959 DgDp_l[j] = MEB::DerivativeMultiVector<Scalar>();
960 var_g[j] = Teuchos::null;
966 if (hasDerivObject) {
967 VectorPtr e_i = createMember(model.
get_p_space(l));
969 assign(e_i.ptr(),ST::zero());
970 const int np_l = e_i->space()->dim();
971 for(
int i = 0 ; i < np_l; ++ i ) {
972 if(out.
get() && trace)
973 *out <<
"\nComputing derivatives for single variable p("<<l<<
")("<<i<<
") ...\n";
975 if(DfDp_l.get()) var.set_f(DfDp_l->col(i));
976 for(
int j = 0; j < Ng; ++j) {
977 MultiVectorPtr DgDp_j_l;
978 if( (DgDp_j_l=DgDp_l[j].getMultiVector()).get() ) {
979 var.set_g(j,var_g[j]);
982 set_ele(i,ST::one(),e_i.ptr());
983 this->calcVariations(
984 model,bp,dir,bfunc,var
986 set_ele(i,ST::zero(),e_i.ptr());
987 if (DfDp_l.get()) var.set_f(Teuchos::null);
988 for (
int j = 0; j < Ng; ++j) {
989 MultiVectorPtr DgDp_j_l;
990 if ( !
is_null(DgDp_j_l=DgDp_l[j].getMultiVector()) ) {
991 assign( DgDp_j_l->col(i).ptr(), *var_g[j] );
995 dir.set_p(l,Teuchos::null);
999 if(out.
get() && trace)
1001 <<
"\nderivatives=\n" << describe(deriv,verbLevel);
1003 if(out.
get() && trace)
1004 *out <<
"\nLeaving DirectionalFiniteDiffCalculator<Scalar>::calcDerivatives(...)\n";
1012 #endif // THYRA_DIRECTIONAL_FINITE_DIFF_CALCULATOR_DEF_HPP
virtual ModelEvaluatorBase::OutArgs< Scalar > createOutArgs() const =0
Create an empty output functions/derivatives object that can be set up and passed to evalModel()...
int Ng() const
Return the number of axillary response functions g(j)(...) supported (Ng >= 0).
virtual RCP< const VectorSpaceBase< Scalar > > get_x_space() const =0
Return the vector space for the state variables x <: RE^n_x.
ModelEvaluatorBase::OutArgs< Scalar > createOutArgs(const ModelEvaluator< Scalar > &model, const SelectedDerivatives &fdDerivatives)
Create an augmented out args object for holding finite difference objects.
Pure abstract base interface for evaluating a stateless "model" that can be mapped into a number of d...
Simple utility class used to select finite difference derivatives for OutArgs object.
void setParameterList(RCP< ParameterList > const ¶mList)
bool is_null(const boost::shared_ptr< T > &p)
DirectionalFiniteDiffCalculatorTypes::EFDStepSelectType EFDStepSelectType
Concrete aggregate class for all output arguments computable by a ModelEvaluator subclass object...
Derivative< Scalar > get_DfDp(int l) const
Precondition: supports(OUT_ARG_DfDp,l)==true.
RCP< const VectorBase< Scalar > > get_x_dot() const
Precondition: supports(IN_ARG_x_dot)==true.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual void evalModel(const ModelEvaluatorBase::InArgs< Scalar > &inArgs, const ModelEvaluatorBase::OutArgs< Scalar > &outArgs) const =0
Compute all of the requested functions/derivatives at the given point.
Evaluation< VectorBase< Scalar > > get_g(int j) const
Precondition: supports(OUT_ARG_g)==true..
Evaluation< VectorBase< Scalar > > get_f() const
Precondition: supports(OUT_ARG_f)==true.
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
virtual ModelEvaluatorBase::InArgs< Scalar > createInArgs() const =0
Create an empty input arguments object that can be set up and passed to evalModel().
bool supports(EOutArgsMembers arg) const
Determine if an input argument is supported or not.
Derivative< Scalar > get_DgDp(int j, int l) const
Precondition: supports(OUT_ARG_DgDp,j,l)==true.
IntegralType getIntegralValue(ParameterList const ¶mList, std::string const ¶mName)
DirectionalFiniteDiffCalculatorTypes::EFDMethodType EFDMethodType
void calcVariations(const ModelEvaluator< Scalar > &model, const ModelEvaluatorBase::InArgs< Scalar > &basePoint, const ModelEvaluatorBase::InArgs< Scalar > &directions, const ModelEvaluatorBase::OutArgs< Scalar > &baseFunctionValues, const ModelEvaluatorBase::OutArgs< Scalar > &variations) const
Compute variations using directional finite differences..
int Np() const
Return the number of parameter subvectors p(l) supported (Np >= 0).
RCP< const ParameterList > getValidParameters() const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual RCP< const VectorSpaceBase< Scalar > > get_p_space(int l) const =0
Return the vector space for the auxiliary parameters p(l) <: RE^n_p_l.
void calcDerivatives(const ModelEvaluator< Scalar > &model, const ModelEvaluatorBase::InArgs< Scalar > &basePoint, const ModelEvaluatorBase::OutArgs< Scalar > &baseFunctionValues, const ModelEvaluatorBase::OutArgs< Scalar > &derivatives) const
Compute entire derivative objects using finite differences.
void validateParameters(ParameterList const &validParamList, int const depth=1000, EValidateUsed const validateUsed=VALIDATE_USED_ENABLED, EValidateDefaults const validateDefaults=VALIDATE_DEFAULTS_ENABLED) const
Base subclass for ModelEvaluator that defines some basic types.
virtual RCP< const VectorSpaceBase< Scalar > > get_f_space() const =0
Return the vector space for the state function f(...) <: RE^n_x.
DirectionalFiniteDiffCalculator(EFDMethodType fd_method_type=DirectionalFiniteDiffCalculatorTypes::FD_ORDER_FOUR_AUTO, EFDStepSelectType fd_step_select_type=DirectionalFiniteDiffCalculatorTypes::FD_STEP_ABSOLUTE, ScalarMag fd_step_size=-1.0, ScalarMag fd_step_size_min=-1.0)
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
TypeTo as(const TypeFrom &t)
RCP< const ParameterList > getParameterList() const
virtual RCP< const VectorSpaceBase< Scalar > > get_g_space(int j) const =0
Return the vector space for the auxiliary response functions g(j) <: RE^n_g_j.
ST::magnitudeType ScalarMag
RCP< ParameterList > unsetParameterList()
ModelEvaluatorBase()
constructor
RCP< ParameterList > getNonconstParameterList()
int Np() const
Return the number of parameter subvectors p(l) supported (Np >= 0).
RCP< const VectorBase< Scalar > > get_x_dot_dot() const
Precondition: supports(IN_ARG_x_dot_dot)==true.
bool supports(EInArgsMembers arg) const
Determines if an input argument is supported or not.
RCP< const VectorBase< Scalar > > get_x() const
Precondition: supports(IN_ARG_x)==true.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
RCP< const VectorBase< Scalar > > get_p(int l) const
Get p(l) where 0 <= l && l < this->Np().
Concrete aggregate class for all input arguments computable by a ModelEvaluator subclass object...