Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

ElementFunction.h

Go to the documentation of this file.
00001 // Copyright (C) 2003 Johan Hoffman and Anders Logg.
00002 // Licensed under the GNU GPL Version 2.
00003 
00004 #ifndef __ELEMENT_FUNCTION_H
00005 #define __ELEMENT_FUNCTION_H
00006 
00007 #include <dolfin/dolfin_log.h>
00008 #include <dolfin/constants.h>
00009 #include <dolfin/Point.h>
00010 #include <dolfin/FunctionSpace.h>
00011 #include <dolfin/Integral.h>
00012 
00013 namespace dolfin {
00014 
00015   class FunctionSpace::ShapeFunction;
00016   class FunctionSpace::Product;
00017   class Function;
00018   
00019   class FunctionSpace::ElementFunction {
00020   public:
00021 
00022     // Empty constructor for v = 0
00023     ElementFunction();
00024     
00025     // Initialisation
00026     ElementFunction(real a);
00027     ElementFunction(const ShapeFunction   &v);
00028     ElementFunction(const Product         &v);
00029     ElementFunction(const ElementFunction &v);
00030     
00031     // Constructors for a * v
00032     ElementFunction(real a, const ShapeFunction   &v);
00033     ElementFunction(real a, const Product         &v);
00034     ElementFunction(real a, const ElementFunction &v);
00035     
00036     // Constructors for a0 * v0 + a1 * v1
00037     ElementFunction(real a0, const ShapeFunction   &v0, real a1, const ShapeFunction   &v1);
00038     ElementFunction(real a0, const Product         &v0, real a1, const Product         &v1);
00039     ElementFunction(real a0, const ElementFunction &v0, real a1, const ElementFunction &v1);
00040     ElementFunction(real a0, const ShapeFunction   &v0, real a1, const Product         &v1);
00041     ElementFunction(real a0, const ShapeFunction   &v0, real a1, const ElementFunction &v1);
00042     ElementFunction(real a0, const Product         &v0, real a1, const ElementFunction &v1);
00043     
00044     // Constructors for  v0 * v1
00045     ElementFunction(const ShapeFunction   &v0, const ShapeFunction   &v1);
00046     ElementFunction(const Product         &v0, const Product         &v1);
00047     ElementFunction(const ElementFunction &v0, const ElementFunction &v1);
00048     ElementFunction(const ShapeFunction   &v0, const Product         &v1);
00049     ElementFunction(const ShapeFunction   &v0, const ElementFunction &v1);
00050     ElementFunction(const Product         &v0, const ElementFunction &v1);
00051     
00052     // Constructor for scalar product
00053     ElementFunction(const ElementFunction& v0, const ElementFunction& v1, const ElementFunction& v2,
00054                     const ElementFunction& w0, const ElementFunction& w1, const ElementFunction& w2);
00055     
00056     // Destructor
00057     ~ElementFunction();
00058     
00059     //--- Operators ---
00060     
00061     // Evaluation
00062     real operator() (real x, real y, real z, real t) const;
00063     real operator() (Point p) const;
00064     
00065     // Assignment
00066     ElementFunction& operator= (real a);
00067     ElementFunction& operator= (const ShapeFunction   &v);
00068     ElementFunction& operator= (const Product         &v);
00069     ElementFunction& operator= (const ElementFunction &v);
00070     
00071     // Addition
00072     ElementFunction  operator+ (const ShapeFunction   &v) const;
00073     ElementFunction  operator+ (const Product         &v) const;
00074     ElementFunction  operator+ (const ElementFunction &v) const;
00075     ElementFunction  operator+=(const ShapeFunction   &v);
00076     ElementFunction  operator+=(const Product         &v);
00077     ElementFunction  operator+=(const ElementFunction &v);
00078     
00079     // Subtraction
00080     ElementFunction  operator- (const ShapeFunction   &v) const;
00081     ElementFunction  operator- (const Product         &v) const;
00082     ElementFunction  operator- (const ElementFunction &v) const;
00083     
00084     // Multiplication
00085     ElementFunction  operator* (real a)                   const;
00086     ElementFunction  operator* (const ShapeFunction   &v) const;
00087     ElementFunction  operator* (const Product         &v) const;
00088     ElementFunction  operator* (const ElementFunction &v) const;
00089 
00090     // Derivatives
00091     ElementFunction ddx() const;
00092     ElementFunction ddy() const;
00093     ElementFunction ddz() const;
00094 
00095     // Set the number of terms
00096     void init(int size);
00097     
00098     // Set values
00099     void set(int i, const ShapeFunction &v, real value);
00100    
00101     // Integration
00102     real operator* (Integral::Measure& dm) const;
00103     
00104     // Output
00105     friend LogStream& operator<<(LogStream& stream, const ElementFunction& v);
00106     
00107     // Friends
00108     friend class Function;
00109 
00110     // Vector element function
00111     class Vector {
00112     public:
00113       
00114       Vector(int size);
00115       Vector(const Vector& v);
00116       Vector(const ElementFunction& v0, const ElementFunction& v1, const ElementFunction& v2);
00117       ~Vector();
00118       
00119       int size() const;
00120       
00121       ElementFunction& operator() (int i);
00122       const ElementFunction operator, (const Vector& v) const;
00123       
00124     private:
00125       ElementFunction* v;
00126       int _size;
00127     };
00128     
00129   private:
00130     
00131     int n;      // Number of terms
00132     real *a;    // Coefficients
00133     real c;     // Constant (offset)
00134     Product *v; // Products
00135     
00136   };
00137   
00138   FunctionSpace::ElementFunction operator* (real a, const FunctionSpace::ElementFunction& v);
00139   
00140 }
00141 
00142 #endif


Documentation automatically generated with Doxygen on 10 Sep 2004.