OGS
ComputeElementVolumeNumerically.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
5
6#include <typeinfo>
7
16#include "MeshLib/MeshEnums.h"
35
36namespace MeshToolsLib
37{
38template <typename ShapeFunction>
40{
41 // Space dimension is set to 3 in case that 1D or 2D element is inclined.
42 constexpr int space_dim = 3;
44
45 // Integration order is set to 3:
46 auto const& integration_method =
47 NumLib::IntegrationMethodRegistry::template getIntegrationMethod<
48 typename ShapeFunction::MeshElement>(NumLib::IntegrationOrder{3});
49
50 auto const shape_function_data =
52 e, false /*is_axially_symmetric*/, integration_method);
53
54 auto const n_integration_points = integration_method.getNumberOfPoints();
55 double volume = 0.0;
56 for (unsigned ip = 0; ip < n_integration_points; ++ip)
57 {
58 auto const weight = integration_method.getWeightedPoint(ip).getWeight();
59 volume += shape_function_data[ip].detJ * weight;
60 }
61
62 return volume;
63}
64
66{
67 switch (e.getCellType())
68 {
99 default:
100 OGS_FATAL(
101 "Numerical volume calculation is not available for element "
102 "with type {}. ",
104 }
105}
106
107} // namespace MeshToolsLib
#define OGS_FATAL(...)
Definition Error.h:19
EigenFixedShapeMatrixPolicy< ShapeFunction, GlobalDim > ShapeMatrixPolicyType
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)
std::vector< typename ShapeMatricesType::ShapeMatrices, Eigen::aligned_allocator< typename ShapeMatricesType::ShapeMatrices > > initShapeMatrices(MeshLib::Element const &e, bool const is_axially_symmetric, IntegrationMethod const &integration_method)