diff --git a/src/patchkernel/patch_kernel.cpp b/src/patchkernel/patch_kernel.cpp index cbaf5ba024..29b2364fff 100644 --- a/src/patchkernel/patch_kernel.cpp +++ b/src/patchkernel/patch_kernel.cpp @@ -243,7 +243,6 @@ PatchKernel::PatchKernel(const PatchKernel &other) m_boxMaxCounter(other.m_boxMaxCounter), 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_dimension(other.m_dimension), @@ -330,7 +329,6 @@ PatchKernel::PatchKernel(PatchKernel &&other) m_boxMaxCounter(std::move(other.m_boxMaxCounter)), 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_id(std::move(other.m_id)), @@ -420,7 +418,6 @@ PatchKernel & PatchKernel::operator=(PatchKernel &&other) m_boxMaxCounter = std::move(other.m_boxMaxCounter); 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_id = std::move(other.m_id); @@ -524,12 +521,6 @@ void PatchKernel::initialize() // Set interfaces build strategy setInterfacesBuildStrategy(INTERFACES_NONE); - // Set the spawn as unneeded - // - // Specific implementation will set the appropriate status during their - // initialization. - setSpawnStatus(SPAWN_UNNEEDED); - // Set the adaption as clean setAdaptionStatus(ADAPTION_CLEAN); @@ -646,12 +637,6 @@ std::vector PatchKernel::update(bool trackAdaption, bool squeeze // Finalize alterations finalizeAlterations(squeezeStorage); - // Spawn - bool spawnNeeed = (getSpawnStatus() == SPAWN_NEEDED); - if (spawnNeeed) { - mergeAdaptionInfo(spawn(trackAdaption), updateInfo); - } - // Adaption bool adaptionDirty = (getAdaptionStatus(true) == ADAPTION_DIRTY); if (adaptionDirty) { @@ -681,44 +666,6 @@ void PatchKernel::simulateCellUpdate(const long id, adaption::Marker marker, std throw std::runtime_error ("This function has not been implemented for the specified patch."); } -/*! - Generates the patch. - - \param trackSpawn if set to true the changes to the patch will be tracked - \result Returns a vector of adaption::Info that can be used to track - the changes done during the spawn. -*/ -std::vector PatchKernel::spawn(bool trackSpawn) -{ - std::vector spawnInfo; - -#if BITPIT_ENABLE_MPI==1 - // This is a collevtive operation and should be called by all processes - if (isPartitioned()) { - const auto &communicator = getCommunicator(); - MPI_Barrier(communicator); - } -#endif - - // Check spawn status - SpawnStatus spawnStatus = getSpawnStatus(); - if (spawnStatus == SPAWN_UNNEEDED || spawnStatus == SPAWN_DONE) { - return spawnInfo; - } - - // Spawn the patch - spawnInfo = _spawn(trackSpawn); - - // Finalize patch alterations - finalizeAlterations(true); - - // Spwan is done - setSpawnStatus(SPAWN_DONE); - - // Done - return spawnInfo; -} - /*! Execute patch adaption. @@ -1335,33 +1282,6 @@ void PatchKernel::_writeFinalize() // Nothing to do } -/*! - 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 -{ - // There is no need to check the spawn status globally because the spawn - // status will always be the same on all the processes. - - return m_spawnStatus; -} - -/*! - Set the current spawn status. - - \param status is the spawn status that will be set -*/ -void PatchKernel::setSpawnStatus(SpawnStatus status) -{ - m_spawnStatus = status; -} - - /*! Checks if the patch supports adaption. @@ -1470,10 +1390,6 @@ bool PatchKernel::isDirty(bool global) const assert(isDirty || m_alteredInterfaces.empty()); } - if (!isDirty) { - isDirty |= (getSpawnStatus() == SPAWN_NEEDED); - } - if (!isDirty) { isDirty |= (getAdaptionStatus(false) == ADAPTION_DIRTY); } @@ -5265,24 +5181,6 @@ void PatchKernel::restoreInterfaces(std::istream &stream) setAdaptionMode(previousAdaptionMode); } -/*! - Generates the patch. - - Default implementation is a no-op function. - - \param trackSpawn if set to true the changes to the patch will be tracked - \result Returns a vector of adaption::Info that can be used to track - the changes done during the spawn. -*/ -std::vector PatchKernel::_spawn(bool trackSpawn) -{ - BITPIT_UNUSED(trackSpawn); - - assert(false && "The patch needs to implement _spawn"); - - return std::vector(); -} - /*! Prepares the patch for performing the adaption. @@ -8345,9 +8243,6 @@ bool PatchKernel::dump(std::ostream &stream) const utils::binary::write(stream, 0); #endif - // Spawn status - utils::binary::write(stream, m_spawnStatus); - // Adaption information utils::binary::write(stream, m_adaptionMode); utils::binary::write(stream, m_adaptionStatus); @@ -8446,9 +8341,6 @@ void PatchKernel::restore(std::istream &stream, bool reregister) utils::binary::read(stream, dummyHaloSize); #endif - // Spawn status - utils::binary::read(stream, m_spawnStatus); - // Adaption information utils::binary::read(stream, m_adaptionMode); utils::binary::read(stream, m_adaptionStatus); diff --git a/src/patchkernel/patch_kernel.hpp b/src/patchkernel/patch_kernel.hpp index 03717ef9a3..dab4c909b1 100644 --- a/src/patchkernel/patch_kernel.hpp +++ b/src/patchkernel/patch_kernel.hpp @@ -329,15 +329,6 @@ friend class PatchManager; INTERFACES_AUTOMATIC }; - /*! - Spawn status - */ - enum SpawnStatus { - SPAWN_UNNEEDED = -1, - SPAWN_NEEDED, - SPAWN_DONE - }; - /*! Adaption mode */ @@ -403,9 +394,6 @@ friend class PatchManager; virtual void simulateCellUpdate(const long id, adaption::Marker marker, std::vector *virtualCells, PiercedVector *virtualVertices) const; - SpawnStatus getSpawnStatus() const; - std::vector spawn(bool trackSpawn); - bool isAdaptionSupported() const; AdaptionMode getAdaptionMode() const; AdaptionStatus getAdaptionStatus(bool global = false) const; @@ -917,9 +905,6 @@ friend class PatchManager; bool testAlterationFlags(AlterationFlags availableFlags, AlterationFlags requestedFlags) const; - void setSpawnStatus(SpawnStatus status); - virtual std::vector _spawn(bool trackAdaption); - void setAdaptionMode(AdaptionMode mode); void setAdaptionStatus(AdaptionStatus status); virtual std::vector _adaptionPrepare(bool trackAdaption); @@ -1027,8 +1012,6 @@ friend class PatchManager; InterfacesBuildStrategy m_interfacesBuildStrategy; - SpawnStatus m_spawnStatus; - AdaptionMode m_adaptionMode; AdaptionStatus m_adaptionStatus; diff --git a/src/volcartesian/volcartesian.cpp b/src/volcartesian/volcartesian.cpp index b9c93458d2..60c3541552 100644 --- a/src/volcartesian/volcartesian.cpp +++ b/src/volcartesian/volcartesian.cpp @@ -470,9 +470,6 @@ void VolCartesian::initialize() // Set the bounding box as frozen setBoundingBoxFrozen(true); - // This patch need to be spawn - setSpawnStatus(SPAWN_NEEDED); - // Set the light memory mode setMemoryMode(MemoryMode::MEMORY_LIGHT); @@ -930,34 +927,44 @@ std::array VolCartesian::getSpacing() const */ void VolCartesian::switchMemoryMode(MemoryMode mode) { + // Early return if the current memory mode matches the requested one if (mode == getMemoryMode()) { return; } - // Update the data structures + // Update patch data structures switch (mode) { case MemoryMode::MEMORY_NORMAL: - // Spawn the patch to activate normal memory mode - spawn(false); + { + // Enable manual adaption + AdaptionMode previousAdaptionMode = getAdaptionMode(); + setAdaptionMode(ADAPTION_MANUAL); + + // Create the mesh + addVertices(); + addCells(); + + // Restore previous adaption mode + setAdaptionMode(previousAdaptionMode); break; + } case MemoryMode::MEMORY_LIGHT: + { // To put the patch in memory mode we need to reset the generic data // of the patch, therefore we can call the 'reset' implementation of // the kernel. VolumeKernel::reset(); - // Now the patch needs to be spawn - setSpawnStatus(SPAWN_NEEDED); - - // Set the light memory mode - setMemoryMode(mode); - break; + } } + + // Set the requested memory mode + setMemoryMode(mode); } /*! @@ -994,67 +1001,6 @@ double VolCartesian::getSpacing(int direction) const return m_cellSpacings[direction]; } -/*! - Generates the patch. - - \param trackSpawn if set to true the changes to the patch will be tracked - \result Returns a vector of adaption::Info that can be used to track - the changes done during the update. -*/ -std::vector VolCartesian::_spawn(bool trackSpawn) -{ - std::vector updateInfo; - - // If the patch is in 'normal' mode there is nothing to do. - if (getMemoryMode() == MEMORY_NORMAL) { - return updateInfo; - } - - // Enable manual adaption - AdaptionMode previousAdaptionMode = getAdaptionMode(); - setAdaptionMode(ADAPTION_MANUAL); - - // Definition of the mesh - addVertices(); - addCells(); - - // Restore previous adaption mode - setAdaptionMode(previousAdaptionMode); - - // Adaption info - if (trackSpawn) { - updateInfo.emplace_back(); - adaption::Info &adaptionCellInfo = updateInfo.back(); - adaptionCellInfo.type = adaption::TYPE_CREATION; - adaptionCellInfo.entity = adaption::ENTITY_CELL; - adaptionCellInfo.current.reserve(m_cells.size()); - for (auto &cell : m_cells) { - adaptionCellInfo.current.emplace_back(); - long &cellId = adaptionCellInfo.current.back(); - cellId = cell.getId(); - } - - updateInfo.emplace_back(); - adaption::Info &adaptionInterfaceInfo = updateInfo.back(); - adaptionInterfaceInfo.type = adaption::TYPE_CREATION; - adaptionInterfaceInfo.entity = adaption::ENTITY_INTERFACE; - adaptionInterfaceInfo.current.reserve(m_interfaces.size()); - for (auto &interface : m_interfaces) { - adaptionInterfaceInfo.current.emplace_back(); - long &interfaceId = adaptionInterfaceInfo.current.back(); - interfaceId = interface.getId(); - } - } else { - updateInfo.emplace_back(); - } - - // Updating the adaption brings the patch is in normal memory mode - setMemoryMode(MemoryMode::MEMORY_NORMAL); - - // Done - return updateInfo; -} - /*! Creates the vertices of the patch. */ @@ -1173,9 +1119,6 @@ void VolCartesian::_dump(std::ostream &stream) const */ void VolCartesian::_restore(std::istream &stream) { - // This patch need to be spawn - setSpawnStatus(SPAWN_NEEDED); - // Origin std::array origin; utils::binary::read(stream, origin[0]); diff --git a/src/volcartesian/volcartesian.hpp b/src/volcartesian/volcartesian.hpp index 96a2a2c7a7..0dec239eef 100644 --- a/src/volcartesian/volcartesian.hpp +++ b/src/volcartesian/volcartesian.hpp @@ -149,8 +149,6 @@ class VolCartesian : public VolumeKernel { long getCellFaceNeighsLinearId(long id, int face) const; protected: - std::vector _spawn(bool trackSpawn) override; - void _updateAdjacencies() override; void _updateInterfaces() override; diff --git a/src/voloctree/voloctree.cpp b/src/voloctree/voloctree.cpp index 0f9b2d0c23..49c30c47a4 100644 --- a/src/voloctree/voloctree.cpp +++ b/src/voloctree/voloctree.cpp @@ -482,13 +482,16 @@ void VolOctree::initialize() { log::cout() << ">> Initializing Octree mesh" << std::endl; + // Set the adaption as clean + // + // Setting the adaptation as dirty guarantees that, at the first patch + // updated, all the data structures will be properly initialized. + setAdaptionStatus(ADAPTION_DIRTY); + // Reset the cell and interface type info m_cellTypeInfo = nullptr; m_interfaceTypeInfo = nullptr; - // This patch need to be spawn - setSpawnStatus(SPAWN_NEEDED); - // Initialize the tolerance // // Since the patch re-implements the function to reset the tolerance, @@ -922,26 +925,6 @@ int VolOctree::getCellFamilySplitLocalVertex(long id) const return m_tree->getFamilySplittingNode(octant); } -/*! - Generates the patch. - - \param trackSpawn if set to true the changes to the patch will be tracked - \result Returns a vector of adaption::Info that can be used to track - the changes done during the update. -*/ -std::vector VolOctree::_spawn(bool trackSpawn) -{ - std::vector updateInfo; - - // Perform initial import - if (empty()) { - m_tree->adapt(); - updateInfo = sync(trackSpawn); - } - - return updateInfo; -} - /*! Prepares the patch for performing the adaption. @@ -957,10 +940,6 @@ std::vector VolOctree::_adaptionPrepare(bool trackAdaption) { BITPIT_UNUSED(trackAdaption); - if (getSpawnStatus() == SPAWN_NEEDED) { - throw std::runtime_error ("The initial import has not been performed."); - } - // Call pre-adapt routine m_tree->preadapt(); diff --git a/src/voloctree/voloctree.hpp b/src/voloctree/voloctree.hpp index 52fe391594..0ce5910532 100644 --- a/src/voloctree/voloctree.hpp +++ b/src/voloctree/voloctree.hpp @@ -131,8 +131,6 @@ class VolOctree : public VolumeKernel { void setCommunicator(MPI_Comm communicator) override; #endif - std::vector _spawn(bool trackSpawn) override; - void _updateAdjacencies() override; std::vector _adaptionPrepare(bool trackAdaption) override;