MFEM  v3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
eltrans.cpp
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.googlecode.com.
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 
13 #include <cmath>
14 #include "fem.hpp"
15 
16 namespace mfem
17 {
18 
20  JacobianIsEvaluated(0),
21  WeightIsEvaluated(0),
22  IntPoint(static_cast<IntegrationPoint *>(NULL)),
23  Attribute(-1),
24  ElementNo(-1)
25 {
26 
27 }
28 
30 {
31  switch (GeomType)
32  {
33  case Geometry::POINT : FElem = &PointFE; break;
34  case Geometry::SEGMENT : FElem = &SegmentFE; break;
35  case Geometry::TRIANGLE : FElem = &TriangleFE; break;
36  case Geometry::SQUARE : FElem = &QuadrilateralFE; break;
37  case Geometry::TETRAHEDRON : FElem = &TetrahedronFE; break;
38  case Geometry::CUBE : FElem = &HexahedronFE; break;
39  default:
40  MFEM_ABORT("unknown Geometry::Type!");
41  }
42  int dim = FElem->GetDim();
43  int dof = FElem->GetDof();
44  const IntegrationRule &nodes = FElem->GetNodes();
45  PointMat.SetSize(dim, dof);
46  for (int j = 0; j < dof; j++)
47  nodes.IntPoint(j).Get(&PointMat(0,j), dim);
48 }
49 
51 {
52  if (JacobianIsEvaluated) return dFdx;
53 
54  dshape.SetSize(FElem->GetDof(), FElem->GetDim());
55  dFdx.SetSize(PointMat.Height(), dshape.Width());
56 
57  FElem -> CalcDShape(*IntPoint, dshape);
58  Mult(PointMat, dshape, dFdx);
59 
61 
62  return dFdx;
63 }
64 
66 {
67  if (FElem->GetDim() == 0)
68  return 1.0;
70  return Wght;
71  Jacobian();
73  return (Wght = dFdx.Weight());
74 }
75 
77 {
78  switch (FElem->Space())
79  {
80  case FunctionSpace::Pk:
81  return (FElem->GetOrder()-1);
82  case FunctionSpace::Qk:
83  return (FElem->GetOrder());
84  default:
85  mfem_error("IsoparametricTransformation::OrderJ()");
86  }
87  return 0;
88 }
89 
91 {
92  switch (FElem->Space())
93  {
94  case FunctionSpace::Pk:
95  return (FElem->GetOrder() - 1) * FElem->GetDim();
96  case FunctionSpace::Qk:
97  return (FElem->GetOrder() * FElem->GetDim() - 1);
98  default:
99  mfem_error("IsoparametricTransformation::OrderW()");
100  }
101  return 0;
102 }
103 
105 {
106  if (FElem->Space() == fe->Space())
107  {
108  int k = FElem->GetOrder();
109  int d = FElem->GetDim();
110  int l = fe->GetOrder();
111  switch (fe->Space())
112  {
113  case FunctionSpace::Pk:
114  return ((k-1)*(d-1)+(l-1));
115  case FunctionSpace::Qk:
116  return (k*(d-1)+(l-1));
117  }
118  }
119  mfem_error("IsoparametricTransformation::OrderGrad(...)");
120  return 0;
121 }
122 
124  Vector &trans)
125 {
126  shape.SetSize(FElem->GetDof());
127  trans.SetSize(PointMat.Height());
128 
129  FElem -> CalcShape(ip, shape);
130  PointMat.Mult(shape, trans);
131 }
132 
134  DenseMatrix &tr)
135 {
136  int dof, n, dim, i, j, k;
137 
138  dim = PointMat.Height();
139  dof = FElem->GetDof();
140  n = ir.GetNPoints();
141 
142  shape.SetSize(dof);
143  tr.SetSize(dim, n);
144 
145  for (j = 0; j < n; j++)
146  {
147  FElem -> CalcShape (ir.IntPoint(j), shape);
148  for (i = 0; i < dim; i++)
149  {
150  tr(i, j) = 0.0;
151  for (k = 0; k < dof; k++)
152  tr(i, j) += PointMat(i, k) * shape(k);
153  }
154  }
155 }
156 
158  IntegrationPoint &ip2)
159 {
160  double vec[3];
161  Vector v (vec, Transf.GetPointMat().Height());
162 
163  Transf.Transform (ip1, v);
164  ip2.x = vec[0];
165  ip2.y = vec[1];
166  ip2.z = vec[2];
167 }
168 
170  IntegrationRule &ir2)
171 {
172  int i, n;
173 
174  n = ir1.GetNPoints();
175  for (i = 0; i < n; i++)
176  Transform (ir1.IntPoint(i), ir2.IntPoint(i));
177 }
178 
179 }
int GetNPoints() const
Returns the number of the points in the integration rule.
Definition: intrules.hpp:202
Abstract class for Finite Elements.
Definition: fe.hpp:42
void Get(double *p, const int dim) const
Definition: intrules.hpp:35
int GetDim() const
Returns the space dimension for the finite element.
Definition: fe.hpp:80
Class for integration rule.
Definition: intrules.hpp:63
const IntegrationPoint * IntPoint
Definition: eltrans.hpp:28
void SetSize(int s)
Resizes the vector if the new size is different.
Definition: vector.hpp:248
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
Definition: table.cpp:351
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols.
Definition: operator.hpp:41
void SetIdentityTransformation(int GeomType)
Definition: eltrans.cpp:29
int GetOrder() const
Returns the order of the finite element.
Definition: fe.hpp:89
Data type dense matrix.
Definition: densemat.hpp:22
int Space() const
Returns the type of space on each element.
Definition: fe.hpp:92
virtual void Transform(const IntegrationPoint &, Vector &)
Definition: eltrans.cpp:123
friend void Mult(const DenseMatrix &b, const DenseMatrix &c, DenseMatrix &a)
Matrix matrix multiplication. A = B * C.
Definition: densemat.cpp:2445
double Weight() const
Definition: densemat.cpp:348
PointFiniteElement PointFE
Definition: point.cpp:28
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
Definition: intrules.hpp:205
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows.
Definition: operator.hpp:35
virtual int OrderGrad(const FiniteElement *fe)
order of adj(J)^t.grad(fi)
Definition: eltrans.cpp:104
TriLinear3DFiniteElement HexahedronFE
Definition: hexahedron.cpp:60
const IntegrationRule & GetNodes() const
Definition: fe.hpp:110
virtual const DenseMatrix & Jacobian()
Definition: eltrans.cpp:50
int GetDof() const
Returns the degrees of freedom in the FE space.
Definition: fe.hpp:86
void mfem_error(const char *msg)
Definition: error.cpp:23
void Transform(const IntegrationPoint &, IntegrationPoint &)
Definition: eltrans.cpp:157
Linear3DFiniteElement TetrahedronFE
Linear2DFiniteElement TriangleFE
Definition: triangle.cpp:127
Class for integration point with weight.
Definition: intrules.hpp:25
IsoparametricTransformation Transf
Definition: eltrans.hpp:92
Vector data type.
Definition: vector.hpp:29
void SetSize(int s)
If the matrix is not a square matrix of size s then recreate it.
Definition: densemat.cpp:73
BiLinear2DFiniteElement QuadrilateralFE
Linear1DFiniteElement SegmentFE
Definition: segment.cpp:41