MeshZones: Added mesh change functions

in preparation for zones updating themselves on mesh topology change
This commit is contained in:
Henry Weller
2024-03-04 21:58:52 +00:00
parent c161539597
commit 0840ae5d37
20 changed files with 112 additions and 85 deletions

View File

@ -416,8 +416,6 @@ int main(int argc, char *argv[])
if (mesh.faceZones().findIndex(name) == -1)
{
mesh.faceZones().clearAddressing();
const label sz = mesh.faceZones().size();
labelList addr(0);

View File

@ -460,7 +460,6 @@ autoPtr<polyTopoChangeMap> reorderMesh
// Re-do the faceZones
{
meshFaceZones& faceZones = mesh.faceZones();
faceZones.clearAddressing();
forAll(faceZones, zoneI)
{
faceZone& fZone = faceZones[zoneI];
@ -491,7 +490,6 @@ autoPtr<polyTopoChangeMap> reorderMesh
// Re-do the cellZones
{
meshCellZones& cellZones = mesh.cellZones();
cellZones.clearAddressing();
forAll(cellZones, zoneI)
{
cellZones[zoneI] = UIndirectList<label>

View File

@ -1844,7 +1844,6 @@ int main(int argc, char *argv[])
}
else
{
mesh.cellZones()[zoneI].clearAddressing();
mesh.cellZones()[zoneI] = regionCells;
}
Info<< " Region " << regioni << " : created new cellZone "

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -49,9 +49,9 @@ void Foam::polyMesh::topoChange(const polyTopoChangeMap& map)
boundary_.topoChange();
// Update zones
pointZones_.clearAddressing();
faceZones_.clearAddressing();
cellZones_.clearAddressing();
pointZones_.topoChange(map);
faceZones_.topoChange(map);
cellZones_.topoChange(map);
// Remove the stored tet base points
tetBasePtIsPtr_.clear();
@ -127,6 +127,11 @@ void Foam::polyMesh::topoChange(const polyTopoChangeMap& map)
void Foam::polyMesh::mapMesh(const polyMeshMap& map)
{
// Update zones
pointZones_.mapMesh(map);
faceZones_.mapMesh(map);
cellZones_.mapMesh(map);
meshObjects::mapMesh<polyMesh>(*this, map);
meshObjects::mapMesh<pointMesh>(*this, map);
}
@ -134,6 +139,11 @@ void Foam::polyMesh::mapMesh(const polyMeshMap& map)
void Foam::polyMesh::distribute(const polyDistributionMap& map)
{
// Update zones
pointZones_.distribute(map);
faceZones_.distribute(map);
cellZones_.distribute(map);
meshObjects::distribute<polyMesh>(*this, map);
meshObjects::distribute<pointMesh>(*this, map);
}

View File

@ -515,6 +515,48 @@ void Foam::MeshZones<ZoneType, MeshType>::movePoints(const pointField& p)
}
template<class ZoneType, class MeshType>
void Foam::MeshZones<ZoneType, MeshType>::topoChange
(
const polyTopoChangeMap& map
)
{
PtrList<ZoneType>& zones = *this;
forAll(zones, zi)
{
zones[zi].topoChange(map);
}
}
template<class ZoneType, class MeshType>
void Foam::MeshZones<ZoneType, MeshType>::mapMesh(const polyMeshMap& map)
{
PtrList<ZoneType>& zones = *this;
forAll(zones, zi)
{
zones[zi].mapMesh(map);
}
}
template<class ZoneType, class MeshType>
void Foam::MeshZones<ZoneType, MeshType>::distribute
(
const polyDistributionMap& map
)
{
PtrList<ZoneType>& zones = *this;
forAll(zones, zi)
{
zones[zi].distribute(map);
}
}
template<class ZoneType, class MeshType>
void Foam::MeshZones<ZoneType, MeshType>::swap(MeshZones& otherZones)
{

View File

@ -50,6 +50,10 @@ namespace Foam
// Forward declaration of friend functions and operators
class polyTopoChangeMap;
class polyMeshMap;
class polyDistributionMap;
template<class ZoneType, class MeshType> class MeshZones;
template<class ZoneType, class MeshType>
@ -177,7 +181,16 @@ public:
bool checkParallelSync(const bool report = false) const;
//- Correct zones after moving points
void movePoints(const pointField&);
virtual void movePoints(const pointField&);
//- Update topology using the given map
virtual void topoChange(const polyTopoChangeMap& map);
//- Update from another mesh using the given map
virtual void mapMesh(const polyMeshMap&);
//- Redistribute or update using the given distribution map
virtual void distribute(const polyDistributionMap&);
//- Swap zones
// For run-time mesh replacement and mesh to mesh mapping

View File

@ -145,30 +145,14 @@ void Foam::cellZone::writeDict(Ostream& os) const
void Foam::cellZone::operator=(const cellZone& zn)
{
clearAddressing();
zone::operator=(zn);
}
void Foam::cellZone::operator=(cellZone&& zn)
{
clearAddressing();
zone::operator=(move(zn));
}
void Foam::cellZone::operator=(const labelUList& addr)
{
clearAddressing();
zone::operator=(addr);
}
void Foam::cellZone::operator=(labelList&& addr)
{
clearAddressing();
zone::operator=(move(addr));
}
// ************************************************************************* //

View File

@ -212,18 +212,14 @@ public:
// Member Operators
using zone::operator=;
//- Assignment to zone, clearing demand-driven data
void operator=(const cellZone&);
//- Move assignment to zone, clearing demand-driven data
void operator=(cellZone&&);
//- Assign addressing, clearing demand-driven data
void operator=(const labelUList&);
//- Move addressing, clearing demand-driven data
void operator=(labelList&&);
// I-O

View File

@ -386,6 +386,7 @@ void Foam::faceZone::topoChange(const polyTopoChangeMap& map)
{
clearAddressing();
/*
labelList newAddressing(size());
boolList newFlipMap(flipMap_.size());
label nFaces = 0;
@ -409,12 +410,7 @@ void Foam::faceZone::topoChange(const polyTopoChangeMap& map)
transfer(newAddressing);
flipMap_.transfer(newFlipMap);
}
void Foam::faceZone::mapMesh(const polyMeshMap&)
{
NotImplemented;
*/
}
@ -551,7 +547,6 @@ void Foam::faceZone::writeDict(Ostream& os) const
void Foam::faceZone::operator=(const faceZone& zn)
{
clearAddressing();
zone::operator=(zn);
flipMap_ = zn.flipMap_;
}
@ -559,7 +554,6 @@ void Foam::faceZone::operator=(const faceZone& zn)
void Foam::faceZone::operator=(faceZone&& zn)
{
clearAddressing();
zone::operator=(move(zn));
flipMap_ = move(zn.flipMap_);
}

View File

@ -50,9 +50,6 @@ SourceFiles
namespace Foam
{
class polyTopoChangeMap;
class polyMeshMap;
// Forward declaration of friend functions and operators
class faceZone;
@ -289,9 +286,6 @@ public:
//- Update topology using the given map
virtual void topoChange(const polyTopoChangeMap&);
//- Update from another mesh using the given map
virtual void mapMesh(const polyMeshMap&);
//- Write
virtual void write(Ostream&) const;

View File

@ -197,32 +197,16 @@ void Foam::pointZone::writeDict(Ostream& os) const
void Foam::pointZone::operator=(const pointZone& zn)
{
clearAddressing();
zone::operator=(zn);
}
void Foam::pointZone::operator=(pointZone&& zn)
{
clearAddressing();
zone::operator=(move(zn));
}
void Foam::pointZone::operator=(const labelUList& addr)
{
clearAddressing();
zone::operator=(addr);
}
void Foam::pointZone::operator=(labelList&& addr)
{
clearAddressing();
zone::operator=(move(addr));
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const pointZone& zn)

View File

@ -204,28 +204,20 @@ public:
// true if in error.
virtual bool checkParallelSync(const bool report = false) const;
//- Correct patch after moving points
virtual void movePoints(const pointField&)
{}
//- Write dictionary
virtual void writeDict(Ostream&) const;
// Member Operators
using zone::operator=;
//- Assignment to zone, clearing demand-driven data
void operator=(const pointZone&);
//- Move assignment to zone, clearing demand-driven data
void operator=(pointZone&&);
//- Assign addressing, clearing demand-driven data
void operator=(const labelUList&);
//- Move addressing, clearing demand-driven data
void operator=(labelList&&);
// I-O

View File

@ -220,6 +220,24 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const
}
void Foam::zone::topoChange(const polyTopoChangeMap& map)
{
clearAddressing();
}
void Foam::zone::mapMesh(const polyMeshMap&)
{
clearAddressing();
}
void Foam::zone::distribute(const polyDistributionMap&)
{
clearAddressing();
}
void Foam::zone::write(Ostream& os) const
{
os << nl << name_
@ -231,24 +249,28 @@ void Foam::zone::write(Ostream& os) const
void Foam::zone::operator=(const zone& zn)
{
clearAddressing();
labelList::operator=(zn);
}
void Foam::zone::operator=(zone&& zn)
{
clearAddressing();
labelList::operator=(move(zn));
}
void Foam::zone::operator=(const labelUList& addr)
{
clearAddressing();
labelList::operator=(addr);
}
void Foam::zone::operator=(labelList&& addr)
{
clearAddressing();
labelList::operator=(move(addr));
}

View File

@ -48,6 +48,10 @@ namespace Foam
// Forward declaration of friend functions and operators
class polyTopoChangeMap;
class polyMeshMap;
class polyDistributionMap;
class zone;
Ostream& operator<<(Ostream&, const zone&);
@ -167,6 +171,15 @@ public:
virtual void movePoints(const pointField&)
{}
//- Update topology using the given map
virtual void topoChange(const polyTopoChangeMap& map);
//- Update from another mesh using the given map
virtual void mapMesh(const polyMeshMap&);
//- Redistribute or update using the given distribution map
virtual void distribute(const polyDistributionMap&);
//- Write
virtual void write(Ostream&) const;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -762,9 +762,6 @@ bool Foam::polyMeshZipUpCells(polyMesh& mesh)
true // boundary forms valid boundary mesh.
);
// Reset any addressing on face zones.
mesh.faceZones().clearAddressing();
// Clear the addressing
mesh.clearOut();

View File

@ -282,7 +282,6 @@ bool cellZoneSet::writeObject
{
cellZones[zoneID] = addressing_;
}
cellZones.clearAddressing();
return ok && cellZones.write(write);
}

View File

@ -498,7 +498,6 @@ bool faceZoneSet::writeObject
{
faceZones[zoneID].resetAddressing(addressing_, flipMap_);
}
faceZones.clearAddressing();
return ok && faceZones.write(write);
}

View File

@ -283,7 +283,6 @@ bool pointZoneSet::writeObject
{
pointZones[zoneID] = addressing_;
}
pointZones.clearAddressing();
return ok && pointZones.write(write);
}

View File

@ -973,7 +973,6 @@ void Foam::domainDecomposition::decompose()
}
}
procMesh.pointZones().clearAddressing();
procMesh.pointZones().setSize(zonePoints.size());
forAll(zonePoints, zoneI)
{
@ -1065,7 +1064,6 @@ void Foam::domainDecomposition::decompose()
}
}
procMesh.faceZones().clearAddressing();
procMesh.faceZones().setSize(zoneFaces.size());
forAll(zoneFaces, zoneI)
{
@ -1129,7 +1127,6 @@ void Foam::domainDecomposition::decompose()
}
}
procMesh.cellZones().clearAddressing();
procMesh.cellZones().setSize(zoneCells.size());
forAll(zoneCells, zoneI)
{

View File

@ -1586,7 +1586,6 @@ void Foam::polyTopoChange::resetZones
}
// Reset the addressing on the zone
newMesh.pointZones().clearAddressing();
forAll(newMesh.pointZones(), zoneI)
{
if (debug)
@ -1668,7 +1667,6 @@ void Foam::polyTopoChange::resetZones
}
// Reset the addressing on the zone
newMesh.faceZones().clearAddressing();
forAll(newMesh.faceZones(), zoneI)
{
if (debug)
@ -1736,7 +1734,6 @@ void Foam::polyTopoChange::resetZones
}
// Reset the addressing on the zone
newMesh.cellZones().clearAddressing();
forAll(newMesh.cellZones(), zoneI)
{
if (debug)