diff --git a/applications/solvers/foamMultiRun/regionSolvers/regionSolversI.H b/applications/solvers/foamMultiRun/regionSolvers/regionSolversI.H index f41f9eaacd..27ea8d15a9 100644 --- a/applications/solvers/foamMultiRun/regionSolvers/regionSolversI.H +++ b/applications/solvers/foamMultiRun/regionSolvers/regionSolversI.H @@ -129,7 +129,7 @@ inline Foam::regionSolvers::iterator Foam::regionSolvers::end() // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -inline Foam::regionSolvers::operator PtrList&() +inline Foam::regionSolvers::operator PtrList&() { return solvers_; } diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index 19db79a679..cf2bec168f 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C @@ -424,7 +424,7 @@ int main(int argc, char *argv[]) { forAll(regionNames, regioni) { - writeDecomposition(regionMeshes.meshes(regioni)()); + writeDecomposition(regionMeshes[regioni]()); Info<< endl; fileHandler().flush(); } @@ -462,7 +462,7 @@ int main(int argc, char *argv[]) { if (writeCellProc && stat >= fvMesh::TOPO_CHANGE) { - writeDecomposition(regionMeshes.meshes(regioni)()); + writeDecomposition(regionMeshes[regioni]()); Info<< endl; fileHandler().flush(); } @@ -530,8 +530,8 @@ int main(int argc, char *argv[]) // Prefixed scope { - const RegionConstRef meshes = - regionMeshes.meshes(regioni); + const RegionRef meshes = + regionMeshes[regioni]; // Search for objects at this time IOobjectList objects @@ -720,8 +720,8 @@ int main(int argc, char *argv[]) { // Prefixed scope { - const RegionConstRef meshes = - regionMeshes.meshes(regioni); + const RegionRef meshes = + regionMeshes[regioni]; Info<< "Distributing uniform files" << endl; diff --git a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C index 2b46fd0005..b914c50901 100644 --- a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C +++ b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C @@ -322,7 +322,7 @@ int main(int argc, char *argv[]) { forAll(regionNames, regioni) { - writeDecomposition(regionMeshes.meshes(regioni)()); + writeDecomposition(regionMeshes[regioni]()); Info<< endl; fileHandler().flush(); } @@ -351,7 +351,7 @@ int main(int argc, char *argv[]) { if (writeCellProc && stat >= fvMesh::TOPO_CHANGE) { - writeDecomposition(regionMeshes.meshes(regioni)()); + writeDecomposition(regionMeshes[regioni]()); Info<< endl; fileHandler().flush(); } @@ -368,8 +368,8 @@ int main(int argc, char *argv[]) // Prefixed scope { - const RegionConstRef meshes = - regionMeshes.meshes(regioni); + const RegionRef meshes = + regionMeshes[regioni]; // Search for objects at this time IOobjectList objects @@ -586,8 +586,8 @@ int main(int argc, char *argv[]) { // Prefixed scope { - const RegionConstRef meshes = - regionMeshes.meshes(regioni); + const RegionRef meshes = + regionMeshes[regioni]; Info<< "Collecting uniform files" << endl; diff --git a/src/OpenFOAM/meshes/multiRegion/MultiRegionList.H b/src/OpenFOAM/meshes/multiRegion/MultiRegionList.H new file mode 100644 index 0000000000..6e6448bbf5 --- /dev/null +++ b/src/OpenFOAM/meshes/multiRegion/MultiRegionList.H @@ -0,0 +1,111 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2023 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::MultiRegionList + +Description + Class which combines a UPtrList or PtrListr of region-associated objects + (meshes, solvers, domainDecompositions, ...) with the automatic region + prefixing provided by MultiRegionRefs. + +\*---------------------------------------------------------------------------*/ + +#ifndef MultiRegionList_H +#define MultiRegionList_H + +#include "MultiRegionRefs.H" +#include "PtrList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class MultiRegionListBase Declaration +\*---------------------------------------------------------------------------*/ + +template class Container, class Region> +class MultiRegionListBase +: + private Container, + public MultiRegionRefs +{ +public: + + // Constructors + + //- Construct from a list of regions + MultiRegionListBase(Container& regions, bool reuse) + : + Container(regions, reuse), + MultiRegionRefs(static_cast&>(*this)) + {} + + //- Construct from a list of regions + MultiRegionListBase(Container&& regions) + : + Container(std::move(regions)), + MultiRegionRefs(static_cast&>(*this)) + {} + + + // Member Functions + + //- Inherit the size method + using MultiRegionRefs::size; + + + // Member Operators + + //- Inherit the access operator + using MultiRegionRefs::operator[]; +}; + + +/*---------------------------------------------------------------------------*\ + Typedef MultiRegionList Declaration +\*---------------------------------------------------------------------------*/ + +template +using MultiRegionList = MultiRegionListBase; + + +/*---------------------------------------------------------------------------*\ + Typedef MultiRegionUList Declaration +\*---------------------------------------------------------------------------*/ + +template +using MultiRegionUList = MultiRegionListBase; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/multiRegion/MultiRegionRefs.C b/src/OpenFOAM/meshes/multiRegion/MultiRegionRefs.C new file mode 100644 index 0000000000..aedb31cb22 --- /dev/null +++ b/src/OpenFOAM/meshes/multiRegion/MultiRegionRefs.C @@ -0,0 +1,171 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2023 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 "MultiRegionRefs.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +bool Foam::MultiRegionRefs::prefixes() const +{ + return regions_.size() > 1; +} + + +template +Foam::string::size_type Foam::MultiRegionRefs::prefixWidth() const +{ + string::size_type n = 0; + + if (prefixes()) + { + forAll(regions_, regioni) + { + n = max(n, regionName(regions_[regioni]).size() + 1); + } + } + + return n; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +template +Foam::RegionRef::RegionRef +( + const MultiRegionRefs& mrr, + const label regioni, + Region& region +) +: + mrr_(*reinterpret_cast*>(&mrr)), + regioni_(regioni), + region_(region) +{ + if (mrr_.prefixes() && regioni_ != -1) + { + const string::size_type dn = + mrr_.prefixWidth() + - regionName(mrr_.regions_[regioni]).size(); + + Sout.prefix() = + regionName(mrr_.regions_[regioni]) + string(dn, ' '); + } +} + + +template +Foam::RegionRef::RegionRef(RegionRef&& rp) +: + RegionRef(rp.mrr_, rp.regioni_, rp.region_) +{ + rp.regioni_ = -1; +} + + +template +Foam::MultiRegionRefs::MultiRegionRefs(UPtrList& regions) +: + regions_(regions), + previousPrefix_(Sout.prefix()) +{ + if (prefixes()) + { + Sout.prefix() = string(prefixWidth(), ' '); + } + else + { + Sout.prefix() = word::null; + } +} + + +// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * // + +template +Foam::RegionRef::~RegionRef() +{ + if (mrr_.prefixes() && regioni_ != -1) + { + Sout.prefix() = string(mrr_.prefixWidth(), ' '); + } +} + + +template +Foam::MultiRegionRefs::~MultiRegionRefs() +{ + Sout.prefix() = previousPrefix_; +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +template +Foam::label Foam::MultiRegionRefs::size() const +{ + return regions_.size(); +} + + +// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // + +template +Foam::RegionRef::operator Region&() const +{ + return region_; +} + + +template +Region& Foam::RegionRef::operator()() const +{ + return region_; +} + + +template +Foam::RegionRef Foam::MultiRegionRefs::operator[] +( + const label regioni +) const +{ + return RegionRef(*this, regioni, regions_[regioni]); +} + + +template +Foam::RegionRef Foam::MultiRegionRefs::operator[] +( + const label regioni +) +{ + return RegionRef(*this, regioni, regions_[regioni]); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/multiRegion/MultiRegionRefs.H b/src/OpenFOAM/meshes/multiRegion/MultiRegionRefs.H new file mode 100644 index 0000000000..26764cfa5a --- /dev/null +++ b/src/OpenFOAM/meshes/multiRegion/MultiRegionRefs.H @@ -0,0 +1,182 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2023 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::MultiRegionRefs + +Description + Class to wrap a UPtrList of of region-associated objects (meshes, solvers, + domainDecompositions, ...). Access will return a wrapped reference and will + set the Info prefix to the region name. The prefix will remain until the + wrapped reference goes out of scope. + +\*---------------------------------------------------------------------------*/ + +#ifndef MultiRegionRefs_H +#define MultiRegionRefs_H + +#include "IOstreams.H" +#include "regionName.H" +#include "UPtrList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +template +class MultiRegionRefs; + + +/*---------------------------------------------------------------------------*\ + Class RegionRef Declaration +\*---------------------------------------------------------------------------*/ + +template +class RegionRef +{ +private: + + // Private Data + + //- The multi-region container + const MultiRegionRefs& mrr_; + + //- The region index + label regioni_; + + //- Reference to the region object + Region& region_; + + +public: + + // Constructors + + //- Construct form components + template + RegionRef + ( + const MultiRegionRefs& mrr, + const label regioni, + Region& region + ); + + //- Disallow copy construct + RegionRef(const RegionRef& rp) = delete; + + //- Move construct + RegionRef(RegionRef&& rp); + + + //- Destructor + ~RegionRef(); + + + // Member operators + + //- Cast to reference + operator Region&() const; + + //- Obtain the reference + Region& operator()() const; +}; + + +/*---------------------------------------------------------------------------*\ + Class MultiRegionRefs Declaration +\*---------------------------------------------------------------------------*/ + +template +class MultiRegionRefs +{ + // Private Data + + //- List of region pointers + UPtrList& regions_; + + //- Previous prefix to restore on destruction + const word previousPrefix_; + + + // Private Member Functions + + //- Are we prefixing? + bool prefixes() const; + + //- Width of the write prefix + string::size_type prefixWidth() const; + + +public: + + // Friendship + + //- Declare friendship with region-reference class + friend class RegionRef; + + //- Declare friendship with const-region-reference class + friend class RegionRef; + + + // Constructors + + //- Construct from a list of region pointers + MultiRegionRefs(UPtrList& regions); + + + //- Destructor + ~MultiRegionRefs(); + + + // Member Functions + + //- Return the size + label size() const; + + + // Member Operators + + //- Const-access a region + RegionRef operator[](const label regioni) const; + + //- Access a region + RegionRef operator[](const label regioni); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "MultiRegionRefs.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/multiRegion/regionName.H b/src/OpenFOAM/meshes/multiRegion/regionName.H new file mode 100644 index 0000000000..170878e9d0 --- /dev/null +++ b/src/OpenFOAM/meshes/multiRegion/regionName.H @@ -0,0 +1,58 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2023 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 . + +Function + Foam::regionName + +\*---------------------------------------------------------------------------*/ + +#ifndef regionName_H +#define regionName_H + +#include "polyMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + template + const word& regionName(const Region& region); + + template<> + inline const word& regionName(const word& name) + { + return name == polyMesh::defaultRegion ? word::null : name; + } + + template + const word& regionName(const Region& region) + { + return regionName(region.name()); + } +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/solver/solver.H b/src/finiteVolume/solver/solver.H index aff47c95d5..92d5d89012 100644 --- a/src/finiteVolume/solver/solver.H +++ b/src/finiteVolume/solver/solver.H @@ -40,6 +40,7 @@ SourceFiles #include "pimpleNoLoopControl.H" #include "fvModels.H" #include "fvConstraints.H" +#include "regionName.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -202,6 +203,13 @@ public: }; +template<> +inline const word& regionName(const solver& region) +{ + return regionName(region.mesh); +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/parallel/parallel/Make/files b/src/parallel/parallel/Make/files index 1b3416e703..24a9f1aaec 100644 --- a/src/parallel/parallel/Make/files +++ b/src/parallel/parallel/Make/files @@ -3,7 +3,6 @@ domainDecomposition.C domainDecompositionDecompose.C domainDecompositionReconstruct.C domainDecompositionNonConformal.C -multiRegionPrefixer.C multiDomainDecomposition.C LIB = $(FOAM_LIBBIN)/libparallel diff --git a/src/parallel/parallel/domainDecomposition.H b/src/parallel/parallel/domainDecomposition.H index 8e71aeb879..54bea35661 100644 --- a/src/parallel/parallel/domainDecomposition.H +++ b/src/parallel/parallel/domainDecomposition.H @@ -42,6 +42,7 @@ SourceFiles #include "processorRunTimes.H" #include "volFields.H" #include "surfaceFields.H" +#include "regionName.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -360,6 +361,16 @@ public: }; +template<> +inline const word& regionName +( + const domainDecomposition& region +) +{ + return regionName(region.regionName()); +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/parallel/parallel/multiDomainDecomposition.C b/src/parallel/parallel/multiDomainDecomposition.C index 6ff7483054..7777623290 100644 --- a/src/parallel/parallel/multiDomainDecomposition.C +++ b/src/parallel/parallel/multiDomainDecomposition.C @@ -33,6 +33,29 @@ namespace Foam } +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +Foam::PtrList Foam::multiDomainDecomposition::init +( + const processorRunTimes& runTimes, + const wordList& regionNames +) +{ + Foam::PtrList result(regionNames.size()); + + forAll(result, regioni) + { + result.set + ( + regioni, + new domainDecomposition(runTimes, regionNames[regioni]) + ); + } + + return result; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::multiDomainDecomposition::multiDomainDecomposition @@ -41,19 +64,9 @@ Foam::multiDomainDecomposition::multiDomainDecomposition const wordList& regionNames ) : - multiRegionPrefixer(false, regionNames), - runTimes_(runTimes), - regionMeshes_(regionNames.size()) -{ - forAll(regionMeshes_, regioni) - { - regionMeshes_.set - ( - regioni, - new domainDecomposition(runTimes, regionNames[regioni]) - ); - } -} + MultiRegionList(init(runTimes, regionNames)), + runTimes_(runTimes) +{} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // @@ -68,13 +81,13 @@ bool Foam::multiDomainDecomposition::readDecompose(const bool doSets) { bool result = false; - forAll(regionMeshes_, regioni) + forAll(*this, regioni) { - if (meshes(regioni)().readDecompose(doSets)) + if (this->operator[](regioni)().readDecompose(doSets)) { result = true; - if (regioni != regionMeshes_.size() - 1) + if (regioni != size() - 1) { Info<< endl; } @@ -89,13 +102,13 @@ bool Foam::multiDomainDecomposition::readReconstruct(const bool doSets) { bool result = false; - forAll(regionMeshes_, regioni) + forAll(*this, regioni) { - if (meshes(regioni)().readReconstruct(doSets)) + if (this->operator[](regioni)().readReconstruct(doSets)) { result = true; - if (regioni != regionMeshes_.size() - 1) + if (regioni != size() - 1) { Info<< endl; } @@ -111,16 +124,12 @@ Foam::multiDomainDecomposition::readUpdateDecompose() { fvMesh::readUpdateState result = fvMesh::UNCHANGED; - forAll(regionMeshes_, regioni) + forAll(*this, regioni) { const fvMesh::readUpdateState regionResult = - meshes(regioni)().readUpdateDecompose(); + this->operator[](regioni)().readUpdateDecompose(); - if - ( - regioni != regionMeshes_.size() - 1 - && regionResult >= fvMesh::TOPO_CHANGE - ) + if (regioni != size() - 1 && regionResult >= fvMesh::TOPO_CHANGE) { Info<< endl; } @@ -137,16 +146,12 @@ Foam::multiDomainDecomposition::readUpdateReconstruct() { fvMesh::readUpdateState result = fvMesh::UNCHANGED; - forAll(regionMeshes_, regioni) + forAll(*this, regioni) { const fvMesh::readUpdateState regionResult = - meshes(regioni)().readUpdateReconstruct(); + this->operator[](regioni)().readUpdateReconstruct(); - if - ( - regioni != regionMeshes_.size() - 1 - && regionResult >= fvMesh::TOPO_CHANGE - ) + if (regioni != size() - 1 && regionResult >= fvMesh::TOPO_CHANGE) { Info<< endl; } @@ -160,18 +165,18 @@ Foam::multiDomainDecomposition::readUpdateReconstruct() void Foam::multiDomainDecomposition::writeComplete(const bool doSets) const { - forAll(regionMeshes_, regioni) + forAll(*this, regioni) { - meshes(regioni)().writeComplete(doSets); + this->operator[](regioni)().writeComplete(doSets); } } void Foam::multiDomainDecomposition::writeProcs(const bool doSets) const { - forAll(regionMeshes_, regioni) + forAll(*this, regioni) { - meshes(regioni)().writeProcs(doSets); + this->operator[](regioni)().writeProcs(doSets); } } diff --git a/src/parallel/parallel/multiDomainDecomposition.H b/src/parallel/parallel/multiDomainDecomposition.H index 1b2722d339..26231640c8 100644 --- a/src/parallel/parallel/multiDomainDecomposition.H +++ b/src/parallel/parallel/multiDomainDecomposition.H @@ -36,7 +36,7 @@ SourceFiles #define multiDomainDecomposition_H #include "domainDecomposition.H" -#include "multiRegionPrefixer.H" +#include "MultiRegionList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -49,15 +49,22 @@ namespace Foam class multiDomainDecomposition : - private multiRegionPrefixer + public MultiRegionList { // Private Data //- Run times const processorRunTimes& runTimes_; - //- The region complete and processor meshes - PtrList regionMeshes_; + + // Private Member Functions + + //- Initialise and return the list of regions + static Foam::PtrList init + ( + const processorRunTimes& runTimes, + const wordList& regionNames + ); public: @@ -82,36 +89,6 @@ public: // Member Functions - //- Access the meshes for a region - inline RegionConstRef meshes - ( - const label regioni - ) const - { - return - RegionConstRef - ( - *this, - regioni, - regionMeshes_[regioni] - ); - } - - //- Access the meshes for a region - inline RegionRef meshes - ( - const label regioni - ) - { - return - RegionRef - ( - *this, - regioni, - regionMeshes_[regioni] - ); - } - //- Return the number of processors in the decomposition inline label nProcs() const { diff --git a/src/parallel/parallel/multiRegionPrefixer.C b/src/parallel/parallel/multiRegionPrefixer.C deleted file mode 100644 index a48dc1f105..0000000000 --- a/src/parallel/parallel/multiRegionPrefixer.C +++ /dev/null @@ -1,123 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2023 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 "multiRegionPrefixer.H" -#include "IOstreams.H" - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -bool Foam::multiRegionPrefixer::prefixes() const -{ - return prefixSingleRegion_ || regionNames_.size() > 1; -} - - -Foam::string::size_type Foam::multiRegionPrefixer::prefixWidth() const -{ - string::size_type n = 0; - - if (prefixes()) - { - forAll(regionNames_, regionj) - { - n = max(n, regionNames_[regionj].size() + 1); - } - } - - return n; -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::multiRegionPrefixer::regionPrefixer::regionPrefixer -( - const multiRegionPrefixer& mrp, - const label regioni -) -: - mrp_(mrp), - regioni_(regioni) -{ - if (mrp_.prefixes() && regioni_ != -1) - { - const string::size_type dn = - mrp_.prefixWidth() - - mrp_.regionNames_[regioni].size(); - - Sout.prefix() = - mrp_.regionNames_[regioni] + string(dn, ' '); - } -} - - -Foam::multiRegionPrefixer::regionPrefixer::regionPrefixer -( - regionPrefixer&& rp -) -: - regionPrefixer(rp.mrp_, rp.regioni_) -{ - rp.regioni_ = -1; -} - - -Foam::multiRegionPrefixer::multiRegionPrefixer -( - const bool prefixSingleRegion, - const wordList& regionNames -) -: - prefixSingleRegion_(prefixSingleRegion), - regionNames_(regionNames) -{ - if (prefixes()) - { - Sout.prefix() = string(prefixWidth(), ' '); - } -} - - -// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * // - -Foam::multiRegionPrefixer::regionPrefixer::~regionPrefixer() -{ - if (mrp_.prefixes() && regioni_ != -1) - { - Sout.prefix() = string(mrp_.prefixWidth(), ' '); - } -} - - -Foam::multiRegionPrefixer::~multiRegionPrefixer() -{ - if (prefixes()) - { - Sout.prefix() = string::null; - } -} - - -// ************************************************************************* // diff --git a/src/parallel/parallel/multiRegionPrefixer.H b/src/parallel/parallel/multiRegionPrefixer.H deleted file mode 100644 index 8ee2cf0c17..0000000000 --- a/src/parallel/parallel/multiRegionPrefixer.H +++ /dev/null @@ -1,241 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2023 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::multiRegionPrefixer - -SourceFiles - multiRegionPrefixer.C - -\*---------------------------------------------------------------------------*/ - -#ifndef multiRegionPrefixer_H -#define multiRegionPrefixer_H - -#include "wordList.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class multiRegionPrefixer Declaration -\*---------------------------------------------------------------------------*/ - -class multiRegionPrefixer -{ -private: - - // Private Data - - //- Should we prefix a single region? - const bool prefixSingleRegion_; - - //- Region names - const wordList& regionNames_; - - - // Private Member Functions - - //- Are we prefixing? - bool prefixes() const; - - //- Width of the write prefix - string::size_type prefixWidth() const; - - -public: - - // Public classes - - //- Prefixer for a single region - class regionPrefixer - { - private: - - // Private data - - //- The multi-region prefixing engine - const multiRegionPrefixer& mrp_; - - //- The region index - label regioni_; - - - public: - - // Constructors - - //- Construct from components - regionPrefixer - ( - const multiRegionPrefixer& mrp, - const label regioni - ); - - //- Disallow copy construct - regionPrefixer(const regionPrefixer& rp) = delete; - - //- Move construct - regionPrefixer(regionPrefixer&& rp); - - - //- Destructor - ~regionPrefixer(); - - - // Member operators - - //- Disallow copy assign - regionPrefixer& operator=(const regionPrefixer&) = delete; - - //- Disallow move assign - regionPrefixer& operator=(regionPrefixer&&) = delete; - }; - - - // Constructors - - //- Construct from components - multiRegionPrefixer - ( - const bool prefixSingleRegion, - const wordList& regionNames - ); - - - //- Destructor - ~multiRegionPrefixer(); -}; - - -/*---------------------------------------------------------------------------*\ - Class RegionConstRef Declaration -\*---------------------------------------------------------------------------*/ - -template -class RegionConstRef -: - private multiRegionPrefixer::regionPrefixer -{ -private: - - // Private Data - - //- Reference to the region object - const Region& r_; - - -public: - - // Constructors - - //- Construct form components - inline RegionConstRef - ( - const multiRegionPrefixer& mrp, - const label regioni, - const Region& r - ) - : - multiRegionPrefixer::regionPrefixer(mrp, regioni), - r_(r) - {} - - - // Member operators - - //- Cast to reference - inline operator const Region&() const - { - return r_; - } - - //- Obtain the reference - inline const Region& operator()() const - { - return r_; - } -}; - - -/*---------------------------------------------------------------------------*\ - Class RegionRef Declaration -\*---------------------------------------------------------------------------*/ - -template -class RegionRef -: - public RegionConstRef -{ -private: - - // Private Data - - //- Reference to the region object - Region& r_; - - -public: - - // Constructors - - //- Construct form components - inline RegionRef - ( - const multiRegionPrefixer& mrp, - const label regioni, - Region& r - ) - : - RegionConstRef(mrp, regioni, r), - r_(r) - {} - - - // Member operators - - //- Cast to reference - inline operator Region&() const - { - return r_; - } - - //- Obtain the reference - inline Region& operator()() - { - return r_; - } -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* //