ENH: use offsets from CoherentMesh to remove communication (globalIndex) in OFCstream::writeGlobalGeometricField

- extended interface of Foam::CoherentMesh to access to boundary patch offsets
- modified and extended interface of Foam::Offsets
This commit is contained in:
Gregor Weiss 2023-10-11 15:46:44 +02:00
parent 4b35549b20
commit f352c854a7
7 changed files with 48 additions and 6 deletions

View file

@ -52,7 +52,7 @@ defineTemplateTypeNameAndDebug(surfaceTensorField, 0);
template<>
label IFCstream::coherentFieldSize<fvsPatchField, surfaceMesh>()
{
return coherentMesh_.internalSurfaceFieldOffsets().size();
return coherentMesh_.internalSurfaceFieldOffsets().count();
}

View file

@ -417,6 +417,7 @@ Foam::OFCstream<Type, Foam::fvsPatchField, Foam::surfaceMesh>::OFCstream
template<class Type>
Foam::OFCstream<Type, Foam::fvsPatchField, Foam::surfaceMesh>::~OFCstream()
{
internalFieldOffsets_ = coherentMesh_.internalSurfaceFieldOffsets();
combineCoherentInternal();
this->removeProcPatchesFromDict();
this->writeGlobalGeometricField();

View file

@ -342,6 +342,13 @@ void Foam::OFCstreamBase::writeGlobalGeometricField()
}
sliceStreamPtr->access("fields", path);
std::vector<Offsets> offsets({internalFieldOffsets_});
const auto& patchOffsets = coherentMesh_.patchOffsets();
for (Offsets off : patchOffsets)
{
offsets.push_back(off);
}
forAll(fieldDataEntries, i)
{
fieldDataEntry& fde = *(fieldDataEntries[i]);
@ -355,12 +362,11 @@ void Foam::OFCstreamBase::writeGlobalGeometricField()
// processorXX.
if (!fde.uniform())
{
const label nElems = fde.uList().size(); //nElems();
const label nCmpts = fde.uList().nComponents();
const globalIndex bgi(nElems);
const label nGlobalElems = bgi.size();
const label elemOffset = bgi.offset(Pstream::myProcNo());
const label nGlobalElems = offsets[i].size();
const label elemOffset = offsets[i].offset();
const label nElems = offsets[i].count();
// Write to engine
sliceStreamPtr->put

View file

@ -65,6 +65,7 @@ protected:
fileName pathname_;
CoherentMesh& coherentMesh_;
Offsets internalFieldOffsets_;
//- Dictionary holding both entries for the ASCII file and pointer,
// size data for the BLOBs.
@ -208,6 +209,7 @@ public:
//- Destructor
virtual ~OFCstream()
{
internalFieldOffsets_ = coherentMesh_.cellOffsets();
this->removeProcPatchesFromDict();
this->writeGlobalGeometricField();
}

View file

@ -164,6 +164,11 @@ public:
return procBoundaryIDs_;
}
inline const std::vector<Offsets>& patchOffsets() const
{
return boundarySurfacePatchOffsets_;
}
void polyNeighbours(labelList&);
void polyOwner(labelList&);

View file

@ -84,12 +84,30 @@ Foam::label Foam::Offsets::count(Foam::label myProcNo) const
}
Foam::label Foam::Offsets::size() const
Foam::label Foam::Offsets::count() const
{
return count(Pstream::myProcNo());
}
Foam::label Foam::Offsets::offset(Foam::label myProcNo) const
{
return lowerBound(myProcNo);
}
Foam::label Foam::Offsets::offset() const
{
return offset(Pstream::myProcNo());
}
Foam::label Foam::Offsets::size() const
{
return upperBound(Pstream::nProcs()-1);
}
Foam::Offsets::iterator Foam::Offsets::begin()
{
return offset_pairs_.begin();

View file

@ -88,6 +88,16 @@ public:
// Return the difference between lower and upper bound
label count(label) const;
// Return the count for this rank
label count() const;
// Return the lower bound
label offset(label) const;
// Return the offset for this rank
label offset() const;
// Return the global size
label size() const;
iterator begin();