MFEM  v3.3
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
eltrans.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_ELEMENTTRANSFORM
13 #define MFEM_ELEMENTTRANSFORM
14 
15 #include "../config/config.hpp"
16 #include "../linalg/linalg.hpp"
17 #include "intrules.hpp"
18 #include "fe.hpp"
19 
20 namespace mfem
21 {
22 
24 {
25 protected:
28  double Wght;
29  int EvalState;
31  {
36  };
37 
38  // Evaluate the Jacobian of the transformation at the IntPoint and store it
39  // in dFdx.
40  virtual const DenseMatrix &EvalJacobian() = 0;
41 
42  double EvalWeight();
43  const DenseMatrix &EvalAdjugateJ();
44  const DenseMatrix &EvalInverseJ();
45 
46 public:
48 
50 
51  void SetIntPoint(const IntegrationPoint *ip)
52  { IntPoint = ip; EvalState = 0; }
53  const IntegrationPoint &GetIntPoint() { return *IntPoint; }
54 
55  virtual void Transform(const IntegrationPoint &, Vector &) = 0;
56  virtual void Transform(const IntegrationRule &, DenseMatrix &) = 0;
57 
58  /// Transform columns of 'matrix', store result in 'result'.
59  virtual void Transform(const DenseMatrix &matrix, DenseMatrix &result) = 0;
60 
61  /** Return the Jacobian of the transformation at the IntPoint.
62  The first column contains the x derivatives of the
63  transformation, the second -- the y derivatives, etc. */
65  { return (EvalState & JACOBIAN_MASK) ? dFdx : EvalJacobian(); }
66 
67  double Weight() { return (EvalState & WEIGHT_MASK) ? Wght : EvalWeight(); }
68 
70  { return (EvalState & ADJUGATE_MASK) ? adjJ : EvalAdjugateJ(); }
71 
73  { return (EvalState & INVERSE_MASK) ? invJ : EvalInverseJ(); }
74 
75  virtual int Order() = 0;
76  virtual int OrderJ() = 0;
77  virtual int OrderW() = 0;
78  /// order of adj(J)^t.grad(fi)
79  virtual int OrderGrad(const FiniteElement *fe) = 0;
80 
81  /** Get dimension of target space (we support 2D meshes embedded in 3D; in
82  this case the function should return "3"). */
83  virtual int GetSpaceDim() = 0;
84 
85  /** Attempt to find the IntegrationPoint that is transformed into the given
86  point in physical space. If the inversion fails a non-zero value is
87  returned. This method is not 100 percent reliable for non-linear
88  transformations. */
89  virtual int TransformBack(const Vector &, IntegrationPoint &) = 0;
90 
91  virtual ~ElementTransformation() { }
92 };
93 
95 {
96 private:
97  DenseMatrix dshape;
98  Vector shape;
99 
100  const FiniteElement *FElem;
101  DenseMatrix PointMat; // dim x dof
102 
103  // Evaluate the Jacobian of the transformation at the IntPoint and store it
104  // in dFdx.
105  virtual const DenseMatrix &EvalJacobian();
106 
107 public:
108  void SetFE(const FiniteElement *FE) { FElem = FE; }
109  const FiniteElement* GetFE() const { return FElem; }
110 
111  /** @brief Read and write access to the underlying point matrix describing
112  the transformation. */
113  /** The dimensions of the matrix are space-dim x dof. The transformation is
114  defined as
115 
116  x=F(xh)=P.phi(xh),
117 
118  where xh (x hat) is the reference point, x is the corresponding physical
119  point, P is the point matrix, and phi(xh) is the column-vector of all
120  basis functions evaluated at xh. The columns of P represent the control
121  points in physical space defining the transformation. */
122  DenseMatrix &GetPointMat() { return PointMat; }
123 
124  void SetIdentityTransformation(int GeomType);
125 
126  virtual void Transform(const IntegrationPoint &, Vector &);
127  virtual void Transform(const IntegrationRule &, DenseMatrix &);
128  virtual void Transform(const DenseMatrix &matrix, DenseMatrix &result);
129 
130  virtual int Order() { return FElem->GetOrder(); }
131  virtual int OrderJ();
132  virtual int OrderW();
133  virtual int OrderGrad(const FiniteElement *fe);
134 
135  virtual int GetSpaceDim()
136  {
137  // this function should only be called after PointMat is initialized
138  return PointMat.Height();
139  }
140 
141  virtual int TransformBack(const Vector &, IntegrationPoint &);
142 
144 };
145 
147 {
148 public:
150  void Transform (const IntegrationPoint &, IntegrationPoint &);
151  void Transform (const IntegrationRule &, IntegrationRule &);
152 };
153 
155 {
156 public:
160 };
161 
162 /* Elem1(Loc1(x)) = Face(x) = Elem2(Loc2(x))
163 
164 
165  Physical Space
166 
167  *--------* ^ *--------*
168  Elem1No / / \ / \ / \ \ Elem2No
169  / / \ / \ / \ \
170  / / n \ / \ / \ \
171  *--------* ==> * ( ) * *--------*
172  \ \ / \ / \ / /
173  \ \ / \ / \ / /
174  \ \ / \ / \ / /
175  *--------* v *--------*
176 
177  ^ ^
178  | ^ |
179  Elem1 | | | Elem2
180  | | Face |
181  |
182  *--------* *--------*
183  / /| / /|
184  1 *--------* | 1 *--------* 1 *--------* |
185  | | | Loc1 | | Loc2 | | |
186  | | * <----- | x | -----> | | *
187  | |/ | | | |/
188  *--------* *--------* *--------*
189  0 1 0 1 0 1
190 
191  Reference Space
192 */
193 
194 }
195 
196 #endif
Abstract class for Finite Elements.
Definition: fe.hpp:46
virtual ~ElementTransformation()
Definition: eltrans.hpp:91
const DenseMatrix & AdjugateJacobian()
Definition: eltrans.hpp:69
ElementTransformation * Face
Definition: eltrans.hpp:158
Class for an integration rule - an Array of IntegrationPoint.
Definition: intrules.hpp:83
DenseMatrix & GetPointMat()
Read and write access to the underlying point matrix describing the transformation.
Definition: eltrans.hpp:122
const IntegrationPoint * IntPoint
Definition: eltrans.hpp:26
void SetIntPoint(const IntegrationPoint *ip)
Definition: eltrans.hpp:51
void SetIdentityTransformation(int GeomType)
Definition: eltrans.cpp:56
int GetOrder() const
Returns the order of the finite element.
Definition: fe.hpp:124
Data type dense matrix using column-major storage.
Definition: densemat.hpp:22
virtual int TransformBack(const Vector &, IntegrationPoint &)
Definition: eltrans.cpp:203
IntegrationPointTransformation Loc2
Definition: eltrans.hpp:159
const DenseMatrix & EvalAdjugateJ()
Definition: eltrans.cpp:34
const DenseMatrix & InverseJacobian()
Definition: eltrans.hpp:72
const FiniteElement * GetFE() const
Definition: eltrans.hpp:109
virtual void Transform(const IntegrationPoint &, Vector &)
Definition: eltrans.cpp:142
const IntegrationPoint & GetIntPoint()
Definition: eltrans.hpp:53
ElementTransformation * Elem2
Definition: eltrans.hpp:158
virtual int TransformBack(const Vector &, IntegrationPoint &)=0
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
Definition: operator.hpp:36
IntegrationPointTransformation Loc1
Definition: eltrans.hpp:159
virtual int OrderGrad(const FiniteElement *fe)
order of adj(J)^t.grad(fi)
Definition: eltrans.cpp:123
const DenseMatrix & Jacobian()
Definition: eltrans.hpp:64
const DenseMatrix & EvalInverseJ()
Definition: eltrans.cpp:44
void Transform(const IntegrationPoint &, IntegrationPoint &)
Definition: eltrans.cpp:256
Class for integration point with weight.
Definition: intrules.hpp:25
virtual int OrderGrad(const FiniteElement *fe)=0
order of adj(J)^t.grad(fi)
void SetFE(const FiniteElement *FE)
Definition: eltrans.hpp:108
IsoparametricTransformation Transf
Definition: eltrans.hpp:149
ElementTransformation * Elem1
Definition: eltrans.hpp:158
virtual const DenseMatrix & EvalJacobian()=0
Vector data type.
Definition: vector.hpp:36
virtual void Transform(const IntegrationPoint &, Vector &)=0
virtual int GetSpaceDim()=0