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_DISCRETEFUNCTION_H
00032 #define SUNDANCE_DISCRETEFUNCTION_H
00033 
00034 #include "SundanceDefs.hpp"
00035 #include "SundanceExpr.hpp"
00036 #include "SundanceDiscreteFunctionStub.hpp"
00037 #include "SundanceDiscreteFunctionData.hpp"
00038 #include "SundanceFuncWithBasis.hpp"
00039 #include "SundanceDiscreteSpace.hpp"
00040 #include "PlayaVectorDecl.hpp"
00041 
00042 namespace Sundance
00043 {
00044 using namespace Teuchos;
00045   
00046 
00047 
00048 
00049 
00050 
00051 class DiscreteFunction : public DiscreteFunctionStub,
00052                          public FuncWithBasis
00053 {
00054 public:
00055 
00056   DiscreteFunction(const DiscreteSpace& space, const std::string& name="");
00057 
00058 
00059   DiscreteFunction(const DiscreteSpace& space, const Vector<double>& vec, 
00060     const std::string& name="");
00061 
00062 
00063   DiscreteFunction(const DiscreteSpace& space, const double& constantValue,
00064     const std::string& name="");
00065 
00066   DiscreteFunction(const DiscreteSpace& space, const Array<string>& names);
00067 
00068 
00069   DiscreteFunction(const DiscreteSpace& space, const Vector<double>& vec, 
00070     const Array<string>& names);
00071 
00072 
00073   DiscreteFunction(const DiscreteSpace& space, const double& constantValue,
00074     const Array<string>& name);
00075 
00076 
00077   static const DiscreteFunction* discFunc(const Expr& expr);
00078 
00079 
00080 
00081   static DiscreteFunction* discFunc(Expr& expr);
00082 
00083 
00084   void updateGhosts() const ;
00085 
00086 
00087   void setVector(const Vector<double>& vec);
00088 
00089 
00090   const Vector<double>& getVector() const 
00091     {return data_->getVector();}
00092 
00093 
00094   const DiscreteSpace& discreteSpace() const 
00095     {return data_->discreteSpace();}
00096 
00097 
00098   const Mesh& mesh() const {return discreteSpace().mesh();}
00099 
00100 
00101   const RCP<DOFMapBase>& map() const {return discreteSpace().map();}
00102 
00103 
00104   RCP<GhostView<double> >  ghostView() const 
00105     {return data_->ghostView();}
00106 
00107   const DiscreteFunctionData* data() const {return data_.get();}
00108 
00109 
00110 
00111   virtual ~DiscreteFunction() {;}
00112 
00113   
00114   GET_RCP(ExprBase);
00115 
00116 
00117 
00118   RCP<const MapStructure> getLocalValues(int cellDim, 
00119     const Array<int>& cellLID,
00120     Array<Array<double> >& localValues) const ;
00121 
00122 
00123 private:
00124 
00125   RCP<DiscreteFuncDataStub> getRCP(DiscreteFunctionData* ptr);
00126 
00127   RCP<DiscreteFunctionData> data_;
00128 
00129 };
00130 
00131 
00132 
00133 
00134 
00135 void updateDiscreteFunction(const Expr& newVals, Expr oldVals);
00136 
00137 
00138 
00139 
00140 
00141 
00142 Expr copyDiscreteFunction(const Expr& u0, const string& name = "");
00143 
00144 
00145 
00146 
00147 
00148 void addVecToDiscreteFunction(Expr u, const Vector<double>& v);
00149 
00150 
00151 
00152 
00153 Vector<double> getDiscreteFunctionVector(const Expr& u);
00154 
00155 
00156 
00157 
00158 
00159 void setDiscreteFunctionVector(Expr u, const Vector<double>& v);
00160 
00161 
00162 
00163 
00164 
00165 Mesh getDiscreteFunctionMesh(const Expr& u);
00166 
00167 
00168 
00169 
00170 
00171 DiscreteSpace getDiscreteSpace(const Expr& u);
00172 
00173 
00174 }
00175 
00176 
00177 
00178 #endif