NGSolve  4.9
fem/finiteelement.hpp
00001 #ifndef FILE_FINITEELEMENT
00002 #define FILE_FINITEELEMENT
00003 
00004 
00005 /*********************************************************************/
00006 /* File:   finiteelement.hpp                                         */
00007 /* Author: Joachim Schoeberl                                         */
00008 /* Date:   25. Mar. 2000                                             */
00009 /*********************************************************************/
00010 
00011 namespace ngfem
00012 {
00013 
00014   /*
00015     Finite Element Definitions
00016   */
00017 
00018 
00026   /*
00027   class Dof
00028   {
00029   public:
00031     Node node;
00033     int nr_on_node;
00034 
00035   public:
00037     Dof () { ; }
00038 
00040     Dof (Node anode, int anr_on_node)
00041       : node(anode), nr_on_node(anr_on_node) { ; }
00042   
00044     Dof (const Dof & d2)
00045     { node = d2.node; nr_on_node = d2.nr_on_node; }
00046 
00048     const Node & GetNode() const { return node; }
00049 
00051     int GetNrOnNode () const { return nr_on_node; }
00052   };
00053 
00055   inline ostream & operator<< (ostream & ost, const Dof & dof)
00056   {
00057     ost << dof.GetNode() << "," << dof.GetNrOnNode();
00058     return ost;
00059   }
00060   */
00061 
00062 
00069   class NGS_DLL_HEADER FiniteElement
00070   {
00071   protected:
00073     ELEMENT_TYPE eltype;
00075     int ndof;
00077     int order;
00078   protected:
00080     FiniteElement () { ; }
00081 
00083     FiniteElement (ELEMENT_TYPE aeltype, int andof, int aorder)
00084       : eltype(aeltype), ndof(andof), order(aorder)
00085     { ; }
00086 
00087   public:
00089     virtual ~FiniteElement () { ; }
00090 
00092     int GetNDof () const { return ndof; }
00093 
00095     int Order () const { return order; }
00096 
00098     ELEMENT_TYPE ElementType() const { return eltype; }
00099 
00101     virtual string ClassName() const { return "FiniteElement"; }
00102 
00104     virtual void PrecomputeShapes (const IntegrationRule & ir) { ; }
00105   };
00106 
00107  
00108 
00109 
00115   class NGS_DLL_HEADER CompoundFiniteElement : public FiniteElement
00116   {
00117   protected:
00119     ArrayMem<const FiniteElement*,10> fea;
00120   public:
00122     CompoundFiniteElement (Array<const FiniteElement*> & afea);
00123 
00125     int GetNComponents() const { return fea.Size(); }
00126 
00128     const FiniteElement & operator[] (int i) const { return *fea[i]; }
00129 
00131     IntRange GetRange (int comp) const
00132     {
00133       int base = 0;
00134       for (int i = 0; i < comp; i++)
00135         base += fea[i]->GetNDof();
00136       return IntRange (base, base+fea[comp]->GetNDof());
00137     }
00138 
00140     virtual string ClassName() const { return "CompoundFiniteElement"; }
00141   };
00142 
00143 
00144 
00145 
00149   template <ELEMENT_TYPE ET>
00150   class DummyFE : public FiniteElement
00151   {
00152   public:
00153     DummyFE ()
00154       : FiniteElement(ET, 0, 0) { ; }
00155   };
00156 
00157 }
00158 
00159 
00160 #endif