OGS
ComputeElementVolumeNumerically.cpp
Go to the documentation of this file.
1
13
14#include <typeinfo>
15
24#include "MeshLib/MeshEnums.h"
43
44namespace MeshToolsLib
45{
46template <typename ShapeFunction>
48{
49 // Space dimension is set to 3 in case that 1D or 2D element is inclined.
50 constexpr int space_dim = 3;
52
53 // Integration order is set to 3:
54 auto const& integration_method =
55 NumLib::IntegrationMethodRegistry::template getIntegrationMethod<
56 typename ShapeFunction::MeshElement>(NumLib::IntegrationOrder{3});
57
58 auto const shape_function_data =
59 NumLib::initShapeMatrices<ShapeFunction, ShapeMatricesType, space_dim>(
60 e, false /*is_axially_symmetric*/, integration_method);
61
62 auto const n_integration_points = integration_method.getNumberOfPoints();
63 double volume = 0.0;
64 for (unsigned ip = 0; ip < n_integration_points; ++ip)
65 {
66 auto const weight = integration_method.getWeightedPoint(ip).getWeight();
67 volume += shape_function_data[ip].detJ * weight;
68 }
69
70 return volume;
71}
72
74{
75 switch (e.getCellType())
76 {
78 return computeElementVolumeNumerically<NumLib::ShapeLine2>(e);
80 return computeElementVolumeNumerically<NumLib::ShapeLine3>(e);
82 return computeElementVolumeNumerically<NumLib::ShapeTri3>(e);
84 return computeElementVolumeNumerically<NumLib::ShapeTri6>(e);
86 return computeElementVolumeNumerically<NumLib::ShapeQuad4>(e);
88 return computeElementVolumeNumerically<NumLib::ShapeQuad8>(e);
90 return computeElementVolumeNumerically<NumLib::ShapeQuad9>(e);
92 return computeElementVolumeNumerically<NumLib::ShapeTet4>(e);
94 return computeElementVolumeNumerically<NumLib::ShapeHex8>(e);
96 return computeElementVolumeNumerically<NumLib::ShapeHex20>(e);
98 return computeElementVolumeNumerically<NumLib::ShapeTet10>(e);
100 return computeElementVolumeNumerically<NumLib::ShapePrism6>(e);
102 return computeElementVolumeNumerically<NumLib::ShapePrism15>(e);
104 return computeElementVolumeNumerically<NumLib::ShapePyra5>(e);
106 return computeElementVolumeNumerically<NumLib::ShapePyra13>(e);
107 default:
108 OGS_FATAL(
109 "Numerical volume calculation is not available for element "
110 "with type {}. ",
112 }
113}
114
115} // namespace MeshToolsLib
Definition of the Element class.
#define OGS_FATAL(...)
Definition Error.h:26
Definition of the Hex class.
Definition of the Line class.
Definition of mesh-related Enumerations.
Definition of the Prism class.
Definition of the Pyramid class.
Definition of the Quad class.
Definition of the Tet class.
Definition of the Tri class.
virtual CellType getCellType() const =0
std::string CellType2String(const CellType t)
Given a MeshElemType this returns the appropriate string.
double computeElementVolumeNumerically(MeshLib::Element const &e)