[Tempus] WrapperModelEvaluator: add W_prec capability
Created by: bartgol
Currently, the ResidualModelEvaluator does not do anything to allow the use of W_prec. NOX has two ways to get a preconditioner from the model: through model_->create_W_prec()
and through model_->get_W_factory()->getPreconditionerFactory()->createPrec()
(assuming the prec factory is nonnull). Without the support for W_prec in ResidualModelEvaluator, in order to get NOX to use a preconditioner one must force his/her transientModel object to return a lows factory that does have a valid preconditioner factory
However, this is not always convenient/safe. One may want to always use his/her particular preconditioner for the problem at hand, and writing such a generic structure as a preconditioner factory for just one preconditioner seems too big of a hassle (besides not forcing the user to use the particular preconditioner for the problem). He/she may be better off writing the create_W_prec method in his/her model evaluator, and be done with it.
To fix this, I suggest to add the following lines to the method createOutArgsImpl of ResidualModelEvaluator
MEB::OutArgsSetup<Scalar> transientOutArgs = transientModel_->createOutArgs();
if (transientOutArgs.supports(MEB::OUT_ARG_W_prec))
{
outArgs.setSupports(MEB::OUT_ARG_W_prec);
}
add this method to the class
Teuchos::RCP<Thyra::PreconditionerBase<Scalar> > create_W_prec() const
{ return transientModel_->create_W_prec(); }
and finally add these lines in the evalModelImpl method (right before the call to evalModel of the transientModel)
if (outArgs.supports(MEB::OUT_ARG_W_prec) && transientOutArgs.supports(MEB::OUT_ARG_W_prec))
{
transientOutArgs.set_W_prec(outArgs.get_W_prec());
}
(the second part in the if may be redundant, I'm not sure).