polyBoundaryMesh: Update indices in neighbour patches on reorder
This commit is contained in:
@ -121,27 +121,19 @@ void renamePatches
|
||||
const labelList& patchesToRename
|
||||
)
|
||||
{
|
||||
polyBoundaryMesh& polyPatches =
|
||||
polyBoundaryMesh& patches =
|
||||
const_cast<polyBoundaryMesh&>(mesh.boundaryMesh());
|
||||
|
||||
// Create a list of all the new names
|
||||
wordList newNames = patches.names();
|
||||
forAll(patchesToRename, i)
|
||||
{
|
||||
label patchi = patchesToRename[i];
|
||||
polyPatch& pp = polyPatches[patchi];
|
||||
|
||||
if (isA<coupledPolyPatch>(pp))
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Encountered coupled patch " << pp.name()
|
||||
<< ". Will only rename the patch itself,"
|
||||
<< " not any referred patches."
|
||||
<< " This might have to be done by hand."
|
||||
<< endl;
|
||||
}
|
||||
|
||||
pp.name() = prefix + '_' + pp.name();
|
||||
const label patchi = patchesToRename[i];
|
||||
newNames[patchi] = prefix + '_' + newNames[patchi];
|
||||
}
|
||||
// Recalculate any demand driven data (e.g. group to name lookup)
|
||||
polyPatches.updateMesh();
|
||||
|
||||
// Apply to the patches
|
||||
patches.renamePatches(newNames, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -57,7 +57,9 @@ Ostream& operator<<(Ostream&, const patchIdentifier&);
|
||||
|
||||
class patchIdentifier
|
||||
{
|
||||
// Private Data
|
||||
protected:
|
||||
|
||||
// Protected Data
|
||||
|
||||
//- Name of patch
|
||||
word name_;
|
||||
@ -66,7 +68,7 @@ class patchIdentifier
|
||||
label index_;
|
||||
|
||||
//- Optional physical type
|
||||
mutable word physicalType_;
|
||||
word physicalType_;
|
||||
|
||||
//- Optional groups patch belongs to
|
||||
wordList inGroups_;
|
||||
@ -113,10 +115,10 @@ public:
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Return name for modification
|
||||
word& name()
|
||||
//- Return the index of this patch in the boundaryMesh
|
||||
label index() const
|
||||
{
|
||||
return name_;
|
||||
return index_;
|
||||
}
|
||||
|
||||
//- Return the optional physical type of the patch
|
||||
@ -131,18 +133,6 @@ public:
|
||||
return physicalType_;
|
||||
}
|
||||
|
||||
//- Return the index of this patch in the boundaryMesh
|
||||
label index() const
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
|
||||
//- Return the index of this patch in the boundaryMesh for modification
|
||||
label& index()
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
|
||||
//- Return the optional groups patch belongs to
|
||||
const wordList& inGroups() const
|
||||
{
|
||||
|
||||
@ -1106,7 +1106,29 @@ void Foam::polyBoundaryMesh::updateMesh()
|
||||
}
|
||||
|
||||
|
||||
void Foam::polyBoundaryMesh::shuffle
|
||||
void Foam::polyBoundaryMesh::renamePatches
|
||||
(
|
||||
const wordUList& newNames,
|
||||
const bool validBoundary
|
||||
)
|
||||
{
|
||||
polyPatchList& patches = *this;
|
||||
forAll(patches, patchi)
|
||||
{
|
||||
if (patches.set(patchi))
|
||||
{
|
||||
patches[patchi].rename(newNames);
|
||||
}
|
||||
}
|
||||
|
||||
if (validBoundary)
|
||||
{
|
||||
updateMesh();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::polyBoundaryMesh::reorderPatches
|
||||
(
|
||||
const labelUList& newToOld,
|
||||
const bool validBoundary
|
||||
@ -1117,12 +1139,11 @@ void Foam::polyBoundaryMesh::shuffle
|
||||
|
||||
// Adapt indices
|
||||
polyPatchList& patches = *this;
|
||||
|
||||
forAll(patches, patchi)
|
||||
{
|
||||
if (patches.set(patchi))
|
||||
{
|
||||
patches[patchi].index() = patchi;
|
||||
patches[patchi].reorder(newToOld);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -221,12 +221,21 @@ public:
|
||||
//- Correct polyBoundaryMesh after topology update
|
||||
void updateMesh();
|
||||
|
||||
//- Reorders patches. Ordering does not have to be done in
|
||||
// ascending or descending order. Reordering has to be unique.
|
||||
// (is shuffle) If validBoundary calls updateMesh()
|
||||
// after reordering to recalculate data (so call needs to be parallel
|
||||
// sync in that case)
|
||||
void shuffle(const labelUList& newToOld, const bool validBoundary);
|
||||
//- Rename the patches. If validBoundary is set this calls updateMesh()
|
||||
// after reordering to recalculate data (so the call needs to be
|
||||
// parallel synchronised).
|
||||
void renamePatches(const wordUList& newNames, const bool validBoundary);
|
||||
|
||||
//- Reorders the patches. Ordering does not have to be done in
|
||||
// ascending or descending order. Reordering has to be unique (is a
|
||||
// shuffle). If validBoundary is set this calls updateMesh() after
|
||||
// reordering to recalculate data (so the call needs to be parallel
|
||||
// synchronised).
|
||||
void reorderPatches
|
||||
(
|
||||
const labelUList& newToOld,
|
||||
const bool validBoundary
|
||||
);
|
||||
|
||||
//- writeData member function required by regIOobject
|
||||
bool writeData(Ostream&) const;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -1037,7 +1037,7 @@ void Foam::polyMesh::reorderPatches
|
||||
*this
|
||||
);
|
||||
|
||||
boundary_.shuffle(newToOld, validBoundary);
|
||||
boundary_.reorderPatches(newToOld, validBoundary);
|
||||
|
||||
// Warn mesh objects
|
||||
meshObject::reorderPatches<polyMesh>(*this, newToOld, validBoundary);
|
||||
|
||||
@ -117,6 +117,23 @@ void Foam::cyclicPolyPatch::updateMesh(PstreamBuffers& pBufs)
|
||||
}
|
||||
|
||||
|
||||
void Foam::cyclicPolyPatch::rename(const wordList& newNames)
|
||||
{
|
||||
polyPatch::rename(newNames);
|
||||
nbrPatch().nbrPatchName_ = newNames[index()];
|
||||
}
|
||||
|
||||
|
||||
void Foam::cyclicPolyPatch::reorder(const labelUList& newToOldIndex)
|
||||
{
|
||||
polyPatch::reorder(newToOldIndex);
|
||||
if (nbrPatchID_ != -1)
|
||||
{
|
||||
nbrPatchID_ = findIndex(newToOldIndex, nbrPatchID_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cyclicPolyPatch::cyclicPolyPatch
|
||||
|
||||
@ -137,6 +137,13 @@ protected:
|
||||
//- Update of the patch topology
|
||||
virtual void updateMesh(PstreamBuffers&);
|
||||
|
||||
//- Reset the patch name
|
||||
virtual void rename(const wordList& newNames);
|
||||
|
||||
//- Reset the patch index
|
||||
virtual void reorder(const labelUList& newToOldIndex);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Declare friendship with processorCyclicPolyPatch
|
||||
|
||||
@ -59,6 +59,7 @@ void Foam::polyPatch::movePoints(PstreamBuffers&, const pointField& p)
|
||||
primitivePatch::movePoints(p);
|
||||
}
|
||||
|
||||
|
||||
void Foam::polyPatch::updateMesh(PstreamBuffers&)
|
||||
{
|
||||
primitivePatch::clearGeom();
|
||||
@ -72,6 +73,18 @@ void Foam::polyPatch::clearGeom()
|
||||
}
|
||||
|
||||
|
||||
void Foam::polyPatch::rename(const wordList& newNames)
|
||||
{
|
||||
name_ = newNames[index_];
|
||||
}
|
||||
|
||||
|
||||
void Foam::polyPatch::reorder(const labelUList& newToOldIndex)
|
||||
{
|
||||
index_ = findIndex(newToOldIndex, index_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::polyPatch::polyPatch
|
||||
|
||||
@ -122,6 +122,12 @@ protected:
|
||||
//- Clear geometry
|
||||
virtual void clearGeom();
|
||||
|
||||
//- Reset the patch name
|
||||
virtual void rename(const wordList& newNames);
|
||||
|
||||
//- Reset the patch index
|
||||
virtual void reorder(const labelUList& newToOldIndex);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
@ -217,6 +217,23 @@ void Foam::cyclicAMIPolyPatch::clearGeom()
|
||||
}
|
||||
|
||||
|
||||
void Foam::cyclicAMIPolyPatch::rename(const wordList& newNames)
|
||||
{
|
||||
polyPatch::rename(newNames);
|
||||
nbrPatch().nbrPatchName_ = newNames[index()];
|
||||
}
|
||||
|
||||
|
||||
void Foam::cyclicAMIPolyPatch::reorder(const labelUList& newToOldIndex)
|
||||
{
|
||||
polyPatch::reorder(newToOldIndex);
|
||||
if (nbrPatchID_ != -1)
|
||||
{
|
||||
nbrPatchID_ = findIndex(newToOldIndex, nbrPatchID_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
|
||||
|
||||
@ -119,6 +119,12 @@ protected:
|
||||
//- Clear geometry
|
||||
virtual void clearGeom();
|
||||
|
||||
//- Reset the patch name
|
||||
virtual void rename(const wordList& newNames);
|
||||
|
||||
//- Reset the patch index
|
||||
virtual void reorder(const labelUList& newToOldIndex);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user