mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: additional Map/HashTable constructors and ListOp functions
- construct Map/HashTable from key/value lists. - invertToMap() : like invert() but returns a Map<label>, which is useful for sparse numbering - inplaceRenumber() : taking a Map<label> for the mapper ENH: construct/reset CStringList for list of C-strings
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -98,19 +98,6 @@ bool skipSection(IFstream& inFile)
|
||||
}
|
||||
|
||||
|
||||
void renumber
|
||||
(
|
||||
const Map<label>& mshToFoam,
|
||||
labelList& labels
|
||||
)
|
||||
{
|
||||
forAll(labels, labelI)
|
||||
{
|
||||
labels[labelI] = mshToFoam[labels[labelI]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Find face in pp which uses all vertices in meshF (in mesh point labels)
|
||||
label findFace(const primitivePatch& pp, const labelList& meshF)
|
||||
{
|
||||
@ -587,7 +574,7 @@ void readCellsLegacy
|
||||
{
|
||||
lineStr >> triPoints[0] >> triPoints[1] >> triPoints[2];
|
||||
|
||||
renumber(mshToFoam, triPoints);
|
||||
inplaceRenumber(mshToFoam, triPoints);
|
||||
|
||||
const auto regFnd = physToPatch.cfind(regPhys);
|
||||
|
||||
@ -620,7 +607,7 @@ void readCellsLegacy
|
||||
>> quadPoints[0] >> quadPoints[1] >> quadPoints[2]
|
||||
>> quadPoints[3];
|
||||
|
||||
renumber(mshToFoam, quadPoints);
|
||||
inplaceRenumber(mshToFoam, quadPoints);
|
||||
|
||||
const auto regFnd = physToPatch.cfind(regPhys);
|
||||
|
||||
@ -662,7 +649,7 @@ void readCellsLegacy
|
||||
>> tetPoints[0] >> tetPoints[1] >> tetPoints[2]
|
||||
>> tetPoints[3];
|
||||
|
||||
renumber(mshToFoam, tetPoints);
|
||||
inplaceRenumber(mshToFoam, tetPoints);
|
||||
|
||||
cells[celli++].reset(tet, tetPoints);
|
||||
|
||||
@ -683,7 +670,7 @@ void readCellsLegacy
|
||||
>> pyrPoints[0] >> pyrPoints[1] >> pyrPoints[2]
|
||||
>> pyrPoints[3] >> pyrPoints[4];
|
||||
|
||||
renumber(mshToFoam, pyrPoints);
|
||||
inplaceRenumber(mshToFoam, pyrPoints);
|
||||
|
||||
cells[celli++].reset(pyr, pyrPoints);
|
||||
|
||||
@ -704,7 +691,7 @@ void readCellsLegacy
|
||||
>> prismPoints[0] >> prismPoints[1] >> prismPoints[2]
|
||||
>> prismPoints[3] >> prismPoints[4] >> prismPoints[5];
|
||||
|
||||
renumber(mshToFoam, prismPoints);
|
||||
inplaceRenumber(mshToFoam, prismPoints);
|
||||
|
||||
cells[celli].reset(prism, prismPoints);
|
||||
|
||||
@ -745,7 +732,7 @@ void readCellsLegacy
|
||||
>> hexPoints[4] >> hexPoints[5]
|
||||
>> hexPoints[6] >> hexPoints[7];
|
||||
|
||||
renumber(mshToFoam, hexPoints);
|
||||
inplaceRenumber(mshToFoam, hexPoints);
|
||||
|
||||
cells[celli].reset(hex, hexPoints);
|
||||
|
||||
@ -929,7 +916,7 @@ void readCells
|
||||
IStringStream lineStr(line);
|
||||
lineStr >> elemID >> triPoints[0] >> triPoints[1] >> triPoints[2];
|
||||
|
||||
renumber(mshToFoam, triPoints);
|
||||
inplaceRenumber(mshToFoam, triPoints);
|
||||
|
||||
const auto regFnd = physToPatch.cfind(regPhys);
|
||||
|
||||
@ -967,7 +954,7 @@ void readCells
|
||||
>> quadPoints[0] >> quadPoints[1] >> quadPoints[2]
|
||||
>> quadPoints[3];
|
||||
|
||||
renumber(mshToFoam, quadPoints);
|
||||
inplaceRenumber(mshToFoam, quadPoints);
|
||||
|
||||
const auto regFnd = physToPatch.cfind(regPhys);
|
||||
|
||||
@ -1017,7 +1004,7 @@ void readCells
|
||||
>> tetPoints[0] >> tetPoints[1] >> tetPoints[2]
|
||||
>> tetPoints[3];
|
||||
|
||||
renumber(mshToFoam, tetPoints);
|
||||
inplaceRenumber(mshToFoam, tetPoints);
|
||||
|
||||
cells[celli++].reset(tet, tetPoints);
|
||||
}
|
||||
@ -1044,7 +1031,7 @@ void readCells
|
||||
>> pyrPoints[0] >> pyrPoints[1] >> pyrPoints[2]
|
||||
>> pyrPoints[3] >> pyrPoints[4];
|
||||
|
||||
renumber(mshToFoam, pyrPoints);
|
||||
inplaceRenumber(mshToFoam, pyrPoints);
|
||||
|
||||
cells[celli++].reset(pyr, pyrPoints);
|
||||
}
|
||||
@ -1071,7 +1058,7 @@ void readCells
|
||||
>> prismPoints[0] >> prismPoints[1] >> prismPoints[2]
|
||||
>> prismPoints[3] >> prismPoints[4] >> prismPoints[5];
|
||||
|
||||
renumber(mshToFoam, prismPoints);
|
||||
inplaceRenumber(mshToFoam, prismPoints);
|
||||
|
||||
cells[celli].reset(prism, prismPoints);
|
||||
|
||||
@ -1118,7 +1105,7 @@ void readCells
|
||||
>> hexPoints[4] >> hexPoints[5]
|
||||
>> hexPoints[6] >> hexPoints[7];
|
||||
|
||||
renumber(mshToFoam, hexPoints);
|
||||
inplaceRenumber(mshToFoam, hexPoints);
|
||||
|
||||
cells[celli].reset(hex, hexPoints);
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -219,14 +219,14 @@ void readPoints
|
||||
<< endl;
|
||||
}
|
||||
|
||||
point pt;
|
||||
is.getLine(line);
|
||||
pt[0] = readUnvScalar(line.substr(0, 25));
|
||||
pt[1] = readUnvScalar(line.substr(25, 25));
|
||||
pt[2] = readUnvScalar(line.substr(50, 25));
|
||||
|
||||
unvPointID.append(pointi);
|
||||
points.append(pt);
|
||||
unvPointID.push_back(pointi);
|
||||
point& p = points.emplace_back();
|
||||
|
||||
p.x() = readUnvScalar(line.substr(0, 25));
|
||||
p.y() = readUnvScalar(line.substr(25, 25));
|
||||
p.z() = readUnvScalar(line.substr(50, 25));
|
||||
}
|
||||
|
||||
points.shrink();
|
||||
@ -847,7 +847,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
labelList own(boundaryFaces.size(), -1);
|
||||
labelList nei(boundaryFaces.size(), -1);
|
||||
Map<label> faceToCell[2];
|
||||
Pair<Map<label>> faceToCell;
|
||||
|
||||
{
|
||||
// Can use face::symmHasher or use sorted indices instead
|
||||
@ -996,12 +996,7 @@ int main(int argc, char *argv[])
|
||||
labelHashSet alreadyOnBoundary;
|
||||
|
||||
// Construct map from boundaryFaceIndices
|
||||
Map<label> boundaryFaceToIndex(boundaryFaceIndices.size());
|
||||
|
||||
forAll(boundaryFaceIndices, i)
|
||||
{
|
||||
boundaryFaceToIndex.insert(boundaryFaceIndices[i], i);
|
||||
}
|
||||
Map<label> boundaryFaceToIndex(invertToMap(boundaryFaceIndices));
|
||||
|
||||
forAll(patchFaceVerts, patchi)
|
||||
{
|
||||
@ -1216,20 +1211,13 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
const label old = oldIndizes[i];
|
||||
label noveau = -1;
|
||||
label c1 = -1, c2 = -1;
|
||||
if (faceToCell[0].found(old))
|
||||
{
|
||||
c1 = faceToCell[0][old];
|
||||
}
|
||||
if (faceToCell[1].found(old))
|
||||
{
|
||||
c2 = faceToCell[1][old];
|
||||
}
|
||||
|
||||
label c1 = faceToCell[0].lookup(old, -1);
|
||||
label c2 = faceToCell[1].lookup(old, -1);
|
||||
|
||||
if (c1 < c2)
|
||||
{
|
||||
label tmp = c1;
|
||||
c1 = c2;
|
||||
c2 = tmp;
|
||||
std::swap(c1, c2);
|
||||
}
|
||||
if (c2 == -1)
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -197,7 +197,7 @@ int main(int argc, char *argv[])
|
||||
//
|
||||
|
||||
pointField points(nNodes);
|
||||
Map<label> nodeToPoint(nNodes);
|
||||
Map<label> nodeToPoint(2*nNodes);
|
||||
|
||||
{
|
||||
labelList pointIndex(nNodes);
|
||||
@ -439,23 +439,16 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
// Get Foam patchID and update region->patch table.
|
||||
label patchi = 0;
|
||||
label patchi = regionToPatch.lookup(region, -1);
|
||||
|
||||
const auto patchFind = regionToPatch.cfind(region);
|
||||
|
||||
if (patchFind.good())
|
||||
{
|
||||
patchi = *patchFind;
|
||||
}
|
||||
else
|
||||
if (patchi < 0)
|
||||
{
|
||||
patchi = nPatches;
|
||||
regionToPatch.insert(region, nPatches++);
|
||||
|
||||
Info<< "Mapping tetgen region " << region
|
||||
<< " to patch "
|
||||
<< patchi << endl;
|
||||
|
||||
regionToPatch.insert(region, nPatches++);
|
||||
}
|
||||
|
||||
boundaryPatch[facei] = patchi;
|
||||
|
||||
@ -295,9 +295,7 @@ void addToInterface
|
||||
else
|
||||
{
|
||||
// Create new interface of size 1.
|
||||
Map<label> zoneToSize;
|
||||
zoneToSize.insert(zoneID, 1);
|
||||
regionsToSize.insert(interface, zoneToSize);
|
||||
regionsToSize(interface).insert(zoneID, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -484,18 +482,10 @@ void getInterfaceSizes
|
||||
zoneName + "_" + name1 + "_to_" + name0
|
||||
);
|
||||
}
|
||||
interfaceSizes[nInterfaces] = infoIter();
|
||||
|
||||
if (regionsToInterface.found(e))
|
||||
{
|
||||
regionsToInterface[e].insert(zoneID, nInterfaces);
|
||||
}
|
||||
else
|
||||
{
|
||||
Map<label> zoneAndInterface;
|
||||
zoneAndInterface.insert(zoneID, nInterfaces);
|
||||
regionsToInterface.insert(e, zoneAndInterface);
|
||||
}
|
||||
interfaceSizes[nInterfaces] = infoIter();
|
||||
regionsToInterface(e).insert(zoneID, nInterfaces);
|
||||
|
||||
nInterfaces++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user