Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Examples  

DiscreteFunction.h

Go to the documentation of this file.
00001 #ifndef DISCRETEFUNCTION_H
00002 #define DISCRETEFUNCTION_H
00003 
00004 #include "SundanceDefs.h"
00005 
00006 #include "TSFSmartPtr.h"
00007 #include "FuncExprBase.h"
00008 #include "DenseSerialVector.h"
00009 #include "TSFRBTree.h"
00010 #include "BasisFamily.h"
00011 #include "SundanceVectorSpace.h"
00012 #include "DistributedDOFMap.h"
00013 #include "TSFTimeMonitor.h"
00014 #include "TSFVector.h"
00015 #include "TSFNonDupArray.h"
00016 
00017 namespace Sundance
00018 {
00019 
00020   using namespace TSF;
00021   using std::string;
00022 
00023   using std::ostream;
00024 
00025   /**
00026    * \ingroup UserLevelSymbolics
00027    * Symbolic representation of a discrete solution of a finite-element problem.
00028    */
00029 
00030   class DiscreteFunction : public FuncExprBase
00031     {
00032     public:
00033       /** \name User-level methods */
00034       //@{
00035       /** Discretize an expression on a mesh, using the given basis */
00036       DiscreteFunction(const TSFVectorSpace& space,
00037                        const Expr& expr,
00038                        const string& name="");
00039 
00040       static Expr discretize(const TSFVectorSpace& space, const Expr& expr,
00041                              const string& name="");
00042       //@}
00043 
00044       /** \name Developer-only methods */
00045       //@{
00046       /** Build a component of a discrete function from a vector and vector map.
00047        *  This is used when building a solution expr from the solution of
00048        * a numerical linear algebra problem
00049        */
00050       DiscreteFunction(const AbstractFunctionSpace& abstractSpace,
00051                        const TSFVector& vector, int myReducedIndex,
00052                        const string& name="");
00053       /** */
00054       virtual ~DiscreteFunction(){;}
00055 
00056       /** */
00057       virtual void evaluate(const WorkSet& workSet,
00058                             const QuadratureFamily& quadFamily,
00059                             DenseSerialVector& result) const ;
00060 
00061       /** */
00062       virtual void evaluate(const AbstractFunctionSpace& targetSpace,
00063                             const TSFArray<Cell>& cells,
00064                             const TSFArray<int>& cellIndices,
00065                             const TSFArray<int>& dofIndices,
00066                             const TSFArray<Point>& x,
00067                             DenseSerialVector& values) const ;
00068 
00069       /** probe value at a point */
00070       virtual double probeAtMeshPoint(int localPointIndex) const ;
00071 
00072       /** */
00073       virtual double norm() const ;
00074       /** */
00075       virtual double quickNorm() const ;
00076       /** */
00077       virtual double maxNorm() const ;
00078       /** */
00079       virtual void getVector(TSFVector& vector) const ;
00080 
00081       /** */
00082       virtual void setVector(const TSFVector& vector) ;
00083       /** */
00084       virtual void readValues(const string& filename);
00085 
00086       /** */
00087       virtual ExprValue average(const Cell& cell) const ;
00088 
00089       // differentiation
00090       /** */
00091       virtual void derivative(const MultiIndex& d, Expr& result) const ;
00092 
00093       /** */
00094       virtual const MultiIndex& multiIndex() const {return ExprBase::dummyMultiIndex_;}
00095 
00096       // ordering and RTTI
00097       /** */
00098       virtual bool operator==(const Expr& other) const ;
00099       /** */
00100       virtual bool operator<(const Expr& other) const ;
00101       /** */
00102       virtual int sortPriority() const {return DISCRETEFUNCTION;}
00103       /** */
00104       virtual bool isDiscreteFunction() const {return true;}
00105 
00106       // misc
00107       /** */
00108       virtual ExprBase* clone() const ;
00109       /** */
00110       virtual void print(ostream& os, bool paren=false) const ;
00111       /** */
00112       virtual string toString(bool paren=false) const ;
00113 
00114       // FE support
00115       virtual void getBasis(BasisFamily& basis) const {basis = getBasis();}
00116 
00117       virtual bool getMesh(Mesh& mesh) const {mesh = abstractSpace_.mesh(); return true;}
00118 
00119       /** return the DOF map associated with a discrete function */
00120       virtual void getDOFMap(TSFSmartPtr<DOFMapBase>& m) const
00121         {m = abstractSpace_.map();}
00122 
00123       /** return the index of a discrete function into a list */
00124       virtual int getReducedIndex() const {return myReducedIndex_;}
00125 
00126       /** get the cell sets on which this function is defined */
00127       virtual void getDomain(TSFNonDupArray<CellSet>& domain) const
00128         {domain = abstractSpace_.domains(myReducedIndex_);}
00129 
00130       /** */
00131       virtual void matlabDump(ostream& os) const ;
00132 
00133       /** */
00134       virtual void fullForm(ostream& os) const ;
00135 
00136       /** */
00137       virtual XMLObject toXML() const ;
00138 
00139       void checkEvaluationCells(const TSFArray<Cell>& cells, int nCells) const ;
00140 
00141       static bool& paranoidChecking() {static bool rtn = false; return rtn;}
00142 
00143       //@}
00144       friend class DiscreteFunctionDeriv;
00145 
00146 
00147     private:
00148 
00149       const BasisFamily& getBasis() const
00150         {return abstractSpace_.basis(myReducedIndex_);}
00151 
00152       const TSFSmartPtr<DOFMapBase>& map() const
00153         {return abstractSpace_.map();}
00154 
00155       /* */
00156       AbstractFunctionSpace abstractSpace_;
00157 
00158       /* */
00159       CellSet domain_;
00160 
00161       /* */
00162       TSFVector vector_;
00163 
00164       /* */
00165       int myReducedIndex_;
00166 
00167       static TSFTimer& discretizeTimer();
00168     };
00169 
00170 }
00171 #endif
00172 
00173 
00174 
00175 

Contact:
Kevin Long (krlong@ca.sandia.gov)


Documentation generated by