SundanceNonlinearProblem.cpp
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 #include "SundanceNonlinearProblem.hpp"
00032 #include "SundanceOut.hpp"
00033 #include "PlayaTabs.hpp"
00034 #include "SundanceAssembler.hpp"
00035 #include "SundanceDiscreteFunction.hpp"
00036 #include "SundanceEquationSet.hpp"
00037 #include "SundanceLinearSolveDriver.hpp"
00038 
00039 #ifndef HAVE_TEUCHOS_EXPLICIT_INSTANTIATION
00040 #include "PlayaLinearOperatorImpl.hpp"
00041 #endif
00042 
00043 
00044 using namespace Sundance;
00045 using namespace Teuchos;
00046 using namespace std;
00047 using namespace Playa;
00048 
00049 
00050 static Time& nlpCtorTimer() 
00051 {
00052   static RCP<Time> rtn 
00053     = TimeMonitor::getNewTimer("NonlinearProblem ctor"); 
00054   return *rtn;
00055 }
00056 
00057 
00058 NonlinearProblem::NonlinearProblem() 
00059   : op_()
00060 {
00061   TimeMonitor timer(nlpCtorTimer());
00062 }
00063 
00064 
00065 NonlinearProblem::NonlinearProblem(const Mesh& mesh, 
00066   const Expr& eqn, 
00067   const Expr& bc,
00068   const Expr& test, 
00069   const Expr& unk, 
00070   const Expr& u0, 
00071   const VectorType<double>& vecType)
00072   : op_(rcp(new NLOp(mesh, eqn, bc, test, unk, u0, vecType)))
00073 {}
00074 
00075 NonlinearProblem::NonlinearProblem(const Mesh& mesh, 
00076   const Expr& eqn, 
00077   const Expr& bc,
00078   const Expr& test, 
00079   const Expr& unk, 
00080   const Expr& u0, 
00081   const Expr& params, 
00082   const Expr& paramValues,  
00083   const VectorType<double>& vecType)
00084   : op_(rcp(new NLOp(mesh, eqn, bc, test, unk, u0, 
00085         params, paramValues, vecType)))
00086 {}
00087 
00088 NonlinearProblem::NonlinearProblem(
00089   const Mesh& mesh, const Expr& eqn, const Expr& bc,
00090   const BlockArray& test, const BlockArray& unk, const Expr& u0)
00091   : op_(rcp(new NLOp(mesh, eqn, bc, test, unk, u0)))
00092 {}
00093 
00094 
00095 NonlinearProblem::NonlinearProblem(const RCP<Assembler>& assembler, 
00096                                    const Expr& u0)
00097   : op_(rcp(new NLOp(assembler, u0)))
00098 {}
00099 
00100 
00101 
00102 SolverState<double>
00103 NonlinearProblem::solve(const NOXSolver& solver) const
00104 {
00105   RCP<NonlinearOperatorBase<double> > op = op_;
00106   NonlinearOperator<double> F = op;
00107   Vector<double> soln;
00108   SolverState<double> rtn = solver.solve(F, soln);
00109   F.setEvalPt(soln);
00110   return rtn;
00111 }
00112 
00113 
00114 
00115 SolverState<double>
00116 NonlinearProblem::solve(const NonlinearSolver<double>& solver) const
00117 {
00118   RCP<NonlinearOperatorBase<double> > op = op_;
00119   NonlinearOperator<double> F = op;
00120   Vector<double> soln;
00121   SolverState<double> rtn = solver.solve(F, soln);
00122   F.setEvalPt(soln);
00123   return rtn;
00124 }
00125 

Site Contact