STYLE: default construct/assignment for mergedSurf

COMP: fix incorrect reference in meshedSurfRef
This commit is contained in:
Mark Olesen
2018-10-10 19:08:27 +02:00
parent 07dafe7b0b
commit b76f2421dc
3 changed files with 131 additions and 30 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -29,24 +29,42 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::mergedSurf::mergedSurf()
:
points_(),
faces_(),
zones_(),
pointsMap_()
{}
Foam::mergedSurf::mergedSurf Foam::mergedSurf::mergedSurf
( (
const meshedSurf& surf, const meshedSurf& unmergedSurface,
const scalar mergeDim const scalar mergeDim
) )
: :
mergedSurf() mergedSurf()
{ {
merge(surf, mergeDim); merge(unmergedSurface, mergeDim);
}
Foam::mergedSurf::mergedSurf
(
const pointField& unmergedPoints,
const faceList& unmergedFaces,
const scalar mergeDim
)
:
mergedSurf()
{
merge(unmergedPoints, unmergedFaces, mergeDim);
}
Foam::mergedSurf::mergedSurf
(
const pointField& unmergedPoints,
const faceList& unmergedFaces,
const labelList& originalIds,
const scalar mergeDim
)
:
mergedSurf()
{
merge(unmergedPoints, unmergedFaces, originalIds, mergeDim);
} }
@ -69,15 +87,43 @@ void Foam::mergedSurf::clear()
bool Foam::mergedSurf::merge bool Foam::mergedSurf::merge
( (
const meshedSurf& surf, const meshedSurf& unmergedSurface,
const scalar mergeDim const scalar mergeDim
) )
{ {
// needed for extra safety? return
// clear(); merge
(
unmergedSurface.points(),
unmergedSurface.faces(),
unmergedSurface.zoneIds(),
mergeDim
);
}
bool Foam::mergedSurf::merge
(
const pointField& unmergedPoints,
const faceList& unmergedFaces,
const scalar mergeDim
)
{
return merge(unmergedPoints, unmergedFaces, labelList(), mergeDim);
}
bool Foam::mergedSurf::merge
(
const pointField& unmergedPoints,
const faceList& unmergedFaces,
const labelList& originalIds,
const scalar mergeDim
)
{
if (!use()) if (!use())
{ {
clear(); // Extra safety?
return false; return false;
} }
@ -86,8 +132,8 @@ bool Foam::mergedSurf::merge
mergeDim, mergeDim,
primitivePatch primitivePatch
( (
SubList<face>(surf.faces(), surf.faces().size()), SubList<face>(unmergedFaces, unmergedFaces.size()),
surf.points() unmergedPoints
), ),
points_, points_,
faces_, faces_,
@ -96,7 +142,7 @@ bool Foam::mergedSurf::merge
// Now handle zone/region information // Now handle zone/region information
List<labelList> allZones(Pstream::nProcs()); List<labelList> allZones(Pstream::nProcs());
allZones[Pstream::myProcNo()] = surf.zoneIds(); allZones[Pstream::myProcNo()] = originalIds;
Pstream::gatherList(allZones); Pstream::gatherList(allZones);
if (Pstream::master()) if (Pstream::master())

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -25,7 +25,9 @@ Class
Foam::mergedSurf Foam::mergedSurf
Description Description
Simple class to manage surface merging information Simple class to manage surface merging information.
Merging is done with PatchTools::gatherAndMerge()
SourceFiles SourceFiles
mergedSurf.C mergedSurf.C
@ -55,20 +57,43 @@ class mergedSurf
labelList zones_; labelList zones_;
labelList pointsMap_; labelList pointsMap_;
//- No copy construct
mergedSurf(const mergedSurf&) = delete;
// Assignment is needed for lists
public: public:
// Constructors // Constructors
//- Construct null //- Construct null
mergedSurf(); mergedSurf() = default;
//- Construct and merge meshed surfaces immediately (in parallel only). //- Copy construct null
mergedSurf(const meshedSurf&, const scalar mergeDim); mergedSurf(const mergedSurf&) = default;
//- Move construct
mergedSurf(mergedSurf&&) = default;
//- Construct and merge.
mergedSurf
(
const meshedSurf& unmergedSurface,
const scalar mergeDim
);
//- Construct and merge.
mergedSurf
(
const pointField& unmergedPoints,
const faceList& unmergedFaces,
const scalar mergeDim
);
//- Construct and merge
mergedSurf
(
const pointField& unmergedPoints,
const faceList& unmergedFaces,
const labelList& originalIds,
const scalar mergeDim
);
//- Destructor //- Destructor
@ -117,7 +142,37 @@ public:
void clear(); void clear();
//- Merge meshed surfaces (in parallel only). //- Merge meshed surfaces (in parallel only).
bool merge(const meshedSurf&, const scalar mergeDim); bool merge
(
const meshedSurf& unmergedSurface,
const scalar mergeDim
);
//- Merge meshed surfaces (in parallel only).
bool merge
(
const pointField& unmergedPoints,
const faceList& unmergedFaces,
const scalar mergeDim
);
//- Merge meshed surfaces (in parallel only).
bool merge
(
const pointField& unmergedPoints,
const faceList& unmergedFaces,
const labelList& originalIds,
const scalar mergeDim
);
// Member Operators
//- Copy assignment
mergedSurf& operator=(const mergedSurf&) = default;
//- Move assignment
mergedSurf& operator=(mergedSurf&&) = default;
}; };

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -69,7 +69,7 @@ public:
( (
const pointField& pts, const pointField& pts,
const faceList& faces, const faceList& faces,
const labelUList& ids = Foam::emptyLabelList const labelList& ids = labelList()
) )
: :
points_(pts), points_(pts),