diff --git a/src/finiteVolume/fields/surfaceFields/surfaceFields.C b/src/finiteVolume/fields/surfaceFields/surfaceFields.C index ba7d8fb..917a715 100644 --- a/src/finiteVolume/fields/surfaceFields/surfaceFields.C +++ b/src/finiteVolume/fields/surfaceFields/surfaceFields.C @@ -52,7 +52,7 @@ defineTemplateTypeNameAndDebug(surfaceTensorField, 0); template<> label IFCstream::coherentFieldSize() { - return coherentMesh_.internalSurfaceFieldOffsets().size(); + return coherentMesh_.internalSurfaceFieldOffsets().count(); } diff --git a/src/finiteVolume/fields/surfaceFields/surfaceFieldsI.H b/src/finiteVolume/fields/surfaceFields/surfaceFieldsI.H index 4731c5e..5f897f3 100644 --- a/src/finiteVolume/fields/surfaceFields/surfaceFieldsI.H +++ b/src/finiteVolume/fields/surfaceFields/surfaceFieldsI.H @@ -417,6 +417,7 @@ Foam::OFCstream::OFCstream template Foam::OFCstream::~OFCstream() { + internalFieldOffsets_ = coherentMesh_.internalSurfaceFieldOffsets(); combineCoherentInternal(); this->removeProcPatchesFromDict(); this->writeGlobalGeometricField(); diff --git a/src/foam/db/IOstreams/SliceStreams/OFCstream.C b/src/foam/db/IOstreams/SliceStreams/OFCstream.C index 5025e9c..9eae9a4 100644 --- a/src/foam/db/IOstreams/SliceStreams/OFCstream.C +++ b/src/foam/db/IOstreams/SliceStreams/OFCstream.C @@ -342,6 +342,13 @@ void Foam::OFCstreamBase::writeGlobalGeometricField() } sliceStreamPtr->access("fields", path); + std::vector 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 diff --git a/src/foam/db/IOstreams/SliceStreams/OFCstream.H b/src/foam/db/IOstreams/SliceStreams/OFCstream.H index 4e9942a..7a51f4e 100644 --- a/src/foam/db/IOstreams/SliceStreams/OFCstream.H +++ b/src/foam/db/IOstreams/SliceStreams/OFCstream.H @@ -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(); } diff --git a/src/foam/meshes/polyMesh/CoherentMesh/CoherentMesh.H b/src/foam/meshes/polyMesh/CoherentMesh/CoherentMesh.H index befb6fd..0ed578a 100644 --- a/src/foam/meshes/polyMesh/CoherentMesh/CoherentMesh.H +++ b/src/foam/meshes/polyMesh/CoherentMesh/CoherentMesh.H @@ -164,6 +164,11 @@ public: return procBoundaryIDs_; } + inline const std::vector& patchOffsets() const + { + return boundarySurfacePatchOffsets_; + } + void polyNeighbours(labelList&); void polyOwner(labelList&); diff --git a/src/foam/meshes/polyMesh/CoherentMesh/Offsets.C b/src/foam/meshes/polyMesh/CoherentMesh/Offsets.C index e03a456..6a79f9b 100644 --- a/src/foam/meshes/polyMesh/CoherentMesh/Offsets.C +++ b/src/foam/meshes/polyMesh/CoherentMesh/Offsets.C @@ -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(); diff --git a/src/foam/meshes/polyMesh/CoherentMesh/Offsets.H b/src/foam/meshes/polyMesh/CoherentMesh/Offsets.H index 46c1b36..a9e972c 100644 --- a/src/foam/meshes/polyMesh/CoherentMesh/Offsets.H +++ b/src/foam/meshes/polyMesh/CoherentMesh/Offsets.H @@ -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();