preserve flipmap

This commit is contained in:
mattijs
2009-06-29 17:30:02 +01:00
parent 4d8c3ffe1f
commit e6416c2604
3 changed files with 123 additions and 99 deletions

View File

@ -58,23 +58,6 @@ const Foam::point Foam::polyTopoChange::greatPoint
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Renumber
void Foam::polyTopoChange::renumber
(
const labelList& map,
DynamicList<label>& elems
)
{
forAll(elems, elemI)
{
if (elems[elemI] >= 0)
{
elems[elemI] = map[elems[elemI]];
}
}
}
// Renumber with special handling for merged items (marked with <-1)
void Foam::polyTopoChange::renumberReverseMap
(
@ -208,6 +191,20 @@ void Foam::polyTopoChange::countMap
}
Foam::labelHashSet Foam::polyTopoChange::getSetIndices(const PackedBoolList& lst)
{
labelHashSet values(lst.count());
forAll(lst, i)
{
if (lst[i])
{
values.insert(i);
}
}
return values;
}
void Foam::polyTopoChange::writeMeshStats(const polyMesh& mesh, Ostream& os)
{
const polyBoundaryMesh& patches = mesh.boundaryMesh();
@ -782,9 +779,11 @@ void Foam::polyTopoChange::reorderCompactFaces
renumberKey(oldToNew, faceFromPoint_);
renumberKey(oldToNew, faceFromEdge_);
renumber(oldToNew, flipFaceFlux_);
inplaceReorder(oldToNew, flipFaceFlux_);
flipFaceFlux_.setCapacity(newSize);
renumberKey(oldToNew, faceZone_);
renumberKey(oldToNew, faceZoneFlip_);
inplaceReorder(oldToNew, faceZoneFlip_);
faceZoneFlip_.setCapacity(newSize);
}
@ -1097,6 +1096,18 @@ void Foam::polyTopoChange::compact
{
faces_[faceI] = faces_[faceI].reverseFace();
Swap(faceOwner_[faceI], faceNeighbour_[faceI]);
flipFaceFlux_[faceI] =
(
flipFaceFlux_[faceI]
? 0
: 1
);
faceZoneFlip_[faceI] =
(
faceZoneFlip_[faceI]
? 0
: 1
);
}
}
}
@ -2302,9 +2313,9 @@ void Foam::polyTopoChange::addMesh
faceMap_.setCapacity(faceMap_.size() + nAllFaces);
faceFromPoint_.resize(faceFromPoint_.size() + nAllFaces/100);
faceFromEdge_.resize(faceFromEdge_.size() + nAllFaces/100);
flipFaceFlux_.resize(flipFaceFlux_.size() + nAllFaces/100);
flipFaceFlux_.setCapacity(faces_.size() + nAllFaces);
faceZone_.resize(faceZone_.size() + nAllFaces/100);
faceZoneFlip_.resize(faceZoneFlip_.size() + nAllFaces/100);
faceZoneFlip_.setCapacity(faces_.size() + nAllFaces);
// Precalc offset zones
@ -2716,15 +2727,12 @@ Foam::label Foam::polyTopoChange::addFace
}
reverseFaceMap_.append(faceI);
if (flipFaceFlux)
{
flipFaceFlux_.insert(faceI);
}
flipFaceFlux_[faceI] = (flipFaceFlux ? 1 : 0);
if (zoneID >= 0)
{
faceZone_.insert(faceI, zoneID);
faceZoneFlip_.insert(faceI, zoneFlip);
faceZoneFlip_[faceI] = (zoneFlip ? 1 : 0);
}
return faceI;
@ -2754,34 +2762,27 @@ void Foam::polyTopoChange::modifyFace
faceNeighbour_[faceI] = nei;
region_[faceI] = patchID;
if (flipFaceFlux)
{
flipFaceFlux_.insert(faceI);
}
else
{
flipFaceFlux_.erase(faceI);
}
flipFaceFlux_[faceI] = (flipFaceFlux ? 1 : 0);
Map<label>::iterator faceFnd = faceZone_.find(faceI);
if (faceFnd != faceZone_.end())
{
faceZoneFlip_[faceI] = (zoneFlip ? 1 : 0);
if (zoneID >= 0)
{
faceFnd() = zoneID;
faceZoneFlip_.find(faceI)() = zoneFlip;
}
else
{
faceZone_.erase(faceFnd);
faceZoneFlip_.erase(faceI);
}
}
else if (zoneID >= 0)
{
faceZone_.insert(faceI, zoneID);
faceZoneFlip_.insert(faceI, zoneFlip);
faceZoneFlip_[faceI] = (zoneFlip ? 1 : 0);
}
}
@ -2823,9 +2824,9 @@ void Foam::polyTopoChange::removeFace(const label faceI, const label mergeFaceI)
}
faceFromEdge_.erase(faceI);
faceFromPoint_.erase(faceI);
flipFaceFlux_.erase(faceI);
flipFaceFlux_[faceI] = 0;
faceZone_.erase(faceI);
faceZoneFlip_.erase(faceI);
faceZoneFlip_[faceI] = 0;
}
@ -3119,6 +3120,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::changeMesh
labelListList faceZonePointMap(mesh.faceZones().size());
calcFaceZonePointMap(mesh, oldFaceZoneMeshPointMaps, faceZonePointMap);
labelHashSet flipFaceFluxSet(getSetIndices(flipFaceFlux_));
return autoPtr<mapPolyMesh>
(
@ -3147,7 +3149,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::changeMesh
reverseFaceMap_,
reverseCellMap_,
flipFaceFlux_,
flipFaceFluxSet,
patchPointMap,
@ -3410,6 +3412,8 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::makeMesh
writeMeshStats(mesh, Pout);
}
labelHashSet flipFaceFluxSet(getSetIndices(flipFaceFlux_));
return autoPtr<mapPolyMesh>
(
new mapPolyMesh
@ -3437,7 +3441,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::makeMesh
reverseFaceMap_,
reverseCellMap_,
flipFaceFlux_,
flipFaceFluxSet,
patchPointMap,

View File

@ -171,13 +171,13 @@ class polyTopoChange
Map<label> faceFromEdge_;
//- In mapping whether to reverse the flux.
labelHashSet flipFaceFlux_;
PackedBoolList flipFaceFlux_;
//- Zone of face
Map<label> faceZone_;
//- Orientation of face in zone
Map<bool> faceZoneFlip_;
PackedBoolList faceZoneFlip_;
//- Active faces
label nActiveFaces_;
@ -216,8 +216,7 @@ class polyTopoChange
template<class T>
static void renumberKey(const labelList& map, Map<T>&);
//- Renumber elements of list according to map
static void renumber(const labelList&, DynamicList<label>&);
//- Renumber elements of container according to map
static void renumber(const labelList&, labelHashSet&);
//- Special handling of reverse maps which have <-1 in them
static void renumberReverseMap(const labelList&, DynamicList<label>&);
@ -225,6 +224,9 @@ class polyTopoChange
//- Renumber & compact elements of list according to map
static void renumberCompact(const labelList&, labelList&);
//- Get all set elements as a labelHashSet
static labelHashSet getSetIndices(const PackedBoolList&);
//- Count number of added and removed quantities from maps.
static void countMap
(