Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/festim/exports/maximum_surface.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from mpi4py import MPI

import numpy as np

import festim.exports.surface_quantity as sq
Expand Down Expand Up @@ -28,5 +30,8 @@ def compute(self):
indices = self.surface.locate_boundary_facet_indices(
solution.function_space.mesh
)
self.value = np.max(self.field.solution.x.array[indices])

self.value = solution.function_space.mesh.comm.allreduce(
np.max(self.field.solution.x.array[indices]), op=MPI.MAX
)
self.data.append(self.value)
7 changes: 6 additions & 1 deletion src/festim/exports/maximum_volume.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from mpi4py import MPI

import numpy as np

from festim.exports import VolumeQuantity
Expand Down Expand Up @@ -27,5 +29,8 @@ def compute(self):
"""
solution = self.field.solution
indices = self.volume.locate_subdomain_entities(solution.function_space.mesh)
self.value = np.max(self.field.solution.x.array[indices])

self.value = solution.function_space.mesh.comm.allreduce(
np.max(self.field.solution.x.array[indices]), op=MPI.MAX
)
self.data.append(self.value)
7 changes: 6 additions & 1 deletion src/festim/exports/minimum_surface.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from mpi4py import MPI

import numpy as np

import festim.exports.surface_quantity as sq
Expand Down Expand Up @@ -28,5 +30,8 @@ def compute(self):
indices = self.surface.locate_boundary_facet_indices(
solution.function_space.mesh
)
self.value = np.min(self.field.solution.x.array[indices])

self.value = solution.function_space.mesh.comm.allreduce(
np.min(self.field.solution.x.array[indices]), op=MPI.MIN
)
self.data.append(self.value)
9 changes: 6 additions & 3 deletions src/festim/exports/minimum_volume.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from mpi4py import MPI

import numpy as np

from festim.exports import VolumeQuantity
Expand Down Expand Up @@ -26,7 +28,8 @@ def compute(self):
"""
solution = self.field.solution
indices = self.volume.locate_subdomain_entities(solution.function_space.mesh)
# FIXME: np.min/np.max is not parallel safe (unique value per process)
# Needs to use a reduction operation (MPI.comm.allreduce(..., op=...))
self.value = np.min(self.field.solution.x.array[indices])

self.value = solution.function_space.mesh.comm.allreduce(
np.min(self.field.solution.x.array[indices]), op=MPI.MIN
)
self.data.append(self.value)
Loading