MFEM v2.0
element.hpp
Go to the documentation of this file.
00001 // Copyright (c) 2010, Lawrence Livermore National Security, LLC. Produced at
00002 // the Lawrence Livermore National Laboratory. LLNL-CODE-443211. All Rights
00003 // reserved. See file COPYRIGHT for details.
00004 //
00005 // This file is part of the MFEM library. For more information and source code
00006 // availability see http://mfem.googlecode.com.
00007 //
00008 // MFEM is free software; you can redistribute it and/or modify it under the
00009 // terms of the GNU Lesser General Public License (as published by the Free
00010 // Software Foundation) version 2.1 dated February 1999.
00011 
00012 #ifndef MFEM_ELEMENT
00013 #define MFEM_ELEMENT
00014 
00015 class Mesh;
00016 
00018 class Element
00019 {
00020 protected:
00021 
00023    int attribute, base_geom;
00024 
00025 public:
00026 
00028    enum Type { POINT, SEGMENT, TRIANGLE, QUADRILATERAL, TETRAHEDRON,
00029                HEXAHEDRON, BISECTED, QUADRISECTED, OCTASECTED };
00030 
00032    explicit Element(int bg = Geometry::POINT) { attribute = -1; base_geom = bg; }
00033 
00035    virtual void SetVertices(const int *ind);
00036 
00038    virtual int GetType() const = 0;
00039 
00040    int GetGeometryType() const { return base_geom; }
00041 
00043    virtual void GetVertices(Array<int> &v) const = 0;
00044 
00045    virtual int *GetVertices() = 0;
00046 
00047    virtual int GetNVertices() const = 0;
00048 
00049    virtual int GetNEdges() const = 0;
00050 
00051    virtual const int *GetEdgeVertices(int) const = 0;
00052 
00054    virtual void MarkEdge(DenseMatrix &pmat) {}
00055 
00057    virtual void MarkEdge(const DSTable &v_to_v, const int *length) {}
00058 
00060    virtual int NeedRefinement(DSTable &v_to_v, int *middle) const { return 0; }
00061 
00063    inline int GetAttribute() const { return attribute; }
00064 
00066    inline void SetAttribute(const int attr) { attribute = attr; }
00067 
00068    virtual int GetRefinementFlag() { return 0; }
00069 
00070    virtual Element *Duplicate(Mesh *m) const = 0;
00071 
00073    virtual ~Element() { }
00074 };
00075 
00076 class RefinedElement : public Element
00077 {
00078 public:
00079 
00080    enum { COARSE = 0, FINE = 1 };
00081 
00082    // The default value is set in the file 'point.cpp'
00083    static int State;
00084 
00085    Element *CoarseElem, *FirstChild;
00086 
00087    RefinedElement() { }
00088 
00089    RefinedElement(Element *ce) : Element(ce->GetGeometryType())
00090    { attribute = ce->GetAttribute(); CoarseElem = ce; }
00091    // Assumes that the coarse element and its first child have the
00092    // same attribute and the same base geometry ...
00093 
00094    void SetCoarseElem(Element *ce)
00095    {
00096       base_geom = ce->GetGeometryType();
00097       attribute = ce->GetAttribute();
00098       CoarseElem = ce;
00099    }
00100 
00101    Element *IAm()
00102    {
00103       if (State == RefinedElement::COARSE) return CoarseElem;
00104       return FirstChild;
00105    }
00106    const Element *IAm() const
00107    {
00108       if (State == RefinedElement::COARSE) return CoarseElem;
00109       return FirstChild;
00110    }
00111 
00112    virtual void SetVertices(const int *ind) { IAm()->SetVertices(ind); }
00113 
00114    virtual void GetVertices(Array<int> &v) const { IAm()->GetVertices(v); }
00115 
00116    virtual int *GetVertices() { return IAm()->GetVertices(); }
00117 
00118    virtual int GetNVertices() const { return IAm()->GetNVertices(); }
00119 
00120    virtual int GetNEdges() const { return(IAm()->GetNEdges()); }
00121 
00122    virtual const int *GetEdgeVertices(int ei) const
00123    { return(IAm()->GetEdgeVertices(ei)); }
00124 
00125    virtual void MarkEdge(DenseMatrix &pmat) { IAm()->MarkEdge(pmat); }
00126 
00127    virtual void MarkEdge(const DSTable &v_to_v, const int *length)
00128    { IAm()->MarkEdge(v_to_v, length); }
00129 
00130    virtual int NeedRefinement(DSTable &v_to_v, int *middle) const
00131    { return IAm()->NeedRefinement(v_to_v, middle); }
00132 };
00133 
00134 class BisectedElement : public RefinedElement
00135 {
00136 public:
00137    int SecondChild;
00138 
00139    BisectedElement() { }
00140    BisectedElement(Element *ce) : RefinedElement(ce) { }
00141 
00142    virtual int GetType() const { return Element::BISECTED; }
00143 
00144    virtual Element *Duplicate(Mesh *m) const
00145    { mfem_error("BisectedElement::Duplicate()"); return NULL; }
00146 };
00147 
00148 class QuadrisectedElement : public RefinedElement
00149 {
00150 public:
00151    int Child2, Child3, Child4;
00152 
00153    QuadrisectedElement(Element *ce) : RefinedElement(ce) { }
00154 
00155    virtual int GetType() const { return Element::QUADRISECTED; }
00156 
00157    virtual Element *Duplicate(Mesh *m) const
00158    { mfem_error("QuadrisectedElement::Duplicate()"); return NULL; }
00159 };
00160 
00161 class OctasectedElement : public RefinedElement
00162 {
00163 public:
00164    int Child[7];
00165 
00166    OctasectedElement(Element *ce) : RefinedElement(ce) { }
00167 
00168    virtual int GetType() const { return Element::OCTASECTED; }
00169 
00170    virtual Element *Duplicate(Mesh *m) const
00171    { mfem_error("OctasectedElement::Duplicate()"); return NULL; }
00172 };
00173 
00174 #ifdef MFEM_USE_MEMALLOC
00175 // defined in tetrahedron.cpp
00176 extern MemAlloc <BisectedElement, 1024> BEMemory;
00177 #endif
00178 
00179 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines