/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2022-2026 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . \*---------------------------------------------------------------------------*/ #include "meshObjects.H" #include "MeshObjects.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // template void Foam::meshObjects::Delete(regIOobject& io) { if (meshObjects::debug) { Pout<< " Destroying " << io.name() << endl; } if (io.ownedByRegistry()) { io.checkOut(); } else { FatalErrorInFunction << "Attempt to checkout and delete object " << io.name() << " not owned by registry." << abort(FatalError); } } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template void Foam::meshObjects::movePoints(objectRegistry& obr) { HashTable*> meshObjects ( obr.lookupClass>() ); if (meshObjects::debug) { Pout<< "meshObjects::movePoints(objectRegistry&) :" << " moving " << Mesh::typeName << " meshObjects for region " << obr.name() << endl; } forAllIter ( typename HashTable*>, meshObjects, iter ) { if (isA>(*iter())) { if (meshObjects::debug) { Pout<< " Moving " << iter()->io_.name() << endl; } dynamic_cast*>(iter())->movePoints(); } else { Delete(iter()->io_); } } } template void Foam::meshObjects::distribute ( objectRegistry& obr, const polyDistributionMap& map ) { HashTable*> meshObjects ( obr.lookupClass>() ); if (meshObjects::debug) { Pout<< "meshObjects::distribute(objectRegistry&, " "const polyDistributionMap& map) : updating " << Mesh::typeName << " meshObjects for region " << obr.name() << endl; } forAllIter ( typename HashTable*>, meshObjects, iter ) { if (isA>(*iter())) { if (meshObjects::debug) { Pout<< " Distributing " << iter()->io_.name() << endl; } dynamic_cast*>(iter()) ->distribute(map); } else { Delete(iter()->io_); } } } template void Foam::meshObjects::topoChange ( objectRegistry& obr, const polyTopoChangeMap& map ) { HashTable*> meshObjects ( obr.lookupClass>() ); if (meshObjects::debug) { Pout<< "meshObjects::topoChange(objectRegistry&, " "const polyTopoChangeMap& map) : updating " << Mesh::typeName << " meshObjects for region " << obr.name() << endl; } forAllIter ( typename HashTable*>, meshObjects, iter ) { if (isA>(*iter())) { if (meshObjects::debug) { Pout<< " Updating " << iter()->io_.name() << endl; } dynamic_cast*>(iter()) ->topoChange(map); } else { Delete(iter()->io_); } } } template void Foam::meshObjects::mapMesh ( objectRegistry& obr, const polyMeshMap& map ) { HashTable*> meshObjects ( obr.lookupClass>() ); if (meshObjects::debug) { Pout<< "meshObjects::mapMesh(objectRegistry&, " "const polyMeshMap& map) : updating " << Mesh::typeName << " meshObjects for region " << obr.name() << endl; } forAllIter ( typename HashTable*>, meshObjects, iter ) { if (isA>(*iter())) { if (meshObjects::debug) { Pout<< " Updating " << iter()->io_.name() << endl; } dynamic_cast*>(iter())->mapMesh(map); } else { Delete(iter()->io_); } } } template void Foam::meshObjects::swap ( objectRegistry& obr, Mesh& otherMesh ) { HashTable*> meshObjects ( obr.lookupClass>() ); if (meshObjects::debug) { Pout<< "meshObjects::swap(objectRegistry&, " "const Mesh& otherMesh) : swapping " << Mesh::typeName << " meshObjects for region " << obr.name() << endl; } forAllIter ( typename HashTable*>, meshObjects, iter ) { if (isA>(*iter())) { if (meshObjects::debug) { Pout<< " Swapping " << iter()->io_.name() << endl; } dynamic_cast*>(iter()) ->swap(otherMesh); } else { Delete(iter()->io_); } } } template void Foam::meshObjects::addPatch(objectRegistry& obr, const label patchi) { HashTable*> meshObjects ( obr.lookupClass>() ); if (meshObjects::debug) { Pout<< "meshObjects::addPatch(objectRegistry&, " "const label patchi) : updating " << Mesh::typeName << " meshObjects for region " << obr.name() << endl; } forAllIter ( typename HashTable*>, meshObjects, iter ) { if (isA>(*iter())) { if (meshObjects::debug) { Pout<< " Adding patch to " << iter()->io_.name() << endl; } dynamic_cast*>(iter()) ->addPatch(patchi); } else { Delete(iter()->io_); } } } template void Foam::meshObjects::reorderPatches ( objectRegistry& obr, const labelUList& newToOld, const bool validBoundary ) { HashTable*> meshObjects ( obr.lookupClass>() ); if (meshObjects::debug) { Pout<< "meshObjects::addPatch(objectRegistry&, " "const labelUList&, const bool) : updating " << Mesh::typeName << " meshObjects for region " << obr.name() << endl; } forAllIter ( typename HashTable*>, meshObjects, iter ) { if (isA>(*iter())) { if (meshObjects::debug) { Pout<< " Adding patch to " << iter()->io_.name() << endl; } dynamic_cast*>(iter())->reorderPatches ( newToOld, validBoundary ); } else { Delete(iter()->io_); } } } template void Foam::meshObjects::reset(objectRegistry& obr) { HashTable*> meshObjects ( obr.lookupClass>() ); if (meshObjects::debug) { Pout<< "meshObjects::reset(objectRegistry&) :" << " resetting " << Mesh::typeName << " meshObjects for region " << obr.name() << endl; } forAllIter ( typename HashTable*>, meshObjects, iter ) { if (isA>(*iter())) { if (meshObjects::debug) { Pout<< " Resetting " << iter()->io_.name() << endl; } dynamic_cast*>(iter())->reset(); } else { Delete(iter()->io_); } } } template class MeshObjectType> void Foam::meshObjects::clear(objectRegistry& obr) { HashTable*> meshObjects ( obr.lookupClass>() ); if (meshObjects::debug) { Pout<< "meshObjects::clear(objectRegistry&) :" << " clearing " << Mesh::typeName << " meshObjects for region " << obr.name() << endl; } forAllIter(typename HashTable*>, meshObjects, iter) { if (isA>(*iter())) { if (meshObjects::debug) { Pout<< " Clearing " << iter()->io_.name() << endl; } dynamic_cast*>(iter())->clear(); } else { Delete(iter()->io_); } } } template < class Mesh, template class FromType, template class ToType > void Foam::meshObjects::clearUpto(objectRegistry& obr) { HashTable*> meshObjects ( obr.lookupClass>() ); if (meshObjects::debug) { Pout<< "meshObjects::clearUpto(objectRegistry&) :" << " clearing " << Mesh::typeName << " meshObjects for region " << obr.name() << endl; } forAllIter(typename HashTable*>, meshObjects, iter) { if (!isA>(*iter())) { Delete(iter()->io_); } } } template class MeshObjectType> void Foam::meshObjects::clearAll(objectRegistry& obr) { HashTable*> meshObjects ( obr.lookupClass>() ); if (meshObjects::debug) { Pout<< "meshObjects::clear(objectRegistry&) :" << " clearing " << Mesh::typeName << " meshObjects for region " << obr.name() << endl; } forAllIter(typename HashTable*>, meshObjects, iter) { Delete(iter()->io_); } } // ************************************************************************* //