diff --git a/src/patchkernel/patch_kernel.cpp b/src/patchkernel/patch_kernel.cpp index 179654f069..19fab212af 100644 --- a/src/patchkernel/patch_kernel.cpp +++ b/src/patchkernel/patch_kernel.cpp @@ -242,7 +242,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), @@ -329,7 +328,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)), @@ -419,7 +417,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); @@ -523,13 +520,10 @@ 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 + // + // Setting the adaptation as dirty guarantees that, at the first patch + // updated, all the data structures will be properly initialized. setAdaptionStatus(ADAPTION_CLEAN); #if BITPIT_ENABLE_MPI==1 @@ -645,12 +639,6 @@ std::vector PatchKernel::update(bool trackAdaption, bool squeeze // Finalize alterations mergeAdaptionInfo(finalizeAlterations(trackAdaption, squeezeStorage), adaptionData); - // Spawn - bool spawnNeeed = (getSpawnStatus() == SPAWN_NEEDED); - if (spawnNeeed) { - mergeAdaptionInfo(spawn(trackAdaption), adaptionData); - } - // Adaption bool adaptionDirty = (getAdaptionStatus(true) == ADAPTION_DIRTY); if (adaptionDirty) { @@ -689,33 +677,7 @@ void PatchKernel::simulateCellUpdate(const long id, adaption::Marker marker, std */ std::vector PatchKernel::spawn(bool trackSpawn) { - std::vector spawnData; - -#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 spawnData; - } - - // Spawn the patch - spawnData = _spawn(trackSpawn); - - // Finalize patch alterations - finalizeAlterations(true); - - // Spwan is done - setSpawnStatus(SPAWN_DONE); - - // Done - return spawnData; + return adaption(trackSpawn); } /*! @@ -1347,23 +1309,9 @@ void PatchKernel::write(VTKWriteMode mode) */ 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; + return SPAWN_UNNEEDED; } - /*! Checks if the patch supports adaption. @@ -1472,10 +1420,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); } @@ -5237,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. @@ -8341,9 +8267,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); @@ -8442,9 +8365,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 466af687f4..7ff9207f00 100644 --- a/src/patchkernel/patch_kernel.hpp +++ b/src/patchkernel/patch_kernel.hpp @@ -399,8 +399,8 @@ 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); + BITPIT_DEPRECATED(SpawnStatus getSpawnStatus() const); + BITPIT_DEPRECATED(std::vector spawn(bool trackSpawn)); bool isAdaptionSupported() const; AdaptionMode getAdaptionMode() const; @@ -891,9 +891,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); @@ -1001,8 +998,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 cc039d8b75..fa38b27d16 100644 --- a/src/volcartesian/volcartesian.cpp +++ b/src/volcartesian/volcartesian.cpp @@ -481,9 +481,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); @@ -949,7 +946,6 @@ void VolCartesian::switchMemoryMode(MemoryMode mode) switch (mode) { case MemoryMode::MEMORY_NORMAL: - // Spawn the patch to activate normal memory mode spawn(false); break; @@ -960,9 +956,6 @@ void VolCartesian::switchMemoryMode(MemoryMode mode) // the kernel. VolumeKernel::reset(); - // Now the patch needs to be spawn - setSpawnStatus(SPAWN_NEEDED); - // Set the light memory mode setMemoryMode(mode); @@ -1012,7 +1005,7 @@ double VolCartesian::getSpacing(int direction) const \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 VolCartesian::spawn(bool trackSpawn) { std::vector adaptionData; @@ -1195,9 +1188,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 d99c4acc0a..4f7571b17a 100644 --- a/src/volcartesian/volcartesian.hpp +++ b/src/volcartesian/volcartesian.hpp @@ -146,7 +146,7 @@ class VolCartesian : public VolumeKernel { long getCellFaceNeighsLinearId(long id, int face) const; protected: - std::vector _spawn(bool trackSpawn) override; + std::vector spawn(bool trackSpawn); void _updateAdjacencies() override; diff --git a/src/voloctree/voloctree.cpp b/src/voloctree/voloctree.cpp index 80d1b20949..1a5fbbe823 100644 --- a/src/voloctree/voloctree.cpp +++ b/src/voloctree/voloctree.cpp @@ -483,13 +483,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, @@ -939,26 +942,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 adaptionData; - - // Perform initial import - if (empty()) { - m_tree->adapt(); - adaptionData = sync(trackSpawn); - } - - return adaptionData; -} - /*! Prepares the patch for performing the adaption. @@ -975,10 +958,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 6bfde163cd..0952ad51d8 100644 --- a/src/voloctree/voloctree.hpp +++ b/src/voloctree/voloctree.hpp @@ -133,8 +133,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;