fvMesh: added move constructor and disallowed construction
This support efficient return of fvMesh from functions which generate region meshes without allowing risky copy construction.
This commit is contained in:
@ -201,7 +201,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else if (action == 1 || action == 2)
|
else if (action == 1 || action == 2)
|
||||||
{
|
{
|
||||||
// Mesh changing engine.
|
// Mesh topo-change engine.
|
||||||
polyTopoChange meshMod(mesh);
|
polyTopoChange meshMod(mesh);
|
||||||
|
|
||||||
if (action == 1)
|
if (action == 1)
|
||||||
@ -290,16 +290,13 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Info<< nl<< "-- Mesh : moving:" << mesh.moving()
|
Info<< nl<< "-- Mesh : moving:" << mesh.moving()
|
||||||
<< " topoChanged:" << mesh.topoChanged()
|
<< " topoChanged:" << mesh.topoChanged()
|
||||||
<< " changing:" << mesh.changing()
|
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Info<< "Writing fields" << nl << endl;
|
Info<< "Writing fields" << nl << endl;
|
||||||
runTime.write();
|
runTime.write();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Check mesh volume conservation
|
// Check mesh volume conservation
|
||||||
if (mesh.moving())
|
if (mesh.moving())
|
||||||
{
|
{
|
||||||
|
|||||||
@ -118,8 +118,11 @@ public:
|
|||||||
const label nIoObjects = 128
|
const label nIoObjects = 128
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Move constructor
|
||||||
|
objectRegistry(objectRegistry&&) = default;
|
||||||
|
|
||||||
//- Disallow default bitwise copy construction
|
//- Disallow default bitwise copy construction
|
||||||
objectRegistry(const objectRegistry&);
|
objectRegistry(const objectRegistry&) = delete;
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -53,15 +53,6 @@ class data
|
|||||||
:
|
:
|
||||||
public IOdictionary
|
public IOdictionary
|
||||||
{
|
{
|
||||||
// Private Member Functions
|
|
||||||
|
|
||||||
//- Disallow default bitwise copy construction
|
|
||||||
data(const data&) = delete;
|
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
|
||||||
void operator=(const data&) = delete;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Type information
|
//- Type information
|
||||||
@ -72,6 +63,15 @@ public:
|
|||||||
|
|
||||||
//- Construct for objectRegistry
|
//- Construct for objectRegistry
|
||||||
data(const objectRegistry& obr);
|
data(const objectRegistry& obr);
|
||||||
|
|
||||||
|
//- Move constructor
|
||||||
|
data(data&&) = default;
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construction
|
||||||
|
data(const data&) = delete;
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const data&) = delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -83,12 +83,6 @@ class polyBoundaryMesh
|
|||||||
//- Calculate the geometry for the patches (transformation tensors etc.)
|
//- Calculate the geometry for the patches (transformation tensors etc.)
|
||||||
void calcGeometry();
|
void calcGeometry();
|
||||||
|
|
||||||
//- Disallow default bitwise copy construction
|
|
||||||
polyBoundaryMesh(const polyBoundaryMesh&);
|
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
|
||||||
void operator=(const polyBoundaryMesh&);
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -126,6 +120,12 @@ public:
|
|||||||
const polyPatchList&
|
const polyPatchList&
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Move constructor
|
||||||
|
polyBoundaryMesh(polyBoundaryMesh&&) = default;
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construction
|
||||||
|
polyBoundaryMesh(const polyBoundaryMesh&) = delete;
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
~polyBoundaryMesh();
|
~polyBoundaryMesh();
|
||||||
@ -266,6 +266,9 @@ public:
|
|||||||
//- Return reference to polyPatch by name.
|
//- Return reference to polyPatch by name.
|
||||||
polyPatch& operator[](const word&);
|
polyPatch& operator[](const word&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const polyBoundaryMesh&) = delete;
|
||||||
|
|
||||||
|
|
||||||
// Ostream operator
|
// Ostream operator
|
||||||
|
|
||||||
|
|||||||
@ -668,6 +668,35 @@ Foam::polyMesh::polyMesh
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::polyMesh::polyMesh(polyMesh&& mesh)
|
||||||
|
:
|
||||||
|
objectRegistry(move(mesh)),
|
||||||
|
primitiveMesh(move(mesh)),
|
||||||
|
points_(move(mesh.points_)),
|
||||||
|
faces_(move(mesh.faces_)),
|
||||||
|
owner_(move(mesh.owner_)),
|
||||||
|
neighbour_(move(mesh.neighbour_)),
|
||||||
|
clearedPrimitives_(mesh.clearedPrimitives_),
|
||||||
|
boundary_(move(mesh.boundary_)),
|
||||||
|
bounds_(move(mesh.bounds_)),
|
||||||
|
comm_(mesh.comm_),
|
||||||
|
geometricD_(mesh.geometricD_),
|
||||||
|
solutionD_(mesh.solutionD_),
|
||||||
|
tetBasePtIsPtr_(move(mesh.tetBasePtIsPtr_)),
|
||||||
|
cellTreePtr_(move(mesh.cellTreePtr_)),
|
||||||
|
pointZones_(move(mesh.pointZones_)),
|
||||||
|
faceZones_(move(mesh.faceZones_)),
|
||||||
|
cellZones_(move(mesh.cellZones_)),
|
||||||
|
globalMeshDataPtr_(move(mesh.globalMeshDataPtr_)),
|
||||||
|
curMotionTimeIndex_(mesh.curMotionTimeIndex_),
|
||||||
|
oldPointsPtr_(move(mesh.oldPointsPtr_)),
|
||||||
|
oldCellCentresPtr_(move(mesh.oldCellCentresPtr_)),
|
||||||
|
storeOldCellCentres_(mesh.storeOldCellCentres_),
|
||||||
|
moving_(mesh.moving_),
|
||||||
|
topoChanged_(mesh.topoChanged_)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
void Foam::polyMesh::resetPrimitives
|
void Foam::polyMesh::resetPrimitives
|
||||||
(
|
(
|
||||||
pointField&& points,
|
pointField&& points,
|
||||||
|
|||||||
@ -388,8 +388,11 @@ public:
|
|||||||
const bool syncPar = true
|
const bool syncPar = true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Move constructor
|
||||||
|
polyMesh(polyMesh&&);
|
||||||
|
|
||||||
//- Disallow default bitwise copy construction
|
//- Disallow default bitwise copy construction
|
||||||
polyMesh(const polyMesh&);
|
polyMesh(const polyMesh&) = delete;
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
@ -528,13 +531,14 @@ public:
|
|||||||
return moving_;
|
return moving_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Has the mesh topology changed
|
//- Has the mesh topology changed this time-step
|
||||||
bool topoChanged() const
|
bool topoChanged() const
|
||||||
{
|
{
|
||||||
return topoChanged_;
|
return topoChanged_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Is mesh changing (topology changing and/or moving)
|
//- Is mesh changing
|
||||||
|
// Moving or mesh topology changed this time-step)
|
||||||
bool changing() const
|
bool changing() const
|
||||||
{
|
{
|
||||||
return moving() || topoChanged();
|
return moving() || topoChanged();
|
||||||
|
|||||||
@ -811,8 +811,7 @@ Foam::polyMesh::polyMesh
|
|||||||
oldPointsPtr_(nullptr),
|
oldPointsPtr_(nullptr),
|
||||||
oldCellCentresPtr_(nullptr),
|
oldCellCentresPtr_(nullptr),
|
||||||
storeOldCellCentres_(false),
|
storeOldCellCentres_(false),
|
||||||
moving_(false),
|
moving_(false)
|
||||||
topoChanged_(false)
|
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -79,9 +79,6 @@ class MeshZones
|
|||||||
//- Read if IOobject flags set. Return true if read.
|
//- Read if IOobject flags set. Return true if read.
|
||||||
bool read();
|
bool read();
|
||||||
|
|
||||||
//- Disallow default bitwise copy construction
|
|
||||||
MeshZones(const MeshZones&);
|
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const MeshZones<ZoneType, MeshType>&);
|
void operator=(const MeshZones<ZoneType, MeshType>&);
|
||||||
|
|
||||||
@ -117,6 +114,12 @@ public:
|
|||||||
const PtrList<ZoneType>&
|
const PtrList<ZoneType>&
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Move constructor
|
||||||
|
MeshZones(MeshZones&&) = default;
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construction
|
||||||
|
MeshZones(const MeshZones&) = delete;
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
~MeshZones();
|
~MeshZones();
|
||||||
|
|||||||
@ -443,8 +443,11 @@ public:
|
|||||||
const label nCells
|
const label nCells
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Move constructor
|
||||||
|
primitiveMesh(primitiveMesh&&) = default;
|
||||||
|
|
||||||
//- Disallow default bitwise copy construction
|
//- Disallow default bitwise copy construction
|
||||||
primitiveMesh(const primitiveMesh&);
|
primitiveMesh(const primitiveMesh&) = delete;
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -85,8 +85,11 @@ public:
|
|||||||
//- Construct from polyBoundaryMesh
|
//- Construct from polyBoundaryMesh
|
||||||
fvBoundaryMesh(const fvMesh&, const polyBoundaryMesh&);
|
fvBoundaryMesh(const fvMesh&, const polyBoundaryMesh&);
|
||||||
|
|
||||||
|
//- Move constructor
|
||||||
|
fvBoundaryMesh(fvBoundaryMesh&&) = default;
|
||||||
|
|
||||||
//- Disallow default bitwise copy construction
|
//- Disallow default bitwise copy construction
|
||||||
fvBoundaryMesh(const fvBoundaryMesh&);
|
fvBoundaryMesh(const fvBoundaryMesh&) = delete;
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|||||||
@ -580,6 +580,47 @@ Foam::fvMesh::fvMesh
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::fvMesh::fvMesh(fvMesh&& mesh)
|
||||||
|
:
|
||||||
|
polyMesh(Foam::move(mesh)),
|
||||||
|
surfaceInterpolation(Foam::move(mesh)),
|
||||||
|
data(static_cast<const objectRegistry&>(*this)),
|
||||||
|
boundary_(Foam::move(mesh.boundary_)),
|
||||||
|
stitcher_(Foam::move(mesh.stitcher_)),
|
||||||
|
topoChanger_(Foam::move(mesh.topoChanger_)),
|
||||||
|
distributor_(Foam::move(mesh.distributor_)),
|
||||||
|
mover_(Foam::move(mesh.mover_)),
|
||||||
|
lduPtr_(Foam::move(mesh.lduPtr_)),
|
||||||
|
polyFacesBfPtr_(Foam::move(mesh.polyFacesBfPtr_)),
|
||||||
|
polyBFaceOffsetsPtr_(Foam::move(mesh.polyBFaceOffsetsPtr_)),
|
||||||
|
polyBFaceOffsetPatchesPtr_(Foam::move(mesh.polyBFaceOffsetPatchesPtr_)),
|
||||||
|
polyBFaceOffsetPatchFacesPtr_
|
||||||
|
(
|
||||||
|
Foam::move(mesh.polyBFaceOffsetPatchFacesPtr_)
|
||||||
|
),
|
||||||
|
polyBFacePatchesPtr_(Foam::move(mesh.polyBFacePatchesPtr_)),
|
||||||
|
polyBFacePatchFacesPtr_(Foam::move(mesh.polyBFacePatchFacesPtr_)),
|
||||||
|
curTimeIndex_(mesh.curTimeIndex_),
|
||||||
|
VPtr_(Foam::move(mesh.VPtr_)),
|
||||||
|
V0Ptr_(Foam::move(mesh.V0Ptr_)),
|
||||||
|
V00Ptr_(Foam::move(mesh.V00Ptr_)),
|
||||||
|
SfSlicePtr_(Foam::move(mesh.SfSlicePtr_)),
|
||||||
|
SfPtr_(Foam::move(mesh.SfPtr_)),
|
||||||
|
magSfSlicePtr_(Foam::move(mesh.magSfSlicePtr_)),
|
||||||
|
magSfPtr_(Foam::move(mesh.magSfPtr_)),
|
||||||
|
CSlicePtr_(Foam::move(mesh.CSlicePtr_)),
|
||||||
|
CPtr_(Foam::move(mesh.CPtr_)),
|
||||||
|
CfSlicePtr_(Foam::move(mesh.CfSlicePtr_)),
|
||||||
|
CfPtr_(Foam::move(mesh.CfPtr_)),
|
||||||
|
phiPtr_(Foam::move(mesh.phiPtr_))
|
||||||
|
{
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< FUNCTION_NAME << "Moving fvMesh" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::fvMesh::~fvMesh()
|
Foam::fvMesh::~fvMesh()
|
||||||
@ -590,6 +631,12 @@ Foam::fvMesh::~fvMesh()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::fvMesh::topoChanging() const
|
||||||
|
{
|
||||||
|
return topoChanger_->dynamic();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::fvMesh::dynamic() const
|
bool Foam::fvMesh::dynamic() const
|
||||||
{
|
{
|
||||||
return topoChanger_->dynamic() || mover_->dynamic();
|
return topoChanger_->dynamic() || mover_->dynamic();
|
||||||
|
|||||||
@ -370,8 +370,11 @@ public:
|
|||||||
const bool syncPar = true
|
const bool syncPar = true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Move constructor
|
||||||
|
fvMesh(fvMesh&&);
|
||||||
|
|
||||||
//- Disallow default bitwise copy construction
|
//- Disallow default bitwise copy construction
|
||||||
fvMesh(const fvMesh&);
|
fvMesh(const fvMesh&) = delete;
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
@ -532,6 +535,9 @@ public:
|
|||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
|
|
||||||
|
//- Does the mesh topology change?
|
||||||
|
bool topoChanging() const;
|
||||||
|
|
||||||
//- Is this mesh dynamic?
|
//- Is this mesh dynamic?
|
||||||
bool dynamic() const;
|
bool dynamic() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user