MultiRegionRefs, MultiRegionUList, MultiRegionList: Centralised region prefixing
These classes permit any PtrList of region-associated objects (meshes, solvers, domainDecompositions, ...) to prefix the region name to the log. At present these classes are used by decomposePar and reconstructPar only. The foamMultiRun solver still handles its own prefixing.
This commit is contained in:
@ -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<domainDecomposition> meshes =
|
||||
regionMeshes.meshes(regioni);
|
||||
const RegionRef<domainDecomposition> 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<domainDecomposition> meshes =
|
||||
regionMeshes.meshes(regioni);
|
||||
const RegionRef<domainDecomposition> meshes =
|
||||
regionMeshes[regioni];
|
||||
|
||||
Info<< "Distributing uniform files" << endl;
|
||||
|
||||
|
||||
@ -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<domainDecomposition> meshes =
|
||||
regionMeshes.meshes(regioni);
|
||||
const RegionRef<domainDecomposition> 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<domainDecomposition> meshes =
|
||||
regionMeshes.meshes(regioni);
|
||||
const RegionRef<domainDecomposition> meshes =
|
||||
regionMeshes[regioni];
|
||||
|
||||
Info<< "Collecting uniform files" << endl;
|
||||
|
||||
|
||||
111
src/OpenFOAM/meshes/multiRegion/MultiRegionList.H
Normal file
111
src/OpenFOAM/meshes/multiRegion/MultiRegionList.H
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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<template<class> class Container, class Region>
|
||||
class MultiRegionListBase
|
||||
:
|
||||
private Container<Region>,
|
||||
public MultiRegionRefs<Region>
|
||||
{
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from a list of regions
|
||||
MultiRegionListBase(Container<Region>& regions, bool reuse)
|
||||
:
|
||||
Container<Region>(regions, reuse),
|
||||
MultiRegionRefs<Region>(static_cast<Container<Region>&>(*this))
|
||||
{}
|
||||
|
||||
//- Construct from a list of regions
|
||||
MultiRegionListBase(Container<Region>&& regions)
|
||||
:
|
||||
Container<Region>(std::move(regions)),
|
||||
MultiRegionRefs<Region>(static_cast<Container<Region>&>(*this))
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Inherit the size method
|
||||
using MultiRegionRefs<Region>::size;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Inherit the access operator
|
||||
using MultiRegionRefs<Region>::operator[];
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Typedef MultiRegionList Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Region>
|
||||
using MultiRegionList = MultiRegionListBase<PtrList, Region>;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Typedef MultiRegionUList Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Region>
|
||||
using MultiRegionUList = MultiRegionListBase<UPtrList, Region>;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
171
src/OpenFOAM/meshes/multiRegion/MultiRegionRefs.C
Normal file
171
src/OpenFOAM/meshes/multiRegion/MultiRegionRefs.C
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "MultiRegionRefs.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Region>
|
||||
bool Foam::MultiRegionRefs<Region>::prefixes() const
|
||||
{
|
||||
return regions_.size() > 1;
|
||||
}
|
||||
|
||||
|
||||
template<class Region>
|
||||
Foam::string::size_type Foam::MultiRegionRefs<Region>::prefixWidth() const
|
||||
{
|
||||
string::size_type n = 0;
|
||||
|
||||
if (prefixes())
|
||||
{
|
||||
forAll(regions_, regioni)
|
||||
{
|
||||
n = max(n, regionName(regions_[regioni]).size() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Region>
|
||||
template<class NonConstRegion>
|
||||
Foam::RegionRef<Region>::RegionRef
|
||||
(
|
||||
const MultiRegionRefs<NonConstRegion>& mrr,
|
||||
const label regioni,
|
||||
Region& region
|
||||
)
|
||||
:
|
||||
mrr_(*reinterpret_cast<const MultiRegionRefs<Region>*>(&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<class Region>
|
||||
Foam::RegionRef<Region>::RegionRef(RegionRef&& rp)
|
||||
:
|
||||
RegionRef(rp.mrr_, rp.regioni_, rp.region_)
|
||||
{
|
||||
rp.regioni_ = -1;
|
||||
}
|
||||
|
||||
|
||||
template<class Region>
|
||||
Foam::MultiRegionRefs<Region>::MultiRegionRefs(UPtrList<Region>& regions)
|
||||
:
|
||||
regions_(regions),
|
||||
previousPrefix_(Sout.prefix())
|
||||
{
|
||||
if (prefixes())
|
||||
{
|
||||
Sout.prefix() = string(prefixWidth(), ' ');
|
||||
}
|
||||
else
|
||||
{
|
||||
Sout.prefix() = word::null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Region>
|
||||
Foam::RegionRef<Region>::~RegionRef()
|
||||
{
|
||||
if (mrr_.prefixes() && regioni_ != -1)
|
||||
{
|
||||
Sout.prefix() = string(mrr_.prefixWidth(), ' ');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Region>
|
||||
Foam::MultiRegionRefs<Region>::~MultiRegionRefs()
|
||||
{
|
||||
Sout.prefix() = previousPrefix_;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Region>
|
||||
Foam::label Foam::MultiRegionRefs<Region>::size() const
|
||||
{
|
||||
return regions_.size();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Region>
|
||||
Foam::RegionRef<Region>::operator Region&() const
|
||||
{
|
||||
return region_;
|
||||
}
|
||||
|
||||
|
||||
template<class Region>
|
||||
Region& Foam::RegionRef<Region>::operator()() const
|
||||
{
|
||||
return region_;
|
||||
}
|
||||
|
||||
|
||||
template<class Region>
|
||||
Foam::RegionRef<const Region> Foam::MultiRegionRefs<Region>::operator[]
|
||||
(
|
||||
const label regioni
|
||||
) const
|
||||
{
|
||||
return RegionRef<const Region>(*this, regioni, regions_[regioni]);
|
||||
}
|
||||
|
||||
|
||||
template<class Region>
|
||||
Foam::RegionRef<Region> Foam::MultiRegionRefs<Region>::operator[]
|
||||
(
|
||||
const label regioni
|
||||
)
|
||||
{
|
||||
return RegionRef<Region>(*this, regioni, regions_[regioni]);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
182
src/OpenFOAM/meshes/multiRegion/MultiRegionRefs.H
Normal file
182
src/OpenFOAM/meshes/multiRegion/MultiRegionRefs.H
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 Region>
|
||||
class MultiRegionRefs;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class RegionRef Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Region>
|
||||
class RegionRef
|
||||
{
|
||||
private:
|
||||
|
||||
// Private Data
|
||||
|
||||
//- The multi-region container
|
||||
const MultiRegionRefs<Region>& mrr_;
|
||||
|
||||
//- The region index
|
||||
label regioni_;
|
||||
|
||||
//- Reference to the region object
|
||||
Region& region_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct form components
|
||||
template<class NonConstRegion>
|
||||
RegionRef
|
||||
(
|
||||
const MultiRegionRefs<NonConstRegion>& 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 Region>
|
||||
class MultiRegionRefs
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- List of region pointers
|
||||
UPtrList<Region>& 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<Region>;
|
||||
|
||||
//- Declare friendship with const-region-reference class
|
||||
friend class RegionRef<const Region>;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from a list of region pointers
|
||||
MultiRegionRefs(UPtrList<Region>& regions);
|
||||
|
||||
|
||||
//- Destructor
|
||||
~MultiRegionRefs();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the size
|
||||
label size() const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Const-access a region
|
||||
RegionRef<const Region> operator[](const label regioni) const;
|
||||
|
||||
//- Access a region
|
||||
RegionRef<Region> operator[](const label regioni);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "MultiRegionRefs.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
58
src/OpenFOAM/meshes/multiRegion/regionName.H
Normal file
58
src/OpenFOAM/meshes/multiRegion/regionName.H
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
Function
|
||||
Foam::regionName
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef regionName_H
|
||||
#define regionName_H
|
||||
|
||||
#include "polyMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
template<class Region>
|
||||
const word& regionName(const Region& region);
|
||||
|
||||
template<>
|
||||
inline const word& regionName(const word& name)
|
||||
{
|
||||
return name == polyMesh::defaultRegion ? word::null : name;
|
||||
}
|
||||
|
||||
template<class Region>
|
||||
const word& regionName(const Region& region)
|
||||
{
|
||||
return regionName(region.name());
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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
|
||||
|
||||
@ -3,7 +3,6 @@ domainDecomposition.C
|
||||
domainDecompositionDecompose.C
|
||||
domainDecompositionReconstruct.C
|
||||
domainDecompositionNonConformal.C
|
||||
multiRegionPrefixer.C
|
||||
multiDomainDecomposition.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libparallel
|
||||
|
||||
@ -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<domainDecomposition>
|
||||
(
|
||||
const domainDecomposition& region
|
||||
)
|
||||
{
|
||||
return regionName(region.regionName());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
@ -33,6 +33,29 @@ namespace Foam
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
Foam::PtrList<Foam::domainDecomposition> Foam::multiDomainDecomposition::init
|
||||
(
|
||||
const processorRunTimes& runTimes,
|
||||
const wordList& regionNames
|
||||
)
|
||||
{
|
||||
Foam::PtrList<domainDecomposition> 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<domainDecomposition>(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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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<domainDecomposition>
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Run times
|
||||
const processorRunTimes& runTimes_;
|
||||
|
||||
//- The region complete and processor meshes
|
||||
PtrList<domainDecomposition> regionMeshes_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Initialise and return the list of regions
|
||||
static Foam::PtrList<domainDecomposition> init
|
||||
(
|
||||
const processorRunTimes& runTimes,
|
||||
const wordList& regionNames
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
@ -82,36 +89,6 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Access the meshes for a region
|
||||
inline RegionConstRef<domainDecomposition> meshes
|
||||
(
|
||||
const label regioni
|
||||
) const
|
||||
{
|
||||
return
|
||||
RegionConstRef<domainDecomposition>
|
||||
(
|
||||
*this,
|
||||
regioni,
|
||||
regionMeshes_[regioni]
|
||||
);
|
||||
}
|
||||
|
||||
//- Access the meshes for a region
|
||||
inline RegionRef<domainDecomposition> meshes
|
||||
(
|
||||
const label regioni
|
||||
)
|
||||
{
|
||||
return
|
||||
RegionRef<domainDecomposition>
|
||||
(
|
||||
*this,
|
||||
regioni,
|
||||
regionMeshes_[regioni]
|
||||
);
|
||||
}
|
||||
|
||||
//- Return the number of processors in the decomposition
|
||||
inline label nProcs() const
|
||||
{
|
||||
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 Region>
|
||||
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 Region>
|
||||
class RegionRef
|
||||
:
|
||||
public RegionConstRef<Region>
|
||||
{
|
||||
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<Region>(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
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user