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 #ifndef SUNDANCE_NLOP_H
00032 #define SUNDANCE_NLOP_H
00033
00034 #include "SundanceDefs.hpp"
00035 #include "SundanceMesh.hpp"
00036 #include "SundanceExpr.hpp"
00037 #include "SundanceBlock.hpp"
00038 #include "SundanceDiscreteFunction.hpp"
00039 #include "SundanceObjectWithVerbosity.hpp"
00040 #include "PlayaNonlinearOperatorBase.hpp"
00041 #include "PlayaLinearOperatorDecl.hpp"
00042 #include "PlayaVectorDecl.hpp"
00043 #include "PlayaVectorType.hpp"
00044
00045 namespace Sundance
00046 {
00047 using namespace Teuchos;
00048
00049 class Assembler;
00050
00051
00052
00053
00054
00055
00056 class NLOp
00057 : public ObjectWithClassVerbosity<NLOp>,
00058 public Playa::NonlinearOperatorBase<double>
00059 {
00060 public:
00061
00062 NLOp();
00063
00064
00065
00066 NLOp(const Mesh& mesh, const Expr& eqn, const Expr& bc,
00067 const Expr& test, const Expr& unk, const Expr& u0,
00068 const Playa::VectorType<double>& vecType,
00069 bool partitionBCs = false);
00070
00071
00072
00073 NLOp(const Mesh& mesh, const Expr& eqn, const Expr& bc,
00074 const BlockArray& test, const BlockArray& unk, const Expr& u0);
00075
00076
00077
00078
00079 NLOp(const Mesh& mesh, const Expr& eqn, const Expr& bc,
00080 const Expr& test, const Expr& unk, const Expr& u0,
00081 const Expr& params, const Expr& paramVals,
00082 const Playa::VectorType<double>& vecType,
00083 bool partitionBCs = false);
00084
00085
00086
00087 NLOp(const RCP<Assembler>& assembler,
00088 const Expr& u0);
00089
00090
00091 LinearOperator<double> computeJacobianAndFunction(Vector<double>& functionValue) const ;
00092
00093
00094 void computeJacobianAndFunction(LinearOperator<double>& J,
00095 Vector<double>& resid) const ;
00096
00097
00098 Expr computeSensitivities(const LinearSolver<double>& solver) const ;
00099
00100
00101
00102 Expr getU0() const {return u0_;}
00103
00104
00105 Playa::Vector<double> computeFunctionValue() const ;
00106
00107
00108 void computeFunctionValue(Vector<double>& resid) const ;
00109
00110
00111 Playa::Vector<double> getInitialGuess() const ;
00112
00113
00114 LinearOperator<double> allocateJacobian() const ;
00115
00116
00117 void setInitialGuess(const Expr& u0New);
00118
00119
00120 void reAssembleProblem() const;
00121
00122
00123 GET_RCP(Playa::NonlinearOperatorBase<double>);
00124
00125 protected:
00126
00127 void updateDiscreteFunctionValue(const Vector<double>& vec) const ;
00128 private:
00129
00130
00131 RCP<Assembler> assembler_;
00132
00133
00134 mutable Playa::LinearOperator<double> J_;
00135
00136
00137 Expr u0_;
00138
00139
00140 Expr params_;
00141
00142
00143 Expr paramVals_;
00144 };
00145 }
00146
00147
00148
00149
00150 #endif