MFEM v2.0
fespace.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_FESPACE
00013 #define MFEM_FESPACE
00014 
00015 /* Class FiniteElementSpace - responsible for providing FEM view of the mesh
00016    (mainly managing the set of degrees of freedom). */
00017 
00020 class Ordering
00021 {
00022 public:
00026    enum Type { byNODES, byVDIM };
00027 };
00028 
00030 typedef int RefinementType;
00031 
00033 class RefinementData {
00034 public:
00036    RefinementType type;
00038    int num_fine_elems;
00040    int num_fine_dofs;
00042    Table * fl_to_fc;
00044    DenseMatrix * I;
00046    ~RefinementData() { delete fl_to_fc; delete I;}
00047 };
00048 
00049 class NURBSExtension;
00050 
00052 class FiniteElementSpace
00053 {
00054 protected:
00056    Mesh *mesh;
00057 
00059    int vdim;
00060 
00062    int ndofs;
00063 
00067    int ordering;
00068 
00069    const FiniteElementCollection *fec;
00070    int nvdofs, nedofs, nfdofs, nbdofs;
00071    int *fdofs, *bdofs;
00072 
00074    Array<RefinementData *> RefData;
00075 
00076    Table *elem_dof;
00077    Table *bdrElem_dof;
00078    Array<int> dof_elem_array, dof_ldof_array;
00079 
00080    NURBSExtension *NURBSext;
00081    int own_ext;
00082 
00083    void UpdateNURBS();
00084 
00085    void Constructor();
00086    void Destructor();   // does not destroy 'RefData'
00087 
00088    /* Create a FE space stealing all data (except RefData) from the
00089       given FE space. This is used in SaveUpdate() */
00090    FiniteElementSpace(FiniteElementSpace &);
00091 
00093    void ConstructRefinementData (int k, int cdofs, RefinementType type);
00094 
00096    DenseMatrix * LocalInterpolation (int k, int cdofs,
00097                                      RefinementType type,
00098                                      Array<int> &rows);
00099 
00100 public:
00101    FiniteElementSpace(Mesh *m, const FiniteElementCollection *f,
00102                       int dim = 1, int order = Ordering::byNODES);
00103 
00105    inline Mesh * GetMesh() const { return mesh; };
00106 
00107    NURBSExtension *GetNURBSext() { return NURBSext; }
00108 
00110    inline int GetVDim() const { return vdim; };
00111 
00113    int GetOrder(int i) const;
00114 
00116    inline int GetNDofs() const { return ndofs; };
00117 
00118    inline int GetVSize() const { return vdim * ndofs; };
00119 
00121    inline int GetOrdering() const { return ordering; };
00122 
00123    const FiniteElementCollection *FEColl() const { return fec; };
00124 
00125    int GetNVDofs() const { return nvdofs; }
00126    int GetNEDofs() const { return nedofs; }
00127    int GetNFDofs() const { return nfdofs; }
00128 
00130    inline int GetNE() const { return mesh -> GetNE(); };
00131 
00133    inline int GetNV() const { return mesh -> GetNV(); };
00134 
00136    inline int GetNBE() const { return mesh -> GetNBE(); };
00137 
00139    inline int GetElementType (int i) const
00140    { return mesh -> GetElementType(i); }
00141 
00143    inline void GetElementVertices (int i, Array<int> &vertices) const
00144    { mesh -> GetElementVertices(i, vertices); }
00145 
00147    inline int GetBdrElementType (int i) const
00148    { return mesh -> GetBdrElementType(i); }
00149 
00151    ElementTransformation * GetElementTransformation(int i) const
00152    { return mesh -> GetElementTransformation(i); };
00153 
00156    void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
00157    { mesh->GetElementTransformation(i, ElTr); }
00158 
00160    ElementTransformation * GetBdrElementTransformation(int i) const
00161    { return mesh -> GetBdrElementTransformation(i); };
00162 
00163    int GetAttribute(int i) { return mesh -> GetAttribute(i); };
00164 
00165    int GetBdrAttribute(int i) { return mesh -> GetBdrAttribute(i); };
00166 
00168    virtual void GetElementDofs (int i, Array<int> &dofs) const;
00169 
00171    virtual void GetBdrElementDofs (int i, Array<int> &dofs) const;
00172 
00175    void GetFaceDofs (int i, Array<int> &dofs) const;
00176 
00179    void GetEdgeDofs (int i, Array<int> &dofs) const;
00180 
00181    void GetElementInteriorDofs (int i, Array<int> &dofs) const;
00182 
00183    void GetEdgeInteriorDofs (int i, Array<int> &dofs) const;
00184 
00185    void DofsToVDofs (Array<int> &dofs) const;
00186 
00187    void DofsToVDofs (int vd, Array<int> &dofs) const;
00188 
00189    int DofToVDof (int dof, int vd) const;
00190 
00191    int VDofToDof(int vdof) const
00192    { return (ordering == Ordering::byNODES) ? (vdof%ndofs) : (vdof/vdim); }
00193 
00194    static void AdjustVDofs (Array<int> &vdofs);
00195 
00197    void GetElementVDofs (int i, Array<int> &dofs) const;
00198 
00200    void GetBdrElementVDofs (int i, Array<int> &dofs) const;
00201 
00203    void GetFaceVDofs (int iF, Array<int> &dofs) const;
00204 
00206    void GetEdgeVDofs (int iE, Array<int> &dofs) const;
00207 
00208    void GetElementInteriorVDofs (int i, Array<int> &vdofs) const;
00209 
00210    void GetEdgeInteriorVDofs (int i, Array<int> &vdofs) const;
00211 
00212    void BuildElementToDofTable();
00213 
00214    void BuildDofToArrays();
00215 
00216    const Table &GetElementToDofTable() const { return *elem_dof; }
00217 
00218    int GetElementForDof  (int i) { return dof_elem_array[i]; }
00219    int GetLocalDofForDof (int i) { return dof_ldof_array[i]; }
00220 
00222    const FiniteElement * GetFE (int i) const;
00223 
00225    const FiniteElement * GetBE (int i) const;
00226 
00235    SparseMatrix * GlobalRestrictionMatrix (FiniteElementSpace *cfes,
00236                                            int one_vdim = -1);
00237 
00239    virtual void GetEssentialVDofs(Array<int> &bdr_attr_is_ess,
00240                                   Array<int> &ess_dofs);
00241 
00242    void EliminateEssentialBCFromGRM (FiniteElementSpace *cfes,
00243                                      Array<int> &bdr_attr_is_ess,
00244                                      SparseMatrix *R);
00245 
00247    SparseMatrix * GlobalRestrictionMatrix(FiniteElementSpace *cfes,
00248                                           Array<int> &bdr_attr_is_ess,
00249                                           int one_vdim = -1);
00250 
00253    SparseMatrix * D2C_GlobalRestrictionMatrix(FiniteElementSpace *cfes);
00254 
00257    SparseMatrix * D2Const_GlobalRestrictionMatrix(FiniteElementSpace *cfes);
00258 
00262    SparseMatrix * H2L_GlobalRestrictionMatrix (FiniteElementSpace *lfes);
00263 
00264    virtual void Update();
00266    virtual FiniteElementSpace *SaveUpdate();
00267 
00268    void Save (ostream &out) const;
00269 
00270    virtual ~FiniteElementSpace();
00271 };
00272 
00273 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines