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 "TSFNOXSolver.H"
00037 
00038 namespace Sundance
00039 {
00040 using namespace Teuchos;
00041 
00042 
00043 /** 
00044  * NonlinearProblem encapsulates a discrete nonlinear problem
00045  */
00046 class NonlinearProblem 
00047   : public ObjectWithClassVerbosity<NonlinearProblem>
00048 {
00049 public:
00050   /** Empty ctor */
00051   NonlinearProblem();
00052 
00053   /** Construct with a mesh, equation set, bcs, test and unknown funcs,
00054    * and a vector type */
00055   NonlinearProblem(const Mesh& mesh, const Expr& eqn, const Expr& bc,
00056     const Expr& test, const Expr& unk, const Expr& u0, 
00057     const TSFExtended::VectorType<double>& vecType);
00058 
00059   /** Construct with a mesh, equation set, bcs, test and unknown funcs,
00060    * parameters, and a vector type */
00061   NonlinearProblem(const Mesh& mesh, const Expr& eqn, const Expr& bc,
00062     const Expr& test, const Expr& unk, const Expr& u0, 
00063     const Expr& params, const Expr& paramVals,  
00064     const TSFExtended::VectorType<double>& vecType);
00065 
00066 
00067   /** */
00068   NonlinearProblem(const RCP<Assembler>& assembler, 
00069     const Expr& u0);
00070 
00071   /** Compute direct sensitivities to parameters */
00072   Expr computeSensitivities(const LinearSolver<double>& solver) const 
00073     {return op_->computeSensitivities(solver);}
00074 
00075   /** Solve the nonlinear problem */
00076   NOX::StatusTest::StatusType solve(const NOXSolver& solver) const ;
00077 
00078   /** Return the current evaluation point as a Sundance expression */
00079   Expr getU0() const {return op_->getU0();}
00080 
00081   /** Set an initial guess */
00082   void setInitialGuess(const Expr& u0New) {op_->setInitialGuess(u0New);}
00083       
00084 
00085   /** Compute the residual and Jacobian at the current evaluation point */
00086   LinearOperator<double> computeJacobianAndFunction(Vector<double>& functionValue) const 
00087     {return op_->computeJacobianAndFunction(functionValue);}
00088       
00089   /** Write the Jacobian and residual into the objects provided */
00090   void computeJacobianAndFunction(LinearOperator<double>& J,
00091     Vector<double>& resid) const 
00092     {op_->computeJacobianAndFunction(J, resid);}
00093 
00094   /** Compute the residual at the current eval point */
00095   TSFExtended::Vector<double> computeFunctionValue() const 
00096     {return op_->computeFunctionValue();}
00097       
00098   /** Write the residual into the object provided */
00099   void computeFunctionValue(Vector<double>& resid) const 
00100     {op_->computeFunctionValue(resid);}
00101       
00102   /** Get an initial guess */
00103   TSFExtended::Vector<double> getInitialGuess() const 
00104     {return op_->getInitialGuess();}
00105       
00106   /** Create the Jacobian object, but don't fill it in. */
00107   LinearOperator<double> allocateJacobian() const 
00108     {return op_->allocateJacobian();}
00109 
00110 private:
00111   RCP<NLOp> op_;
00112 };
00113 }
00114 
00115 
00116 
00117 
00118 #endif

Site Contact