SundanceNLOp.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_NLOP_H
00032 #define SUNDANCE_NLOP_H
00033 
00034 #include "SundanceDefs.hpp"
00035 #include "SundanceMesh.hpp"
00036 #include "SundanceExpr.hpp"
00037 #include "SundanceDiscreteFunction.hpp"
00038 #include "SundanceObjectWithVerbosity.hpp"
00039 #include "TSFNonlinearOperatorBase.hpp"
00040 #include "TSFLinearOperatorDecl.hpp"
00041 #include "TSFVectorDecl.hpp"
00042 #include "TSFVectorType.hpp"
00043 
00044 namespace Sundance
00045 {
00046 using namespace Teuchos;
00047 
00048 class Assembler;
00049 
00050 
00051 /** 
00052  * NLOp encapsulates a discrete nonlinear problem, and can
00053  * be passed to a nonlinear solver such as NOX.
00054  */
00055 class NLOp 
00056   : public ObjectWithClassVerbosity<NLOp>,
00057     public TSFExtended::NonlinearOperatorBase<double>
00058 {
00059 public:
00060   /** Empty ctor */
00061   NLOp();
00062 
00063   /** Construct with a mesh, equation set, bcs, test and unknown funcs,
00064    * and a vector type */
00065   NLOp(const Mesh& mesh, const Expr& eqn, const Expr& bc,
00066     const Expr& test, const Expr& unk, const Expr& u0, 
00067     const TSFExtended::VectorType<double>& vecType,
00068     bool partitionBCs = false);
00069 
00070   /** Construct with a mesh, equation set, bcs, test and unknown funcs,
00071    * parameters, and a vector type */
00072   NLOp(const Mesh& mesh, const Expr& eqn, const Expr& bc,
00073     const Expr& test, const Expr& unk, const Expr& u0, 
00074     const Expr& params, const Expr& paramVals,  
00075     const TSFExtended::VectorType<double>& vecType,
00076     bool partitionBCs = false);
00077 
00078 
00079   /** */
00080   NLOp(const RCP<Assembler>& assembler, 
00081     const Expr& u0);
00082 
00083   /** Compute the residual and Jacobian at the current evaluation point */
00084   LinearOperator<double> computeJacobianAndFunction(Vector<double>& functionValue) const ;
00085 
00086   /** Write the Jacobian and residual into the objects provided */
00087   void computeJacobianAndFunction(LinearOperator<double>& J,
00088     Vector<double>& resid) const ;
00089 
00090   /** Compute direct sensitivities to parameters */
00091   Expr computeSensitivities(const LinearSolver<double>& solver) const ;
00092       
00093 
00094   /** Return the current evaluation point as a Sundance expression */
00095   Expr getU0() const {return u0_;}
00096 
00097   /** Compute the residual at the current eval point */
00098   TSFExtended::Vector<double> computeFunctionValue() const ;
00099       
00100   /** Write the residual into the object provided */
00101   void computeFunctionValue(Vector<double>& resid) const ;
00102 
00103   /** Get an initial guess */
00104   TSFExtended::Vector<double> getInitialGuess() const ;
00105 
00106   /** Create the Jacobian object, but don't fill it in. */
00107   LinearOperator<double> allocateJacobian() const ;
00108 
00109   /** Set an initial guess */
00110   void setInitialGuess(const Expr& u0New);
00111 
00112 
00113   /* Handle boilerplate */
00114   GET_RCP(TSFExtended::NonlinearOperatorBase<double>);
00115 
00116 private:
00117       
00118   /** */
00119   RCP<Assembler> assembler_;
00120 
00121   /** */
00122   mutable TSFExtended::LinearOperator<double> J_;
00123 
00124   /** */
00125   Expr u0_;
00126 
00127   /** */
00128   Expr params_;
00129 
00130   /** */
00131   Expr paramVals_;
00132 
00133   /** */
00134   mutable DiscreteFunction* discreteU0_;
00135       
00136 };
00137 }
00138 
00139 
00140 
00141 
00142 #endif

Site Contact