diff --git a/src/lineunstructured/lineunstructured.cpp b/src/lineunstructured/lineunstructured.cpp index 5748711fe8..70d5d9a5a7 100644 --- a/src/lineunstructured/lineunstructured.cpp +++ b/src/lineunstructured/lineunstructured.cpp @@ -50,13 +50,13 @@ namespace bitpit { among the processes */ LineUnstructured::LineUnstructured(MPI_Comm communicator) - : LineKernel(communicator, 1, true) + : LineKernel(communicator, 1, ADAPTION_MANUAL, PARTITIONING_ENABLED) #else /*! Creates an uninitialized serial patch. */ LineUnstructured::LineUnstructured() - : LineKernel(true) + : LineKernel(ADAPTION_MANUAL) #endif { } @@ -74,7 +74,7 @@ LineUnstructured::LineUnstructured() among the processes */ LineUnstructured::LineUnstructured(int dimension, MPI_Comm communicator) - : LineKernel(PatchManager::AUTOMATIC_ID, dimension, communicator, 1, true) + : LineKernel(PatchManager::AUTOMATIC_ID, dimension, communicator, 1, ADAPTION_MANUAL, PARTITIONING_ENABLED) #else /*! Creates a patch. @@ -82,7 +82,7 @@ LineUnstructured::LineUnstructured(int dimension, MPI_Comm communicator) \param dimension is the dimension of the patch */ LineUnstructured::LineUnstructured(int dimension) - : LineKernel(PatchManager::AUTOMATIC_ID, dimension, true) + : LineKernel(PatchManager::AUTOMATIC_ID, dimension, ADAPTION_MANUAL) #endif { } @@ -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, true) + : LineKernel(id, dimension, communicator, 1, ADAPTION_MANUAL, PARTITIONING_ENABLED) #else /*! Creates a patch. @@ -110,7 +110,7 @@ LineUnstructured::LineUnstructured(int id, int dimension, MPI_Comm communicator) \param dimension is the dimension of the patch */ LineUnstructured::LineUnstructured(int id, int dimension) - : LineKernel(id, dimension, true) + : LineKernel(id, dimension, ADAPTION_MANUAL) #endif { } @@ -127,7 +127,7 @@ LineUnstructured::LineUnstructured(int id, int dimension) among the processes */ LineUnstructured::LineUnstructured(std::istream &stream, MPI_Comm communicator) - : LineKernel(communicator, 1, false) + : LineKernel(communicator, 1, ADAPTION_MANUAL, PARTITIONING_ENABLED) #else /*! Creates a patch restoring the patch saved in the specified stream. @@ -135,7 +135,7 @@ LineUnstructured::LineUnstructured(std::istream &stream, MPI_Comm communicator) \param stream is the stream to read from */ LineUnstructured::LineUnstructured(std::istream &stream) - : LineKernel(false) + : LineKernel(ADAPTION_MANUAL) #endif { // Restore the patch @@ -152,20 +152,6 @@ std::unique_ptr LineUnstructured::clone() const return std::unique_ptr(new LineUnstructured(*this)); } -/*! - * Enables or disables expert mode. - * - * When expert mode is enabled, it will be possible to change the - * patch using low level functions (e.g., it will be possible to - * add individual cells, add vertices, delete cells, ...). - * - * \param expert if true, the expert mode will be enabled - */ -void LineUnstructured::setExpert(bool expert) -{ - LineKernel::setExpert(expert); -} - /*! * Get the version associated to the binary dumps. * diff --git a/src/lineunstructured/lineunstructured.hpp b/src/lineunstructured/lineunstructured.hpp index c3b9516022..a98a22bad8 100644 --- a/src/lineunstructured/lineunstructured.hpp +++ b/src/lineunstructured/lineunstructured.hpp @@ -55,7 +55,7 @@ class LineUnstructured : public LineKernel { std::unique_ptr clone() const override; // Setters - void setExpert(bool expert); + using LineKernel::setExpert; // Search algorithms long locatePoint(const std::array &point) const override; diff --git a/src/patchkernel/line_kernel.cpp b/src/patchkernel/line_kernel.cpp index 2faee59b66..994287a7cb 100644 --- a/src/patchkernel/line_kernel.cpp +++ b/src/patchkernel/line_kernel.cpp @@ -40,18 +40,21 @@ namespace bitpit { will be created \param haloSize is the size, expressed in number of layers, of the ghost cells halo - \param expert if true, the expert mode will be enabled + \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, bool expert) - : PatchKernel(communicator, haloSize, expert) +LineKernel::LineKernel(MPI_Comm communicator, std::size_t haloSize, + AdaptionMode adaptionMode, PartitioningMode partitioningMode) + : PatchKernel(communicator, haloSize, adaptionMode, partitioningMode) #else /*! Creates a patch. - \param expert if true, the expert mode will be enabled + \param adaptionMode is the adaption mode that will be used for the patch */ -LineKernel::LineKernel(bool expert) - : PatchKernel(expert) +LineKernel::LineKernel(AdaptionMode adaptionMode) + : PatchKernel(adaptionMode) #endif { initialize(); @@ -71,19 +74,22 @@ LineKernel::LineKernel(bool expert) will be created \param haloSize is the size, expressed in number of layers, of the ghost cells halo - \param expert if true, the expert mode will be enabled + \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, bool expert) - : PatchKernel(dimension, communicator, haloSize, expert) +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. \param dimension is the dimension of the patch - \param expert if true, the expert mode will be enabled + \param adaptionMode is the adaption mode that will be used for the patch */ -LineKernel::LineKernel(int dimension, bool expert) - : PatchKernel(dimension, expert) +LineKernel::LineKernel(int dimension, AdaptionMode adaptionMode) + : PatchKernel(dimension, adaptionMode) #endif { initialize(); @@ -104,20 +110,23 @@ LineKernel::LineKernel(int dimension, bool expert) will be created \param haloSize is the size, expressed in number of layers, of the ghost cells halo - \param expert if true, the expert mode will be enabled + \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, bool expert) - : PatchKernel(id, dimension, communicator, haloSize, expert) +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. \param id is the id that will be assigned to the patch \param dimension is the dimension of the patch - \param expert if true, the expert mode will be enabled + \param adaptionMode is the adaption mode that will be used for the patch */ -LineKernel::LineKernel(int id, int dimension, bool expert) - : PatchKernel(id, dimension, expert) +LineKernel::LineKernel(int id, int dimension, AdaptionMode adaptionMode) + : PatchKernel(id, dimension, adaptionMode) #endif { } diff --git a/src/patchkernel/line_kernel.hpp b/src/patchkernel/line_kernel.hpp index afbaf2a68f..0e77ed38ec 100644 --- a/src/patchkernel/line_kernel.hpp +++ b/src/patchkernel/line_kernel.hpp @@ -49,13 +49,13 @@ class LineKernel : public PatchKernel { protected: #if BITPIT_ENABLE_MPI==1 - LineKernel(MPI_Comm communicator, std::size_t haloSize, bool expert); - LineKernel(int dimension, MPI_Comm communicator, std::size_t haloSize, bool expert); - LineKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize, bool expert); + 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(bool expert); - LineKernel(int dimension, bool expert); - LineKernel(int id, int dimension, bool expert); + LineKernel(AdaptionMode adaptionMode); + LineKernel(int dimension, AdaptionMode adaptionMode); + LineKernel(int id, int dimension, AdaptionMode adaptionMode); #endif }; diff --git a/src/patchkernel/patch_kernel.cpp b/src/patchkernel/patch_kernel.cpp index d6cca8f0cd..cbaf5ba024 100644 --- a/src/patchkernel/patch_kernel.cpp +++ b/src/patchkernel/patch_kernel.cpp @@ -65,18 +65,24 @@ namespace bitpit { will be created \param haloSize is the size, expressed in number of layers, of the ghost cells halo - \param expert if true, the expert mode will be enabled + \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, bool expert) +PatchKernel::PatchKernel(MPI_Comm communicator, std::size_t haloSize, + AdaptionMode adaptionMode, PartitioningMode partitioningMode) #else /*! Creates a patch. - \param expert if true, the expert mode will be enabled + \param adaptionMode is the adaption mode that will be used for the patch */ -PatchKernel::PatchKernel(bool expert) +PatchKernel::PatchKernel(AdaptionMode adaptionMode) +#endif + : m_adaptionMode(adaptionMode) +#if BITPIT_ENABLE_MPI==1 + , m_partitioningMode(partitioningMode) #endif - : m_expert(expert) { // Initialize the patch #if BITPIT_ENABLE_MPI==1 @@ -107,19 +113,25 @@ PatchKernel::PatchKernel(bool expert) will be created \param haloSize is the size, expressed in number of layers, of the ghost cells halo - \param expert if true, the expert mode will be enabled + \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, bool expert) +PatchKernel::PatchKernel(int dimension, MPI_Comm communicator, std::size_t haloSize, + AdaptionMode adaptionMode, PartitioningMode partitioningMode) #else /*! Creates a patch. \param dimension is the dimension of the patch - \param expert if true, the expert mode will be enabled + \param adaptionMode is the adaption mode that will be used for the patch */ -PatchKernel::PatchKernel(int dimension, bool expert) +PatchKernel::PatchKernel(int dimension, AdaptionMode adaptionMode) +#endif + : m_adaptionMode(adaptionMode) +#if BITPIT_ENABLE_MPI==1 + , m_partitioningMode(partitioningMode) #endif - : m_expert(expert) { // Initialize the patch #if BITPIT_ENABLE_MPI==1 @@ -154,20 +166,26 @@ PatchKernel::PatchKernel(int dimension, bool expert) will be created \param haloSize is the size, expressed in number of layers, of the ghost cells halo - \param expert if true, the expert mode will be enabled + \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, bool expert) +PatchKernel::PatchKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize, + AdaptionMode adaptionMode, PartitioningMode partitioningMode) #else /*! Creates a patch. \param id is the id that will be assigned to the patch \param dimension is the dimension of the patch - \param expert if true, the expert mode will be enabled + \param adaptionMode is the adaption mode that will be used for the patch */ -PatchKernel::PatchKernel(int id, int dimension, bool expert) +PatchKernel::PatchKernel(int id, int dimension, AdaptionMode adaptionMode) +#endif + : m_adaptionMode(adaptionMode) +#if BITPIT_ENABLE_MPI==1 + , m_partitioningMode(partitioningMode) #endif - : m_expert(expert) { // Initialize the patch #if BITPIT_ENABLE_MPI==1 @@ -226,13 +244,14 @@ PatchKernel::PatchKernel(const PatchKernel &other) m_adjacenciesBuildStrategy(other.m_adjacenciesBuildStrategy), m_interfacesBuildStrategy(other.m_interfacesBuildStrategy), m_spawnStatus(other.m_spawnStatus), + m_adaptionMode(other.m_adaptionMode), m_adaptionStatus(other.m_adaptionStatus), - m_expert(other.m_expert), m_dimension(other.m_dimension), 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), @@ -312,8 +331,8 @@ PatchKernel::PatchKernel(PatchKernel &&other) m_adjacenciesBuildStrategy(std::move(other.m_adjacenciesBuildStrategy)), m_interfacesBuildStrategy(std::move(other.m_interfacesBuildStrategy)), m_spawnStatus(std::move(other.m_spawnStatus)), + m_adaptionMode(std::move(other.m_adaptionMode)), m_adaptionStatus(std::move(other.m_adaptionStatus)), - m_expert(std::move(other.m_expert)), m_id(std::move(other.m_id)), m_dimension(std::move(other.m_dimension)), m_toleranceCustom(std::move(other.m_toleranceCustom)), @@ -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)), @@ -401,8 +421,8 @@ PatchKernel & PatchKernel::operator=(PatchKernel &&other) m_adjacenciesBuildStrategy = std::move(other.m_adjacenciesBuildStrategy); m_interfacesBuildStrategy = std::move(other.m_interfacesBuildStrategy); m_spawnStatus = std::move(other.m_spawnStatus); + m_adaptionMode = std::move(other.m_adaptionMode); m_adaptionStatus = std::move(other.m_adaptionStatus); - m_expert = std::move(other.m_expert); m_id = std::move(other.m_id); m_dimension = std::move(other.m_dimension); m_toleranceCustom = std::move(other.m_toleranceCustom); @@ -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); @@ -509,11 +530,8 @@ void PatchKernel::initialize() // initialization. setSpawnStatus(SPAWN_UNNEEDED); - // Set the adaption as unsupported - // - // Specific implementation will set the appropriate status during their - // initialization. - setAdaptionStatus(ADAPTION_UNSUPPORTED); + // Set the adaption as clean + setAdaptionStatus(ADAPTION_CLEAN); #if BITPIT_ENABLE_MPI==1 // Initialize communicator @@ -523,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; @@ -719,14 +733,20 @@ std::vector PatchKernel::adaption(bool trackAdaption, bool squee { std::vector adaptionInfo; - // Check adaption status + // Early return if adaption cannot be performed + AdaptionMode adaptionMode = getAdaptionMode(); + if (adaptionMode == ADAPTION_DISABLED) { + return adaptionInfo; + } + AdaptionStatus adaptionStatus = getAdaptionStatus(true); - if (adaptionStatus == ADAPTION_UNSUPPORTED || adaptionStatus == ADAPTION_CLEAN) { + if (adaptionStatus == ADAPTION_CLEAN) { return adaptionInfo; } else if (adaptionStatus != ADAPTION_DIRTY) { throw std::runtime_error ("An adaption is already in progress."); } + // Run adaption adaptionPrepare(false); adaptionInfo = adaptionAlter(trackAdaption, squeezeStorage); @@ -753,9 +773,14 @@ std::vector PatchKernel::adaptionPrepare(bool trackAdaption) { std::vector adaptionInfo; - // Check adaption status + // Early return if adaption cannot be performed + AdaptionMode adaptionMode = getAdaptionMode(); + if (adaptionMode == ADAPTION_DISABLED) { + return adaptionInfo; + } + AdaptionStatus adaptionStatus = getAdaptionStatus(true); - if (adaptionStatus == ADAPTION_UNSUPPORTED || adaptionStatus == ADAPTION_CLEAN) { + if (adaptionStatus == ADAPTION_CLEAN) { return adaptionInfo; } else if (adaptionStatus != ADAPTION_DIRTY) { throw std::runtime_error ("An adaption is already in progress."); @@ -789,9 +814,14 @@ std::vector PatchKernel::adaptionAlter(bool trackAdaption, bool { std::vector adaptionInfo; - // Check adaption status + // Early return if adaption cannot be performed + AdaptionMode adaptionMode = getAdaptionMode(); + if (adaptionMode == ADAPTION_DISABLED) { + return adaptionInfo; + } + AdaptionStatus adaptionStatus = getAdaptionStatus(); - if (adaptionStatus == ADAPTION_UNSUPPORTED || adaptionStatus == ADAPTION_CLEAN) { + if (adaptionStatus == ADAPTION_CLEAN) { return adaptionInfo; } else if (adaptionStatus != ADAPTION_PREPARED) { throw std::runtime_error ("The prepare function has not been called."); @@ -816,8 +846,14 @@ std::vector PatchKernel::adaptionAlter(bool trackAdaption, bool */ void PatchKernel::adaptionCleanup() { + // Early return if adaption cannot be performed + AdaptionMode adaptionMode = getAdaptionMode(); + if (adaptionMode == ADAPTION_DISABLED) { + return; + } + AdaptionStatus adaptionStatus = getAdaptionStatus(); - if (adaptionStatus == ADAPTION_UNSUPPORTED || adaptionStatus == ADAPTION_CLEAN) { + if (adaptionStatus == ADAPTION_CLEAN) { return; } else if (adaptionStatus == ADAPTION_PREPARED) { throw std::runtime_error ("It is not yet possible to abort an adaption."); @@ -1100,7 +1136,7 @@ void PatchKernel::_resetInterfaces(bool release) */ bool PatchKernel::reserveVertices(size_t nVertices) { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return false; } @@ -1123,7 +1159,7 @@ bool PatchKernel::reserveVertices(size_t nVertices) */ bool PatchKernel::reserveCells(size_t nCells) { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return false; } @@ -1148,7 +1184,7 @@ bool PatchKernel::reserveCells(size_t nCells) */ bool PatchKernel::reserveInterfaces(size_t nInterfaces) { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return false; } @@ -1302,6 +1338,9 @@ void PatchKernel::_writeFinalize() /*! Returns the current spawn status. + Span functionality is obsolete. The patch dosn't need to be spawned + anymore. + \return The current spawn status. */ PatchKernel::SpawnStatus PatchKernel::getSpawnStatus() const @@ -1330,12 +1369,48 @@ void PatchKernel::setSpawnStatus(SpawnStatus status) */ bool PatchKernel::isAdaptionSupported() const { - return (getAdaptionStatus() != ADAPTION_UNSUPPORTED); + return (getAdaptionMode() != ADAPTION_DISABLED); +} + +/*! + Returns the adaption mode. + + Adaption mode tells if the patch can be adapted and which strategies can + be used to adapt the patch. + + The following adaption modes are supported: + - disabled, no adaption can be performed; + - automatic, adaption is performed specifying which cells should be + refiend/coarsen and then the patch will perform all the alterations + needed to fulfill the adaption requests; + - manual, this modes allows to use low level function to add and delete + individual cells and vertices. It's up to the user to guarantee the + consistency of the patch. + + \return The adaption mode. +*/ +PatchKernel::AdaptionMode PatchKernel::getAdaptionMode() const +{ + return m_adaptionMode; +} + +/*! + Set the adaption mode. + + See PatchKernel::getAdaptionMode() for a list of supported adaption modes. + + \param mode is the adaption mode that will be set +*/ +void PatchKernel::setAdaptionMode(AdaptionMode mode) +{ + m_adaptionMode = mode; } /*! Returns the current adaption status. + Adaption mode tells which stage of the adaption process + \param global if set to true, the adaption status will be evaluated globally across all the partitions \return The current adaption status. @@ -1447,11 +1522,13 @@ bool PatchKernel::isDirty(bool global) const */ void PatchKernel::setExpert(bool expert) { - if (isExpert() == expert) { - return; + static AdaptionMode initialAdaptionMode; + if (!expert) { + initialAdaptionMode = m_adaptionMode; + m_adaptionMode = ADAPTION_MANUAL; + } else { + m_adaptionMode = initialAdaptionMode; } - - m_expert = expert; } /*! @@ -1466,7 +1543,7 @@ void PatchKernel::setExpert(bool expert) */ bool PatchKernel::isExpert() const { - return m_expert; + return (m_adaptionMode == ADAPTION_MANUAL); } /*! @@ -1927,7 +2004,7 @@ PatchKernel::VertexIterator PatchKernel::addVertex(Vertex &&source, long id) */ PatchKernel::VertexIterator PatchKernel::addVertex(const std::array &coords, long id) { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return vertexEnd(); } @@ -2017,7 +2094,7 @@ PatchKernel::VertexIterator PatchKernel::_addInternalVertex(const std::array &coords, long id) { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return vertexEnd(); } @@ -2059,7 +2136,7 @@ void PatchKernel::_restoreInternalVertex(const VertexIterator &iterator, const s */ bool PatchKernel::deleteVertex(long id) { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return false; } @@ -2217,7 +2294,7 @@ std::vector PatchKernel::findOrphanVertices() */ bool PatchKernel::deleteOrphanVertices() { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return false; } @@ -2237,7 +2314,7 @@ bool PatchKernel::deleteOrphanVertices() std::vector PatchKernel::collapseCoincidentVertices() { std::vector collapsedVertices; - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return collapsedVertices; } @@ -2326,7 +2403,7 @@ std::vector PatchKernel::collapseCoincidentVertices() */ bool PatchKernel::deleteCoincidentVertices() { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return false; } @@ -2911,7 +2988,7 @@ PatchKernel::CellIterator PatchKernel::addCell(ElementType type, const std::vect PatchKernel::CellIterator PatchKernel::addCell(ElementType type, std::unique_ptr &&connectStorage, long id) { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return cellEnd(); } @@ -3034,7 +3111,7 @@ void PatchKernel::setAddedCellAlterationFlags(long id) PatchKernel::CellIterator PatchKernel::restoreCell(ElementType type, std::unique_ptr &&connectStorage, long id) { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return cellEnd(); } @@ -3105,7 +3182,7 @@ void PatchKernel::setRestoredCellAlterationFlags(long id) */ bool PatchKernel::deleteCell(long id) { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return false; } @@ -4524,7 +4601,7 @@ PatchKernel::InterfaceIterator PatchKernel::addInterface(ElementType type, std::unique_ptr &&connectStorage, long id) { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return interfaceEnd(); } @@ -4606,7 +4683,7 @@ PatchKernel::InterfaceIterator PatchKernel::restoreInterface(ElementType type, std::unique_ptr &&connectStorage, long id) { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return interfaceEnd(); } @@ -4667,7 +4744,7 @@ void PatchKernel::setRestoredInterfaceAlterationFlags(long id) */ bool PatchKernel::deleteInterface(long id) { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return false; } @@ -4787,7 +4864,7 @@ std::vector PatchKernel::findOrphanInterfaces() const */ bool PatchKernel::deleteOrphanInterfaces() { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return false; } @@ -4929,9 +5006,9 @@ void PatchKernel::restoreVertices(std::istream &stream) // Restore kernel m_vertices.restoreKernel(stream); - // Enable advanced editing - bool originalExpertStatus = isExpert(); - setExpert(true); + // Enable manual adaption + AdaptionMode previousAdaptionMode = getAdaptionMode(); + setAdaptionMode(ADAPTION_MANUAL); // Restore vertices long nVertices = m_vertices.size(); @@ -4970,8 +5047,8 @@ void PatchKernel::restoreVertices(std::istream &stream) utils::binary::read(stream, dummyLastInternalVertexId); #endif - // Set original advanced editing status - setExpert(originalExpertStatus); + // Restore previous adaption mode + setAdaptionMode(previousAdaptionMode); } /*! @@ -5030,9 +5107,9 @@ void PatchKernel::restoreCells(std::istream &stream) // Restore kernel m_cells.restoreKernel(stream); - // Enable advanced editing - bool originalExpertStatus = isExpert(); - setExpert(true); + // Enable manual adaption + AdaptionMode previousAdaptionMode = getAdaptionMode(); + setAdaptionMode(ADAPTION_MANUAL); // Restore cells long nCells = m_cells.size(); @@ -5091,8 +5168,8 @@ void PatchKernel::restoreCells(std::istream &stream) // Update adjacencies updateAdjacencies(); - // Set original advanced editing status - setExpert(originalExpertStatus); + // Restore previous adaption mode + setAdaptionMode(previousAdaptionMode); } /*! @@ -5145,9 +5222,9 @@ void PatchKernel::restoreInterfaces(std::istream &stream) // Restore kernel m_interfaces.restoreKernel(stream); - // Enable advanced editing - bool originalExpertStatus = isExpert(); - setExpert(true); + // Enable manual adaption + AdaptionMode previousAdaptionMode = getAdaptionMode(); + setAdaptionMode(ADAPTION_MANUAL); // Restore interfaces long nInterfaces = m_interfaces.size(); @@ -5184,8 +5261,8 @@ void PatchKernel::restoreInterfaces(std::istream &stream) unsetCellAlterationFlags(FLAG_INTERFACES_DIRTY); m_alteredInterfaces.clear(); - // Set original advanced editing status - setExpert(originalExpertStatus); + // Restore previous adaption mode + setAdaptionMode(previousAdaptionMode); } /*! @@ -5335,7 +5412,7 @@ bool PatchKernel::_enableCellBalancing(long id, bool enabled) */ bool PatchKernel::sortVertices() { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return false; } @@ -5366,7 +5443,7 @@ bool PatchKernel::sortVertices() */ bool PatchKernel::sortCells() { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return false; } @@ -5395,7 +5472,7 @@ bool PatchKernel::sortCells() */ bool PatchKernel::sortInterfaces() { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return false; } @@ -5428,7 +5505,7 @@ bool PatchKernel::sort() */ bool PatchKernel::squeezeVertices() { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return false; } @@ -5448,7 +5525,7 @@ bool PatchKernel::squeezeVertices() */ bool PatchKernel::squeezeCells() { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return false; } @@ -5468,7 +5545,7 @@ bool PatchKernel::squeezeCells() */ bool PatchKernel::squeezeInterfaces() { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return false; } @@ -6428,9 +6505,9 @@ void PatchKernel::updateInterfaces(bool forcedUpdated) // Update interfaces if (interfacesDirty) { - // Enable advanced editing - bool originalExpertStatus = isExpert(); - setExpert(true); + // Enable manual adaption + AdaptionMode previousAdaptionMode = getAdaptionMode(); + setAdaptionMode(ADAPTION_MANUAL); // Prune stale interfaces pruneStaleInterfaces(); @@ -6442,8 +6519,8 @@ void PatchKernel::updateInterfaces(bool forcedUpdated) unsetCellAlterationFlags(FLAG_INTERFACES_DIRTY); m_alteredInterfaces.clear(); - // Set original advanced editing status - setExpert(originalExpertStatus); + // Restore previous adaption mode + setAdaptionMode(previousAdaptionMode); } else { initializeInterfaces(currentStrategy); } @@ -8271,14 +8348,17 @@ bool PatchKernel::dump(std::ostream &stream) const // Spawn status utils::binary::write(stream, m_spawnStatus); - // Adaption status + // Adaption information + 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 @@ -8369,13 +8449,18 @@ void PatchKernel::restore(std::istream &stream, bool reregister) // Spawn status utils::binary::read(stream, m_spawnStatus); - // Adaption status + // Adaption information + 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 cab4daf44a..03717ef9a3 100644 --- a/src/patchkernel/patch_kernel.hpp +++ b/src/patchkernel/patch_kernel.hpp @@ -338,22 +338,41 @@ friend class PatchManager; SPAWN_DONE }; + /*! + Adaption mode + */ + enum AdaptionMode { + ADAPTION_DISABLED = -1, //! No adaption can be performed + ADAPTION_AUTOMATIC, //! Adaption is performed specifying which cells should be + //! refined/coarsen and then the patch will perform all the + //! alterations needed to fulfill the adaption requests + ADAPTION_MANUAL, //! Allows to use low level function to add and delete individual + //! cells and vertices. It's up to the user to guarantee the + //! consistency of the patch + }; + /*! Adaption status */ enum AdaptionStatus { - ADAPTION_UNSUPPORTED = -1, ADAPTION_CLEAN, ADAPTION_DIRTY, ADAPTION_PREPARED, 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 @@ -388,6 +407,7 @@ friend class PatchManager; std::vector spawn(bool trackSpawn); bool isAdaptionSupported() const; + AdaptionMode getAdaptionMode() const; AdaptionStatus getAdaptionStatus(bool global = false) const; std::vector adaption(bool trackAdaption = true, bool squeezeStorage = false); std::vector adaptionPrepare(bool trackAdaption = true); @@ -403,7 +423,7 @@ friend class PatchManager; void enableCellBalancing(long id, bool enabled); bool isDirty(bool global = false) const; - bool isExpert() const; + BITPIT_DEPRECATED(bool isExpert() const); int getId() const; int getDimension() const; @@ -737,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; @@ -801,13 +822,13 @@ friend class PatchManager; AlterationFlagsStorage m_alteredInterfaces; #if BITPIT_ENABLE_MPI==1 - PatchKernel(MPI_Comm communicator, std::size_t haloSize, bool expert); - PatchKernel(int dimension, MPI_Comm communicator, std::size_t haloSize, bool expert); - PatchKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize, bool expert); + 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(bool expert); - PatchKernel(int dimension, bool expert); - PatchKernel(int id, int dimension, bool expert); + PatchKernel(AdaptionMode adaptionMode); + PatchKernel(int dimension, AdaptionMode adaptionMode); + PatchKernel(int id, int dimension, AdaptionMode adaptionMode); #endif PatchKernel(const PatchKernel &other); PatchKernel & operator=(const PatchKernel &other) = delete; @@ -899,6 +920,7 @@ friend class PatchManager; void setSpawnStatus(SpawnStatus status); virtual std::vector _spawn(bool trackAdaption); + void setAdaptionMode(AdaptionMode mode); void setAdaptionStatus(AdaptionStatus status); virtual std::vector _adaptionPrepare(bool trackAdaption); virtual std::vector _adaptionAlter(bool trackAdaption); @@ -926,7 +948,7 @@ friend class PatchManager; virtual void _writePrepare(); virtual void _writeFinalize(); - void setExpert(bool expert); + BITPIT_DEPRECATED(void setExpert(bool expert)); void extractEnvelope(PatchKernel &envelope) const; @@ -937,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); @@ -1006,10 +1029,9 @@ friend class PatchManager; SpawnStatus m_spawnStatus; + AdaptionMode m_adaptionMode; AdaptionStatus m_adaptionStatus; - bool m_expert; - int m_id; int m_dimension; @@ -1020,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.tpp b/src/patchkernel/patch_kernel.tpp index fba80ddf17..13834b6024 100644 --- a/src/patchkernel/patch_kernel.tpp +++ b/src/patchkernel/patch_kernel.tpp @@ -53,7 +53,7 @@ std::unique_ptr PatchKernel::clone(const patch_t *original) template bool PatchKernel::deleteCells(const IdStorage &ids) { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return false; } @@ -104,7 +104,7 @@ bool PatchKernel::deleteCells(const IdStorage &ids) template bool PatchKernel::deleteVertices(const IdStorage &ids) { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return false; } @@ -155,7 +155,7 @@ bool PatchKernel::deleteVertices(const IdStorage &ids) template bool PatchKernel::deleteInterfaces(const IdStorage &ids) { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return false; } diff --git a/src/patchkernel/patch_kernel_parallel.cpp b/src/patchkernel/patch_kernel_parallel.cpp index f30c49f469..88d07bf9af 100644 --- a/src/patchkernel/patch_kernel_parallel.cpp +++ b/src/patchkernel/patch_kernel_parallel.cpp @@ -349,7 +349,7 @@ void PatchKernel::_setHaloSize(std::size_t haloSize) */ PatchKernel::VertexIterator PatchKernel::internalVertex2GhostVertex(long id, int owner) { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return m_vertices.end(); } @@ -390,7 +390,7 @@ PatchKernel::VertexIterator PatchKernel::internalVertex2GhostVertex(long id, int */ PatchKernel::VertexIterator PatchKernel::ghostVertex2InternalVertex(long id) { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return m_vertices.end(); } @@ -469,7 +469,7 @@ const Vertex & PatchKernel::getFirstGhostVertex() const */ PatchKernel::VertexIterator PatchKernel::restoreVertex(const std::array &coords, int owner, long id) { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return vertexEnd(); } @@ -616,7 +616,7 @@ void PatchKernel::updateFirstGhostVertexId() */ PatchKernel::CellIterator PatchKernel::internalCell2GhostCell(long id, int owner, int haloLayer) { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return m_cells.end(); } @@ -657,7 +657,7 @@ PatchKernel::CellIterator PatchKernel::internalCell2GhostCell(long id, int owner */ PatchKernel::CellIterator PatchKernel::ghostCell2InternalCell(long id) { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return m_cells.end(); } @@ -1010,7 +1010,7 @@ PatchKernel::CellIterator PatchKernel::addCell(ElementType type, const std::vect PatchKernel::CellIterator PatchKernel::addCell(ElementType type, std::unique_ptr &&connectStorage, int owner, int haloLayer, long id) { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return cellEnd(); } @@ -1109,7 +1109,7 @@ PatchKernel::CellIterator PatchKernel::_addGhostCell(ElementType type, std::uniq PatchKernel::CellIterator PatchKernel::restoreCell(ElementType type, std::unique_ptr &&connectStorage, int owner, int haloLayer, long id) { - if (!isExpert()) { + if (getAdaptionMode() != ADAPTION_MANUAL) { return cellEnd(); } @@ -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 cf84bd2254..3ffa33d24a 100644 --- a/src/patchkernel/point_kernel.cpp +++ b/src/patchkernel/point_kernel.cpp @@ -37,18 +37,19 @@ namespace bitpit { \param communicator is the communicator to be used for exchanging data among the processes. If a null comunicator is provided, a serial patch will be created - \param expert if true, the expert mode will be enabled + \param adaptionMode is the adaption mode that will be used for the patch */ -PointKernel::PointKernel(MPI_Comm communicator, bool expert) - : PatchKernel(communicator, 0, expert) +PointKernel::PointKernel(MPI_Comm communicator, + AdaptionMode adaptionMode, PartitioningMode partitioningMode) + : PatchKernel(communicator, 0, adaptionMode, partitioningMode) #else /*! Creates a patch. - \param expert if true, the expert mode will be enabled + \param adaptionMode is the adaption mode that will be used for the patch */ -PointKernel::PointKernel(bool expert) - : PatchKernel(expert) +PointKernel::PointKernel(AdaptionMode adaptionMode) + : PatchKernel(adaptionMode) #endif { initialize(); @@ -66,19 +67,24 @@ PointKernel::PointKernel(bool expert) \param communicator is the communicator to be used for exchanging data among the processes. If a null comunicator is provided, a serial patch will be created - \param expert if true, the expert mode will be enabled + \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, bool expert) - : PatchKernel(dimension, communicator, 0, expert) +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 expert if true, the expert mode will be enabled + \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, bool expert) - : PatchKernel(dimension, expert) +PointKernel::PointKernel(int dimension, AdaptionMode adaptionMode) + : PatchKernel(dimension, adaptionMode) #endif { initialize(); @@ -97,20 +103,23 @@ PointKernel::PointKernel(int dimension, bool expert) \param communicator is the communicator to be used for exchanging data among the processes. If a null comunicator is provided, a serial patch will be created - \param expert if true, the expert mode will be enabled + \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, bool expert) - : PatchKernel(id, dimension, communicator, 0, expert) +PointKernel::PointKernel(int id, int dimension, MPI_Comm communicator, + AdaptionMode adaptionMode, PartitioningMode partitioningMode) + : PatchKernel(id, dimension, communicator, 0, adaptionMode, partitioningMode) #else /*! Creates a patch. \param id is the id that will be assigned to the patch \param dimension is the dimension of the patch - \param expert if true, the expert mode will be enabled + \param adaptionMode is the adaption mode that will be used for the patch */ -PointKernel::PointKernel(int id, int dimension, bool expert) - : PatchKernel(id, dimension, expert) +PointKernel::PointKernel(int id, int dimension, AdaptionMode adaptionMode) + : PatchKernel(id, dimension, adaptionMode) #endif { } diff --git a/src/patchkernel/point_kernel.hpp b/src/patchkernel/point_kernel.hpp index 6bb8e6c253..d9157066b1 100644 --- a/src/patchkernel/point_kernel.hpp +++ b/src/patchkernel/point_kernel.hpp @@ -43,13 +43,13 @@ class PointKernel : public PatchKernel { protected: #if BITPIT_ENABLE_MPI==1 - PointKernel(MPI_Comm communicator, bool expert); - PointKernel(int dimension, MPI_Comm communicator, bool expert); - PointKernel(int id, int dimension, MPI_Comm communicator, bool expert); + 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(bool expert); - PointKernel(int dimension, bool expert); - PointKernel(int id, int dimension, bool expert); + PointKernel(AdaptionMode adaptionMode); + PointKernel(int dimension, AdaptionMode adaptionMode); + PointKernel(int id, int dimension, AdaptionMode adaptionMode); #endif private: diff --git a/src/patchkernel/surface_kernel.cpp b/src/patchkernel/surface_kernel.cpp index c7e6b8768a..ebe37f6d1b 100644 --- a/src/patchkernel/surface_kernel.cpp +++ b/src/patchkernel/surface_kernel.cpp @@ -70,18 +70,21 @@ const unsigned short SurfaceKernel::SELECT_ALL = 3; will be created \param haloSize is the size, expressed in number of layers, of the ghost cells halo - \param expert if true, the expert mode will be enabled + \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, bool expert) - : PatchKernel(communicator, haloSize, expert) +SurfaceKernel::SurfaceKernel(MPI_Comm communicator, std::size_t haloSize, + AdaptionMode adaptionMode, PartitioningMode partitioningMode) + : PatchKernel(communicator, haloSize, adaptionMode, partitioningMode) #else /*! Creates a patch. - \param expert if true, the expert mode will be enabled + \param adaptionMode is the adaption mode that will be used for the patch */ -SurfaceKernel::SurfaceKernel(bool expert) - : PatchKernel(expert) +SurfaceKernel::SurfaceKernel(AdaptionMode adaptionMode) + : PatchKernel(adaptionMode) #endif { initialize(); @@ -101,19 +104,22 @@ SurfaceKernel::SurfaceKernel(bool expert) will be created \param haloSize is the size, expressed in number of layers, of the ghost cells halo - \param expert if true, the expert mode will be enabled + \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, bool expert) - : PatchKernel(dimension, communicator, haloSize, expert) +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. \param dimension is the dimension of the patch - \param expert if true, the expert mode will be enabled + \param adaptionMode is the adaption mode that will be used for the patch */ -SurfaceKernel::SurfaceKernel(int dimension, bool expert) - : PatchKernel(dimension, expert) +SurfaceKernel::SurfaceKernel(int dimension, AdaptionMode adaptionMode) + : PatchKernel(dimension, adaptionMode) #endif { initialize(); @@ -134,20 +140,23 @@ SurfaceKernel::SurfaceKernel(int dimension, bool expert) will be created \param haloSize is the size, expressed in number of layers, of the ghost cells halo - \param expert if true, the expert mode will be enabled + \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, bool expert) - : PatchKernel(id, dimension, communicator, haloSize, expert) +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. \param id is the id that will be assigned to the patch \param dimension is the dimension of the patch - \param expert if true, the expert mode will be enabled + \param adaptionMode is the adaption mode that will be used for the patch */ -SurfaceKernel::SurfaceKernel(int id, int dimension, bool expert) - : PatchKernel(id, dimension, expert) +SurfaceKernel::SurfaceKernel(int id, int dimension, AdaptionMode adaptionMode) + : PatchKernel(id, dimension, adaptionMode) #endif { } diff --git a/src/patchkernel/surface_kernel.hpp b/src/patchkernel/surface_kernel.hpp index de40ed5bcf..f8e4defc78 100644 --- a/src/patchkernel/surface_kernel.hpp +++ b/src/patchkernel/surface_kernel.hpp @@ -99,13 +99,13 @@ class SurfaceKernel : public PatchKernel { protected: #if BITPIT_ENABLE_MPI==1 - SurfaceKernel(MPI_Comm communicator, std::size_t haloSize, bool expert); - SurfaceKernel(int dimension, MPI_Comm communicator, std::size_t haloSize, bool expert); - SurfaceKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize, bool expert); + 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(bool expert); - SurfaceKernel(int dimension, bool expert); - SurfaceKernel(int id, int dimension, bool expert); + SurfaceKernel(AdaptionMode adaptionMode); + SurfaceKernel(int dimension, AdaptionMode adaptionMode); + SurfaceKernel(int id, int dimension, AdaptionMode adaptionMode); #endif }; diff --git a/src/patchkernel/volume_kernel.cpp b/src/patchkernel/volume_kernel.cpp index 9d5733dc5c..2693bdff5c 100644 --- a/src/patchkernel/volume_kernel.cpp +++ b/src/patchkernel/volume_kernel.cpp @@ -49,18 +49,21 @@ namespace bitpit { will be created \param haloSize is the size, expressed in number of layers, of the ghost cells halo - \param expert if true, the expert mode will be enabled + \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, bool expert) - : PatchKernel(communicator, haloSize, expert) +VolumeKernel::VolumeKernel(MPI_Comm communicator, std::size_t haloSize, + AdaptionMode adaptionMode, PartitioningMode partitioningMode) + : PatchKernel(communicator, haloSize, adaptionMode, partitioningMode) #else /*! Creates a patch. - \param expert if true, the expert mode will be enabled + \param adaptionMode is the adaption mode that will be used for the patch */ -VolumeKernel::VolumeKernel(bool expert) - : PatchKernel(expert) +VolumeKernel::VolumeKernel(AdaptionMode adaptionMode) + : PatchKernel(adaptionMode) #endif { } @@ -79,19 +82,22 @@ VolumeKernel::VolumeKernel(bool expert) will be created \param haloSize is the size, expressed in number of layers, of the ghost cells halo - \param expert if true, the expert mode will be enabled + \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, bool expert) - : PatchKernel(dimension, communicator, haloSize, expert) +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. \param dimension is the dimension of the patch - \param expert if true, the expert mode will be enabled + \param adaptionMode is the adaption mode that will be used for the patch */ -VolumeKernel::VolumeKernel(int dimension, bool expert) - : PatchKernel(dimension, expert) +VolumeKernel::VolumeKernel(int dimension, AdaptionMode adaptionMode) + : PatchKernel(dimension, adaptionMode) #endif { } @@ -111,20 +117,23 @@ VolumeKernel::VolumeKernel(int dimension, bool expert) will be created \param haloSize is the size, expressed in number of layers, of the ghost cells halo - \param expert if true, the expert mode will be enabled + \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, bool expert) - : PatchKernel(id, dimension, communicator, haloSize, expert) +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. \param id is the id that will be assigned to the patch \param dimension is the dimension of the patch - \param expert if true, the expert mode will be enabled + \param adaptionMode is the adaption mode that will be used for the patch */ -VolumeKernel::VolumeKernel(int id, int dimension, bool expert) - : PatchKernel(id, dimension, expert) +VolumeKernel::VolumeKernel(int id, int dimension, AdaptionMode adaptionMode) + : PatchKernel(id, dimension, adaptionMode) #endif { } diff --git a/src/patchkernel/volume_kernel.hpp b/src/patchkernel/volume_kernel.hpp index d0b596d335..e3d73fc6bd 100644 --- a/src/patchkernel/volume_kernel.hpp +++ b/src/patchkernel/volume_kernel.hpp @@ -56,13 +56,13 @@ class VolumeKernel : public PatchKernel { protected: #if BITPIT_ENABLE_MPI==1 - VolumeKernel(MPI_Comm communicator, std::size_t haloSize, bool expert); - VolumeKernel(int dimension, MPI_Comm communicator, std::size_t haloSize, bool expert); - VolumeKernel(int id, int dimension, MPI_Comm communicator, std::size_t haloSize, bool expert); + 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(bool expert); - VolumeKernel(int dimension, bool expert); - VolumeKernel(int id, int dimension, bool expert); + VolumeKernel(AdaptionMode adaptionMode); + VolumeKernel(int dimension, AdaptionMode adaptionMode); + VolumeKernel(int id, int dimension, AdaptionMode adaptionMode); #endif }; diff --git a/src/pointcloud/pointcloud.cpp b/src/pointcloud/pointcloud.cpp index 7975c1dd00..2690f74496 100644 --- a/src/pointcloud/pointcloud.cpp +++ b/src/pointcloud/pointcloud.cpp @@ -49,13 +49,13 @@ namespace bitpit { among the processes */ PointCloud::PointCloud(MPI_Comm communicator) - : PointKernel(communicator, true) + : PointKernel(communicator, ADAPTION_MANUAL, PARTITIONING_DISABLED) #else /*! Creates an uninitialized serial patch. */ PointCloud::PointCloud() - : PointKernel(true) + : PointKernel(ADAPTION_MANUAL) #endif { } @@ -73,7 +73,7 @@ PointCloud::PointCloud() among the processes */ PointCloud::PointCloud(int dimension, MPI_Comm communicator) - : PointKernel(PatchManager::AUTOMATIC_ID, dimension, communicator, true) + : PointKernel(PatchManager::AUTOMATIC_ID, dimension, communicator, ADAPTION_MANUAL, PARTITIONING_DISABLED) #else /*! Creates a patch. @@ -81,7 +81,7 @@ PointCloud::PointCloud(int dimension, MPI_Comm communicator) \param dimension is the dimension of the patch */ PointCloud::PointCloud(int dimension) - : PointKernel(PatchManager::AUTOMATIC_ID, dimension, true) + : PointKernel(PatchManager::AUTOMATIC_ID, dimension, ADAPTION_MANUAL) #endif { } @@ -100,7 +100,7 @@ PointCloud::PointCloud(int dimension) among the processes */ PointCloud::PointCloud(int id, int dimension, MPI_Comm communicator) - : PointKernel(id, dimension, communicator, true) + : PointKernel(id, dimension, communicator, ADAPTION_MANUAL, PARTITIONING_DISABLED) #else /*! Creates a patch. @@ -109,7 +109,7 @@ PointCloud::PointCloud(int id, int dimension, MPI_Comm communicator) \param dimension is the dimension of the patch */ PointCloud::PointCloud(int id, int dimension) - : PointKernel(id, dimension, true) + : PointKernel(id, dimension, ADAPTION_MANUAL) #endif { } @@ -126,7 +126,7 @@ PointCloud::PointCloud(int id, int dimension) among the processes */ PointCloud::PointCloud(std::istream &stream, MPI_Comm communicator) - : PointKernel(communicator, false) + : PointKernel(communicator, ADAPTION_MANUAL, PARTITIONING_DISABLED) #else /*! Creates a patch restoring the patch saved in the specified stream. @@ -134,7 +134,7 @@ PointCloud::PointCloud(std::istream &stream, MPI_Comm communicator) \param stream is the stream to read from */ PointCloud::PointCloud(std::istream &stream) - : PointKernel(false) + : PointKernel(ADAPTION_MANUAL) #endif { // Restore the patch @@ -151,20 +151,6 @@ std::unique_ptr PointCloud::clone() const return std::unique_ptr(new PointCloud(*this)); } -/*! - * Enables or disables expert mode. - * - * When expert mode is enabled, it will be possible to change the - * patch using low level functions (e.g., it will be possible to - * add individual cells, add vertices, delete cells, ...). - * - * \param expert if true, the expert mode will be enabled - */ -void PointCloud::setExpert(bool expert) -{ - PointKernel::setExpert(expert); -} - /*! * Get the version associated to the binary dumps. * diff --git a/src/pointcloud/pointcloud.hpp b/src/pointcloud/pointcloud.hpp index 2a258e7285..a0d5795ecc 100644 --- a/src/pointcloud/pointcloud.hpp +++ b/src/pointcloud/pointcloud.hpp @@ -53,7 +53,7 @@ class PointCloud : public PointKernel { std::unique_ptr clone() const override; // Setters - void setExpert(bool expert); + using PointKernel::setExpert; // Search algorithms long locatePoint(const std::array &point) const override; diff --git a/src/surfunstructured/surfunstructured.cpp b/src/surfunstructured/surfunstructured.cpp index b3eea69d36..5e7620fd64 100644 --- a/src/surfunstructured/surfunstructured.cpp +++ b/src/surfunstructured/surfunstructured.cpp @@ -53,13 +53,13 @@ namespace bitpit { cells halo */ SurfUnstructured::SurfUnstructured(MPI_Comm communicator, std::size_t haloSize) - : SurfaceKernel(communicator, haloSize, true) + : SurfaceKernel(communicator, haloSize, ADAPTION_MANUAL, PARTITIONING_ENABLED) #else /*! Creates an uninitialized serial patch. */ SurfUnstructured::SurfUnstructured() - : SurfaceKernel(true) + : SurfaceKernel(ADAPTION_MANUAL) #endif { } @@ -79,7 +79,7 @@ SurfUnstructured::SurfUnstructured() cells halo */ SurfUnstructured::SurfUnstructured(int dimension, MPI_Comm communicator, std::size_t haloSize) - : SurfaceKernel(PatchManager::AUTOMATIC_ID, dimension, communicator, haloSize, true) + : SurfUnstructured(PatchManager::AUTOMATIC_ID, dimension, communicator, haloSize) #else /*! Creates a patch. @@ -87,7 +87,7 @@ SurfUnstructured::SurfUnstructured(int dimension, MPI_Comm communicator, std::si \param dimension is the dimension of the patch */ SurfUnstructured::SurfUnstructured(int dimension) - : SurfaceKernel(PatchManager::AUTOMATIC_ID, dimension, true) + : SurfUnstructured(PatchManager::AUTOMATIC_ID, dimension) #endif { } @@ -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, true) + : SurfaceKernel(id, dimension, communicator, haloSize, ADAPTION_MANUAL, PARTITIONING_ENABLED) #else /*! Creates a patch. @@ -117,7 +117,7 @@ SurfUnstructured::SurfUnstructured(int id, int dimension, MPI_Comm communicator, \param dimension is the dimension of the patch */ SurfUnstructured::SurfUnstructured(int id, int dimension) - : SurfaceKernel(id, dimension, true) + : SurfaceKernel(id, dimension, ADAPTION_MANUAL) #endif { } @@ -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, false) + : SurfaceKernel(communicator, haloSize, ADAPTION_MANUAL, PARTITIONING_ENABLED) #else /*! Creates a patch restoring the patch saved in the specified stream. @@ -144,7 +144,7 @@ SurfUnstructured::SurfUnstructured(std::istream &stream, MPI_Comm communicator, \param stream is the stream to read from */ SurfUnstructured::SurfUnstructured(std::istream &stream) - : SurfaceKernel(false) + : SurfaceKernel(ADAPTION_MANUAL) #endif { // Restore the patch @@ -161,20 +161,6 @@ std::unique_ptr SurfUnstructured::clone() const return std::unique_ptr(new SurfUnstructured(*this)); } -/*! - * Enables or disables expert mode. - * - * When expert mode is enabled, it will be possible to change the - * patch using low level functions (e.g., it will be possible to - * add individual cells, add vertices, delete cells, ...). - * - * \param expert if true, the expert mode will be enabled - */ -void SurfUnstructured::setExpert(bool expert) -{ - SurfaceKernel::setExpert(expert); -} - /*! * Get the version associated to the binary dumps. * diff --git a/src/surfunstructured/surfunstructured.hpp b/src/surfunstructured/surfunstructured.hpp index 749344cd0b..f72b4b0c03 100644 --- a/src/surfunstructured/surfunstructured.hpp +++ b/src/surfunstructured/surfunstructured.hpp @@ -55,7 +55,7 @@ class SurfUnstructured : public SurfaceKernel { std::unique_ptr clone() const override; // Setters - void setExpert(bool expert); + using SurfaceKernel::setExpert; // Search algorithms long locatePoint(const std::array &point) const override; diff --git a/src/volcartesian/volcartesian.cpp b/src/volcartesian/volcartesian.cpp index 038f215209..b9c93458d2 100644 --- a/src/volcartesian/volcartesian.cpp +++ b/src/volcartesian/volcartesian.cpp @@ -65,9 +65,9 @@ namespace bitpit { */ VolCartesian::VolCartesian() #if BITPIT_ENABLE_MPI==1 - : VolumeKernel(MPI_COMM_NULL, 0, false) + : VolumeKernel(MPI_COMM_NULL, 0, ADAPTION_DISABLED, PARTITIONING_DISABLED) #else - : VolumeKernel(false) + : VolumeKernel(ADAPTION_DISABLED) #endif { initialize(); @@ -103,9 +103,9 @@ 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, false) + : VolumeKernel(id, dimension, MPI_COMM_NULL, 0, ADAPTION_DISABLED, PARTITIONING_DISABLED) #else - : VolumeKernel(id, dimension, false) + : VolumeKernel(id, dimension, ADAPTION_DISABLED) #endif { initialize(); @@ -144,9 +144,9 @@ 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, false) + : VolumeKernel(id, dimension, MPI_COMM_NULL, 0, ADAPTION_DISABLED, PARTITIONING_DISABLED) #else - : VolumeKernel(id, dimension, false) + : VolumeKernel(id, dimension, ADAPTION_DISABLED) #endif { initialize(); @@ -185,9 +185,9 @@ 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, false) + : VolumeKernel(id, dimension, MPI_COMM_NULL, 0, ADAPTION_DISABLED, PARTITIONING_DISABLED) #else - : VolumeKernel(id, dimension, false) + : VolumeKernel(id, dimension, ADAPTION_DISABLED) #endif { initialize(); @@ -206,9 +206,9 @@ VolCartesian::VolCartesian(int id, int dimension, */ VolCartesian::VolCartesian(std::istream &stream) #if BITPIT_ENABLE_MPI==1 - : VolumeKernel(MPI_COMM_NULL, 0, false) + : VolumeKernel(MPI_COMM_NULL, 0, ADAPTION_DISABLED, PARTITIONING_DISABLED) #else - : VolumeKernel(false) + : VolumeKernel(ADAPTION_DISABLED) #endif { initialize(); @@ -344,8 +344,9 @@ void VolCartesian::_updateInterfaces() const ReferenceElementInfo &interfaceTypeInfo = ReferenceElementInfo::getInfo(interfaceType); const int nInterfaceVertices = interfaceTypeInfo.nVertices; - // Enable advanced editing - setExpert(true); + // Enable manual adaption + AdaptionMode previousAdaptionMode = getAdaptionMode(); + setAdaptionMode(ADAPTION_MANUAL); // Initialize interfaces for (Cell &cell : getCells()) { @@ -404,8 +405,8 @@ void VolCartesian::_updateInterfaces() } } - // Disable advanced editing - setExpert(false); + // Restore previous adaption mode + setAdaptionMode(previousAdaptionMode); } } @@ -1009,15 +1010,16 @@ std::vector VolCartesian::_spawn(bool trackSpawn) return updateInfo; } - // Enable advanced editing - setExpert(true); + // Enable manual adaption + AdaptionMode previousAdaptionMode = getAdaptionMode(); + setAdaptionMode(ADAPTION_MANUAL); // Definition of the mesh addVertices(); addCells(); - // Disable advanced editing - setExpert(false); + // Restore previous adaption mode + setAdaptionMode(previousAdaptionMode); // Adaption info if (trackSpawn) { diff --git a/src/voloctree/voloctree.cpp b/src/voloctree/voloctree.cpp index 312301fd5b..0f9b2d0c23 100644 --- a/src/voloctree/voloctree.cpp +++ b/src/voloctree/voloctree.cpp @@ -74,13 +74,13 @@ namespace bitpit { cells halo */ VolOctree::VolOctree(MPI_Comm communicator, std::size_t haloSize) - : VolumeKernel(communicator, haloSize, false) + : VolumeKernel(communicator, haloSize, ADAPTION_AUTOMATIC, PARTITIONING_ENABLED) #else /*! Creates an uninitialized serial patch. */ VolOctree::VolOctree() - : VolumeKernel(false) + : VolumeKernel(ADAPTION_AUTOMATIC) #endif { // Create the tree @@ -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, false) + : VolumeKernel(id, dimension, communicator, haloSize, ADAPTION_AUTOMATIC, PARTITIONING_ENABLED) #else /*! Creates a patch. @@ -181,7 +181,7 @@ VolOctree::VolOctree(int id, int dimension, const std::array &origin, \param dh is the maximum allowed cell size of the initial refinement */ VolOctree::VolOctree(int id, int dimension, const std::array &origin, double length, double dh) - : VolumeKernel(id, dimension, false) + : VolumeKernel(id, dimension, ADAPTION_AUTOMATIC) #endif { // Create the tree @@ -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, false) + : VolumeKernel(communicator, haloSize, ADAPTION_AUTOMATIC, PARTITIONING_ENABLED) #else /*! Creates a patch restoring the patch saved in the specified stream. @@ -251,7 +251,7 @@ VolOctree::VolOctree(std::istream &stream, MPI_Comm communicator, std::size_t ha \param stream is the stream to read from */ VolOctree::VolOctree(std::istream &stream) - : VolumeKernel(false) + : VolumeKernel(ADAPTION_AUTOMATIC) #endif { // Initialize the tree @@ -305,9 +305,9 @@ 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(), false) + : VolumeKernel(id, tree->getDim(), tree->getComm(), tree->getNofGhostLayers(), ADAPTION_AUTOMATIC, PARTITIONING_ENABLED) #else - : VolumeKernel(id, tree->getDim(), false) + : VolumeKernel(id, tree->getDim(), ADAPTION_AUTOMATIC) #endif { // Associate the tree @@ -489,9 +489,6 @@ void VolOctree::initialize() // This patch need to be spawn setSpawnStatus(SPAWN_NEEDED); - // This patch supports adaption - setAdaptionStatus(ADAPTION_CLEAN); - // Initialize the tolerance // // Since the patch re-implements the function to reset the tolerance, @@ -1392,8 +1389,9 @@ std::vector VolOctree::sync(bool trackChanges) } } - // Enable advanced editing - setExpert(true); + // Enable manual adaption + AdaptionMode previousAdaptionMode = getAdaptionMode(); + setAdaptionMode(ADAPTION_MANUAL); // Renumber cells renumberCells(renumberedOctants); @@ -1502,8 +1500,8 @@ std::vector VolOctree::sync(bool trackChanges) StitchInfo().swap(stitchInfo); - // Disable advanced editing - setExpert(false); + // Restore previous adaption mode + setAdaptionMode(previousAdaptionMode); // Track mesh adaption if (trackChanges) { @@ -2344,8 +2342,9 @@ void VolOctree::_restore(std::istream &stream) // Restore kernel of cell's containers m_cells.restoreKernel(stream); - // Activate expert mode - setExpert(true); + // Enable manual adaption + AdaptionMode previousAdaptionMode = getAdaptionMode(); + setAdaptionMode(ADAPTION_MANUAL); // Restore cells size_t nOctants = m_tree->getNumOctants(); @@ -2367,8 +2366,8 @@ void VolOctree::_restore(std::istream &stream) // Restore interfaces restoreInterfaces(stream); - // De-activate expert mode - setExpert(false); + // Restore previous adaption mode + setAdaptionMode(previousAdaptionMode); // // Restore bounding box diff --git a/src/volunstructured/volunstructured.cpp b/src/volunstructured/volunstructured.cpp index b55f4037b6..f1190e3a9f 100644 --- a/src/volunstructured/volunstructured.cpp +++ b/src/volunstructured/volunstructured.cpp @@ -54,13 +54,13 @@ namespace bitpit { cells halo */ VolUnstructured::VolUnstructured(MPI_Comm communicator, std::size_t haloSize) - : VolumeKernel(communicator, haloSize, true) + : VolumeKernel(communicator, haloSize, ADAPTION_MANUAL, PARTITIONING_ENABLED) #else /*! Creates an uninitialized serial patch. */ VolUnstructured::VolUnstructured() - : VolumeKernel(true) + : VolumeKernel(ADAPTION_MANUAL) #endif { } @@ -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, true) + : VolumeKernel(id, dimension, communicator, haloSize, ADAPTION_MANUAL, PARTITIONING_ENABLED) #else /*! Creates a patch. @@ -120,7 +120,7 @@ VolUnstructured::VolUnstructured(int id, int dimension, MPI_Comm communicator, s \param dimension is the dimension of the patch */ VolUnstructured::VolUnstructured(int id, int dimension) - : VolumeKernel(id, dimension, true) + : VolumeKernel(id, dimension, ADAPTION_MANUAL) #endif { } @@ -135,20 +135,6 @@ std::unique_ptr VolUnstructured::clone() const return std::unique_ptr(new VolUnstructured(*this)); } -/*! - * Enables or disables expert mode. - * - * When expert mode is enabled, it will be possible to change the - * patch using low level functions (e.g., it will be possible to - * add individual cells, add vertices, delete cells, ...). - * - * \param expert if true, the expert mode will be enabled - */ -void VolUnstructured::setExpert(bool expert) -{ - VolumeKernel::setExpert(expert); -} - /*! Evaluates the volume of the specified cell. diff --git a/src/volunstructured/volunstructured.hpp b/src/volunstructured/volunstructured.hpp index ab04346738..4e85137e22 100644 --- a/src/volunstructured/volunstructured.hpp +++ b/src/volunstructured/volunstructured.hpp @@ -50,7 +50,7 @@ class VolUnstructured : public VolumeKernel { std::unique_ptr clone() const override; - void setExpert(bool expert); + using VolumeKernel::setExpert; double evalCellVolume(long id) const override; double evalCellSize(long id) const override; 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() ; diff --git a/test/integration_tests/surfunstructured/test_surfunstructured_00001.cpp b/test/integration_tests/surfunstructured/test_surfunstructured_00001.cpp index 7053fb8aa4..99c09ba397 100644 --- a/test/integration_tests/surfunstructured/test_surfunstructured_00001.cpp +++ b/test/integration_tests/surfunstructured/test_surfunstructured_00001.cpp @@ -242,18 +242,6 @@ vector cell_list; // Counters // none -// ========================================================================== // -// INITIALIZE MESH PARAMETERS // -// ========================================================================== // -{ - // Scope variables ------------------------------------------------------ // - // none - - // Enable changes ------------------------------------------------------- // - mesh.setExpert(true); - //mesh.setParallel(1 ,0); -} - // ========================================================================== // // OUTPUT MESSAGE // // ========================================================================== // @@ -281,9 +269,6 @@ vector cell_list; #endif vector ring1, ring1_expected{6,7,8,21,22,23,30,31,32}; - // Set envelope attributes ---------------------------------------------- // - envelope.setExpert(true); - // Generate a dummy triangulation --------------------------------------- // log::cout() << "** Generating non-manifold surface triangulation" << endl; generateTestTriangulation(mesh); @@ -356,9 +341,6 @@ vector cell_list; #endif vector ring1, ring1_expected{6,8,21,22,23,30,31,32}; - // Set envelope attributes ---------------------------------------------- // - envelope.setExpert(true); - // Backup copy of cells ------------------------------------------------- // log::cout() << "** Removing cell ID 5, 7, and 17" << endl; cell_17 = mesh.getCell(17); @@ -441,9 +423,6 @@ vector cell_list; vector ring1, ring1_expected{4,6,7,19,20,21}; SurfUnstructured::CellIterator it; - // Set envelope attributes ---------------------------------------------- // - envelope.setExpert(true); - // Insert cells --------------------------------------------------------- // log::cout() << "** inserting previously deleted cells" << endl; it = mesh.addCell(cell_17); @@ -575,17 +554,6 @@ vector internal; // Counters int i; -// ========================================================================== // -// INITIALIZE MESH PARAMETERS // -// ========================================================================== // -{ - // Scope variables ------------------------------------------------------ // - // none - - // Enable changes ------------------------------------------------------- // - mesh.setExpert(true); -} - // ========================================================================== // // OUTPUT MESSAGE // // ========================================================================== // diff --git a/test/integration_tests/surfunstructured/test_surfunstructured_00002.cpp b/test/integration_tests/surfunstructured/test_surfunstructured_00002.cpp index be93c6a533..f98cd6665e 100644 --- a/test/integration_tests/surfunstructured/test_surfunstructured_00002.cpp +++ b/test/integration_tests/surfunstructured/test_surfunstructured_00002.cpp @@ -97,17 +97,6 @@ SurfUnstructured mesh(2); // Counters // none -// ========================================================================== // -// INITIALIZE MESH PARAMETERS // -// ========================================================================== // -{ - // Scope variables ------------------------------------------------------ // - // none - - // Enable changes ------------------------------------------------------- // - mesh.setExpert(true); -} - // ========================================================================== // // OUTPUT MESSAGE // // ========================================================================== // diff --git a/test/integration_tests/surfunstructured/test_surfunstructured_00003.cpp b/test/integration_tests/surfunstructured/test_surfunstructured_00003.cpp index ff659aa7d0..ff88fde4a1 100644 --- a/test/integration_tests/surfunstructured/test_surfunstructured_00003.cpp +++ b/test/integration_tests/surfunstructured/test_surfunstructured_00003.cpp @@ -96,17 +96,6 @@ SurfUnstructured mesh(2); // Counters // none -// ========================================================================== // -// INITIALIZE MESH PARAMETERS // -// ========================================================================== // -{ - // Scope variables ------------------------------------------------------ // - // none - - // Enable changes ------------------------------------------------------- // - mesh.setExpert(true); -} - // ========================================================================== // // OUTPUT MESSAGE // // ========================================================================== // @@ -232,17 +221,6 @@ SurfUnstructured mesh(1); // Counters // none -// ========================================================================== // -// INITIALIZE MESH PARAMETERS // -// ========================================================================== // -{ - // Scope variables ------------------------------------------------------ // - // none - - // Enable changes ------------------------------------------------------- // - mesh.setExpert(true); -} - // ========================================================================== // // OUTPUT MESSAGE // // ========================================================================== // diff --git a/test/integration_tests/surfunstructured/test_surfunstructured_00004.cpp b/test/integration_tests/surfunstructured/test_surfunstructured_00004.cpp index f045cf8ec4..f0b68f088e 100644 --- a/test/integration_tests/surfunstructured/test_surfunstructured_00004.cpp +++ b/test/integration_tests/surfunstructured/test_surfunstructured_00004.cpp @@ -107,18 +107,6 @@ int nV, nE; log::cout() << endl; } -// ========================================================================== // -// SET MESH ATTRIBUTES // -// ========================================================================== // -{ - // Scope variables ------------------------------------------------------ // - // none - - // Set mesh attributes -------------------------------------------------- // - mesh.setExpert(true); - edges.setExpert(true); -} - // ========================================================================== // // STEP#1 IMPORT MESH FROM STL FILE // // ========================================================================== // @@ -345,17 +333,6 @@ int nV, nS, nE; log::cout() << endl; } -// ========================================================================== // -// SET MESH ATTRIBUTES // -// ========================================================================== // -{ - // Scope variables ------------------------------------------------------ // - // none - - // Set mesh attributes -------------------------------------------------- // - mesh.setExpert(true); -} - // ========================================================================== // // STEP#1 IMPORT MESH FROM STL FILE // // ========================================================================== // diff --git a/test/integration_tests/surfunstructured/test_surfunstructured_00007.cpp b/test/integration_tests/surfunstructured/test_surfunstructured_00007.cpp index 88ca91eb45..af80faaf67 100644 --- a/test/integration_tests/surfunstructured/test_surfunstructured_00007.cpp +++ b/test/integration_tests/surfunstructured/test_surfunstructured_00007.cpp @@ -206,7 +206,6 @@ int subtest_001() #else SurfUnstructured mesh(2); #endif - mesh.setExpert(true); // Generate a Dummy Triangulation generateTestTriangulation(mesh); diff --git a/test/integration_tests/surfunstructured/test_surfunstructured_00008.cpp b/test/integration_tests/surfunstructured/test_surfunstructured_00008.cpp index 5ac46be99b..43f3f72940 100644 --- a/test/integration_tests/surfunstructured/test_surfunstructured_00008.cpp +++ b/test/integration_tests/surfunstructured/test_surfunstructured_00008.cpp @@ -64,7 +64,6 @@ int subtest_001( #else SurfUnstructured *mesh = new SurfUnstructured(2); #endif - mesh->setExpert(true); std::vector> verts(5); verts[0] = {{0,0,0}}; diff --git a/test/integration_tests/surfunstructured/test_surfunstructured_00009.cpp b/test/integration_tests/surfunstructured/test_surfunstructured_00009.cpp index b2abf2f02d..5287242212 100644 --- a/test/integration_tests/surfunstructured/test_surfunstructured_00009.cpp +++ b/test/integration_tests/surfunstructured/test_surfunstructured_00009.cpp @@ -53,7 +53,6 @@ int subtest_001() #else std::unique_ptr surfaceMesh(new SurfUnstructured (2)); #endif - surfaceMesh->setExpert(true); surfaceMesh->importSTL("./data/buddha.stl", STLReader::FormatUnknown, true); surfaceMesh->initializeAdjacencies(); surfaceMesh->getVTK().setName("skd_test_STL"); diff --git a/test/integration_tests/surfunstructured/test_surfunstructured_parallel_00001.cpp b/test/integration_tests/surfunstructured/test_surfunstructured_parallel_00001.cpp index 77ee598445..36143e44a2 100644 --- a/test/integration_tests/surfunstructured/test_surfunstructured_parallel_00001.cpp +++ b/test/integration_tests/surfunstructured/test_surfunstructured_parallel_00001.cpp @@ -707,18 +707,6 @@ SurfUnstructured mesh(2, MPI_COMM_WORLD); // Counters // none -// ========================================================================== // -// SET MESH ATTRIBUTES // -// ========================================================================== // -{ - // Scope variables ------------------------------------------------------ // - // none - - // Set expert mode ------------------------------------------------------ // - mesh.setExpert(true); - -} - // ========================================================================== // // OUTPUT MESSAGE // // ========================================================================== // diff --git a/test/integration_tests/surfunstructured/test_surfunstructured_parallel_00006.cpp b/test/integration_tests/surfunstructured/test_surfunstructured_parallel_00006.cpp index 95303f2483..8cc2410fc6 100644 --- a/test/integration_tests/surfunstructured/test_surfunstructured_parallel_00006.cpp +++ b/test/integration_tests/surfunstructured/test_surfunstructured_parallel_00006.cpp @@ -52,7 +52,6 @@ int subtest_001() int myRank = surfaceMesh->getRank(); - surfaceMesh->setExpert(true); if (myRank == 0) { surfaceMesh->importSTL("./data/buddha.stl"); surfaceMesh->deleteCoincidentVertices(); diff --git a/test/integration_tests/surfunstructured/test_surfunstructured_parallel_00007.cpp b/test/integration_tests/surfunstructured/test_surfunstructured_parallel_00007.cpp index bed5c25881..51b92976b5 100644 --- a/test/integration_tests/surfunstructured/test_surfunstructured_parallel_00007.cpp +++ b/test/integration_tests/surfunstructured/test_surfunstructured_parallel_00007.cpp @@ -52,7 +52,6 @@ int subtest_001() int myRank = surfaceMesh->getRank(); - surfaceMesh->setExpert(true); if (myRank == 0) { surfaceMesh->importSTL("./data/buddha.stl"); surfaceMesh->deleteCoincidentVertices(); @@ -281,7 +280,6 @@ int subtest_002() int myRank = surfaceMesh->getRank(); - surfaceMesh->setExpert(true); if (myRank == 0) { surfaceMesh->importSTL("./data/buddha.stl"); surfaceMesh->deleteCoincidentVertices();