SundanceDiscreteFunction.hpp
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 #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  * DiscreteFunction represents a function that is discretized
00049  * on a finite-element space.
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   /** virtual destructor */
00111   virtual ~DiscreteFunction() {;}
00112 
00113   /* boilerplate */
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 /** \relates DiscreteFunction
00133  * Replace the vector in oldVals with the vector from newVals.
00134  */
00135 void updateDiscreteFunction(const Expr& newVals, Expr oldVals);
00136 
00137 
00138 /** \relates DiscreteFunction
00139  * Make a copy of the discrete function u0. The copy will have a shallow
00140  * copy of u0's space, and a deep copy of u0's vector. 
00141  */
00142 Expr copyDiscreteFunction(const Expr& u0, const string& name = "");
00143 
00144 
00145 /** \relates DiscreteFunction
00146  * Add a vector v to the vector underlying the discrete function u.
00147  */
00148 void addVecToDiscreteFunction(Expr u, const Vector<double>& v);
00149 
00150 /** \relates DiscreteFunction
00151  * Get a shallow copy of the vector underlying a discrete function 
00152  */
00153 Vector<double> getDiscreteFunctionVector(const Expr& u);
00154 
00155 
00156 /** \relates DiscreteFunction
00157  * Set the vector underlying a discrete function 
00158  */
00159 void setDiscreteFunctionVector(Expr u, const Vector<double>& v);
00160 
00161 
00162 /** \relates DiscreteFunction
00163  * Get the mesh underlying a discrete function 
00164  */
00165 Mesh getDiscreteFunctionMesh(const Expr& u);
00166 
00167 
00168 /** \relates DiscreteFunction
00169  * Get the discrete space on which a discrete function is defined 
00170  */
00171 DiscreteSpace getDiscreteSpace(const Expr& u);
00172 
00173 
00174 }
00175 
00176 
00177 
00178 #endif

Site Contact