diff --git a/src/OpenFOAM/primitives/RemoteData/RemoteData.H b/src/OpenFOAM/primitives/RemoteData/RemoteData.H index 416a4e391c..e3183f48c8 100644 --- a/src/OpenFOAM/primitives/RemoteData/RemoteData.H +++ b/src/OpenFOAM/primitives/RemoteData/RemoteData.H @@ -36,8 +36,7 @@ SourceFiles #ifndef RemoteData_H #define RemoteData_H -#include "Istream.H" -#include "Ostream.H" +#include "remote.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -62,17 +61,13 @@ inline Ostream& operator<<(Ostream&, const RemoteData&); template class RemoteData +: + public remote { public: // Public Data - //- Processor index - label proci; - - //- Element index - label elementi; - //- Data Type data; diff --git a/src/OpenFOAM/primitives/RemoteData/RemoteDataI.H b/src/OpenFOAM/primitives/RemoteData/RemoteDataI.H index 7abcb4aa35..dc5f668a24 100644 --- a/src/OpenFOAM/primitives/RemoteData/RemoteDataI.H +++ b/src/OpenFOAM/primitives/RemoteData/RemoteDataI.H @@ -30,8 +30,7 @@ License template inline Foam::RemoteData::RemoteData() : - proci(-1), - elementi(-1), + remote(), data() {} @@ -44,8 +43,7 @@ inline Foam::RemoteData::RemoteData const Type& d ) : - proci(p), - elementi(e), + remote(p, e), data(d) {} @@ -111,9 +109,8 @@ inline bool Foam::operator== ) { return - a.proci == b.proci - && a.elementi == b.elementi - && a.data == b.data; + static_cast(a) == static_cast(b) + && a.data == b.data; } @@ -133,17 +130,14 @@ inline bool Foam::operator!= template inline Foam::Ostream& Foam::operator<<(Ostream& os, const RemoteData& p) { - return os - << p.proci << token::SPACE - << p.elementi << token::SPACE - << p.data; + return os << static_cast(p) << token::SPACE << p.data; } template inline Foam::Istream& Foam::operator>>(Istream& is, RemoteData& p) { - return is >> p.proci >> p.elementi >> p.data; + return is >> static_cast(p) >> p.data; } diff --git a/src/OpenFOAM/primitives/remote/remote.H b/src/OpenFOAM/primitives/remote/remote.H new file mode 100644 index 0000000000..8c568c28ff --- /dev/null +++ b/src/OpenFOAM/primitives/remote/remote.H @@ -0,0 +1,113 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2022 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::remote + +Description + Struct for keeping processor, element (cell, face, point) index. + +SourceFiles + remoteI.H + +\*---------------------------------------------------------------------------*/ + +#ifndef remote_H +#define remote_H + +#include "Istream.H" +#include "Ostream.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of friend functions and operators +class remote; +inline bool operator==(const remote&, const remote&); +inline bool operator!=(const remote&, const remote&); +inline Istream& operator>>(Istream&, remote&); +inline Ostream& operator<<(Ostream&, const remote&); + +/*---------------------------------------------------------------------------*\ + Class remote Declaration +\*---------------------------------------------------------------------------*/ + +class remote +{ +public: + + // Public Data + + //- Processor index + label proci; + + //- Element index + label elementi; + + + // Constructors + + //- Construct null + inline remote(); + + //- Construct from components + inline remote(const label, const label); + + //- Construct from stream + inline remote(Istream& is); + + + // Friend Operators + + //- Equality comparison + friend bool operator==(const remote& a, const remote& b); + + //- Inequality comparison + friend bool operator!=(const remote& a, const remote& b); + + + // IOstream Operators + + //- Write to stream + friend Ostream& operator<<(Ostream& os, const remote& p); + + //- Read from stream + friend Istream& operator>>(Istream& is, remote& p); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "remoteI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/remote/remoteI.H b/src/OpenFOAM/primitives/remote/remoteI.H new file mode 100644 index 0000000000..b5ba9f1ac3 --- /dev/null +++ b/src/OpenFOAM/primitives/remote/remoteI.H @@ -0,0 +1,78 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2022 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "remote.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +inline Foam::remote::remote() +: + proci(-1), + elementi(-1) +{} + + +inline Foam::remote::remote(const label p, const label e) +: + proci(p), + elementi(e) +{} + + +inline Foam::remote::remote(Istream& is) +{ + is >> *this; +} + + +// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // + +inline bool Foam::operator==(const remote& a, const remote& b) +{ + return a.proci == b.proci && a.elementi == b.elementi; +} + + +inline bool Foam::operator!=(const remote& a, const remote& b) +{ + return !(a == b); +} + + +// * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * // + +inline Foam::Ostream& Foam::operator<<(Ostream& os, const remote& p) +{ + return os << p.proci << token::SPACE << p.elementi; +} + + +inline Foam::Istream& Foam::operator>>(Istream& is, remote& p) +{ + return is >> p.proci >> p.elementi; +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/fvMeshStitchers/fvMeshStitcher/fvMeshStitcher.C b/src/finiteVolume/fvMesh/fvMeshStitchers/fvMeshStitcher/fvMeshStitcher.C index e46715d83a..092b65ecd6 100644 --- a/src/finiteVolume/fvMesh/fvMeshStitchers/fvMeshStitcher/fvMeshStitcher.C +++ b/src/finiteVolume/fvMesh/fvMeshStitchers/fvMeshStitcher/fvMeshStitcher.C @@ -120,7 +120,7 @@ void Foam::fvMeshStitcher::intersectNonConformalCyclic // non-conformal interfaces are ordered. auto procFacesToIndices = [] ( - const List>& faceOtherProcFaces, + const List>& faceOtherProcFaces, const bool owner ) { @@ -130,8 +130,7 @@ void Foam::fvMeshStitcher::intersectNonConformalCyclic { forAll(faceOtherProcFaces[facei], i) { - const patchToPatch::procFace& otherProcFacei = - faceOtherProcFaces[facei][i]; + const remote& otherProcFacei = faceOtherProcFaces[facei][i]; is[otherProcFacei.proci] ++; } @@ -150,13 +149,12 @@ void Foam::fvMeshStitcher::intersectNonConformalCyclic { forAll(faceOtherProcFaces[facei], i) { - const patchToPatch::procFace& otherProcFacei = - faceOtherProcFaces[facei][i]; + const remote& otherProcFacei = faceOtherProcFaces[facei][i]; FixedList& index = indices[otherProcFacei.proci][is[otherProcFacei.proci] ++]; - index = {facei, otherProcFacei.facei, i}; + index = {facei, otherProcFacei.elementi, i}; if (!owner) Swap(index[0], index[1]); } diff --git a/src/lagrangian/basic/particle/particleTemplates.C b/src/lagrangian/basic/particle/particleTemplates.C index c31b0414d6..58a2f3b84b 100644 --- a/src/lagrangian/basic/particle/particleTemplates.C +++ b/src/lagrangian/basic/particle/particleTemplates.C @@ -295,7 +295,7 @@ bool Foam::particle::hitNonConformalCyclicPatch // Project the particle through the non-conformal patch point receivePos; - const patchToPatch::procFace receiveProcFace = + const remote receiveProcFace = nccpp.ray ( stepFractionSpan(td.mesh)[0] @@ -318,7 +318,7 @@ bool Foam::particle::hitNonConformalCyclicPatch td.sendFromPatch = nccpp.index(); td.sendToProc = receiveProcFace.proci; td.sendToPatch = nccpp.nbrPatchID(); - td.sendToPatchFace = receiveProcFace.facei; + td.sendToPatchFace = receiveProcFace.elementi; return true; } @@ -328,7 +328,7 @@ bool Foam::particle::hitNonConformalCyclicPatch ( td.mesh, nccpp.index(), - receiveProcFace.facei + receiveProcFace.elementi ); correctAfterNonConformalCyclicTransfer ( diff --git a/src/meshTools/nonConformal/polyPatches/nonConformalCyclic/nonConformalCyclicPolyPatch.C b/src/meshTools/nonConformal/polyPatches/nonConformalCyclic/nonConformalCyclicPolyPatch.C index f1a110cbab..964699c59e 100644 --- a/src/meshTools/nonConformal/polyPatches/nonConformalCyclic/nonConformalCyclicPolyPatch.C +++ b/src/meshTools/nonConformal/polyPatches/nonConformalCyclic/nonConformalCyclicPolyPatch.C @@ -318,7 +318,7 @@ Foam::nonConformalCyclicPolyPatch::rays() const } -Foam::patchToPatch::procFace Foam::nonConformalCyclicPolyPatch::ray +Foam::remote Foam::nonConformalCyclicPolyPatch::ray ( const scalar fraction, const label origFacei, diff --git a/src/meshTools/nonConformal/polyPatches/nonConformalCyclic/nonConformalCyclicPolyPatch.H b/src/meshTools/nonConformal/polyPatches/nonConformalCyclic/nonConformalCyclicPolyPatch.H index 288dafb120..bac95c4cde 100644 --- a/src/meshTools/nonConformal/polyPatches/nonConformalCyclic/nonConformalCyclicPolyPatch.H +++ b/src/meshTools/nonConformal/polyPatches/nonConformalCyclic/nonConformalCyclicPolyPatch.H @@ -227,7 +227,7 @@ public: const patchToPatches::rays& rays() const; //- Compute a ray intersection across the coupling - patchToPatch::procFace ray + remote ray ( const scalar fraction, const label origFacei, diff --git a/src/meshTools/patchToPatch/patchToPatch/patchToPatch.C b/src/meshTools/patchToPatch/patchToPatch/patchToPatch.C index 20ce9642ef..e0301c8fe4 100644 --- a/src/meshTools/patchToPatch/patchToPatch/patchToPatch.C +++ b/src/meshTools/patchToPatch/patchToPatch/patchToPatch.C @@ -161,14 +161,14 @@ namespace Foam // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -Foam::List> +Foam::List> Foam::patchToPatch::localFacesToProcFaces ( const List>& localFaces, - const List& map + const List& map ) { - List> result(localFaces.size()); + List> result(localFaces.size()); forAll(localFaces, thisFacei) { @@ -178,7 +178,7 @@ Foam::patchToPatch::localFacesToProcFaces { result[thisFacei][i] = isNull(map) - ? procFace({Pstream::myProcNo(), localFaces[thisFacei][i]}) + ? remote({Pstream::myProcNo(), localFaces[thisFacei][i]}) : map[localFaces[thisFacei][i]]; } } @@ -190,8 +190,8 @@ Foam::patchToPatch::localFacesToProcFaces Foam::List> Foam::patchToPatch::procFacesToLocalFaces ( - const List>& procFaces, - const HashTable>& map + const List>& procFaces, + const HashTable>& map ) { List> result(procFaces.size()); @@ -204,7 +204,7 @@ Foam::patchToPatch::procFacesToLocalFaces { result[tgtFacei][i] = isNull(map) - ? procFaces[tgtFacei][i].facei + ? procFaces[tgtFacei][i].elementi : map[procFaces[tgtFacei][i]]; } } @@ -816,7 +816,7 @@ Foam::labelList Foam::patchToPatch::subsetLocalTgt tgtLocalSrcFaces_ = List>(tgtLocalSrcFaces_, newToOldLocalTgtFace); localTgtProcFacesPtr_() = - List(localTgtProcFacesPtr_(), newToOldLocalTgtFace); + List(localTgtProcFacesPtr_(), newToOldLocalTgtFace); return newToOldLocalTgtFace; } @@ -834,7 +834,7 @@ void Foam::patchToPatch::distributeSrc void Foam::patchToPatch::rDistributeTgt(const primitiveOldTimePatch& tgtPatch) { // Create a map from source procFace to local source face - HashTable> srcProcFaceToLocal; + HashTable> srcProcFaceToLocal; forAll(localSrcProcFacesPtr_(), localSrcFacei) { srcProcFaceToLocal.insert @@ -846,7 +846,7 @@ void Foam::patchToPatch::rDistributeTgt(const primitiveOldTimePatch& tgtPatch) // Collect the source procFaces on the target and convert to local // source face addressing - List> tgtSrcProcFaces = + List> tgtSrcProcFaces = localFacesToProcFaces(tgtLocalSrcFaces_); rDistributeListList(tgtPatch.size(), tgtMapPtr_(), tgtSrcProcFaces); @@ -892,8 +892,8 @@ Foam::patchToPatch::patchToPatch(const bool reverse) tgtLocalSrcFaces_(), srcMapPtr_(nullptr), tgtMapPtr_(nullptr), - localSrcProcFacesPtr_(new List()), - localTgtProcFacesPtr_(new List()) + localSrcProcFacesPtr_(new List()), + localTgtProcFacesPtr_(new List()) {} diff --git a/src/meshTools/patchToPatch/patchToPatch/patchToPatch.H b/src/meshTools/patchToPatch/patchToPatch/patchToPatch.H index fba23b3511..340f553345 100644 --- a/src/meshTools/patchToPatch/patchToPatch/patchToPatch.H +++ b/src/meshTools/patchToPatch/patchToPatch/patchToPatch.H @@ -39,6 +39,7 @@ SourceFiles #include "distributionMap.H" #include "primitivePatch.H" #include "primitiveOldTimePatch.H" +#include "remote.H" #include "runTimeSelectionTables.H" #include "treeBoundBox.H" @@ -53,45 +54,6 @@ namespace Foam class patchToPatch { -public: - - // Public Structures - - //- Structure to conveniently store processor and face indices - struct procFace - { - //- The processor index - label proci; - - //- The face index - label facei; - - //- Equality comparison - friend bool operator==(const procFace& a, const procFace& b) - { - return a.proci == b.proci && a.facei == b.facei; - } - - //- Inequality comparison - friend bool operator!=(const procFace& a, const procFace& b) - { - return !(a == b); - } - - //- Output stream operator - friend Ostream& operator<<(Ostream& os, const procFace& p) - { - return os << p.proci << token::SPACE << p.facei; - } - - //- Input stream operator - friend Istream& operator>>(Istream& is, procFace& p) - { - return is >> p.proci >> p.facei; - } - }; - - protected: // Private Data @@ -118,11 +80,11 @@ protected: //- When running in parallel, a map from local source face index to // source processor and face index - autoPtr> localSrcProcFacesPtr_; + autoPtr> localSrcProcFacesPtr_; //- When running in parallel, a map from local target face index to // target processor and face index - autoPtr> localTgtProcFacesPtr_; + autoPtr> localTgtProcFacesPtr_; // Private Member Functions @@ -156,17 +118,17 @@ protected: ); //- Map local faces to proc faces - static List> localFacesToProcFaces + static List> localFacesToProcFaces ( const List>& localFaces, - const List& map = NullObjectRef>() + const List& map = NullObjectRef>() ); //- Map proc faces to local faces static List> procFacesToLocalFaces ( - const List>& procFaces, - const HashTable>& map + const List>& procFaces, + const HashTable>& map ); @@ -301,7 +263,7 @@ protected: ( const distributionMap& map, const primitiveOldTimePatch& patch, - List& localProcFaces + List& localProcFaces ) const; //- As above, but when you want the proc-faces without the @@ -309,7 +271,7 @@ protected: void distributePatch ( const distributionMap& map, - List& localProcFaces + List& localProcFaces ) const; @@ -441,10 +403,10 @@ public: inline bool isSingleProcess() const; //- For each source face, the coupled target procs and faces - inline List> srcTgtProcFaces() const; + inline List> srcTgtProcFaces() const; //- For each target face, the coupled source procs and faces - inline List> tgtSrcProcFaces() const; + inline List> tgtSrcProcFaces() const; // Interpolation diff --git a/src/meshTools/patchToPatch/patchToPatch/patchToPatchI.H b/src/meshTools/patchToPatch/patchToPatch/patchToPatchI.H index 3617a88ee9..1bd0ca728b 100644 --- a/src/meshTools/patchToPatch/patchToPatch/patchToPatchI.H +++ b/src/meshTools/patchToPatch/patchToPatch/patchToPatchI.H @@ -102,7 +102,7 @@ inline bool Foam::patchToPatch::isSingleProcess() const } -inline Foam::List> +inline Foam::List> Foam::patchToPatch::srcTgtProcFaces() const { return @@ -112,7 +112,7 @@ Foam::patchToPatch::srcTgtProcFaces() const } -inline Foam::List> +inline Foam::List> Foam::patchToPatch::tgtSrcProcFaces() const { return diff --git a/src/meshTools/patchToPatch/patchToPatch/patchToPatchParallelOps.C b/src/meshTools/patchToPatch/patchToPatch/patchToPatchParallelOps.C index a5bc6b9389..2a039f73dc 100644 --- a/src/meshTools/patchToPatch/patchToPatch/patchToPatchParallelOps.C +++ b/src/meshTools/patchToPatch/patchToPatch/patchToPatchParallelOps.C @@ -222,7 +222,7 @@ Foam::patchToPatch::distributePatch ( const distributionMap& map, const primitiveOldTimePatch& patch, - List& localProcFaces + List& localProcFaces ) const { static const label thisProci = Pstream::myProcNo(); @@ -387,7 +387,7 @@ Foam::patchToPatch::distributePatch void Foam::patchToPatch::distributePatch ( const distributionMap& map, - List& localProcFaces + List& localProcFaces ) const { static const label thisProci = Pstream::myProcNo(); diff --git a/src/meshTools/patchToPatch/rays/raysPatchToPatch.C b/src/meshTools/patchToPatch/rays/raysPatchToPatch.C index 58b0b379ff..e0003212bc 100644 --- a/src/meshTools/patchToPatch/rays/raysPatchToPatch.C +++ b/src/meshTools/patchToPatch/rays/raysPatchToPatch.C @@ -165,12 +165,12 @@ Foam::label Foam::patchToPatches::rays::finalise } -Foam::patchToPatch::procFace Foam::patchToPatches::rays::ray +Foam::remote Foam::patchToPatches::rays::ray ( const primitiveOldTimePatch& outPatch, const autoPtr>& localOutPatchPtr, - const autoPtr>& localOutProcFacesPtr, + const autoPtr>& localOutProcFacesPtr, const List>& inLocalOutFaces, const scalar fraction, const label inFacei, @@ -213,12 +213,12 @@ Foam::patchToPatch::procFace Foam::patchToPatches::rays::ray return isSingleProcess() - ? procFace({Pstream::myProcNo(), localOutFacei}) + ? remote({Pstream::myProcNo(), localOutFacei}) : localOutProcFacesPtr()[localOutFacei]; } } - return procFace({-1, -1}); + return remote({-1, -1}); } @@ -257,7 +257,7 @@ Foam::patchToPatches::rays::~rays() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::patchToPatch::procFace Foam::patchToPatches::rays::srcToTgtRay +Foam::remote Foam::patchToPatches::rays::srcToTgtRay ( const primitiveOldTimePatch& tgtPatch, const scalar fraction, @@ -283,7 +283,7 @@ Foam::patchToPatch::procFace Foam::patchToPatches::rays::srcToTgtRay } -Foam::patchToPatch::procFace Foam::patchToPatches::rays::tgtToSrcRay +Foam::remote Foam::patchToPatches::rays::tgtToSrcRay ( const primitiveOldTimePatch& srcPatch, const scalar fraction, diff --git a/src/meshTools/patchToPatch/rays/raysPatchToPatch.H b/src/meshTools/patchToPatch/rays/raysPatchToPatch.H index 000b69e7f9..609ca8e9dc 100644 --- a/src/meshTools/patchToPatch/rays/raysPatchToPatch.H +++ b/src/meshTools/patchToPatch/rays/raysPatchToPatch.H @@ -114,12 +114,12 @@ class rays ); //- Compute a ray intersection - procFace ray + remote ray ( const primitiveOldTimePatch& outPatch, const autoPtr>& localOutPatchPtr, - const autoPtr>& localOutProcFacesPtr, + const autoPtr>& localOutProcFacesPtr, const List>& inLocalOutFacesPtr, const scalar fraction, const label inFacei, @@ -154,7 +154,7 @@ public: // Member Functions //- Compute a ray intersection from the source side to the target - procFace srcToTgtRay + remote srcToTgtRay ( const primitiveOldTimePatch& tgtPatch, const scalar fraction, @@ -165,7 +165,7 @@ public: ) const; //- Compute a ray intersection from the target side to the source - procFace tgtToSrcRay + remote tgtToSrcRay ( const primitiveOldTimePatch& srcPatch, const scalar fraction, diff --git a/src/sampling/meshToMesh/patchToPatchFvPatchFieldMapper.H b/src/sampling/meshToMesh/patchToPatchFvPatchFieldMapper.H index b91e243395..52121f2f91 100644 --- a/src/sampling/meshToMesh/patchToPatchFvPatchFieldMapper.H +++ b/src/sampling/meshToMesh/patchToPatchFvPatchFieldMapper.H @@ -93,7 +93,7 @@ public: size_(-1), hasUnmapped_(false) { - const List> procFaces = + const List> procFaces = forward_ ? pToP_.tgtSrcProcFaces() : pToP_.srcTgtProcFaces(); size_ = procFaces.size();