Files
OpenFOAM-12/src/finiteVolume/fvMesh/fvMeshDistributors/cpuLoad/cpuLoad.C
Henry Weller 41705e9eca Lagrangian: Added support for automatic run-time load-balancing
Optional CPU load caching can be switched-on for Lagrangian cloud tracking
and/or chemistry integration using the new cpuLoad switch in the cloudProperties
or chemistryProperties dictionary files respectively and used for
multi-constraint load-balancing by the fvMeshDistributorsLoadBalancer specified
in the dynamicMeshDict file

distributor
{
    type            loadBalancer;

    libs            ("libfvMeshDistributors.so");

    multiConstraint true;
    redistributionInterval  10;
}

which used the distributor specified in the decomposeParDict file, e.g.

numberOfSubdomains 12;

decomposer      simple;
distributor     zoltan;
libs            ("libzoltanDecomp.so");

simpleCoeffs
{
    n           (2 2 3);
}

zoltanCoeffs
{
    lb_method   rcb;
}

The incompressibleDenseParticleFluid/cyclone case has been updated to
demonstrate this new functionality and shows a speedup ~50% using the Zoltan RCB
multi-constraint distributor.  The multicomponentFluid/counterFlowFlame2D_GRI
case has also been updated to use the new cpuLoad switch.
2024-05-16 13:46:20 +01:00

143 lines
3.5 KiB
C++

/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2022-2024 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 "cpuLoad.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(cpuLoad, 0);
optionalCpuLoad optionalCpuLoad::optionalCpuLoad_;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::cpuLoad::cpuLoad(const fvMesh& mesh, const word& name)
:
volScalarField::Internal
(
IOobject
(
name,
mesh.time().name(),
mesh
),
mesh,
dimensionedScalar(dimTime, 0)
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cpuLoad::~cpuLoad()
{}
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
Foam::optionalCpuLoad& Foam::optionalCpuLoad::New
(
const fvMesh& mesh,
const word& name,
const bool loadBalancing
)
{
if (loadBalancing)
{
if
(
mesh.thisDb().objectRegistry::template
foundObject<cpuLoad>
(
name
)
)
{
return mesh.thisDb().objectRegistry::template
lookupObjectRef<cpuLoad>
(
name
);
}
else
{
if (cpuLoad::debug)
{
InfoInFunction
<< "constructing " << name
<< " for region " << mesh.name() << endl;
}
cpuLoad* cpuLoadPtr(new cpuLoad(mesh, name));
regIOobject::store(cpuLoadPtr);
return *cpuLoadPtr;
}
}
else
{
return optionalCpuLoad::optionalCpuLoad_;
}
}
Foam::optionalCpuLoad& Foam::optionalCpuLoad::New
(
const polyMesh& mesh,
const word& name,
const bool loadBalancing
)
{
if (loadBalancing && isA<fvMesh>(mesh))
{
return New(refCast<const fvMesh>(mesh), name, loadBalancing);
}
else
{
return optionalCpuLoad::optionalCpuLoad_;
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::cpuLoad::reset()
{
cpuTime_.cpuTimeIncrement();
}
void Foam::cpuLoad::cpuTimeIncrement(const label celli)
{
operator[](celli) += cpuTime_.cpuTimeIncrement();
}
// ************************************************************************* //