Skip to content

Commit 7acfb1f

Browse files
author
Kloepfer
committed
changed templating to be topology and changed template paramater name
1 parent ed8c4e2 commit 7acfb1f

File tree

2 files changed

+22
-30
lines changed

2 files changed

+22
-30
lines changed

src/MeshField.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ struct LinearTriangleToVertexField {
7171
}
7272
}
7373

74-
KOKKOS_FUNCTION Kokkos::Array<MeshField::Mesh_Topology, 1>
75-
getTopology() const {
74+
static constexpr KOKKOS_FUNCTION Kokkos::Array<MeshField::Mesh_Topology, 1>
75+
getTopology() {
7676
return {MeshField::Triangle};
7777
}
7878

@@ -102,8 +102,8 @@ struct LinearTetrahedronToVertexField {
102102
__func__);
103103
}
104104
}
105-
KOKKOS_FUNCTION Kokkos::Array<MeshField::Mesh_Topology, 1>
106-
getTopology() const {
105+
static constexpr KOKKOS_FUNCTION Kokkos::Array<MeshField::Mesh_Topology, 1>
106+
getTopology() {
107107
return {MeshField::Tetrahedron};
108108
}
109109

@@ -136,8 +136,8 @@ struct QuadraticTriangleToField {
136136
}
137137
}
138138

139-
KOKKOS_FUNCTION Kokkos::Array<MeshField::Mesh_Topology, 1>
140-
getTopology() const {
139+
static constexpr KOKKOS_FUNCTION Kokkos::Array<MeshField::Mesh_Topology, 1>
140+
getTopology() {
141141
return {MeshField::Triangle};
142142
}
143143

@@ -198,8 +198,8 @@ struct QuadraticTetrahedronToField {
198198
}
199199
}
200200

201-
KOKKOS_FUNCTION Kokkos::Array<MeshField::Mesh_Topology, 1>
202-
getTopology() const {
201+
static constexpr KOKKOS_FUNCTION Kokkos::Array<MeshField::Mesh_Topology, 1>
202+
getTopology() {
203203
return {MeshField::Tetrahedron};
204204
}
205205

src/MeshField_Integrate.hpp

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010

1111
namespace MeshField {
1212
// directly copied from SCOREC/core @ 7cd76473 apf/apfIntegrate.[h|cc]
13-
template <size_t dim> struct IntegrationPoint {
14-
IntegrationPoint(Kokkos::Array<Real, dim> const &p, double w)
13+
template <size_t pointSize> struct IntegrationPoint {
14+
// template parameter pointSize specifies the length of the integration point
15+
// array for one point
16+
IntegrationPoint(Kokkos::Array<Real, pointSize> const &p, double w)
1517
: param(p), weight(w) {}
16-
Kokkos::Array<Real, dim> param;
18+
Kokkos::Array<Real, pointSize> param;
1719
double weight;
1820
};
1921
template <size_t dim> class Integration {
@@ -112,25 +114,16 @@ class TetrahedronIntegration : public EntityIntegration<4> {
112114
return integrations[i];
113115
}
114116
};
115-
template <size_t dim>
116-
std::shared_ptr<EntityIntegration<dim>> const
117-
getIntegration(Mesh_Topology topo) {
118-
if constexpr (dim == 3) {
119-
if (topo == Triangle) {
120-
return std::make_shared<TriangleIntegration>();
121-
}
122-
} else if constexpr (dim == 4) {
123-
if (topo == Tetrahedron) {
124-
return std::make_shared<TetrahedronIntegration>();
125-
}
117+
template <Mesh_Topology topo> auto const getIntegration() {
118+
if constexpr (topo == Triangle) {
119+
return std::make_shared<TriangleIntegration>();
120+
} else if constexpr (topo == Tetrahedron) {
121+
return std::make_shared<TetrahedronIntegration>();
126122
}
127123
fail("getIntegration does not support given topology\n");
128-
return nullptr;
129124
}
130-
template <size_t dim>
131-
std::vector<IntegrationPoint<dim>> getIntegrationPoints(Mesh_Topology topo,
132-
int order) {
133-
auto ip = getIntegration<dim>(topo)->getAccurate(order)->getPoints();
125+
template <Mesh_Topology topo> auto getIntegrationPoints(int order) {
126+
auto ip = getIntegration<topo>()->getAccurate(order)->getPoints();
134127
return ip;
135128
}
136129

@@ -240,10 +233,9 @@ class Integrator {
240233
* FIXME make the sensible
241234
* */
242235
template <typename FieldElement> void process(FieldElement &fes) {
243-
const auto topo = fes.elm2dof.getTopology();
236+
constexpr auto topo = decltype(FieldElement::elm2dof)::getTopology();
244237
pre();
245-
auto ip =
246-
getIntegrationPoints<FieldElement::MeshEntDim + 1>(topo[0], order);
238+
auto ip = getIntegrationPoints<topo[0]>(order);
247239
auto localCoords = getIntegrationPointLocalCoords(fes, ip);
248240
auto weights = getIntegrationPointWeights(fes, ip);
249241
auto dV = getJacobianDeterminants(fes, localCoords, ip.size());

0 commit comments

Comments
 (0)