Skip to content

Commit 3203542

Browse files
committed
integrate: add inter-process reduction hook
1 parent 3822b9f commit 3203542

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/MeshField_Integrate.hpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,12 @@ auto getJacobianDeterminants(FieldElement &fes,
196196
* - `post`: Called after the integration process ends.
197197
* - `atPoints`: Called for each integration point to perform user-defined
198198
* computations.
199+
* - `parallelReduce`: Called after `atPoints` to reduce process-local
200+
* integrations into a global mesh integration.
199201
*
200202
* To use this class, derive from it and implement the `atPoints` method.
201-
* Optionally, override `pre` and `post` for additional setup or cleanup.
203+
* Optionally, override `parallelReduce`, `pre` and `post` for distributed
204+
* memory support, additional setup, or cleanup.
202205
*/
203206
class Integrator {
204207
public:
@@ -227,9 +230,18 @@ class Integrator {
227230
*/
228231
virtual void atPoints(Kokkos::View<Real **> p, Kokkos::View<Real *> w,
229232
Kokkos::View<Real *> dV) = 0;
233+
234+
/** \brief User callback: distributed memory accumulation.
235+
*
236+
* \details If needed, this function supports the use of
237+
* inter-process communication (e.g., MPI) to reduce
238+
* process-local integrations into a global
239+
* mesh integration.
240+
*/
241+
virtual void parallelReduce(){};
242+
230243
/** \brief Run the Integrator over the local field elements.
231-
* \param fes FieldElement
232-
* FIXME make the sensible
244+
* \param fes FieldElement
233245
* */
234246
template <typename FieldElement> void process(FieldElement &fes) {
235247
constexpr auto topo = decltype(FieldElement::elm2dof)::getTopology();
@@ -239,9 +251,8 @@ class Integrator {
239251
auto weights = getIntegrationPointWeights(fes, ip);
240252
auto dV = getJacobianDeterminants(fes, localCoords, ip.size());
241253
atPoints(localCoords, weights, dV);
254+
parallelReduce();
242255
post();
243-
// TODO support distributed meshes by running a parallel reduction with user
244-
// functor
245256
}
246257

247258
protected:

0 commit comments

Comments
 (0)