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>
215 > LocalVerbosityLevel_validator_;
216 static const std::string LocalVerbosityLevel_name_;
218 static const std::string LocalVerbosityLevel_default_;
223 #define THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_GEN_LOCALVERBLEVEL_BEGIN(CLASS_NAME,INARGS,OUTARGS,UNDERLYINGMODEL,LOCALVERBLEVEL) \
225 using Teuchos::includesVerbLevel; \
226 using Teuchos::RCP; \
227 using Teuchos::EVerbosityLevel; \
228 const std::string blahblah_classNameStr \
229 = std::string(CLASS_NAME)+"<"+Teuchos::ScalarTraits<Scalar>::name()+">"; \
230 const std::string blahblah_classFuncNameStr \
231 = blahblah_classNameStr+"::evalModel(...)"; \
232 THYRA_FUNC_TIME_MONITOR(blahblah_classFuncNameStr); \
234 const Thyra::ModelEvaluatorBase::OutArgs<Scalar> &blahblah_outArgs = (OUTARGS); \
236 Teuchos::Time totalTimer(""); \
237 totalTimer.start(true); \
239 const RCP<Teuchos::FancyOStream> out = this->getOStream(); \
240 const EVerbosityLevel verbLevel = this->getVerbLevel(); \
241 const EVerbosityLevel localVerbLevelInput = (LOCALVERBLEVEL); \
242 const EVerbosityLevel localVerbLevel = \
243 ( localVerbLevelInput==Teuchos::VERB_DEFAULT ? verbLevel : localVerbLevelInput ); \
244 Teuchos::OSTab tab(out); \
245 if(out.get() && includesVerbLevel(localVerbLevel,Teuchos::VERB_LOW)) \
246 *out << "\nEntering " << blahblah_classFuncNameStr << " ...\n"; \
248 if(out.get() && includesVerbLevel(localVerbLevel,Teuchos::VERB_MEDIUM)) \
250 << "\ninArgs =\n" << Teuchos::describe((INARGS),localVerbLevel) \
251 << "\noutArgs on input =\n" << Teuchos::describe((OUTARGS),Teuchos::VERB_LOW); \
253 const RCP<const Thyra::ModelEvaluator<Scalar> > \
254 thyraModel = (UNDERLYINGMODEL); \
256 typedef Teuchos::VerboseObjectTempState<Thyra::ModelEvaluatorBase> VOTSME; \
257 VOTSME thyraModel_outputTempState(thyraModel,out,verbLevel)
260 #define THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_LOCALVERBLEVEL_BEGIN(CLASS_NAME,INARGS,OUTARGS,LOCALVERBLEVEL) \
261 THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_GEN_LOCALVERBLEVEL_BEGIN(CLASS_NAME,INARGS,OUTARGS,this->getUnderlyingModel(),LOCALVERBLEVEL)
264 #define THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_GEN_BEGIN(CLASS_NAME,INARGS,OUTARGS,UNDERLYINGMODEL) \
265 THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_GEN_LOCALVERBLEVEL_BEGIN(CLASS_NAME,INARGS,OUTARGS,UNDERLYINGMODEL,Teuchos::VERB_DEFAULT)
268 #define THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_BEGIN(CLASS_NAME,INARGS,OUTARGS) \
269 THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_GEN_BEGIN(CLASS_NAME,INARGS,OUTARGS,this->getUnderlyingModel())
272 #define THYRA_MODEL_EVALUATOR_DECORATOR_EVAL_MODEL_END() \
273 if(out.get() && includesVerbLevel(localVerbLevel,Teuchos::VERB_MEDIUM)) \
275 << "\noutArgs on output =\n" << Teuchos::describe(blahblah_outArgs,localVerbLevel); \
278 if(out.get() && includesVerbLevel(localVerbLevel,Teuchos::VERB_LOW)) \
280 << "\nTotal evaluation time = "<<totalTimer.totalElapsedTime()<<" sec\n" \
281 << "\nLeaving " << blahblah_classFuncNameStr << " ...\n"
291 template<
class Scalar>
299 template<
class Scalar>
302 =
"Local Verbosity Level";
304 template<
class Scalar>
309 template<
class Scalar>
312 = getVerbosityLevelParameterValueName(
320 template<
class Scalar>
325 template<
class Scalar>
330 this->initialize(model);
334 template<
class Scalar>
339 this->initialize(model);
343 template<
class Scalar>
348 model_.initialize(model);
352 template<
class Scalar>
357 model_.initialize(model);
361 template<
class Scalar>
364 model_.uninitialize();
371 template<
class Scalar>
374 return model_.isConst();
378 template<
class Scalar>
382 return model_.getNonconstObj();
386 template<
class Scalar>
390 return model_.getConstObj();
397 template<
class Scalar>
401 return getUnderlyingModel()->get_x_space();
405 template<
class Scalar>
409 return getUnderlyingModel()->get_f_space();
413 template<
class Scalar>
417 return getUnderlyingModel()->get_p_space(l);
421 template<
class Scalar>
425 return getUnderlyingModel()->get_p_names(l);
429 template<
class Scalar>
433 return getUnderlyingModel()->get_g_space(j);
437 template<
class Scalar>
441 return getUnderlyingModel()->get_g_names(j);
445 template<
class Scalar>
449 return getUnderlyingModel()->getNominalValues();
453 template<
class Scalar>
457 return getUnderlyingModel()->getLowerBounds();
461 template<
class Scalar>
465 return getUnderlyingModel()->getUpperBounds();
469 template<
class Scalar>
473 return getUnderlyingModel()->create_W();
477 template<
class Scalar>
481 return getUnderlyingModel()->create_W_op();
485 template<
class Scalar>
489 return getUnderlyingModel()->create_W_prec();
493 template<
class Scalar>
497 return getUnderlyingModel()->get_W_factory();
501 template<
class Scalar>
511 template<
class Scalar>
514 ,
const bool wasSolved
517 getNonconstUnderlyingModel()->reportFinalPoint(finalPoint,wasSolved);
527 template<
class Scalar>
533 if (
is_null(LocalVerbosityLevel_validator_))
534 LocalVerbosityLevel_validator_ =
535 Teuchos::verbosityLevelParameterEntryValidator(
536 LocalVerbosityLevel_name_
539 LocalVerbosityLevel_name_, LocalVerbosityLevel_default_,
540 "Overriding verbosity level for this model evaluator object.\n"
541 "This level will not propagate to nested model evaluator objects\n"
542 "The value of \"default\" result in the object verbosity level being\n"
544 LocalVerbosityLevel_validator_
549 template<
class Scalar>
555 return LocalVerbosityLevel_validator_->getIntegralValue(
556 paramList, LocalVerbosityLevel_name_, LocalVerbosityLevel_default_ );
566 template<
class Scalar>
574 template<
class Scalar>
575 RCP<LinearOpBase<Scalar> >
576 ModelEvaluatorDelegatorBase<Scalar>::create_DgDx_dot_op_impl(
580 return getUnderlyingModel()->create_DgDx_dot_op(j);
584 template<
class Scalar>
585 RCP<LinearOpBase<Scalar> >
586 ModelEvaluatorDelegatorBase<Scalar>::create_DgDx_op_impl(
590 return getUnderlyingModel()->create_DgDx_op(j);
594 template<
class Scalar>
595 RCP<LinearOpBase<Scalar> >
596 ModelEvaluatorDelegatorBase<Scalar>::create_DgDp_op_impl(
600 return getUnderlyingModel()->create_DgDp_op(j,l);
604 template<
class Scalar>
605 ModelEvaluatorBase::OutArgs<Scalar>
606 ModelEvaluatorDelegatorBase<Scalar>::createOutArgsImpl()
const
608 ModelEvaluatorBase::OutArgsSetup<Scalar>
609 outArgs = getUnderlyingModel()->createOutArgs();
610 outArgs.setModelEvalDescription(this->description());
617 #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_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
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...