From eba83ac681ded6e1bcde2337ba3ab00bf8d5cb2d Mon Sep 17 00:00:00 2001 From: Andrea Iob Date: Wed, 10 Apr 2024 15:27:56 +0200 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..70d5d9a5a7 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_ENABLED) #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_ENABLED) #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_ENABLED) #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_ENABLED) #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 7c8e28c930..cbaf5ba024 100644 --- a/src/patchkernel/patch_kernel.cpp +++ b/src/patchkernel/patch_kernel.cpp @@ -66,8 +66,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. @@ -77,6 +80,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 @@ -108,8 +114,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. @@ -120,6 +129,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 @@ -155,8 +167,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. @@ -168,6 +183,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 @@ -232,7 +250,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), @@ -322,6 +341,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)), @@ -411,6 +431,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); @@ -520,11 +541,7 @@ void PatchKernel::initialize() initializeHaloSize(haloSize); // Mark patch as partioned - if (getCommunicator() != MPI_COMM_NULL) { - setPartitioningStatus(PARTITIONING_CLEAN); - } else { - setPartitioningStatus(PARTITIONING_UNSUPPORTED); - } + setPartitioningStatus(PARTITIONING_CLEAN); // Initialize partitioning tags m_partitioningCellsTag = -1; @@ -8335,11 +8352,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 @@ -8434,10 +8453,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 bfd5eb1637..03717ef9a3 100644 --- a/src/patchkernel/patch_kernel.hpp +++ b/src/patchkernel/patch_kernel.hpp @@ -361,11 +361,18 @@ friend class PatchManager; ADAPTION_ALTERED }; + /*! + Partitioning mode + */ + enum PartitioningMode { + PARTITIONING_DISABLED = -1, //! No partitioning can be performed + PARTITIONING_ENABLED //! The patch can be partitioned across the processes + }; + /*! Partitioning status */ enum PartitioningStatus { - PARTITIONING_UNSUPPORTED = -1, PARTITIONING_CLEAN, PARTITIONING_PREPARED, PARTITIONING_ALTERED @@ -750,6 +757,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; @@ -814,9 +822,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); @@ -951,6 +959,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); @@ -1033,6 +1042,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 5ffb0fb974..88d07bf9af 100644 --- a/src/patchkernel/patch_kernel_parallel.cpp +++ b/src/patchkernel/patch_kernel_parallel.cpp @@ -1695,7 +1695,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 ca03d23f80..ebe37f6d1b 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 09deb74f62..f8e4defc78 100644 --- a/src/patchkernel/surface_kernel.hpp +++ b/src/patchkernel/surface_kernel.hpp @@ -99,9 +99,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 ad667bf704..2693bdff5c 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 66e3b6a14d..e3d73fc6bd 100644 --- a/src/patchkernel/volume_kernel.hpp +++ b/src/patchkernel/volume_kernel.hpp @@ -56,9 +56,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 fb1334cf00..5e7620fd64 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 fa7e6293f7..b9c93458d2 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 a4e79c81fb..0f9b2d0c23 100644 --- a/src/voloctree/voloctree.cpp +++ b/src/voloctree/voloctree.cpp @@ -74,7 +74,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. @@ -169,7 +169,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. @@ -243,7 +243,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. @@ -305,7 +305,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 94dad743ab..4ad267c374 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() ;