From b29597ff011c70c77d7476c483229178d7650b81 Mon Sep 17 00:00:00 2001 From: Andrea Iob Date: Fri, 3 Feb 2023 13:59:13 +0100 Subject: [PATCH] patchkernel: explicitly define the partitioning mode Partitioning mode tells if the patch can be partitioned across the processes. The following partitioning modes are supported: - disabled, no partitioning can be performed; - enabled, the patch can be partitioned across the processes. --- src/lineunstructured/lineunstructured.cpp | 8 ++-- src/patchkernel/line_kernel.cpp | 21 ++++++--- src/patchkernel/line_kernel.hpp | 6 +-- src/patchkernel/patch_kernel.cpp | 47 ++++++++++++++----- src/patchkernel/patch_kernel.hpp | 18 +++++-- src/patchkernel/patch_kernel_parallel.cpp | 31 +++++++++++- src/patchkernel/point_kernel.cpp | 21 ++++++--- src/patchkernel/point_kernel.hpp | 6 +-- src/patchkernel/surface_kernel.cpp | 21 ++++++--- src/patchkernel/surface_kernel.hpp | 6 +-- src/patchkernel/volume_kernel.cpp | 21 ++++++--- src/patchkernel/volume_kernel.hpp | 6 +-- src/pointcloud/pointcloud.cpp | 8 ++-- src/surfunstructured/surfunstructured.cpp | 6 +-- src/volcartesian/volcartesian.cpp | 10 ++-- src/voloctree/voloctree.cpp | 8 ++-- src/volunstructured/volunstructured.cpp | 4 +- .../levelset/test_levelset_00001.cpp | 2 +- 18 files changed, 174 insertions(+), 76 deletions(-) diff --git a/src/lineunstructured/lineunstructured.cpp b/src/lineunstructured/lineunstructured.cpp index 0c712faa39..2a9d7636e7 100644 --- a/src/lineunstructured/lineunstructured.cpp +++ b/src/lineunstructured/lineunstructured.cpp @@ -50,7 +50,7 @@ namespace bitpit { among the processes */ LineUnstructured::LineUnstructured(MPI_Comm communicator) - : LineKernel(communicator, 1, ADAPTION_MANUAL) + : LineKernel(communicator, 1, ADAPTION_MANUAL, PARTITIONING_DISABLED) #else /*! Creates an uninitialized serial patch. @@ -74,7 +74,7 @@ LineUnstructured::LineUnstructured() among the processes */ LineUnstructured::LineUnstructured(int dimension, MPI_Comm communicator) - : LineKernel(PatchManager::AUTOMATIC_ID, dimension, communicator, 1, ADAPTION_MANUAL) + : LineKernel(PatchManager::AUTOMATIC_ID, dimension, communicator, 1, ADAPTION_MANUAL, PARTITIONING_DISABLED) #else /*! Creates a patch. @@ -101,7 +101,7 @@ LineUnstructured::LineUnstructured(int dimension) among the processes */ LineUnstructured::LineUnstructured(int id, int dimension, MPI_Comm communicator) - : LineKernel(id, dimension, communicator, 1, ADAPTION_MANUAL) + : LineKernel(id, dimension, communicator, 1, ADAPTION_MANUAL, PARTITIONING_DISABLED) #else /*! Creates a patch. @@ -127,7 +127,7 @@ LineUnstructured::LineUnstructured(int id, int dimension) among the processes */ LineUnstructured::LineUnstructured(std::istream &stream, MPI_Comm communicator) - : LineKernel(communicator, 1, ADAPTION_MANUAL) + : LineKernel(communicator, 1, ADAPTION_MANUAL, PARTITIONING_DISABLED) #else /*! Creates a patch restoring the patch saved in the specified stream. diff --git a/src/patchkernel/line_kernel.cpp b/src/patchkernel/line_kernel.cpp index 436d6c6e71..994287a7cb 100644 --- a/src/patchkernel/line_kernel.cpp +++ b/src/patchkernel/line_kernel.cpp @@ -41,9 +41,12 @@ namespace bitpit { \param haloSize is the size, expressed in number of layers, of the ghost cells halo \param adaptionMode is the adaption mode that will be used for the patch + \param partitioningMode is the partitioning mode that will be used for the + patch */ -LineKernel::LineKernel(MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode) - : PatchKernel(communicator, haloSize, adaptionMode) +LineKernel::LineKernel(MPI_Comm communicator, std::size_t haloSize, + AdaptionMode adaptionMode, PartitioningMode partitioningMode) + : PatchKernel(communicator, haloSize, adaptionMode, partitioningMode) #else /*! Creates a patch. @@ -72,9 +75,12 @@ LineKernel::LineKernel(AdaptionMode adaptionMode) \param haloSize is the size, expressed in number of layers, of the ghost cells halo \param adaptionMode is the adaption mode that will be used for the patch + \param partitioningMode is the partitioning mode that will be used for the + patch */ -LineKernel::LineKernel(int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode) - : PatchKernel(dimension, communicator, haloSize, adaptionMode) +LineKernel::LineKernel(int dimension, MPI_Comm communicator, std::size_t haloSize, + AdaptionMode adaptionMode, PartitioningMode partitioningMode) + : PatchKernel(dimension, communicator, haloSize, adaptionMode, partitioningMode) #else /*! Creates a patch. @@ -105,9 +111,12 @@ LineKernel::LineKernel(int dimension, AdaptionMode adaptionMode) \param haloSize is the size, expressed in number of layers, of the ghost cells halo \param adaptionMode is the adaption mode that will be used for the patch + \param partitioningMode is the partitioning mode that will be used for the + patch */ -LineKernel::LineKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode) - : PatchKernel(id, dimension, communicator, haloSize, adaptionMode) +LineKernel::LineKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize, + AdaptionMode adaptionMode, PartitioningMode partitioningMode) + : PatchKernel(id, dimension, communicator, haloSize, adaptionMode, partitioningMode) #else /*! Creates a patch. diff --git a/src/patchkernel/line_kernel.hpp b/src/patchkernel/line_kernel.hpp index 79c8f68ed0..0e77ed38ec 100644 --- a/src/patchkernel/line_kernel.hpp +++ b/src/patchkernel/line_kernel.hpp @@ -49,9 +49,9 @@ class LineKernel : public PatchKernel { protected: #if BITPIT_ENABLE_MPI==1 - LineKernel(MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode); - LineKernel(int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode); - LineKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode); + LineKernel(MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode, PartitioningMode partitioningMode); + LineKernel(int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode, PartitioningMode partitioningMode); + LineKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode, PartitioningMode partitioningMode); #else LineKernel(AdaptionMode adaptionMode); LineKernel(int dimension, AdaptionMode adaptionMode); diff --git a/src/patchkernel/patch_kernel.cpp b/src/patchkernel/patch_kernel.cpp index f9cc18f8a8..179654f069 100644 --- a/src/patchkernel/patch_kernel.cpp +++ b/src/patchkernel/patch_kernel.cpp @@ -65,8 +65,11 @@ namespace bitpit { \param haloSize is the size, expressed in number of layers, of the ghost cells halo \param adaptionMode is the adaption mode that will be used for the patch + \param partitioningMode is the partitioning mode that will be used for the + patch */ -PatchKernel::PatchKernel(MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode) +PatchKernel::PatchKernel(MPI_Comm communicator, std::size_t haloSize, + AdaptionMode adaptionMode, PartitioningMode partitioningMode) #else /*! Creates a patch. @@ -76,6 +79,9 @@ PatchKernel::PatchKernel(MPI_Comm communicator, std::size_t haloSize, AdaptionMo PatchKernel::PatchKernel(AdaptionMode adaptionMode) #endif : m_adaptionMode(adaptionMode) +#if BITPIT_ENABLE_MPI==1 + , m_partitioningMode(partitioningMode) +#endif { // Initialize the patch #if BITPIT_ENABLE_MPI==1 @@ -107,8 +113,11 @@ PatchKernel::PatchKernel(AdaptionMode adaptionMode) \param haloSize is the size, expressed in number of layers, of the ghost cells halo \param adaptionMode is the adaption mode that will be used for the patch + \param partitioningMode is the partitioning mode that will be used for the + patch */ -PatchKernel::PatchKernel(int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode) +PatchKernel::PatchKernel(int dimension, MPI_Comm communicator, std::size_t haloSize, + AdaptionMode adaptionMode, PartitioningMode partitioningMode) #else /*! Creates a patch. @@ -119,6 +128,9 @@ PatchKernel::PatchKernel(int dimension, MPI_Comm communicator, std::size_t haloS PatchKernel::PatchKernel(int dimension, AdaptionMode adaptionMode) #endif : m_adaptionMode(adaptionMode) +#if BITPIT_ENABLE_MPI==1 + , m_partitioningMode(partitioningMode) +#endif { // Initialize the patch #if BITPIT_ENABLE_MPI==1 @@ -154,8 +166,11 @@ PatchKernel::PatchKernel(int dimension, AdaptionMode adaptionMode) \param haloSize is the size, expressed in number of layers, of the ghost cells halo \param adaptionMode is the adaption mode that will be used for the patch + \param partitioningMode is the partitioning mode that will be used for the + patch */ -PatchKernel::PatchKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode) +PatchKernel::PatchKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize, + AdaptionMode adaptionMode, PartitioningMode partitioningMode) #else /*! Creates a patch. @@ -167,6 +182,9 @@ PatchKernel::PatchKernel(int id, int dimension, MPI_Comm communicator, std::size PatchKernel::PatchKernel(int id, int dimension, AdaptionMode adaptionMode) #endif : m_adaptionMode(adaptionMode) +#if BITPIT_ENABLE_MPI==1 + , m_partitioningMode(partitioningMode) +#endif { // Initialize the patch #if BITPIT_ENABLE_MPI==1 @@ -231,7 +249,8 @@ PatchKernel::PatchKernel(const PatchKernel &other) m_toleranceCustom(other.m_toleranceCustom), m_tolerance(other.m_tolerance) #if BITPIT_ENABLE_MPI==1 - , m_partitioningStatus(other.m_partitioningStatus), + , m_partitioningMode(other.m_partitioningMode), + m_partitioningStatus(other.m_partitioningStatus), m_owner(other.m_owner), m_haloSize(other.m_haloSize), m_partitioningCellsTag(other.m_partitioningCellsTag), @@ -321,6 +340,7 @@ PatchKernel::PatchKernel(PatchKernel &&other) m_nProcessors(std::move(other.m_nProcessors)) #if BITPIT_ENABLE_MPI==1 , m_communicator(std::move(MPI_COMM_NULL)), + m_partitioningMode(other.m_partitioningMode), m_partitioningStatus(std::move(other.m_partitioningStatus)), m_owner(std::move(other.m_owner)), m_haloSize(std::move(other.m_haloSize)), @@ -410,6 +430,7 @@ PatchKernel & PatchKernel::operator=(PatchKernel &&other) m_nProcessors = std::move(other.m_nProcessors); #if BITPIT_ENABLE_MPI==1 m_communicator = std::move(MPI_COMM_NULL); + m_partitioningMode = std::move(other.m_partitioningMode); m_partitioningStatus = std::move(other.m_partitioningStatus); m_owner = std::move(other.m_owner); m_haloSize = std::move(other.m_haloSize); @@ -519,11 +540,7 @@ void PatchKernel::initialize() initializeHaloSize(haloSize); // Mark patch as partioned - if (isPartitioned()) { - setPartitioningStatus(PARTITIONING_CLEAN); - } else { - setPartitioningStatus(PARTITIONING_UNSUPPORTED); - } + setPartitioningStatus(PARTITIONING_CLEAN); // Initialize partitioning tags m_partitioningCellsTag = -1; @@ -8331,11 +8348,13 @@ bool PatchKernel::dump(std::ostream &stream) const utils::binary::write(stream, m_adaptionMode); utils::binary::write(stream, m_adaptionStatus); - // Partition status + // Partition information #if BITPIT_ENABLE_MPI==1 + utils::binary::write(stream, m_partitioningMode); utils::binary::write(stream, m_partitioningStatus); #else - utils::binary::write(stream, PARTITIONING_UNSUPPORTED); + utils::binary::write(stream, PARTITIONING_DISABLED); + utils::binary::write(stream, PARTITIONING_CLEAN); #endif // Adjacencies build strategy @@ -8430,10 +8449,14 @@ void PatchKernel::restore(std::istream &stream, bool reregister) utils::binary::read(stream, m_adaptionMode); utils::binary::read(stream, m_adaptionStatus); - // Partition status + // Partition information #if BITPIT_ENABLE_MPI==1 + utils::binary::read(stream, m_partitioningMode); utils::binary::read(stream, m_partitioningStatus); #else + PartitioningStatus dummyPartitioningMode; + utils::binary::read(stream, dummyPartitioningMode); + PartitioningStatus dummyPartitioningStatus; utils::binary::read(stream, dummyPartitioningStatus); #endif diff --git a/src/patchkernel/patch_kernel.hpp b/src/patchkernel/patch_kernel.hpp index 770a873056..466af687f4 100644 --- a/src/patchkernel/patch_kernel.hpp +++ b/src/patchkernel/patch_kernel.hpp @@ -357,11 +357,18 @@ friend class PatchManager; ADAPTION_ALTERED }; + /*! + Partitioning mode + */ + enum PartitioningMode { + PARTITIONING_DISABLED = -1, + PARTITIONING_ENABLED + }; + /*! Partitioning status */ enum PartitioningStatus { - PARTITIONING_UNSUPPORTED = -1, PARTITIONING_CLEAN, PARTITIONING_PREPARED, PARTITIONING_ALTERED @@ -741,6 +748,7 @@ friend class PatchManager; bool isPartitioned() const; bool isPartitioningSupported() const; bool arePartitioningInfoDirty(bool global = true) const; + PartitioningMode getPartitioningMode() const; PartitioningStatus getPartitioningStatus(bool global = false) const; double evalPartitioningUnbalance() const; double evalPartitioningUnbalance(const std::unordered_map &cellWeights) const; @@ -788,9 +796,9 @@ friend class PatchManager; AlterationFlagsStorage m_alteredInterfaces; #if BITPIT_ENABLE_MPI==1 - PatchKernel(MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode); - PatchKernel(int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode); - PatchKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode); + PatchKernel(MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode, PartitioningMode partitioningMode); + PatchKernel(int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode, PartitioningMode partitioningMode); + PatchKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode, PartitioningMode partitioningMode); #else PatchKernel(AdaptionMode adaptionMode); PatchKernel(int dimension, AdaptionMode adaptionMode); @@ -922,6 +930,7 @@ friend class PatchManager; virtual void _setHaloSize(std::size_t haloSize); void setPartitioned(bool partitioned); + void setPartitioningMode(PartitioningMode mode); void setPartitioningStatus(PartitioningStatus status); virtual std::vector _partitioningPrepare(const std::unordered_map &cellWeights, double defaultWeight, bool trackPartitioning); virtual std::vector _partitioningPrepare(const std::unordered_map &cellRanks, bool trackPartitioning); @@ -1007,6 +1016,7 @@ friend class PatchManager; int m_nProcessors; #if BITPIT_ENABLE_MPI==1 MPI_Comm m_communicator; + PartitioningMode m_partitioningMode; PartitioningStatus m_partitioningStatus; int m_owner; diff --git a/src/patchkernel/patch_kernel_parallel.cpp b/src/patchkernel/patch_kernel_parallel.cpp index d56279ee02..689d0f7391 100644 --- a/src/patchkernel/patch_kernel_parallel.cpp +++ b/src/patchkernel/patch_kernel_parallel.cpp @@ -1786,7 +1786,36 @@ bool PatchKernel::isPartitioned() const */ bool PatchKernel::isPartitioningSupported() const { - return (getPartitioningStatus() != PARTITIONING_UNSUPPORTED); + return (getPartitioningMode() != PARTITIONING_DISABLED); +} + +/*! + Returns the current partitioning mode. + + Partitioning mode tells if the patch can be partitioned across the processes. + + The following partitioning modes are supported: + - disabled, no partitioning can be performed; + - enabled, the patch can be partitioned across the processes. + + \return The current partitioning mode. +*/ +PatchKernel::PartitioningMode PatchKernel::getPartitioningMode() const +{ + return m_partitioningMode; +} + +/*! + Set the current partitioning mode. + + See PatchKernel::getPartitioningMode() for a list of supported partitioning + modes. + + \param mode is the partitioning mode that will be set +*/ +void PatchKernel::setPartitioningMode(PartitioningMode mode) +{ + m_partitioningMode = mode; } /*! diff --git a/src/patchkernel/point_kernel.cpp b/src/patchkernel/point_kernel.cpp index b345180cad..3ffa33d24a 100644 --- a/src/patchkernel/point_kernel.cpp +++ b/src/patchkernel/point_kernel.cpp @@ -39,8 +39,9 @@ namespace bitpit { will be created \param adaptionMode is the adaption mode that will be used for the patch */ -PointKernel::PointKernel(MPI_Comm communicator, AdaptionMode adaptionMode) - : PatchKernel(communicator, 0, adaptionMode) +PointKernel::PointKernel(MPI_Comm communicator, + AdaptionMode adaptionMode, PartitioningMode partitioningMode) + : PatchKernel(communicator, 0, adaptionMode, partitioningMode) #else /*! Creates a patch. @@ -67,15 +68,20 @@ PointKernel::PointKernel(AdaptionMode adaptionMode) among the processes. If a null comunicator is provided, a serial patch will be created \param adaptionMode is the adaption mode that will be used for the patch + \param partitioningMode is the partitioning mode that will be used for the + patch */ -PointKernel::PointKernel(int dimension, MPI_Comm communicator, AdaptionMode adaptionMode) - : PatchKernel(dimension, communicator, 0, adaptionMode) +PointKernel::PointKernel(int dimension, MPI_Comm communicator, + AdaptionMode adaptionMode, PartitioningMode partitioningMode) + : PatchKernel(dimension, communicator, 0, adaptionMode, partitioningMode) #else /*! Creates a patch. \param dimension is the dimension of the patch \param adaptionMode is the adaption mode that will be used for the patch + \param partitioningMode is the partitioning mode that will be used for the + patch */ PointKernel::PointKernel(int dimension, AdaptionMode adaptionMode) : PatchKernel(dimension, adaptionMode) @@ -98,9 +104,12 @@ PointKernel::PointKernel(int dimension, AdaptionMode adaptionMode) among the processes. If a null comunicator is provided, a serial patch will be created \param adaptionMode is the adaption mode that will be used for the patch + \param partitioningMode is the partitioning mode that will be used for the + patch */ -PointKernel::PointKernel(int id, int dimension, MPI_Comm communicator, AdaptionMode adaptionMode) - : PatchKernel(id, dimension, communicator, 0, adaptionMode) +PointKernel::PointKernel(int id, int dimension, MPI_Comm communicator, + AdaptionMode adaptionMode, PartitioningMode partitioningMode) + : PatchKernel(id, dimension, communicator, 0, adaptionMode, partitioningMode) #else /*! Creates a patch. diff --git a/src/patchkernel/point_kernel.hpp b/src/patchkernel/point_kernel.hpp index 185aff4d1c..d9157066b1 100644 --- a/src/patchkernel/point_kernel.hpp +++ b/src/patchkernel/point_kernel.hpp @@ -43,9 +43,9 @@ class PointKernel : public PatchKernel { protected: #if BITPIT_ENABLE_MPI==1 - PointKernel(MPI_Comm communicator, AdaptionMode adaptionMode); - PointKernel(int dimension, MPI_Comm communicator, AdaptionMode adaptionMode); - PointKernel(int id, int dimension, MPI_Comm communicator, AdaptionMode adaptionMode); + PointKernel(MPI_Comm communicator, AdaptionMode adaptionMode, PartitioningMode partitioningMode); + PointKernel(int dimension, MPI_Comm communicator, AdaptionMode adaptionMode, PartitioningMode partitioningMode); + PointKernel(int id, int dimension, MPI_Comm communicator, AdaptionMode adaptionMode, PartitioningMode partitioningMode); #else PointKernel(AdaptionMode adaptionMode); PointKernel(int dimension, AdaptionMode adaptionMode); diff --git a/src/patchkernel/surface_kernel.cpp b/src/patchkernel/surface_kernel.cpp index 423d5ba494..4ac48253d0 100644 --- a/src/patchkernel/surface_kernel.cpp +++ b/src/patchkernel/surface_kernel.cpp @@ -71,9 +71,12 @@ const unsigned short SurfaceKernel::SELECT_ALL = 3; \param haloSize is the size, expressed in number of layers, of the ghost cells halo \param adaptionMode is the adaption mode that will be used for the patch + \param partitioningMode is the partitioning mode that will be used for the + patch */ -SurfaceKernel::SurfaceKernel(MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode) - : PatchKernel(communicator, haloSize, adaptionMode) +SurfaceKernel::SurfaceKernel(MPI_Comm communicator, std::size_t haloSize, + AdaptionMode adaptionMode, PartitioningMode partitioningMode) + : PatchKernel(communicator, haloSize, adaptionMode, partitioningMode) #else /*! Creates a patch. @@ -102,9 +105,12 @@ SurfaceKernel::SurfaceKernel(AdaptionMode adaptionMode) \param haloSize is the size, expressed in number of layers, of the ghost cells halo \param adaptionMode is the adaption mode that will be used for the patch + \param partitioningMode is the partitioning mode that will be used for the + patch */ -SurfaceKernel::SurfaceKernel(int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode) - : PatchKernel(dimension, communicator, haloSize, adaptionMode) +SurfaceKernel::SurfaceKernel(int dimension, MPI_Comm communicator, std::size_t haloSize, + AdaptionMode adaptionMode, PartitioningMode partitioningMode) + : PatchKernel(dimension, communicator, haloSize, adaptionMode, partitioningMode) #else /*! Creates a patch. @@ -135,9 +141,12 @@ SurfaceKernel::SurfaceKernel(int dimension, AdaptionMode adaptionMode) \param haloSize is the size, expressed in number of layers, of the ghost cells halo \param adaptionMode is the adaption mode that will be used for the patch + \param partitioningMode is the partitioning mode that will be used for the + patch */ -SurfaceKernel::SurfaceKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode) - : PatchKernel(id, dimension, communicator, haloSize, adaptionMode) +SurfaceKernel::SurfaceKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize, + AdaptionMode adaptionMode, PartitioningMode partitioningMode) + : PatchKernel(id, dimension, communicator, haloSize, adaptionMode, partitioningMode) #else /*! Creates a patch. diff --git a/src/patchkernel/surface_kernel.hpp b/src/patchkernel/surface_kernel.hpp index c5e49e7621..cfc70453ce 100644 --- a/src/patchkernel/surface_kernel.hpp +++ b/src/patchkernel/surface_kernel.hpp @@ -88,9 +88,9 @@ class SurfaceKernel : public PatchKernel { protected: #if BITPIT_ENABLE_MPI==1 - SurfaceKernel(MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode); - SurfaceKernel(int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode); - SurfaceKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode); + SurfaceKernel(MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode, PartitioningMode partitioningMode); + SurfaceKernel(int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode, PartitioningMode partitioningMode); + SurfaceKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode, PartitioningMode partitioningMode); #else SurfaceKernel(AdaptionMode adaptionMode); SurfaceKernel(int dimension, AdaptionMode adaptionMode); diff --git a/src/patchkernel/volume_kernel.cpp b/src/patchkernel/volume_kernel.cpp index 16cac2f3fc..d4d6a1925e 100644 --- a/src/patchkernel/volume_kernel.cpp +++ b/src/patchkernel/volume_kernel.cpp @@ -50,9 +50,12 @@ namespace bitpit { \param haloSize is the size, expressed in number of layers, of the ghost cells halo \param adaptionMode is the adaption mode that will be used for the patch + \param partitioningMode is the partitioning mode that will be used for the + patch */ -VolumeKernel::VolumeKernel(MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode) - : PatchKernel(communicator, haloSize, adaptionMode) +VolumeKernel::VolumeKernel(MPI_Comm communicator, std::size_t haloSize, + AdaptionMode adaptionMode, PartitioningMode partitioningMode) + : PatchKernel(communicator, haloSize, adaptionMode, partitioningMode) #else /*! Creates a patch. @@ -80,9 +83,12 @@ VolumeKernel::VolumeKernel(AdaptionMode adaptionMode) \param haloSize is the size, expressed in number of layers, of the ghost cells halo \param adaptionMode is the adaption mode that will be used for the patch + \param partitioningMode is the partitioning mode that will be used for the + patch */ -VolumeKernel::VolumeKernel(int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode) - : PatchKernel(dimension, communicator, haloSize, adaptionMode) +VolumeKernel::VolumeKernel(int dimension, MPI_Comm communicator, std::size_t haloSize, + AdaptionMode adaptionMode, PartitioningMode partitioningMode) + : PatchKernel(dimension, communicator, haloSize, adaptionMode, partitioningMode) #else /*! Creates a patch. @@ -112,9 +118,12 @@ VolumeKernel::VolumeKernel(int dimension, AdaptionMode adaptionMode) \param haloSize is the size, expressed in number of layers, of the ghost cells halo \param adaptionMode is the adaption mode that will be used for the patch + \param partitioningMode is the partitioning mode that will be used for the + patch */ -VolumeKernel::VolumeKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode) - : PatchKernel(id, dimension, communicator, haloSize, adaptionMode) +VolumeKernel::VolumeKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize, + AdaptionMode adaptionMode, PartitioningMode partitioningMode) + : PatchKernel(id, dimension, communicator, haloSize, adaptionMode, partitioningMode) #else /*! Creates a patch. diff --git a/src/patchkernel/volume_kernel.hpp b/src/patchkernel/volume_kernel.hpp index b2a18493cf..6996d41547 100644 --- a/src/patchkernel/volume_kernel.hpp +++ b/src/patchkernel/volume_kernel.hpp @@ -52,9 +52,9 @@ class VolumeKernel : public PatchKernel { protected: #if BITPIT_ENABLE_MPI==1 - VolumeKernel(MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode); - VolumeKernel(int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode); - VolumeKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode); + VolumeKernel(MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode, PartitioningMode partitioningMode); + VolumeKernel(int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode, PartitioningMode partitioningMode); + VolumeKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize, AdaptionMode adaptionMode, PartitioningMode partitioningMode); #else VolumeKernel(AdaptionMode adaptionMode); VolumeKernel(int dimension, AdaptionMode adaptionMode); diff --git a/src/pointcloud/pointcloud.cpp b/src/pointcloud/pointcloud.cpp index 9d0d8507fa..2690f74496 100644 --- a/src/pointcloud/pointcloud.cpp +++ b/src/pointcloud/pointcloud.cpp @@ -49,7 +49,7 @@ namespace bitpit { among the processes */ PointCloud::PointCloud(MPI_Comm communicator) - : PointKernel(communicator, ADAPTION_MANUAL) + : PointKernel(communicator, ADAPTION_MANUAL, PARTITIONING_DISABLED) #else /*! Creates an uninitialized serial patch. @@ -73,7 +73,7 @@ PointCloud::PointCloud() among the processes */ PointCloud::PointCloud(int dimension, MPI_Comm communicator) - : PointKernel(PatchManager::AUTOMATIC_ID, dimension, communicator, ADAPTION_MANUAL) + : PointKernel(PatchManager::AUTOMATIC_ID, dimension, communicator, ADAPTION_MANUAL, PARTITIONING_DISABLED) #else /*! Creates a patch. @@ -100,7 +100,7 @@ PointCloud::PointCloud(int dimension) among the processes */ PointCloud::PointCloud(int id, int dimension, MPI_Comm communicator) - : PointKernel(id, dimension, communicator, ADAPTION_MANUAL) + : PointKernel(id, dimension, communicator, ADAPTION_MANUAL, PARTITIONING_DISABLED) #else /*! Creates a patch. @@ -126,7 +126,7 @@ PointCloud::PointCloud(int id, int dimension) among the processes */ PointCloud::PointCloud(std::istream &stream, MPI_Comm communicator) - : PointKernel(communicator, ADAPTION_MANUAL) + : PointKernel(communicator, ADAPTION_MANUAL, PARTITIONING_DISABLED) #else /*! Creates a patch restoring the patch saved in the specified stream. diff --git a/src/surfunstructured/surfunstructured.cpp b/src/surfunstructured/surfunstructured.cpp index aec4416dec..31bfad376f 100644 --- a/src/surfunstructured/surfunstructured.cpp +++ b/src/surfunstructured/surfunstructured.cpp @@ -53,7 +53,7 @@ namespace bitpit { cells halo */ SurfUnstructured::SurfUnstructured(MPI_Comm communicator, std::size_t haloSize) - : SurfaceKernel(communicator, haloSize, ADAPTION_MANUAL) + : SurfaceKernel(communicator, haloSize, ADAPTION_MANUAL, PARTITIONING_ENABLED) #else /*! Creates an uninitialized serial patch. @@ -108,7 +108,7 @@ SurfUnstructured::SurfUnstructured(int dimension) cells halo */ SurfUnstructured::SurfUnstructured(int id, int dimension, MPI_Comm communicator, std::size_t haloSize) - : SurfaceKernel(id, dimension, communicator, haloSize, ADAPTION_MANUAL) + : SurfaceKernel(id, dimension, communicator, haloSize, ADAPTION_MANUAL, PARTITIONING_ENABLED) #else /*! Creates a patch. @@ -136,7 +136,7 @@ SurfUnstructured::SurfUnstructured(int id, int dimension) cells halo */ SurfUnstructured::SurfUnstructured(std::istream &stream, MPI_Comm communicator, std::size_t haloSize) - : SurfaceKernel(communicator, haloSize, ADAPTION_MANUAL) + : SurfaceKernel(communicator, haloSize, ADAPTION_MANUAL, PARTITIONING_ENABLED) #else /*! Creates a patch restoring the patch saved in the specified stream. diff --git a/src/volcartesian/volcartesian.cpp b/src/volcartesian/volcartesian.cpp index f9639d5281..cc039d8b75 100644 --- a/src/volcartesian/volcartesian.cpp +++ b/src/volcartesian/volcartesian.cpp @@ -65,7 +65,7 @@ namespace bitpit { */ VolCartesian::VolCartesian() #if BITPIT_ENABLE_MPI==1 - : VolumeKernel(MPI_COMM_NULL, 0, ADAPTION_DISABLED) + : VolumeKernel(MPI_COMM_NULL, 0, ADAPTION_DISABLED, PARTITIONING_DISABLED) #else : VolumeKernel(ADAPTION_DISABLED) #endif @@ -103,7 +103,7 @@ VolCartesian::VolCartesian(int id, int dimension, const std::array &lengths, const std::array &nCells) #if BITPIT_ENABLE_MPI==1 - : VolumeKernel(id, dimension, MPI_COMM_NULL, 0, ADAPTION_DISABLED) + : VolumeKernel(id, dimension, MPI_COMM_NULL, 0, ADAPTION_DISABLED, PARTITIONING_DISABLED) #else : VolumeKernel(id, dimension, ADAPTION_DISABLED) #endif @@ -144,7 +144,7 @@ VolCartesian::VolCartesian(int id, int dimension, const std::array &origin, double length, int nCells) #if BITPIT_ENABLE_MPI==1 - : VolumeKernel(id, dimension, MPI_COMM_NULL, 0, ADAPTION_DISABLED) + : VolumeKernel(id, dimension, MPI_COMM_NULL, 0, ADAPTION_DISABLED, PARTITIONING_DISABLED) #else : VolumeKernel(id, dimension, ADAPTION_DISABLED) #endif @@ -185,7 +185,7 @@ VolCartesian::VolCartesian(int id, int dimension, const std::array &origin, double length, double dh) #if BITPIT_ENABLE_MPI==1 - : VolumeKernel(id, dimension, MPI_COMM_NULL, 0, ADAPTION_DISABLED) + : VolumeKernel(id, dimension, MPI_COMM_NULL, 0, ADAPTION_DISABLED, PARTITIONING_DISABLED) #else : VolumeKernel(id, dimension, ADAPTION_DISABLED) #endif @@ -206,7 +206,7 @@ VolCartesian::VolCartesian(int id, int dimension, */ VolCartesian::VolCartesian(std::istream &stream) #if BITPIT_ENABLE_MPI==1 - : VolumeKernel(MPI_COMM_NULL, 0, ADAPTION_DISABLED) + : VolumeKernel(MPI_COMM_NULL, 0, ADAPTION_DISABLED, PARTITIONING_DISABLED) #else : VolumeKernel(ADAPTION_DISABLED) #endif diff --git a/src/voloctree/voloctree.cpp b/src/voloctree/voloctree.cpp index 9e988c05d9..80d1b20949 100644 --- a/src/voloctree/voloctree.cpp +++ b/src/voloctree/voloctree.cpp @@ -75,7 +75,7 @@ namespace bitpit { cells halo */ VolOctree::VolOctree(MPI_Comm communicator, std::size_t haloSize) - : VolumeKernel(communicator, haloSize, ADAPTION_AUTOMATIC) + : VolumeKernel(communicator, haloSize, ADAPTION_AUTOMATIC, PARTITIONING_ENABLED) #else /*! Creates an uninitialized serial patch. @@ -170,7 +170,7 @@ VolOctree::VolOctree(int dimension, const std::array &origin, double cells halo */ VolOctree::VolOctree(int id, int dimension, const std::array &origin, double length, double dh, MPI_Comm communicator, std::size_t haloSize) - : VolumeKernel(id, dimension, communicator, haloSize, ADAPTION_AUTOMATIC) + : VolumeKernel(id, dimension, communicator, haloSize, ADAPTION_AUTOMATIC, PARTITIONING_ENABLED) #else /*! Creates a patch. @@ -244,7 +244,7 @@ VolOctree::VolOctree(int id, int dimension, const std::array &origin, cells halo */ VolOctree::VolOctree(std::istream &stream, MPI_Comm communicator, std::size_t haloSize) - : VolumeKernel(communicator, haloSize, ADAPTION_AUTOMATIC) + : VolumeKernel(communicator, haloSize, ADAPTION_AUTOMATIC, PARTITIONING_ENABLED) #else /*! Creates a patch restoring the patch saved in the specified stream. @@ -306,7 +306,7 @@ VolOctree::VolOctree(std::unique_ptr &&tree, std::unique_ptr &&tree, std::unique_ptr *adopter) #if BITPIT_ENABLE_MPI==1 - : VolumeKernel(id, tree->getDim(), tree->getComm(), tree->getNofGhostLayers(), ADAPTION_AUTOMATIC) + : VolumeKernel(id, tree->getDim(), tree->getComm(), tree->getNofGhostLayers(), ADAPTION_AUTOMATIC, PARTITIONING_ENABLED) #else : VolumeKernel(id, tree->getDim(), ADAPTION_AUTOMATIC) #endif diff --git a/src/volunstructured/volunstructured.cpp b/src/volunstructured/volunstructured.cpp index 0ad2ae4d3f..f1190e3a9f 100644 --- a/src/volunstructured/volunstructured.cpp +++ b/src/volunstructured/volunstructured.cpp @@ -54,7 +54,7 @@ namespace bitpit { cells halo */ VolUnstructured::VolUnstructured(MPI_Comm communicator, std::size_t haloSize) - : VolumeKernel(communicator, haloSize, ADAPTION_MANUAL) + : VolumeKernel(communicator, haloSize, ADAPTION_MANUAL, PARTITIONING_ENABLED) #else /*! Creates an uninitialized serial patch. @@ -111,7 +111,7 @@ VolUnstructured::VolUnstructured(int dimension) cells halo */ VolUnstructured::VolUnstructured(int id, int dimension, MPI_Comm communicator, std::size_t haloSize) - : VolumeKernel(id, dimension, communicator, haloSize, ADAPTION_MANUAL) + : VolumeKernel(id, dimension, communicator, haloSize, ADAPTION_MANUAL, PARTITIONING_ENABLED) #else /*! Creates a patch. diff --git a/test/integration_tests/levelset/test_levelset_00001.cpp b/test/integration_tests/levelset/test_levelset_00001.cpp index e6c9641e84..707a3662ef 100644 --- a/test/integration_tests/levelset/test_levelset_00001.cpp +++ b/test/integration_tests/levelset/test_levelset_00001.cpp @@ -124,7 +124,7 @@ int subtest_001() delta = meshMax -meshMin ; bitpit::VolCartesian mesh( 1, dimensions, meshMin, delta, nc); - mesh.update() ; + mesh.switchMemoryMode(bitpit::VolCartesian::MEMORY_NORMAL) ; mesh.initializeAdjacencies() ; mesh.initializeInterfaces() ;