OGS 6.2.0-97-g4a610c866
MapBulkElementPoint.cpp
Go to the documentation of this file.
1 
10 #include <array>
11 
12 #include "MapBulkElementPoint.h"
13 
14 namespace MeshLib
15 {
17  std::size_t const face_id,
18  MathLib::WeightedPoint1D const& wp)
19 {
20  switch (face_id) {
21  case 0:
22  return MathLib::Point3d{std::array<double, 3>{{wp[0], 0.0, 0.0}}};
23  case 1:
24  return MathLib::Point3d{std::array<double, 3>{{1.0, wp[0], 0.0}}};
25  case 2:
26  return MathLib::Point3d{std::array<double, 3>{{1.0 - wp[0], 1.0, 0.0}}};
27  case 3:
28  return MathLib::Point3d{std::array<double, 3>{{0.0, 1.0 - wp[0], 0.0}}};
29  default:
30  OGS_FATAL("Invalid face id '%u' for the quad.", face_id);
31  }
32 }
33 
35  std::size_t const face_id,
36  MathLib::WeightedPoint2D const& wp)
37 {
38  switch (face_id)
39  {
40  case 0:
41  return MathLib::Point3d{
42  std::array<double, 3>{{wp[1], wp[0], -1.0}}};
43  case 1:
44  return MathLib::Point3d{
45  std::array<double, 3>{{wp[0], -1.0, wp[1]}}};
46  case 2:
47  return MathLib::Point3d{std::array<double, 3>{{1.0, wp[0], wp[1]}}};
48  case 3:
49  return MathLib::Point3d{
50  std::array<double, 3>{{-wp[0], -1.0, wp[1]}}};
51  case 4:
52  return MathLib::Point3d{
53  std::array<double, 3>{{-1.0, -wp[0], -wp[1]}}};
54  case 5:
55  return MathLib::Point3d{std::array<double, 3>{{wp[0], wp[1], 1.0}}};
56  default:
57  OGS_FATAL("Invalid face id '%u' for the hexahedron.", face_id);
58  }
59 }
60 
62  std::size_t const face_id,
63  MathLib::WeightedPoint2D const& wp)
64 {
65  switch (face_id)
66  {
67  case 0:
68  return MathLib::Point3d{
69  std::array<double, 3>{{wp[1], wp[0], -1.0}}};
70  case 1:
71  return MathLib::Point3d{
72  std::array<double, 3>{{wp[0]/2.0 + 0.5, 0.0, wp[1]}}};
73  case 2:
74  return MathLib::Point3d{
75  std::array<double, 3>{{0.5 - wp[0]/2.0, 0.5 + wp[0]/2.0, wp[1]}}};
76  case 3:
77  return MathLib::Point3d{
78  std::array<double, 3>{{0, -wp[0]/2.0 + 0.5, wp[1]}}};
79  case 4:
80  return MathLib::Point3d{
81  std::array<double, 3>{{wp[0], wp[1], 1.0}}};
82  default:
83  OGS_FATAL("Invalid face id '%u' for the prism.", face_id);
84  }
85 }
86 
88  std::size_t const bulk_element_id,
89  std::size_t const bulk_face_id,
90  MathLib::WeightedPoint1D const& wp)
91 {
92  auto const* element = mesh.getElement(bulk_element_id);
93  if (element->getCellType() == MeshLib::CellType::QUAD4)
94  {
95  MeshLib::Quad const& quad(*dynamic_cast<MeshLib::Quad const*>(element));
96  return getBulkElementPoint(quad, bulk_face_id, wp);
97  }
98  OGS_FATAL("Wrong cell type '%s' or functionality not yet implemented.",
99  MeshLib::CellType2String(element->getCellType()).c_str());
100 }
101 
103  std::size_t bulk_element_id,
104  std::size_t bulk_face_id,
105  MathLib::WeightedPoint2D const& wp)
106 {
107  auto const* element = mesh.getElement(bulk_element_id);
108  if (element->getCellType() == MeshLib::CellType::HEX8)
109  {
110  MeshLib::Hex const& hex(*dynamic_cast<MeshLib::Hex const*>(element));
111  return getBulkElementPoint(hex, bulk_face_id, wp);
112  }
113  if (element->getCellType() == MeshLib::CellType::PRISM6)
114  {
115  MeshLib::Prism const& prism(
116  *dynamic_cast<MeshLib::Prism const*>(element));
117  return getBulkElementPoint(prism, bulk_face_id, wp);
118  }
119  OGS_FATAL("Wrong cell type '%s' or functionality not yet implemented.",
120  MeshLib::CellType2String(element->getCellType()).c_str());
121 }
122 
123 // TODO disable the 3d elements in the local assembler creator
125  std::size_t /*bulk_element_id*/,
126  std::size_t /*bulk_face_id*/,
127  MathLib::WeightedPoint3D const& /*wp*/)
128 {
129  return MathLib::ORIGIN;
130 }
131 } // namespace MeshLib
MathLib::Point3d getBulkElementPoint(MeshLib::Quad const &, std::size_t const face_id, MathLib::WeightedPoint1D const &wp)
const std::string CellType2String(const CellType t)
Given a MeshElemType this returns the appropriate string.
Definition: MeshEnums.cpp:154
const Element * getElement(std::size_t idx) const
Get the element with the given index.
Definition: Mesh.h:87
const Point3d ORIGIN
Definition: Point3d.h:27
Interface for heuristic search length strategy.
Definition: ProjectData.h:29
#define OGS_FATAL(fmt,...)
Definition: Error.h:63