ENH: keep element ids when reading/writing meshed surfaces (#1600)

This commit is contained in:
Mark Olesen
2020-02-26 00:12:14 +01:00
parent 560c053bc8
commit cfd8873012
22 changed files with 345 additions and 68 deletions

View File

@ -118,7 +118,7 @@ inline static IOobject selectReadIO(const word& name, const Time& runTime)
void Foam::sampledMeshedSurface::setZoneMap()
{
// Ensure zoneIds_ are correctly populated
// Populate zoneIds_ based on surfZone information
const meshedSurface& s = static_cast<const meshedSurface&>(*this);
@ -279,19 +279,10 @@ bool Foam::sampledMeshedSurface::update(const meshSearch& meshSearcher)
s = surface_.subsetMesh(facesToSubset, pointMap, faceMap);
// Ensure zoneIds_ are indeed correct
setZoneMap();
// This is currently only partially useful
if (keepIds_)
{
originalIds_ = faceMap;
}
else
{
originalIds_.clear();
}
// Subset cellOrFaceLabels (for compact faces)
cellOrFaceLabels = labelUIndList(cellOrFaceLabels, faceMap)();
@ -492,8 +483,7 @@ Foam::sampledMeshedSurface::sampledMeshedSurface
),
sampleSource_(sampleSource),
needsUpdate_(true),
keepIds_(false),
originalIds_(),
keepIds_(true),
zoneIds_(),
sampleElements_(),
samplePoints_()
@ -524,8 +514,7 @@ Foam::sampledMeshedSurface::sampledMeshedSurface
),
sampleSource_(samplingSourceNames_.get("source", dict)),
needsUpdate_(true),
keepIds_(dict.lookupOrDefault("keepIds", false)),
originalIds_(),
keepIds_(dict.getOrDefault("keepIds", true)),
zoneIds_(),
sampleElements_(),
samplePoints_()
@ -610,7 +599,6 @@ bool Foam::sampledMeshedSurface::expire()
MeshStorage::clear();
zoneIds_.clear();
originalIds_.clear();
sampleElements_.clear();
samplePoints_.clear();

View File

@ -86,7 +86,7 @@ Usage
surface | surface name in triSurface/ | yes |
patches | Limit to named surface regions (wordRes) | no |
source | cells/insideCells/boundaryFaces | yes |
keepIds | pass through id numbering | no | false
keepIds | pass through id numbering | no | true
file | Alternative file name | no |
fileType | The surface format | no | (extension)
scale | Surface scaling factor | no | 0
@ -156,10 +156,6 @@ private:
//- Retain element ids/order of original surface
bool keepIds_;
//- List of element ids/order of the original surface,
//- when keepIds is active.
labelList originalIds_;
//- For compatibility with the meshSurf interface
labelList zoneIds_;
@ -258,6 +254,12 @@ public:
return zoneIds_;
}
//- Per-face identifier (eg, element Id)
virtual const labelList& faceIds() const
{
return MeshStorage::faceIds();
}
//- Face area vectors
virtual const vectorField& Sf() const
{
@ -279,14 +281,7 @@ public:
//- If element ids/order of the original surface are kept
virtual bool hasFaceIds() const
{
return keepIds_;
}
//- List of element ids/order of the original surface,
// when keepIds is active.
virtual const labelList& originalIds() const
{
return originalIds_;
return keepIds_ && !MeshStorage::faceIds().empty();
}
//- Sampling boundary values instead of cell values

View File

@ -340,13 +340,6 @@ public:
return false;
}
//- List of element ids/order of the original surface,
//- when hasFaceIds is true.
virtual const labelList& originalIds() const
{
return labelList::null();
}
// General registry storage (optional)

View File

@ -558,10 +558,15 @@ bool Foam::sampledSurfaces::performAction(unsigned request)
// Write original ids
if (s.hasFaceIds() && !s.interpolate())
{
// This is still quite horrible.
Field<label> ids(s.faceIds());
ids += label(1); // From 0-based to 1-based
writeSurface
(
outWriter,
Field<label>(s.originalIds()),
ids,
"Ids"
);
}

View File

@ -69,7 +69,7 @@ Description
}
surfaces
(
{
f0surf
{
type meshedSurface;
@ -88,7 +88,7 @@ Description
// Optional: registry storage
store true
}
);
}
}
\endverbatim