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

FiniteElement.h

Go to the documentation of this file.
00001 // Copyright (C) 2002 Johan Hoffman and Anders Logg.
00002 // Licensed under the GNU GPL Version 2.
00003 //
00004 // Modified by Fredrik Bengzon and Johan Jansson, 2004.
00005 
00006 // Definition of a finite element. This is a modified version
00007 // or the standard definition given by Ciarlet (1976).
00008 //                       
00009 //   1.   A reference cell K0
00010 //
00011 //   2.a) A function space P on the reference cell (the local trial space)
00012 //     b) A map I from local to global degrees of freedom
00013 //
00014 //   3.a) A function space Q on the reference cell (the local test space)
00015 //     b) A map J from local to global degrees of freedom
00016 
00017 #ifndef __FINITE_ELEMENT_H
00018 #define __FINITE_ELEMENT_H
00019 
00020 #include <dolfin/constants.h>
00021 #include <dolfin/FunctionSpace.h>
00022 #include <dolfin/ShapeFunction.h>
00023 #include <dolfin/shapefunctions.h>
00024 
00025 namespace dolfin {
00026 
00027   class ExpressionFunction;
00028 
00029   class FiniteElement {
00030   public:
00031 
00032     // Constructor
00033     FiniteElement(FunctionSpace& trial, FunctionSpace& test) : P(&trial), Q(&test) {};
00034     
00035     // Dimension (of trial space)
00036     int dim() const;
00037     
00038     // Update function spaces
00039     void update(const Map& map);
00040     
00041     
00042     // Iterator over shape functions in the local trial space
00043     class TrialFunctionIterator {
00044     public:
00045       
00046       TrialFunctionIterator(const FiniteElement& element);
00047       TrialFunctionIterator(const FiniteElement* element);
00048       
00049       // Global dof (map I)
00050       int dof(const Cell& cell) const;
00051       
00052       // Evaluation of dof
00053       real dof(const Cell& cell, const ExpressionFunction& f, real t) const;
00054       
00055       int  index() const;
00056       bool end() const;
00057       void operator++();
00058       operator FunctionSpace::ShapeFunction() const;
00059       FunctionSpace::ShapeFunction& operator*() const;
00060       FunctionSpace::ShapeFunction* operator->() const;
00061       
00062     private:
00063       
00064       const FiniteElement* e;
00065       FunctionSpace::Iterator v;
00066       
00067     };
00068     
00069     // Iterator over shape functions in the local test space
00070     class TestFunctionIterator {
00071     public:
00072       
00073       TestFunctionIterator(const FiniteElement& element);
00074       TestFunctionIterator(const FiniteElement* element);
00075       
00076       // Global dof (map J)
00077       int dof(const Cell& cell) const;
00078       
00079       // Evaluation of dof
00080       real dof(const Cell& cell, const ExpressionFunction& f, real t) const;
00081       
00082       int  index() const;                               // Index in list
00083       bool end() const;                                 // End of list?
00084       void operator++();                                // Increment
00085       operator FunctionSpace::ShapeFunction() const;    // Cast to ShapeFunction
00086       FunctionSpace::ShapeFunction& operator*() const;  // Dereferencing
00087       FunctionSpace::ShapeFunction* operator->() const; // -> access
00088       
00089     private:
00090       
00091       const FiniteElement* e;
00092       FunctionSpace::Iterator v;
00093       
00094     };
00095 
00096     
00097     // Vector finite element
00098     class Vector {
00099     public:
00100       
00101       Vector(unsigned int size);
00102       //Vector(const Vector& v);
00103       //Vector(const FiniteElement& v0, const FiniteElement& v1, const FiniteElement& v2);
00104       ~Vector();
00105       
00106       unsigned int size() const;
00107       
00108       FiniteElement*& operator() (int i);
00109       
00110       // Iterator over shape functions in the local trial space
00111       class TrialFunctionIterator {
00112       public:
00113         
00114         TrialFunctionIterator(FiniteElement::Vector& element);
00115         TrialFunctionIterator(FiniteElement::Vector* element);
00116         
00117         // Global dof (mapping I)
00118         int dof(const Cell& cell) const;
00119         
00120         // Evaluation of dof
00121         //real dof(const Cell& cell, const ExpressionFunction& f, real t) const;
00122         //int  index() const;
00123         bool end() const;
00124         void operator++();
00125         //operator FunctionSpace::ShapeFunction() const;
00126         FunctionSpace::ShapeFunction::Vector& operator*();
00127         FunctionSpace::ShapeFunction::Vector* operator->();
00128       
00129       private:
00130         
00131         FiniteElement::Vector& e;
00132         FiniteElement::TrialFunctionIterator uiter;
00133         unsigned int componentiter;
00134 
00135         FunctionSpace::ShapeFunction::Vector shapefunction;
00136         //FunctionSpace::ShapeFunction zero;
00137       };
00138 
00139       // Iterator over shape functions in the local test space
00140       class TestFunctionIterator {
00141       public:
00142         
00143         TestFunctionIterator(FiniteElement::Vector& element);
00144         TestFunctionIterator(FiniteElement::Vector* element);
00145         
00146         // Global dof (mapping I)
00147         int dof(const Cell& cell) const;
00148         
00149         // Evaluation of dof
00150         //real dof(const Cell& cell, const ExpressionFunction& f, real t) const;
00151         //int  index() const;
00152         bool end() const;
00153         void operator++();
00154         //operator FunctionSpace::ShapeFunction() const;
00155         FunctionSpace::ShapeFunction::Vector& operator*();
00156         FunctionSpace::ShapeFunction::Vector* operator->();
00157       
00158       private:
00159         
00160         FiniteElement::Vector& e;
00161         FiniteElement::TestFunctionIterator viter;
00162         unsigned int componentiter;
00163 
00164         FunctionSpace::ShapeFunction::Vector shapefunction;
00165         //FunctionSpace::ShapeFunction zero;
00166       };
00167       
00168     private:
00169       FiniteElement** v;
00170       unsigned int _size;
00171     };
00172 
00173 
00174     // Friends
00175     friend class TrialFunctionIterator;
00176     friend class TestFunctionIterator;
00177     friend class Vector::TrialFunctionIterator;
00178     friend class Vector::TestFunctionIterator;
00179     
00180   private:
00181     
00182     FunctionSpace* P; // Local trial space on reference cell
00183     FunctionSpace* Q; // Local test space on reference cell
00184 
00185     FunctionSpace::ShapeFunction zero;
00186     
00187   };
00188   
00189 }
00190 
00191 #endif


Documentation automatically generated with Doxygen on 10 Sep 2004.