42 #ifndef THYRA_LINEAR_NONLINEAR_SOLVER_BASE_HPP
43 #define THYRA_LINEAR_NONLINEAR_SOLVER_BASE_HPP
46 #include "Thyra_NonlinearSolverBase.hpp"
47 #include "Thyra_ModelEvaluatorHelpers.hpp"
48 #include "Teuchos_VerboseObjectParameterListHelpers.hpp"
49 #include "Teuchos_StandardParameterEntryValidators.hpp"
50 #include "Teuchos_as.hpp"
64 template <
class Scalar>
119 template <
class Scalar>
133 template<
class Scalar>
141 paramList_ = paramList;
143 Teuchos::readVerboseObjectSublist(&*paramList_,
this);
145 paramList_->validateParameters(*getValidParameters(),0);
146 #endif // TEUCHOS_DEBUG
150 template<
class Scalar>
158 template<
class Scalar>
163 paramList_ = Teuchos::null;
168 template<
class Scalar>
176 template<
class Scalar>
180 using Teuchos::setDoubleParameter;
using Teuchos::setIntParameter;
184 pl = Teuchos::parameterList();
186 Teuchos::setupVerboseObjectSublist(&*pl);
196 template <
class Scalar>
207 template <
class Scalar>
215 template <
class Scalar>
225 using Teuchos::describe;
229 using Teuchos::getFancyOStream;
239 "TimeStepNonlinearSolver<Scalar>::solve(...)",
240 *x->
space(),*model_->get_x_space() );
242 0!=solveCriteria &&
"ToDo: Support passed in solve criteria!" );
250 VOTSME stateModel_outputTempState(model_,out,
incrVerbLevel(verbLevel,-1));
251 if(out.
get() && showTrace)
253 <<
"\nEntering LinearNonlinearSolver::solve(...) ...\n"
254 <<
"\nmodel = " << describe(*model_,verbLevel);
256 if(out.
get() && dumpAll) {
257 *out <<
"\nInitial guess:\n";
258 *out <<
"\nx = " << *x;
262 if(!J_.get()) J_ = model_->create_W();
264 f = createMember(model_->get_f_space());
265 if(out.
get() && showTrace)
266 *out <<
"\nEvaluating the model f and W ...\n";
267 eval_f_W( *model_, *x, &*f, &*J_ );
271 dx = createMember(model_->get_x_space());
272 if(out.
get() && showTrace)
273 *out <<
"\nSolving the system J*dx = -f ...\n";
274 VOTSLOWSB J_outputTempState(J_,out,
incrVerbLevel(verbLevel,-1));
275 assign( dx.
ptr(), ST::zero() );
277 linearSolveStatus = J_->solve(
NOTRANS, *f, dx.
ptr() );
278 if(out.
get() && showTrace)
279 *out <<
"\nLinear solve status:\n" << linearSolveStatus;
280 Vt_S( dx.
ptr(), Scalar(-ST::one()) );
281 if(out.
get() && dumpAll)
282 *out <<
"\ndx = " << Teuchos::describe(*dx,verbLevel);
284 Thyra::assign( ptr(delta), *dx );
285 if(out.
get() && dumpAll)
286 *out <<
"\ndelta = " << Teuchos::describe(*delta,verbLevel);
291 if(out.
get() && dumpAll)
292 *out <<
"\nUpdated solution x = " << Teuchos::describe(*x,verbLevel);
294 if(out.
get() && showTrace)
295 *out <<
"\nLeaving LinearNonlinearSolver::solve(...) ...\n";
303 template <
class Scalar>
314 template <
class Scalar>
325 #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