SundanceNonlinearProblem.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 // ************************************************************************
00003 // 
00004 //                              Sundance
00005 //                 Copyright (2005) Sandia Corporation
00006 // 
00007 // Copyright (year first published) Sandia Corporation.  Under the terms 
00008 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 
00009 // retains certain rights in this software.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //                                                                                 
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA                                                                                
00025 // Questions? Contact Kevin Long (krlong@sandia.gov), 
00026 // Sandia National Laboratories, Livermore, California, USA
00027 // 
00028 // ************************************************************************
00029 /* @HEADER@ */
00030 
00031 #ifndef SUNDANCE_NONLINEARPROBLEM_H
00032 #define SUNDANCE_NONLINEARPROBLEM_H
00033 
00034 #include "SundanceDefs.hpp"
00035 #include "SundanceNLOp.hpp"
00036 #include "PlayaNOXSolver.hpp"
00037 #include "PlayaNonlinearSolver.hpp"
00038 #include "PlayaNewtonArmijoSolverDecl.hpp"
00039 #ifndef HAVE_TEUCHOS_EXPLICIT_INSTANTIATION
00040 #include "PlayaNewtonArmijoSolverImpl.hpp"
00041 #endif
00042 
00043 namespace Sundance
00044 {
00045 using namespace Teuchos;
00046 
00047 
00048 /** 
00049  * NonlinearProblem encapsulates a discrete nonlinear problem
00050  */
00051 class NonlinearProblem 
00052   : public ObjectWithClassVerbosity<NonlinearProblem>
00053 {
00054 public:
00055   /** Empty ctor */
00056   NonlinearProblem();
00057 
00058   /** Construct with a mesh, equation set, bcs, test and unknown funcs,
00059    * and a vector type */
00060   NonlinearProblem(const Mesh& mesh, const Expr& eqn, const Expr& bc,
00061     const Expr& test, const Expr& unk, const Expr& u0, 
00062     const Playa::VectorType<double>& vecType);
00063 
00064   /** Construct with a mesh, equation set, bcs, test and unknown funcs,
00065    * parameters, and a vector type */
00066   NonlinearProblem(const Mesh& mesh, const Expr& eqn, const Expr& bc,
00067     const Expr& test, const Expr& unk, const Expr& u0, 
00068     const Expr& params, const Expr& paramVals,  
00069     const Playa::VectorType<double>& vecType);
00070 
00071   /** Construct with a mesh, equation set, bcs, test and unknown funcs,
00072    * and a vector type */
00073   NonlinearProblem(const Mesh& mesh, const Expr& eqn, const Expr& bc,
00074     const BlockArray& test, const BlockArray& unk, const Expr& u0);
00075 
00076 
00077   /** */
00078   NonlinearProblem(const RCP<Assembler>& assembler, 
00079     const Expr& u0);
00080 
00081   /** Compute direct sensitivities to parameters */
00082   Expr computeSensitivities(const LinearSolver<double>& solver) const 
00083     {return op_->computeSensitivities(solver);}
00084 
00085   /** Solve the nonlinear problem */
00086   SolverState<double> solve(const NOXSolver& solver) const ;
00087 
00088   /** Solve the nonlinear problem */
00089   SolverState<double> solve(const NonlinearSolver<double>& solver) const ;
00090 
00091   /** Return the current evaluation point as a Sundance expression */
00092   Expr getU0() const {return op_->getU0();}
00093 
00094   /** Set an initial guess */
00095   void setInitialGuess(const Expr& u0New) {op_->setInitialGuess(u0New);}
00096 
00097   /** Set the current evaluation point */
00098   void setEvalPoint(const Expr& u0New) {op_->setInitialGuess(u0New);}
00099       
00100 
00101   /** Compute the residual and Jacobian at the current evaluation point */
00102   LinearOperator<double> computeJacobianAndFunction(Vector<double>& functionValue) const 
00103     {return op_->computeJacobianAndFunction(functionValue);}
00104       
00105   /** Write the Jacobian and residual into the objects provided */
00106   void computeJacobianAndFunction(LinearOperator<double>& J,
00107     Vector<double>& resid) const 
00108     {op_->computeJacobianAndFunction(J, resid);}
00109 
00110   /** Compute the residual at the current eval point */
00111   Playa::Vector<double> computeFunctionValue() const 
00112     {return op_->computeFunctionValue();}
00113       
00114   /** Write the residual into the object provided */
00115   void computeFunctionValue(Vector<double>& resid) const 
00116     {op_->computeFunctionValue(resid);}
00117       
00118   /** Get an initial guess */
00119   Playa::Vector<double> getInitialGuess() const 
00120     {return op_->getInitialGuess();}
00121       
00122   /** Create the Jacobian object, but don't fill it in. */
00123   LinearOperator<double> allocateJacobian() const 
00124     {return op_->allocateJacobian();}
00125 
00126   /** This function forces the assembler to reassemble the matrix */
00127   void reAssembleProblem() const { op_->reAssembleProblem();}
00128 
00129 private:
00130   RCP<NLOp> op_;
00131 };
00132 }
00133 
00134 
00135 
00136 
00137 #endif

Site Contact