Xfem
The Xfem Plugin
xfemElement.h
Go to the documentation of this file.
1 /************************************************************************
2 **
3 ** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4 ** All rights reserved.
5 **
6 ** This file is part of the "GeMA" software. It's use should respect
7 ** the terms in the license agreement that can be found together
8 ** with this source code.
9 ** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10 ** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11 ** A PARTICULAR PURPOSE.
12 **
13 ************************************************************************/
14 
24 #ifndef _GEMA_XFEM_ELEMENT_H_
25 #define _GEMA_XFEM_ELEMENT_H_
26 
27 #include <gmpGemaCell.h>
28 #include <gmpGemaCellMeshData.h>
29 #include <gmElement.h>
30 
31 #include <xfemConfig.h>
32 #include "xfemLuaElement.h"
33 
34 #include <gmLuaCell.h>
35 
36 
40 #define XFEM_ELEMENT_ENRICHED_MASK ((~(~0u >> 1)) >> (32 - GMP_GEMAMESH_CELL_ID_BITS))
41 
43 class XfemElement: public GmElement
44 {
45 public:
47  virtual bool enriched() const = 0;
48 
56  const GmShape* enrichmentShape() const { return linearShape(); }
57 
58 protected:
59  friend class XfemMesh;
60 
62  virtual void setEnriched(bool mode) = 0;
63 };
64 
65 
70 template <class, class, class, GmCellType T, int N, int VN> class XfemGemaElement
71  : public GmpGemaGhostCell<XfemElement, XfemLuaElement, GmpGemaCellMeshData<XfemVector>, T, N, VN>
72 {
73 public:
75  XfemGemaElement(GmCellMesh* mesh, int meshId, int id, int offset)
76  : GmpGemaGhostCell<XfemElement, XfemLuaElement, GmpGemaCellMeshData<XfemVector>, T, N, VN>(mesh, meshId, id, offset) {}
77 
78  // See comments on base class.
79  virtual int cellId() const { return GmpGemaGhostCell<XfemElement, XfemLuaElement, GmpGemaCellMeshData<XfemVector>, T, N, VN>::cellId() & (~XFEM_ELEMENT_ENRICHED_MASK); }
80 
83 
84 protected:
85 
87  virtual void setEnriched(bool mode)
88  {
89  if(mode == enriched())
90  return;
91  replaceCellId(mode ? (cellId() | XFEM_ELEMENT_ENRICHED_MASK) : cellId(), true);
92  }
93 };
94 
95 #endif
96 
XfemGemaElement(GmCellMesh *mesh, int meshId, int id, int offset)
Constructor.
Definition: xfemElement.h:75
virtual void setEnriched(bool mode)=0
Marks the element as enriched or not.
const GmShape * enrichmentShape() const
Returns a shape function object used in the element enrichment.
Definition: xfemElement.h:56
virtual void setEnriched(bool mode)
Marks the element as enriched or not.
Definition: xfemElement.h:87
Basic interface for an XFEM element.
Definition: xfemElement.h:43
Basic class for a XFEM mesh. This is the basic mesh interface for xfem problems adding enrichment cap...
Definition: xfemMesh.h:49
#define XfemVector
XfemVector is a define and not an "using" clause to avoid linking errors arising from instancing Gema...
Definition: xfemConfig.h:43
#define XFEM_ELEMENT_ENRICHED_MASK
Mask with 1 on the most significant bit of the cell id to tell if the element has been enriched or no...
Definition: xfemElement.h:40
virtual bool enriched() const =0
Returns true if this element has been enriched, false when not.
virtual bool enriched() const
Returns true if this element has been enriched, false when not.
Definition: xfemElement.h:82
Basic implementation for an Xfem element, based on a "standard" GeMA mesh element.
Definition: xfemElement.h:70
Declaration of the XfemLuaElement class.
Declaration of usefull configuration definitions for the plugin library.
A proxy class to export XfemElement methods to the Lua environment.
Definition: xfemLuaElement.h:32
virtual const GmShape * linearShape() const