OGS
IntegrationPointDataTools.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
7#include "MeshLib/MeshEnums.h"
12
13namespace MeshToolsLib
14{
15template <typename ElementType>
18{
19 using IntegrationPolicy =
21 using NonGenericIntegrationMethod =
23 NonGenericIntegrationMethod int_met{
24 (unsigned int)ip_meta_data.integration_order};
25 return int_met.getNumberOfPoints();
26}
27
30 MeshLib::Element const& e)
31{
32 switch (e.getCellType())
33 {
36 ip_meta_data);
39 ip_meta_data);
42 ip_meta_data);
45 ip_meta_data);
48 ip_meta_data);
51 ip_meta_data);
54 ip_meta_data);
57 ip_meta_data);
60 ip_meta_data);
63 ip_meta_data);
66 ip_meta_data);
69 ip_meta_data);
72 ip_meta_data);
75 ip_meta_data);
78 MeshLib::Pyramid13>(ip_meta_data);
81 OGS_FATAL("Mesh element type {:s} is not supported",
84 default:
85 OGS_FATAL("Invalid Element Type");
86 }
87 return 0;
88}
89
91 std::vector<MeshLib::Element*> const& mesh_elements,
93 MeshLib::Properties const& properties)
94{
95 // For special field data such as OGS_VERSION, IntegrationPointMetaData,
96 // etc., which are not "real" integration points:
97 if (pv.getPropertyName().find("_ip") == std::string::npos)
98 {
99 return {};
100 }
101
102 auto const n_components = pv.getNumberOfGlobalComponents();
103
104 std::vector<std::size_t> element_ip_data_offsets(mesh_elements.size() + 1);
105 std::size_t counter = 0;
106 auto const ip_meta_data = MeshLib::getIntegrationPointMetaDataSingleField(
108 for (std::size_t i = 0; i < mesh_elements.size(); i++)
109 {
110 auto const* const element = mesh_elements[i];
111
112 // Assuming that the order of elements in mesh_elements is not touched.
113 element_ip_data_offsets[i] = counter;
114 counter += getNumberOfElementIntegrationPoints(ip_meta_data, *element) *
115 n_components;
116 }
117 element_ip_data_offsets[mesh_elements.size()] = counter;
118
119 return element_ip_data_offsets;
120}
121
122} // namespace MeshToolsLib
#define OGS_FATAL(...)
Definition Error.h:19
NumLib::GaussLegendreIntegrationPolicy< MeshElement > IntegrationPolicy
virtual CellType getCellType() const =0
Property manager on mesh items. Class Properties manages scalar, vector or matrix properties....
int getNumberOfGlobalComponents() const
std::string const & getPropertyName() const
std::optional< IntegrationPointMetaData > getIntegrationPointMetaData(MeshLib::Properties const &properties)
TemplateElement< MeshLib::PyramidRule13 > Pyramid13
Definition Pyramid.h:15
std::string CellType2String(const CellType t)
Given a MeshElemType this returns the appropriate string.
IntegrationPointMetaDataSingleField getIntegrationPointMetaDataSingleField(std::optional< IntegrationPointMetaData > const &ip_meta_data, std::string const &field_name)
std::vector< std::size_t > getIntegrationPointDataOffsetsOfMeshElements(std::vector< MeshLib::Element * > const &mesh_elements, MeshLib::PropertyVectorBase const &pv, MeshLib::Properties const &properties)
int getNumberOfElementIntegrationPoints(MeshLib::IntegrationPointMetaDataSingleField const &ip_meta_data, MeshLib::Element const &e)
int getNumberOfElementIntegrationPointsGeneral(MeshLib::IntegrationPointMetaDataSingleField const &ip_meta_data)
NumLib::IntegrationGaussLegendreRegular< MeshElement::dimension > IntegrationMethod