|
10 | 10 |
|
11 | 11 | namespace MeshField { |
12 | 12 | // 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) |
15 | 17 | : param(p), weight(w) {} |
16 | | - Kokkos::Array<Real, dim> param; |
| 18 | + Kokkos::Array<Real, pointSize> param; |
17 | 19 | double weight; |
18 | 20 | }; |
19 | 21 | template <size_t dim> class Integration { |
@@ -112,25 +114,16 @@ class TetrahedronIntegration : public EntityIntegration<4> { |
112 | 114 | return integrations[i]; |
113 | 115 | } |
114 | 116 | }; |
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>(); |
126 | 122 | } |
127 | 123 | fail("getIntegration does not support given topology\n"); |
128 | | - return nullptr; |
129 | 124 | } |
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(); |
134 | 127 | return ip; |
135 | 128 | } |
136 | 129 |
|
@@ -240,10 +233,9 @@ class Integrator { |
240 | 233 | * FIXME make the sensible |
241 | 234 | * */ |
242 | 235 | template <typename FieldElement> void process(FieldElement &fes) { |
243 | | - const auto topo = fes.elm2dof.getTopology(); |
| 236 | + constexpr auto topo = decltype(FieldElement::elm2dof)::getTopology(); |
244 | 237 | pre(); |
245 | | - auto ip = |
246 | | - getIntegrationPoints<FieldElement::MeshEntDim + 1>(topo[0], order); |
| 238 | + auto ip = getIntegrationPoints<topo[0]>(order); |
247 | 239 | auto localCoords = getIntegrationPointLocalCoords(fes, ip); |
248 | 240 | auto weights = getIntegrationPointWeights(fes, ip); |
249 | 241 | auto dV = getJacobianDeterminants(fes, localCoords, ip.size()); |
|
0 commit comments