OGS
MapBulkElementPoint.cpp
Go to the documentation of this file.
1 
11 #include "MapBulkElementPoint.h"
12 
13 #include <array>
14 
15 namespace MeshLib
16 {
18  std::size_t const face_id,
19  MathLib::WeightedPoint1D const& wp)
20 {
21  switch (face_id)
22  {
23  case 0:
24  return MathLib::Point3d{std::array<double, 3>{{wp[0], 0.0, 0.0}}};
25  case 1:
26  return MathLib::Point3d{
27  std::array<double, 3>{{1 - wp[0], wp[0], 0.0}}};
28  case 2:
29  return MathLib::Point3d{
30  std::array<double, 3>{{0.0, 1 - wp[0], 0.0}}};
31  default:
32  OGS_FATAL("Invalid face id '{:d}' for the tri.", face_id);
33  }
34 }
35 
37  std::size_t const face_id,
38  MathLib::WeightedPoint1D const& wp)
39 {
40  switch (face_id)
41  {
42  case 0:
43  return MathLib::Point3d{std::array<double, 3>{{wp[0], 0.0, 0.0}}};
44  case 1:
45  return MathLib::Point3d{std::array<double, 3>{{1.0, wp[0], 0.0}}};
46  case 2:
47  return MathLib::Point3d{
48  std::array<double, 3>{{1.0 - wp[0], 1.0, 0.0}}};
49  case 3:
50  return MathLib::Point3d{
51  std::array<double, 3>{{0.0, 1.0 - wp[0], 0.0}}};
52  default:
53  OGS_FATAL("Invalid face id '{:d}' for the quad.", face_id);
54  }
55 }
56 
58  std::size_t const face_id,
59  MathLib::WeightedPoint2D const& wp)
60 {
61  switch (face_id)
62  {
63  case 0:
64  return MathLib::Point3d{
65  std::array<double, 3>{{wp[1], wp[0], -1.0}}};
66  case 1:
67  return MathLib::Point3d{
68  std::array<double, 3>{{wp[0], -1.0, wp[1]}}};
69  case 2:
70  return MathLib::Point3d{std::array<double, 3>{{1.0, wp[0], wp[1]}}};
71  case 3:
72  return MathLib::Point3d{
73  std::array<double, 3>{{-wp[0], -1.0, wp[1]}}};
74  case 4:
75  return MathLib::Point3d{
76  std::array<double, 3>{{-1.0, -wp[0], -wp[1]}}};
77  case 5:
78  return MathLib::Point3d{std::array<double, 3>{{wp[0], wp[1], 1.0}}};
79  default:
80  OGS_FATAL("Invalid face id '{:d}' for the hexahedron.", face_id);
81  }
82 }
83 
85  std::size_t const face_id,
86  MathLib::WeightedPoint2D const& wp)
87 {
88  switch (face_id)
89  {
90  case 0:
91  return MathLib::Point3d{
92  std::array<double, 3>{{wp[1], wp[0], -1.0}}};
93  case 1:
94  return MathLib::Point3d{
95  std::array<double, 3>{{wp[0] / 2.0 + 0.5, 0.0, wp[1]}}};
96  case 2:
97  return MathLib::Point3d{std::array<double, 3>{
98  {0.5 - wp[0] / 2.0, 0.5 + wp[0] / 2.0, wp[1]}}};
99  case 3:
100  return MathLib::Point3d{
101  std::array<double, 3>{{0, -wp[0] / 2.0 + 0.5, wp[1]}}};
102  case 4:
103  return MathLib::Point3d{std::array<double, 3>{{wp[0], wp[1], 1.0}}};
104  default:
105  OGS_FATAL("Invalid face id '{:d}' for the prism.", face_id);
106  }
107 }
108 
109 MathLib::Point3d getBulkElementPoint(Pyramid const& /*pyramid*/,
110  std::size_t const face_id,
111  MathLib::WeightedPoint2D const& wp)
112 {
113  switch (face_id)
114  {
115  case 0:
116  return MathLib::Point3d{
117  std::array<double, 3>{{2 * wp[0] - 1, -1.0, 2 * wp[1] - 1}}};
118  case 1:
119  return MathLib::Point3d{
120  std::array<double, 3>{{1.0, 2 * wp[0] - 1, 2 * wp[1] - 1}}};
121  case 2:
122  return MathLib::Point3d{
123  std::array<double, 3>{{1 - 2 * wp[0], 1.0, 2 * wp[1] - 1}}};
124  case 3:
125  return MathLib::Point3d{
126  std::array<double, 3>{{-1.0, 2 * wp[1] - 1, 2 * wp[0] - 1}}};
127  case 4:
128  return MathLib::Point3d{
129  std::array<double, 3>{{-wp[0], wp[1], -1.0}}};
130  default:
131  OGS_FATAL("Invalid face id '{:d}' for the pyramid.", face_id);
132  }
133 }
134 
136  std::size_t const face_id,
137  MathLib::WeightedPoint2D const& wp)
138 {
139  switch (face_id)
140  {
141  case 0:
142  return MathLib::Point3d{std::array<double, 3>{{wp[1], wp[0], 0.0}}};
143  case 1:
144  return MathLib::Point3d{std::array<double, 3>{{wp[0], 0.0, wp[1]}}};
145  case 2:
146  return MathLib::Point3d{
147  std::array<double, 3>{{1 - wp[0] - wp[1], wp[0], wp[1]}}};
148  case 3:
149  return MathLib::Point3d{std::array<double, 3>{{0, wp[1], wp[0]}}};
150  default:
151  OGS_FATAL("Invalid face id '{:d}' for the tetrahedron.", face_id);
152  }
153 }
154 
156  std::size_t const bulk_element_id,
157  std::size_t const bulk_face_id,
158  MathLib::WeightedPoint1D const& wp)
159 {
160  auto const* element = mesh.getElement(bulk_element_id);
161  if (element->getCellType() == CellType::QUAD4)
162  {
163  Quad const& quad(*dynamic_cast<Quad const*>(element));
164  return getBulkElementPoint(quad, bulk_face_id, wp);
165  }
166  if (element->getCellType() == CellType::TRI3)
167  {
168  Tri const& tri = *static_cast<Tri const*>(element);
169  return getBulkElementPoint(tri, bulk_face_id, wp);
170  }
171  OGS_FATAL("Wrong cell type '{:s}' or functionality not yet implemented.",
172  CellType2String(element->getCellType()));
173 }
174 
176  std::size_t bulk_element_id,
177  std::size_t bulk_face_id,
178  MathLib::WeightedPoint2D const& wp)
179 {
180  auto const* element = mesh.getElement(bulk_element_id);
181  if (element->getCellType() == CellType::HEX8)
182  {
183  Hex const& hex = *static_cast<Hex const*>(element);
184  return getBulkElementPoint(hex, bulk_face_id, wp);
185  }
186  if (element->getCellType() == CellType::PRISM6)
187  {
188  Prism const& prism = *static_cast<Prism const*>(element);
189  return getBulkElementPoint(prism, bulk_face_id, wp);
190  }
191  if (element->getCellType() == CellType::PYRAMID5)
192  {
193  Pyramid const& pyramid = *static_cast<Pyramid const*>(element);
194  return getBulkElementPoint(pyramid, bulk_face_id, wp);
195  }
196  if (element->getCellType() == CellType::TET4)
197  {
198  Tet const& tet = *static_cast<Tet const*>(element);
199  return getBulkElementPoint(tet, bulk_face_id, wp);
200  }
201  OGS_FATAL("Wrong cell type '{:s}' or functionality not yet implemented.",
202  CellType2String(element->getCellType()));
203 }
204 
205 // TODO disable the 3d elements in the local assembler creator
207  std::size_t /*bulk_element_id*/,
208  std::size_t /*bulk_face_id*/,
209  MathLib::WeightedPoint3D const& /*wp*/)
210 {
211  return MathLib::ORIGIN;
212 }
213 } // namespace MeshLib
#define OGS_FATAL(...)
Definition: Error.h:26
const Element * getElement(std::size_t idx) const
Get the element with the given index.
Definition: Mesh.h:77
const Point3d ORIGIN
Definition: Point3d.h:26
MathLib::Point3d getBulkElementPoint(Tri const &, std::size_t const face_id, MathLib::WeightedPoint1D const &wp)
TemplateElement< MeshLib::TetRule4 > Tet
Definition: Tet.h:25
std::string CellType2String(const CellType t)
Given a MeshElemType this returns the appropriate string.
Definition: MeshEnums.cpp:157
TemplateElement< MeshLib::PrismRule6 > Prism
Definition: Prism.h:25
TemplateElement< MeshLib::PyramidRule5 > Pyramid
Definition: Pyramid.h:25
TemplateElement< MeshLib::QuadRule4 > Quad
Definition: Quad.h:28