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"
32template <
class Scalar>
87template <
class Scalar>
101template<
class Scalar>
108 paramList->validateParametersAndSetDefaults(*getValidParameters(),0);
109 paramList_ = paramList;
111 Teuchos::readVerboseObjectSublist(&*paramList_,
this);
113 paramList_->validateParameters(*getValidParameters(),0);
118template<
class Scalar>
126template<
class Scalar>
136template<
class Scalar>
144template<
class Scalar>
148 using Teuchos::setDoubleParameter;
using Teuchos::setIntParameter;
150 if (is_null(validPL)) {
152 pl = Teuchos::parameterList();
154 Teuchos::setupVerboseObjectSublist(&*pl);
164template <
class Scalar>
175template <
class Scalar>
183template <
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";
271template <
class Scalar>
282template <
class Scalar>
Concrete nonlinear solver for linear equations.
RCP< const ModelEvaluator< Scalar > > getModel() const
RCP< LinearOpWithSolveBase< Scalar > > get_nonconst_W(const bool forceUpToDate)
RCP< const LinearOpWithSolveBase< Scalar > > get_W() const
void setParameterList(RCP< Teuchos::ParameterList > const ¶mList)
void setModel(const RCP< const ModelEvaluator< Scalar > > &model)
RCP< Teuchos::ParameterList > getNonconstParameterList()
RCP< const Teuchos::ParameterList > getValidParameters() const
RCP< Teuchos::ParameterList > unsetParameterList()
RCP< const Teuchos::ParameterList > getParameterList() const
RCP< LinearNonlinearSolver< Scalar > > linearNonlinearSolver()
SolveStatus< Scalar > solve(VectorBase< Scalar > *x, const SolveCriteria< Scalar > *solveCriteria, VectorBase< Scalar > *delta)
Base class for all linear operators that can support a high-level solve operation.
Base subclass for ModelEvaluator that defines some basic types.
Pure abstract base interface for evaluating a stateless "model" that can be mapped into a number of d...
Base class for all nonlinear equation solvers.
Abstract interface for finite-dimensional dense vectors.
virtual RCP< const VectorSpaceBase< Scalar > > space() const =0
Return a smart pointer to the vector space that this vector belongs to.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
#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.
@ NOTRANS
Use the non-transposed operator.
TypeTo as(const TypeFrom &t)
T_To & dyn_cast(T_From &from)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
TEUCHOSCORE_LIB_DLL_EXPORT EVerbosityLevel incrVerbLevel(const EVerbosityLevel inputVerbLevel, const int numLevels)
Simple struct that defines the requested solution criteria for a solve.
Simple struct for the return status from a solve.