10 #ifndef THYRA_LINEAR_NONLINEAR_SOLVER_BASE_HPP
11 #define THYRA_LINEAR_NONLINEAR_SOLVER_BASE_HPP
14 #include "Thyra_NonlinearSolverBase.hpp"
15 #include "Thyra_ModelEvaluatorHelpers.hpp"
16 #include "Teuchos_VerboseObjectParameterListHelpers.hpp"
17 #include "Teuchos_StandardParameterEntryValidators.hpp"
18 #include "Teuchos_as.hpp"
32 template <
class Scalar>
87 template <
class Scalar>
101 template<
class Scalar>
109 paramList_ = paramList;
111 Teuchos::readVerboseObjectSublist(&*paramList_,
this);
113 paramList_->validateParameters(*getValidParameters(),0);
114 #endif // TEUCHOS_DEBUG
118 template<
class Scalar>
126 template<
class Scalar>
131 paramList_ = Teuchos::null;
136 template<
class Scalar>
144 template<
class Scalar>
148 using Teuchos::setDoubleParameter;
using Teuchos::setIntParameter;
152 pl = Teuchos::parameterList();
154 Teuchos::setupVerboseObjectSublist(&*pl);
164 template <
class Scalar>
175 template <
class Scalar>
183 template <
class Scalar>
193 using Teuchos::describe;
197 using Teuchos::getFancyOStream;
207 "TimeStepNonlinearSolver<Scalar>::solve(...)",
208 *x->
space(),*model_->get_x_space() );
210 0!=solveCriteria &&
"ToDo: Support passed in solve criteria!" );
218 VOTSME stateModel_outputTempState(model_,out,
incrVerbLevel(verbLevel,-1));
219 if(out.
get() && showTrace)
221 <<
"\nEntering LinearNonlinearSolver::solve(...) ...\n"
222 <<
"\nmodel = " << describe(*model_,verbLevel);
224 if(out.
get() && dumpAll) {
225 *out <<
"\nInitial guess:\n";
226 *out <<
"\nx = " << *x;
230 if(!J_.get()) J_ = model_->create_W();
232 f = createMember(model_->get_f_space());
233 if(out.
get() && showTrace)
234 *out <<
"\nEvaluating the model f and W ...\n";
235 eval_f_W( *model_, *x, &*f, &*J_ );
239 dx = createMember(model_->get_x_space());
240 if(out.
get() && showTrace)
241 *out <<
"\nSolving the system J*dx = -f ...\n";
242 VOTSLOWSB J_outputTempState(J_,out,
incrVerbLevel(verbLevel,-1));
243 assign( dx.
ptr(), ST::zero() );
245 linearSolveStatus = J_->solve(
NOTRANS, *f, dx.
ptr() );
246 if(out.
get() && showTrace)
247 *out <<
"\nLinear solve status:\n" << linearSolveStatus;
248 Vt_S( dx.
ptr(), Scalar(-ST::one()) );
249 if(out.
get() && dumpAll)
250 *out <<
"\ndx = " << Teuchos::describe(*dx,verbLevel);
252 Thyra::assign( ptr(delta), *dx );
253 if(out.
get() && dumpAll)
254 *out <<
"\ndelta = " << Teuchos::describe(*delta,verbLevel);
259 if(out.
get() && dumpAll)
260 *out <<
"\nUpdated solution x = " << Teuchos::describe(*x,verbLevel);
262 if(out.
get() && showTrace)
263 *out <<
"\nLeaving LinearNonlinearSolver::solve(...) ...\n";
271 template <
class Scalar>
282 template <
class Scalar>
293 #endif // THYRA_LINEAR_NONLINEAR_SOLVER_BASE_HPP
virtual RCP< const VectorSpaceBase< Scalar > > space() const =0
Return a smart pointer to the vector space that this vector belongs to.
Pure abstract base interface for evaluating a stateless "model" that can be mapped into a number of d...
#define THYRA_ASSERT_VEC_SPACES(FUNC_NAME, VS1, VS2)
This is a very useful macro that should be used to validate that two vector spaces are compatible...
Base class for all linear operators that can support a high-level solve operation.
bool is_null(const boost::shared_ptr< T > &p)
basic_OSTab< char > OSTab
Use the non-transposed operator.
RCP< Teuchos::ParameterList > unsetParameterList()
Base class for all nonlinear equation solvers.
void setParameterList(RCP< Teuchos::ParameterList > const ¶mList)
RCP< const Teuchos::ParameterList > getParameterList() const
Concrete nonlinear solver for linear equations.
void setModel(const RCP< const ModelEvaluator< Scalar > > &model)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Abstract interface for finite-dimensional dense vectors.
void validateParametersAndSetDefaults(ParameterList const &validParamList, int const depth=1000)
Simple struct for the return status from a solve.
RCP< LinearOpWithSolveBase< Scalar > > get_nonconst_W(const bool forceUpToDate)
RCP< const ModelEvaluator< Scalar > > getModel() const
Base subclass for ModelEvaluator that defines some basic types.
TEUCHOSCORE_LIB_DLL_EXPORT EVerbosityLevel incrVerbLevel(const EVerbosityLevel inputVerbLevel, const int numLevels)
RCP< const LinearOpWithSolveBase< Scalar > > get_W() const
TypeTo as(const TypeFrom &t)
SolveStatus< Scalar > solve(VectorBase< Scalar > *x, const SolveCriteria< Scalar > *solveCriteria, VectorBase< Scalar > *delta)
RCP< Teuchos::ParameterList > getNonconstParameterList()
Simple struct that defines the requested solution criteria for a solve.
RCP< LinearNonlinearSolver< Scalar > > linearNonlinearSolver()
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
RCP< const Teuchos::ParameterList > getValidParameters() const