42 #ifndef THYRA_DEFAULT_MODEL_EVALUATOR_DELEGETOR_BASE_HPP
43 #define THYRA_DEFAULT_MODEL_EVALUATOR_DELEGETOR_BASE_HPP
46 #include "Thyra_ModelEvaluatorDefaultBase.hpp"
47 #include "Teuchos_ConstNonconstObjectContainer.hpp"
48 #include "Teuchos_TimeMonitor.hpp"
49 #include "Teuchos_StandardParameterEntryValidators.hpp"
81 template<
class Scalar>
219 > LocalVerbosityLevel_validator_;
220 static const std::string LocalVerbosityLevel_name_;
222 static const std::string LocalVerbosityLevel_default_;
227 #define THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_GEN_LOCALVERBLEVEL_BEGIN(CLASS_NAME,INARGS,OUTARGS,UNDERLYINGMODEL,LOCALVERBLEVEL) \
229 using Teuchos::includesVerbLevel; \
230 using Teuchos::RCP; \
231 using Teuchos::EVerbosityLevel; \
232 const std::string blahblah_classNameStr \
233 = std::string(CLASS_NAME)+"<"+Teuchos::ScalarTraits<Scalar>::name()+">"; \
234 const std::string blahblah_classFuncNameStr \
235 = blahblah_classNameStr+"::evalModel(...)"; \
236 THYRA_FUNC_TIME_MONITOR(blahblah_classFuncNameStr); \
238 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &blahblah_outArgs = (OUTARGS); \
240 Teuchos::Time totalTimer(""); \
241 totalTimer.start(true); \
243 const RCP<Teuchos::FancyOStream> out = this->getOStream(); \
244 const EVerbosityLevel verbLevel = this->getVerbLevel(); \
245 const EVerbosityLevel localVerbLevelInput = (LOCALVERBLEVEL); \
246 const EVerbosityLevel localVerbLevel = \
247 ( localVerbLevelInput==Teuchos::VERB_DEFAULT ? verbLevel : localVerbLevelInput ); \
248 Teuchos::OSTab tab(out); \
249 if(out.get() && includesVerbLevel(localVerbLevel,Teuchos::VERB_LOW)) \
250 *out << "\nEntering " << blahblah_classFuncNameStr << " ...\n"; \
252 if(out.get() && includesVerbLevel(localVerbLevel,Teuchos::VERB_MEDIUM)) \
254 << "\ninArgs =\n" << Teuchos::describe((INARGS),localVerbLevel) \
255 << "\noutArgs on input =\n" << Teuchos::describe((OUTARGS),Teuchos::VERB_LOW); \
257 const RCP<const Thyra::ModelEvaluator<Scalar> > \
258 thyraModel = (UNDERLYINGMODEL); \
260 typedef Teuchos::VerboseObjectTempState<Thyra::ModelEvaluatorBase> VOTSME; \
261 VOTSME thyraModel_outputTempState(thyraModel,out,verbLevel)
264 #define THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_LOCALVERBLEVEL_BEGIN(CLASS_NAME,INARGS,OUTARGS,LOCALVERBLEVEL) \
265 THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_GEN_LOCALVERBLEVEL_BEGIN(CLASS_NAME,INARGS,OUTARGS,this->getUnderlyingModel(),LOCALVERBLEVEL)
268 #define THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_GEN_BEGIN(CLASS_NAME,INARGS,OUTARGS,UNDERLYINGMODEL) \
269 THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_GEN_LOCALVERBLEVEL_BEGIN(CLASS_NAME,INARGS,OUTARGS,UNDERLYINGMODEL,Teuchos::VERB_DEFAULT)
272 #define THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_BEGIN(CLASS_NAME,INARGS,OUTARGS) \
273 THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_GEN_BEGIN(CLASS_NAME,INARGS,OUTARGS,this->getUnderlyingModel())
276 #define THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_END() \
277 if(out.get() && includesVerbLevel(localVerbLevel,Teuchos::VERB_MEDIUM)) \
279 << "\noutArgs on output =\n" << Teuchos::describe(blahblah_outArgs,localVerbLevel); \
282 if(out.get() && includesVerbLevel(localVerbLevel,Teuchos::VERB_LOW)) \
284 << "\nTotal evaluation time = "<<totalTimer.totalElapsedTime()<<" sec\n" \
285 << "\nLeaving " << blahblah_classFuncNameStr << " ...\n"
295 template<
class Scalar>
303 template<
class Scalar>
306 =
"Local Verbosity Level";
308 template<
class Scalar>
313 template<
class Scalar>
316 = getVerbosityLevelParameterValueName(
324 template<
class Scalar>
329 template<
class Scalar>
334 this->initialize(model);
338 template<
class Scalar>
343 this->initialize(model);
347 template<
class Scalar>
352 model_.initialize(model);
356 template<
class Scalar>
361 model_.initialize(model);
365 template<
class Scalar>
368 model_.uninitialize();
375 template<
class Scalar>
378 return model_.isConst();
382 template<
class Scalar>
386 return model_.getNonconstObj();
390 template<
class Scalar>
394 return model_.getConstObj();
401 template<
class Scalar>
405 return getUnderlyingModel()->get_x_space();
409 template<
class Scalar>
413 return getUnderlyingModel()->get_f_space();
417 template<
class Scalar>
421 return getUnderlyingModel()->get_f_multiplier_space();
425 template<
class Scalar>
429 return getUnderlyingModel()->get_p_space(l);
433 template<
class Scalar>
437 return getUnderlyingModel()->get_p_names(l);
441 template<
class Scalar>
445 return getUnderlyingModel()->get_g_space(j);
449 template<
class Scalar>
453 return getUnderlyingModel()->get_g_multiplier_space(j);
457 template<
class Scalar>
461 return getUnderlyingModel()->get_g_names(j);
465 template<
class Scalar>
469 return getUnderlyingModel()->getNominalValues();
473 template<
class Scalar>
477 return getUnderlyingModel()->getLowerBounds();
481 template<
class Scalar>
485 return getUnderlyingModel()->getUpperBounds();
489 template<
class Scalar>
493 return getUnderlyingModel()->create_W();
497 template<
class Scalar>
501 return getUnderlyingModel()->create_W_op();
505 template<
class Scalar>
509 return getUnderlyingModel()->create_W_prec();
513 template<
class Scalar>
517 return getUnderlyingModel()->get_W_factory();
521 template<
class Scalar>
527 return std::move(inArgs);
531 template<
class Scalar>
534 ,
const bool wasSolved
537 getNonconstUnderlyingModel()->reportFinalPoint(finalPoint,wasSolved);
547 template<
class Scalar>
553 if (
is_null(LocalVerbosityLevel_validator_))
554 LocalVerbosityLevel_validator_ =
555 Teuchos::verbosityLevelParameterEntryValidator(
556 LocalVerbosityLevel_name_
559 LocalVerbosityLevel_name_, LocalVerbosityLevel_default_,
560 "Overriding verbosity level for this model evaluator object.\n"
561 "This level will not propagate to nested model evaluator objects\n"
562 "The value of \"default\" result in the object verbosity level being\n"
564 LocalVerbosityLevel_validator_
569 template<
class Scalar>
575 return LocalVerbosityLevel_validator_->getIntegralValue(
576 paramList, LocalVerbosityLevel_name_, LocalVerbosityLevel_default_ );
586 template<
class Scalar>
594 template<
class Scalar>
595 RCP<LinearOpBase<Scalar> >
596 ModelEvaluatorDelegatorBase<Scalar>::create_DgDx_dot_op_impl(
600 return getUnderlyingModel()->create_DgDx_dot_op(j);
604 template<
class Scalar>
605 RCP<LinearOpBase<Scalar> >
606 ModelEvaluatorDelegatorBase<Scalar>::create_DgDx_op_impl(
610 return getUnderlyingModel()->create_DgDx_op(j);
614 template<
class Scalar>
615 RCP<LinearOpBase<Scalar> >
616 ModelEvaluatorDelegatorBase<Scalar>::create_DgDp_op_impl(
620 return getUnderlyingModel()->create_DgDp_op(j,l);
624 template<
class Scalar>
625 ModelEvaluatorBase::OutArgs<Scalar>
626 ModelEvaluatorDelegatorBase<Scalar>::createOutArgsImpl()
const
628 ModelEvaluatorBase::OutArgsSetup<Scalar>
629 outArgs = getUnderlyingModel()->createOutArgs();
630 outArgs.setModelEvalDescription(this->description());
631 return std::move(outArgs);
637 #endif // THYRA_DEFAULT_MODEL_EVALUATOR_DELEGETOR_BASE_HPP
Protected subclass of InArgs that only ModelEvaluator subclasses can access to set up the selection o...
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)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
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.
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...