10 #ifndef THYRA_DEFAULT_MODEL_EVALUATOR_DELEGETOR_BASE_HPP
11 #define THYRA_DEFAULT_MODEL_EVALUATOR_DELEGETOR_BASE_HPP
14 #include "Thyra_ModelEvaluatorDefaultBase.hpp"
15 #include "Teuchos_ConstNonconstObjectContainer.hpp"
16 #include "Teuchos_TimeMonitor.hpp"
17 #include "Teuchos_StandardParameterEntryValidators.hpp"
49 template<
class Scalar>
133 #ifdef Thyra_BUILD_HESSIAN_SUPPORT
136 #endif // ifdef Thyra_BUILD_HESSIAN_SUPPORT
191 > LocalVerbosityLevel_validator_;
192 static const std::string LocalVerbosityLevel_name_;
194 static const std::string LocalVerbosityLevel_default_;
199 #define THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_GEN_LOCALVERBLEVEL_BEGIN(CLASS_NAME,INARGS,OUTARGS,UNDERLYINGMODEL,LOCALVERBLEVEL) \
201 using Teuchos::includesVerbLevel; \
202 using Teuchos::RCP; \
203 using Teuchos::EVerbosityLevel; \
204 const std::string blahblah_classNameStr \
205 = std::string(CLASS_NAME)+"<"+Teuchos::ScalarTraits<Scalar>::name()+">"; \
206 const std::string blahblah_classFuncNameStr \
207 = blahblah_classNameStr+"::evalModel(...)"; \
208 THYRA_FUNC_TIME_MONITOR(blahblah_classFuncNameStr); \
210 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &blahblah_outArgs = (OUTARGS); \
212 Teuchos::Time totalTimer(""); \
213 totalTimer.start(true); \
215 const RCP<Teuchos::FancyOStream> out = this->getOStream(); \
216 const EVerbosityLevel verbLevel = this->getVerbLevel(); \
217 const EVerbosityLevel localVerbLevelInput = (LOCALVERBLEVEL); \
218 const EVerbosityLevel localVerbLevel = \
219 ( localVerbLevelInput==Teuchos::VERB_DEFAULT ? verbLevel : localVerbLevelInput ); \
220 Teuchos::OSTab tab(out); \
221 if(out.get() && includesVerbLevel(localVerbLevel,Teuchos::VERB_LOW)) \
222 *out << "\nEntering " << blahblah_classFuncNameStr << " ...\n"; \
224 if(out.get() && includesVerbLevel(localVerbLevel,Teuchos::VERB_MEDIUM)) \
226 << "\ninArgs =\n" << Teuchos::describe((INARGS),localVerbLevel) \
227 << "\noutArgs on input =\n" << Teuchos::describe((OUTARGS),Teuchos::VERB_LOW); \
229 const RCP<const Thyra::ModelEvaluator<Scalar> > \
230 thyraModel = (UNDERLYINGMODEL); \
232 typedef Teuchos::VerboseObjectTempState<Thyra::ModelEvaluatorBase> VOTSME; \
233 VOTSME thyraModel_outputTempState(thyraModel,out,verbLevel)
236 #define THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_LOCALVERBLEVEL_BEGIN(CLASS_NAME,INARGS,OUTARGS,LOCALVERBLEVEL) \
237 THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_GEN_LOCALVERBLEVEL_BEGIN(CLASS_NAME,INARGS,OUTARGS,this->getUnderlyingModel(),LOCALVERBLEVEL)
240 #define THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_GEN_BEGIN(CLASS_NAME,INARGS,OUTARGS,UNDERLYINGMODEL) \
241 THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_GEN_LOCALVERBLEVEL_BEGIN(CLASS_NAME,INARGS,OUTARGS,UNDERLYINGMODEL,Teuchos::VERB_DEFAULT)
244 #define THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_BEGIN(CLASS_NAME,INARGS,OUTARGS) \
245 THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_GEN_BEGIN(CLASS_NAME,INARGS,OUTARGS,this->getUnderlyingModel())
248 #define THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_END() \
249 if(out.get() && includesVerbLevel(localVerbLevel,Teuchos::VERB_MEDIUM)) \
251 << "\noutArgs on output =\n" << Teuchos::describe(blahblah_outArgs,localVerbLevel); \
254 if(out.get() && includesVerbLevel(localVerbLevel,Teuchos::VERB_LOW)) \
256 << "\nTotal evaluation time = "<<totalTimer.totalElapsedTime()<<" sec\n" \
257 << "\nLeaving " << blahblah_classFuncNameStr << " ...\n"
267 template<
class Scalar>
275 template<
class Scalar>
278 =
"Local Verbosity Level";
280 template<
class Scalar>
285 template<
class Scalar>
288 = getVerbosityLevelParameterValueName(
296 template<
class Scalar>
301 template<
class Scalar>
310 template<
class Scalar>
319 template<
class Scalar>
324 model_.initialize(model);
328 template<
class Scalar>
333 model_.initialize(model);
337 template<
class Scalar>
340 model_.uninitialize();
347 template<
class Scalar>
350 return model_.isConst();
354 template<
class Scalar>
358 return model_.getNonconstObj();
362 template<
class Scalar>
366 return model_.getConstObj();
373 template<
class Scalar>
377 return getUnderlyingModel()->get_x_space();
381 template<
class Scalar>
385 return getUnderlyingModel()->get_f_space();
389 template<
class Scalar>
393 return getUnderlyingModel()->get_f_multiplier_space();
397 template<
class Scalar>
401 return getUnderlyingModel()->get_p_space(l);
405 template<
class Scalar>
409 return getUnderlyingModel()->get_p_names(l);
413 template<
class Scalar>
417 return getUnderlyingModel()->get_g_space(j);
421 template<
class Scalar>
425 return getUnderlyingModel()->get_g_multiplier_space(j);
429 template<
class Scalar>
433 return getUnderlyingModel()->get_g_names(j);
437 template<
class Scalar>
441 return getUnderlyingModel()->getNominalValues();
445 template<
class Scalar>
449 return getUnderlyingModel()->getLowerBounds();
453 template<
class Scalar>
457 return getUnderlyingModel()->getUpperBounds();
461 template<
class Scalar>
465 return getUnderlyingModel()->create_W();
469 template<
class Scalar>
473 return getUnderlyingModel()->create_W_op();
477 template<
class Scalar>
481 return getUnderlyingModel()->create_W_prec();
485 template<
class Scalar>
489 return getUnderlyingModel()->get_W_factory();
493 #ifdef Thyra_BUILD_HESSIAN_SUPPORT
494 template<
class Scalar>
498 return getUnderlyingModel()->create_hess_g_pp(j, l1, l2);
500 #endif // ifdef Thyra_BUILD_HESSIAN_SUPPORT
503 template<
class Scalar>
504 ModelEvaluatorBase::InArgs<Scalar>
509 return std::move(inArgs);
513 template<
class Scalar>
516 ,
const bool wasSolved
519 getNonconstUnderlyingModel()->reportFinalPoint(finalPoint,wasSolved);
529 template<
class Scalar>
535 if (
is_null(LocalVerbosityLevel_validator_))
536 LocalVerbosityLevel_validator_ =
537 Teuchos::verbosityLevelParameterEntryValidator(
538 LocalVerbosityLevel_name_
541 LocalVerbosityLevel_name_, LocalVerbosityLevel_default_,
542 "Overriding verbosity level for this model evaluator object.\n"
543 "This level will not propagate to nested model evaluator objects\n"
544 "The value of \"default\" result in the object verbosity level being\n"
546 LocalVerbosityLevel_validator_
551 template<
class Scalar>
557 return LocalVerbosityLevel_validator_->getIntegralValue(
558 paramList, LocalVerbosityLevel_name_, LocalVerbosityLevel_default_ );
568 template<
class Scalar>
576 template<
class Scalar>
577 RCP<LinearOpBase<Scalar> >
578 ModelEvaluatorDelegatorBase<Scalar>::create_DgDx_dot_op_impl(
582 return getUnderlyingModel()->create_DgDx_dot_op(j);
586 template<
class Scalar>
587 RCP<LinearOpBase<Scalar> >
588 ModelEvaluatorDelegatorBase<Scalar>::create_DgDx_op_impl(
592 return getUnderlyingModel()->create_DgDx_op(j);
596 template<
class Scalar>
597 RCP<LinearOpBase<Scalar> >
598 ModelEvaluatorDelegatorBase<Scalar>::create_DgDp_op_impl(
602 return getUnderlyingModel()->create_DgDp_op(j,l);
606 template<
class Scalar>
607 ModelEvaluatorBase::OutArgs<Scalar>
608 ModelEvaluatorDelegatorBase<Scalar>::createOutArgsImpl()
const
610 ModelEvaluatorBase::OutArgsSetup<Scalar>
611 outArgs = getUnderlyingModel()->createOutArgs();
612 outArgs.setModelEvalDescription(this->description());
613 return std::move(outArgs);
619 #endif // THYRA_DEFAULT_MODEL_EVALUATOR_DELEGETOR_BASE_HPP
Protected subclass of InArgs that only ModelEvaluator subclasses can access to set up the selection o...
void initialize(int *argc, char ***argv)
Pure abstract base interface for evaluating a stateless "model" that can be mapped into a number of d...
Default base class for concrete model evaluators.
bool is_null(const boost::shared_ptr< T > &p)
RCP< const VectorSpaceBase< Scalar > > get_x_space() const
RCP< LinearOpBase< Scalar > > create_DfDp_op(int l) const
virtual RCP< const ModelEvaluator< Scalar > > getUnderlyingModel() const
Concrete aggregate class for all output arguments computable by a ModelEvaluator subclass object...
RCP< PreconditionerBase< Scalar > > create_W_prec() const
void uninitialize()
Uninitialize.
void setModelEvalDescription(const std::string &modelEvalDescription)
This is a base class that delegetes almost all function to a wrapped model evaluator object...
void initialize(const RCP< ModelEvaluator< Scalar > > &model)
Initialize given a non-const model evaluator.
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
ModelEvaluatorDelegatorBase()
Constructs to uninitialized.
virtual bool isUnderlyingModelConst() const
RCP< const VectorSpaceBase< Scalar > > get_f_space() const
Teuchos::ArrayView< const std::string > get_g_names(int j) const
RCP< const VectorSpaceBase< Scalar > > get_f_multiplier_space() const
RCP< const VectorSpaceBase< Scalar > > get_p_space(int l) const
void reportFinalPoint(const ModelEvaluatorBase::InArgs< Scalar > &finalPoint, const bool wasSolved)
RCP< LinearOpWithSolveBase< Scalar > > create_W() const
virtual RCP< ModelEvaluator< Scalar > > getNonconstUnderlyingModel()
RCP< LinearOpBase< Scalar > > create_W_op() const
RCP< const Teuchos::Array< std::string > > get_p_names(int l) const
Teuchos::EVerbosityLevel readLocalVerbosityLevelValidatedParameter(ParameterList ¶mList) const
Read the local verbosity level parameter.
ModelEvaluatorBase::InArgs< Scalar > getUpperBounds() const
RCP< const VectorSpaceBase< Scalar > > get_g_space(int j) const
RCP< const VectorSpaceBase< Scalar > > get_g_multiplier_space(int j) const
ModelEvaluatorBase::InArgs< Scalar > createInArgs() const
ModelEvaluatorBase::InArgs< Scalar > getLowerBounds() const
ModelEvaluatorBase::InArgs< Scalar > getNominalValues() const
RCP< const LinearOpWithSolveFactoryBase< Scalar > > get_W_factory() const
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
void setLocalVerbosityLevelValidatedParameter(ParameterList *paramList) const
Set a valid parameter for reading the local verbosity level.
Concrete aggregate class for all input arguments computable by a ModelEvaluator subclass object...