Skip to content
Permalink
Browse files

C++11 conformance and consistency: Added "move" constructors and assi…

…gnment operators to OpenFOAM containers

Replaced all uses of complex Xfer class with C++11 "move" constructors and
assignment operators.  Removed the now redundant Xfer class.

This substantial changes improves consistency between OpenFOAM and the C++11 STL
containers and algorithms, reduces memory allocation and copy overhead when
returning containers from functions and simplifies maintenance of the core
libraries significantly.
  • Loading branch information...
Henry Weller
Henry Weller committed May 25, 2019
1 parent 0889ff9 commit 30bea84facb2cc6190abd767b81c806ff2dd24ea
Showing 323 changed files with 3,239 additions and 2,501 deletions.
@@ -25,10 +25,10 @@ fvMesh mesh
runTime,
IOobject::READ_IF_PRESENT
),
xferMove<Field<vector>>(points),
faces.xfer(),
owner.xfer(),
neighbour.xfer()
move(points),
move(faces),
move(owner),
move(neighbour)
);

List<polyPatch*> patches(1);
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2015-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -261,7 +261,7 @@ Foam::InterfaceCompositionPhaseChangePhaseSystem<BasePhaseSystem>::dmdt


template<class BasePhaseSystem>
Foam::Xfer<Foam::PtrList<Foam::volScalarField>>
Foam::PtrList<Foam::volScalarField>
Foam::InterfaceCompositionPhaseChangePhaseSystem<BasePhaseSystem>::dmdts() const
{
PtrList<volScalarField> dmdts(BasePhaseSystem::dmdts());
@@ -302,7 +302,7 @@ Foam::InterfaceCompositionPhaseChangePhaseSystem<BasePhaseSystem>::dmdts() const
}
}

return dmdts.xfer();
return dmdts;
}


@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2015-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -133,7 +133,7 @@ public:
virtual tmp<volScalarField> dmdt(const phasePairKey& key) const;

//- Return the mass transfer rates for each phase
virtual Xfer<PtrList<volScalarField>> dmdts() const;
virtual PtrList<volScalarField> dmdts() const;

//- Return the mass transfer matrices
virtual autoPtr<phaseSystem::massTransferTable> massTransfer() const;
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2015-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -451,7 +451,7 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::momentumTransferf()


template<class BasePhaseSystem>
Foam::Xfer<Foam::PtrList<Foam::surfaceScalarField>>
Foam::PtrList<Foam::surfaceScalarField>
Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::AFfs() const
{
PtrList<surfaceScalarField> AFfs(this->phaseModels_.size());
@@ -485,12 +485,12 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::AFfs() const
this->fillFields("AFf", dimDensity/dimTime, AFfs);
}

return AFfs.xfer();
return AFfs;
}


template<class BasePhaseSystem>
Foam::Xfer<Foam::PtrList<Foam::surfaceScalarField>>
Foam::PtrList<Foam::surfaceScalarField>
Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::phiFs
(
const PtrList<volScalarField>& rAUs
@@ -626,12 +626,12 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::phiFs
this->fillFields("phiF", dimForce/dimDensity/dimVelocity, phiFs);
}

return phiFs.xfer();
return phiFs;
}


template<class BasePhaseSystem>
Foam::Xfer<Foam::PtrList<Foam::surfaceScalarField>>
Foam::PtrList<Foam::surfaceScalarField>
Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::phiFfs
(
const PtrList<surfaceScalarField>& rAUfs
@@ -789,12 +789,12 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::phiFfs
this->fillFields("phiFf", dimForce/dimDensity/dimVelocity, phiFfs);
}

return phiFfs.xfer();
return phiFfs;
}


template<class BasePhaseSystem>
Foam::Xfer<Foam::PtrList<Foam::surfaceScalarField>>
Foam::PtrList<Foam::surfaceScalarField>
Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::phiKdPhis
(
const PtrList<volScalarField>& rAUs
@@ -831,12 +831,12 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::phiKdPhis
);
}

return phiKdPhis.xfer();
return phiKdPhis;
}


template<class BasePhaseSystem>
Foam::Xfer<Foam::PtrList<Foam::surfaceScalarField>>
Foam::PtrList<Foam::surfaceScalarField>
Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::phiKdPhifs
(
const PtrList<surfaceScalarField>& rAUfs
@@ -873,12 +873,12 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::phiKdPhifs
);
}

return phiKdPhifs.xfer();
return phiKdPhifs;
}


template<class BasePhaseSystem>
Foam::Xfer<Foam::PtrList<Foam::volVectorField>>
Foam::PtrList<Foam::volVectorField>
Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::KdUByAs
(
const PtrList<volScalarField>& rAUs
@@ -909,12 +909,12 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::KdUByAs
this->fillFields("KdUByA", dimVelocity, KdUByAs);
}

return KdUByAs.xfer();
return KdUByAs;
}


template<class BasePhaseSystem>
Foam::Xfer<Foam::PtrList<Foam::surfaceScalarField>>
Foam::PtrList<Foam::surfaceScalarField>
Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::ddtCorrByAs
(
const PtrList<volScalarField>& rAUs,
@@ -1009,7 +1009,7 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::ddtCorrByAs
}
}

return ddtCorrByAs.xfer();
return ddtCorrByAs;
}


@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2015-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -212,33 +212,33 @@ public:

//- Return implicit force coefficients on the faces, for the face-based
// algorithm.
virtual Xfer<PtrList<surfaceScalarField>> AFfs() const;
virtual PtrList<surfaceScalarField> AFfs() const;

//- Return the explicit force fluxes for the cell-based algorithm, that
// do not depend on phase mass/volume fluxes, and can therefore be
// evaluated outside the corrector loop. This includes things like
// lift, turbulent dispersion, and wall lubrication.
virtual Xfer<PtrList<surfaceScalarField>> phiFs
virtual PtrList<surfaceScalarField> phiFs
(
const PtrList<volScalarField>& rAUs
);

//- As phiFs, but for the face-based algorithm
virtual Xfer<PtrList<surfaceScalarField>> phiFfs
virtual PtrList<surfaceScalarField> phiFfs
(
const PtrList<surfaceScalarField>& rAUfs
);

//- Return the explicit drag force fluxes for the cell-based algorithm.
// These depend on phase mass/volume fluxes, and must therefore be
// evaluated inside the corrector loop.
virtual Xfer<PtrList<surfaceScalarField>> phiKdPhis
virtual PtrList<surfaceScalarField> phiKdPhis
(
const PtrList<volScalarField>& rAUs
) const;

//- As phiKdPhis, but for the face-based algorithm
virtual Xfer<PtrList<surfaceScalarField>> phiKdPhifs
virtual PtrList<surfaceScalarField> phiKdPhifs
(
const PtrList<surfaceScalarField>& rAUfs
) const;
@@ -247,7 +247,7 @@ public:
// algorithm. This is the cell-equivalent of phiKdPhis. These depend on
// phase velocities, and must therefore be evaluated inside the
// corrector loop.
virtual Xfer<PtrList<volVectorField>> KdUByAs
virtual PtrList<volVectorField> KdUByAs
(
const PtrList<volScalarField>& rAUs
) const;
@@ -268,7 +268,7 @@ public:
//- Return the flux corrections for the cell-based algorithm. These
// depend on phase mass/volume fluxes, and must therefore be evaluated
// inside the corrector loop.
virtual Xfer<PtrList<surfaceScalarField>> ddtCorrByAs
virtual PtrList<surfaceScalarField> ddtCorrByAs
(
const PtrList<volScalarField>& rAUs,
const bool includeVirtualMass = false
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -102,7 +102,7 @@ Foam::PhaseTransferPhaseSystem<BasePhaseSystem>::dmdt


template<class BasePhaseSystem>
Foam::Xfer<Foam::PtrList<Foam::volScalarField>>
Foam::PtrList<Foam::volScalarField>
Foam::PhaseTransferPhaseSystem<BasePhaseSystem>::dmdts() const
{
PtrList<volScalarField> dmdts(BasePhaseSystem::dmdts());
@@ -116,7 +116,7 @@ Foam::PhaseTransferPhaseSystem<BasePhaseSystem>::dmdts() const
this->addField(pair.phase2(), "dmdt", - rDmdt, dmdts);
}

return dmdts.xfer();
return dmdts;
}


@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -105,7 +105,7 @@ public:
virtual tmp<volScalarField> dmdt(const phasePairKey& key) const;

//- Return the mass transfer rates for each phase
virtual Xfer<PtrList<volScalarField>> dmdts() const;
virtual PtrList<volScalarField> dmdts() const;

//- Return the mass transfer matrices
virtual autoPtr<phaseSystem::massTransferTable> massTransfer() const;
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -148,7 +148,7 @@ Foam::PopulationBalancePhaseSystem<BasePhaseSystem>::dmdt


template<class BasePhaseSystem>
Foam::Xfer<Foam::PtrList<Foam::volScalarField>>
Foam::PtrList<Foam::volScalarField>
Foam::PopulationBalancePhaseSystem<BasePhaseSystem>::dmdts() const
{
PtrList<volScalarField> dmdts(BasePhaseSystem::dmdts());
@@ -162,7 +162,7 @@ Foam::PopulationBalancePhaseSystem<BasePhaseSystem>::dmdts() const
this->addField(pair.phase2(), "dmdt", - pDmdt, dmdts);
}

return dmdts.xfer();
return dmdts;
}


@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -96,7 +96,7 @@ public:
virtual tmp<volScalarField> dmdt(const phasePairKey& key) const;

//- Return the mass transfer rates for each phase
virtual Xfer<PtrList<volScalarField>> dmdts() const;
virtual PtrList<volScalarField> dmdts() const;

//- Return the mass transfer matrices
virtual autoPtr<phaseSystem::massTransferTable> massTransfer() const;
@@ -188,7 +188,7 @@ Foam::ThermalPhaseChangePhaseSystem<BasePhaseSystem>::dmdt


template<class BasePhaseSystem>
Foam::Xfer<Foam::PtrList<Foam::volScalarField>>
Foam::PtrList<Foam::volScalarField>
Foam::ThermalPhaseChangePhaseSystem<BasePhaseSystem>::dmdts() const
{
PtrList<volScalarField> dmdts(BasePhaseSystem::dmdts());
@@ -211,7 +211,7 @@ Foam::ThermalPhaseChangePhaseSystem<BasePhaseSystem>::dmdts() const
this->addField(pair.phase2(), "dmdt", - wDmdt, dmdts);
}

return dmdts.xfer();
return dmdts;
}


@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2015-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -121,7 +121,7 @@ public:
virtual tmp<volScalarField> dmdt(const phasePairKey& key) const;

//- Return the mass transfer rates for each phase
virtual Xfer<PtrList<volScalarField>> dmdts() const;
virtual PtrList<volScalarField> dmdts() const;

//- Return the heat transfer matrices
virtual autoPtr<phaseSystem::heatTransferTable> heatTransfer() const;
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2015-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -342,11 +342,11 @@ Foam::tmp<Foam::volScalarField> Foam::phaseSystem::dmdt
}


Foam::Xfer<Foam::PtrList<Foam::volScalarField>> Foam::phaseSystem::dmdts() const
Foam::PtrList<Foam::volScalarField> Foam::phaseSystem::dmdts() const
{
PtrList<volScalarField> dmdts(this->phaseModels_.size());

return dmdts.xfer();
return dmdts;
}


0 comments on commit 30bea84

Please sign in to comment.
You can’t perform that action at this time.