00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
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