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<> template<>
label IFCstream::coherentFieldSize<fvsPatchField, surfaceMesh>() 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> template<class Type>
Foam::OFCstream<Type, Foam::fvsPatchField, Foam::surfaceMesh>::~OFCstream() Foam::OFCstream<Type, Foam::fvsPatchField, Foam::surfaceMesh>::~OFCstream()
{ {
internalFieldOffsets_ = coherentMesh_.internalSurfaceFieldOffsets();
combineCoherentInternal(); combineCoherentInternal();
this->removeProcPatchesFromDict(); this->removeProcPatchesFromDict();
this->writeGlobalGeometricField(); this->writeGlobalGeometricField();

View file

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

View file

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

View file

@ -164,6 +164,11 @@ public:
return procBoundaryIDs_; return procBoundaryIDs_;
} }
inline const std::vector<Offsets>& patchOffsets() const
{
return boundarySurfacePatchOffsets_;
}
void polyNeighbours(labelList&); void polyNeighbours(labelList&);
void polyOwner(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()); 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() Foam::Offsets::iterator Foam::Offsets::begin()
{ {
return offset_pairs_.begin(); return offset_pairs_.begin();

View file

@ -88,6 +88,16 @@ public:
// Return the difference between lower and upper bound // Return the difference between lower and upper bound
label count(label) const; 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; label size() const;
iterator begin(); iterator begin();