MFEM  v3.2
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
geom.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010, Lawrence Livermore National Security, LLC. Produced at
2 // the Lawrence Livermore National Laboratory. LLNL-CODE-443211. All Rights
3 // reserved. See file COPYRIGHT for details.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability see http://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the GNU Lesser General Public License (as published by the Free
10 // Software Foundation) version 2.1 dated February 1999.
11 
12 #ifndef MFEM_GEOM
13 #define MFEM_GEOM
14 
15 #include "../config/config.hpp"
16 #include "../linalg/densemat.hpp"
17 #include "intrules.hpp"
18 
19 namespace mfem
20 {
21 
29 class Geometry
30 {
31 public:
33 
34  static const int NumGeom = 6;
35  static const int NumBdrArray[];
36  static const char *Name[NumGeom];
37  static const double Volume[NumGeom];
38  static const int Dimension[NumGeom];
39  static const int NumVerts[NumGeom];
40  static const int NumEdges[NumGeom];
41  static const int NumFaces[NumGeom];
42 
43  // Structure that holds constants describing the Geometries.
44  // Currently it contains just the space dimension.
45  template <Type Geom> struct Constants;
46 
47 private:
48  IntegrationRule *GeomVert[NumGeom];
49  IntegrationPoint GeomCenter[NumGeom];
50  DenseMatrix *PerfGeomToGeomJac[NumGeom];
51 
52 public:
53  Geometry();
54  ~Geometry();
55 
56  const IntegrationRule *GetVertices(int GeomType);
57  const IntegrationPoint &GetCenter(int GeomType)
58  { return GeomCenter[GeomType]; }
61  static void GetRandomPoint(int GeomType, IntegrationPoint &ip);
63  static bool CheckPoint(int GeomType, const IntegrationPoint &ip);
68  static bool ProjectPoint(int GeomType, const IntegrationPoint &beg,
69  IntegrationPoint &end);
70 
72  { return PerfGeomToGeomJac[GeomType]; }
73  void GetPerfPointMat(int GeomType, DenseMatrix &pm);
74  void JacToPerfJac(int GeomType, const DenseMatrix &J,
75  DenseMatrix &PJ) const;
76 
77  int NumBdr (int GeomType) { return NumBdrArray[GeomType]; }
78 };
79 
80 template <> struct Geometry::Constants<Geometry::POINT>
81 {
82  static const int Dimension = 0;
83  static const int NumVert = 1;
84 
85  static const int NumOrient = 1;
86  static const int Orient[NumOrient][NumVert];
87  static const int InvOrient[NumOrient];
88 };
89 
90 template <> struct Geometry::Constants<Geometry::SEGMENT>
91 {
92  static const int Dimension = 1;
93  static const int NumVert = 2;
94  static const int NumEdges = 1;
95  static const int Edges[NumEdges][2];
96 
97  static const int NumOrient = 2;
98  static const int Orient[NumOrient][NumVert];
99  static const int InvOrient[NumOrient];
100 };
101 
102 template <> struct Geometry::Constants<Geometry::TRIANGLE>
103 {
104  static const int Dimension = 2;
105  static const int NumVert = 3;
106  static const int NumEdges = 3;
107  static const int Edges[NumEdges][2];
108  // Lower-triangular part of the local vertex-to-vertex graph.
109  struct VertToVert
110  {
111  static const int I[NumVert];
112  static const int J[NumEdges][2]; // {end,edge_idx}
113  };
114  static const int NumFaces = 1;
115  static const int FaceVert[NumFaces][NumVert];
116 
117  // For a given base tuple v={v0,v1,v2}, the orientation of a permutation
118  // u={u0,u1,u2} of v, is an index 'j' such that u[i]=v[Orient[j][i]].
119  // The static method Mesh::GetTriOrientation, computes the index 'j' of the
120  // permutation that maps the second argument 'test' to the first argument
121  // 'base': test[Orient[j][i]]=base[i].
122  static const int NumOrient = 6;
123  static const int Orient[NumOrient][NumVert];
124  // The inverse of orientation 'j' is InvOrient[j].
125  static const int InvOrient[NumOrient];
126 };
127 
128 template <> struct Geometry::Constants<Geometry::SQUARE>
129 {
130  static const int Dimension = 2;
131  static const int NumVert = 4;
132  static const int NumEdges = 4;
133  static const int Edges[NumEdges][2];
134  // Lower-triangular part of the local vertex-to-vertex graph.
135  struct VertToVert
136  {
137  static const int I[NumVert];
138  static const int J[NumEdges][2]; // {end,edge_idx}
139  };
140  static const int NumFaces = 1;
141  static const int FaceVert[NumFaces][NumVert];
142 
143  static const int NumOrient = 8;
144  static const int Orient[NumOrient][NumVert];
145  static const int InvOrient[NumOrient];
146 };
147 
148 template <> struct Geometry::Constants<Geometry::TETRAHEDRON>
149 {
150  static const int Dimension = 3;
151  static const int NumVert = 4;
152  static const int NumEdges = 6;
153  static const int Edges[NumEdges][2];
154  static const int NumFaces = 4;
155  static const int FaceTypes[NumFaces];
156  static const int MaxFaceVert = 3;
157  static const int FaceVert[NumFaces][MaxFaceVert];
158  // Lower-triangular part of the local vertex-to-vertex graph.
159  struct VertToVert
160  {
161  static const int I[NumVert];
162  static const int J[NumEdges][2]; // {end,edge_idx}
163  };
164 };
165 
166 template <> struct Geometry::Constants<Geometry::CUBE>
167 {
168  static const int Dimension = 3;
169  static const int NumVert = 8;
170  static const int NumEdges = 12;
171  static const int Edges[NumEdges][2];
172  static const int NumFaces = 6;
173  static const int FaceTypes[NumFaces];
174  static const int MaxFaceVert = 4;
175  static const int FaceVert[NumFaces][MaxFaceVert];
176  // Lower-triangular part of the local vertex-to-vertex graph.
177  struct VertToVert
178  {
179  static const int I[NumVert];
180  static const int J[NumEdges][2]; // {end,edge_idx}
181  };
182 };
183 
184 extern Geometry Geometries;
185 
187 {
188 public:
189  int Times, ETimes;
192 
193  RefinedGeometry (int NPts, int NRefG, int NRefE) :
194  RefPts (NPts), RefGeoms (NRefG), RefEdges (NRefE) { }
195 };
196 
198 {
199 private:
200  int type; // 0 - uniform points, otherwise - poly1d.ClosedPoints
203 public:
204  GeometryRefiner();
205 
206  void SetType(const int t) { type = t; }
207  RefinedGeometry *Refine (int Geom, int Times, int ETimes = 1);
208  const IntegrationRule *RefineInterior(int Geom, int Times);
209 
211 };
212 
213 extern GeometryRefiner GlobGeometryRefiner;
214 
215 }
216 
217 #endif
Class for integration rule.
Definition: intrules.hpp:83
RefinedGeometry(int NPts, int NRefG, int NRefE)
Definition: geom.hpp:193
static const int NumGeom
Definition: geom.hpp:34
void JacToPerfJac(int GeomType, const DenseMatrix &J, DenseMatrix &PJ) const
Definition: geom.cpp:428
static void GetRandomPoint(int GeomType, IntegrationPoint &ip)
Definition: geom.cpp:190
RefinedGeometry * Refine(int Geom, int Times, int ETimes=1)
Definition: geom.cpp:566
Data type dense matrix using column-major storage.
Definition: densemat.hpp:22
static const double Volume[NumGeom]
Definition: geom.hpp:37
static const int NumBdrArray[]
Definition: geom.hpp:35
static const int NumEdges[NumGeom]
Definition: geom.hpp:40
Array< int > RefEdges
Definition: geom.hpp:191
const IntegrationPoint & GetCenter(int GeomType)
Definition: geom.hpp:57
const IntegrationRule * GetVertices(int GeomType)
Definition: geom.cpp:172
static const int NumFaces[NumGeom]
Definition: geom.hpp:41
Geometry Geometries
Definition: geom.cpp:544
static const int Dimension[NumGeom]
Definition: geom.hpp:38
void SetType(const int t)
Definition: geom.hpp:206
const IntegrationRule * RefineInterior(int Geom, int Times)
Definition: geom.cpp:937
static const int NumVerts[NumGeom]
Definition: geom.hpp:39
GeometryRefiner GlobGeometryRefiner
Definition: geom.cpp:1015
IntegrationRule RefPts
Definition: geom.hpp:190
static const char * Name[NumGeom]
Definition: geom.hpp:36
static bool ProjectPoint(int GeomType, const IntegrationPoint &beg, IntegrationPoint &end)
Definition: geom.cpp:317
void GetPerfPointMat(int GeomType, DenseMatrix &pm)
Definition: geom.cpp:367
int NumBdr(int GeomType)
Definition: geom.hpp:77
DenseMatrix * GetPerfGeomToGeomJac(int GeomType)
Definition: geom.hpp:71
Class for integration point with weight.
Definition: intrules.hpp:25
static bool CheckPoint(int GeomType, const IntegrationPoint &ip)
Check if the given point is inside the given reference element.
Definition: geom.cpp:255
Array< int > RefGeoms
Definition: geom.hpp:191