mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: sampledSurfaces: extracted merging functionality to Patchtools
This commit is contained in:
@ -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) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -27,6 +27,7 @@ License
|
|||||||
|
|
||||||
#include "PatchToolsCheck.C"
|
#include "PatchToolsCheck.C"
|
||||||
#include "PatchToolsEdgeOwner.C"
|
#include "PatchToolsEdgeOwner.C"
|
||||||
|
#include "PatchToolsGatherAndMerge.C"
|
||||||
#include "PatchToolsSearch.C"
|
#include "PatchToolsSearch.C"
|
||||||
#include "PatchToolsSortEdges.C"
|
#include "PatchToolsSortEdges.C"
|
||||||
#include "PatchToolsNormals.C"
|
#include "PatchToolsNormals.C"
|
||||||
|
|||||||
@ -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) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -33,6 +33,7 @@ SourceFiles
|
|||||||
PatchTools.C
|
PatchTools.C
|
||||||
PatchToolsCheck.C
|
PatchToolsCheck.C
|
||||||
PatchToolsEdgeOwner.C
|
PatchToolsEdgeOwner.C
|
||||||
|
PatchToolsGatherAndMerge.C
|
||||||
PatchToolsSearch.C
|
PatchToolsSearch.C
|
||||||
PatchToolsSortEdges.C
|
PatchToolsSortEdges.C
|
||||||
PatchToolsNormals.C
|
PatchToolsNormals.C
|
||||||
@ -236,6 +237,25 @@ public:
|
|||||||
const labelList& meshFaces
|
const labelList& meshFaces
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Gather points and faces onto master and merge (geometrically) into
|
||||||
|
// single patch.
|
||||||
|
template
|
||||||
|
<
|
||||||
|
class Face,
|
||||||
|
template<class> class FaceList,
|
||||||
|
class PointField,
|
||||||
|
class PointType
|
||||||
|
>
|
||||||
|
static void gatherAndMerge
|
||||||
|
(
|
||||||
|
const scalar mergeDist,
|
||||||
|
const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
|
||||||
|
Field<PointType>& mergedPoints,
|
||||||
|
List<Face>& mergedFaces,
|
||||||
|
labelList& pointMergeMap
|
||||||
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,181 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012 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 "PatchTools.H"
|
||||||
|
#include "ListListOps.H"
|
||||||
|
#include "mergePoints.H"
|
||||||
|
#include "face.H"
|
||||||
|
#include "triFace.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
//- Used to offset faces in Pstream::combineOffset
|
||||||
|
template<>
|
||||||
|
class offsetOp<face>
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
face operator()
|
||||||
|
(
|
||||||
|
const face& x,
|
||||||
|
const label offset
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
face result(x.size());
|
||||||
|
|
||||||
|
forAll(x, xI)
|
||||||
|
{
|
||||||
|
result[xI] = x[xI] + offset;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//- Used to offset faces in Pstream::combineOffset
|
||||||
|
template<>
|
||||||
|
class offsetOp<triFace>
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
triFace operator()
|
||||||
|
(
|
||||||
|
const triFace& x,
|
||||||
|
const label offset
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
triFace result(x);
|
||||||
|
|
||||||
|
forAll(x, xI)
|
||||||
|
{
|
||||||
|
result[xI] = x[xI] + offset;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template
|
||||||
|
<
|
||||||
|
class Face,
|
||||||
|
template<class> class FaceList,
|
||||||
|
class PointField,
|
||||||
|
class PointType
|
||||||
|
>
|
||||||
|
void Foam::PatchTools::gatherAndMerge
|
||||||
|
(
|
||||||
|
const scalar mergeDist,
|
||||||
|
const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
|
||||||
|
Field<PointType>& mergedPoints,
|
||||||
|
List<Face>& mergedFaces,
|
||||||
|
labelList& pointMergeMap
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Collect points from all processors
|
||||||
|
labelList pointSizes;
|
||||||
|
{
|
||||||
|
List<Field<PointType> > gatheredPoints(Pstream::nProcs());
|
||||||
|
gatheredPoints[Pstream::myProcNo()] = p.localPoints();
|
||||||
|
Pstream::gatherList(gatheredPoints);
|
||||||
|
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
pointSizes = ListListOps::subSizes
|
||||||
|
(
|
||||||
|
gatheredPoints,
|
||||||
|
accessOp<Field<PointType> >()
|
||||||
|
);
|
||||||
|
|
||||||
|
mergedPoints = ListListOps::combine<Field<PointType> >
|
||||||
|
(
|
||||||
|
gatheredPoints,
|
||||||
|
accessOp<Field<PointType> >()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Collect faces from all processors and renumber using sizes of
|
||||||
|
// gathered points
|
||||||
|
{
|
||||||
|
List<List<Face> > gatheredFaces(Pstream::nProcs());
|
||||||
|
gatheredFaces[Pstream::myProcNo()] = p.localFaces();
|
||||||
|
Pstream::gatherList(gatheredFaces);
|
||||||
|
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
mergedFaces = static_cast<const List<Face>&>
|
||||||
|
(
|
||||||
|
ListListOps::combineOffset<List<Face> >
|
||||||
|
(
|
||||||
|
gatheredFaces,
|
||||||
|
pointSizes,
|
||||||
|
accessOp<List<Face> >(),
|
||||||
|
offsetOp<Face>()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
Field<PointType> newPoints;
|
||||||
|
labelList oldToNew;
|
||||||
|
|
||||||
|
bool hasMerged = mergePoints
|
||||||
|
(
|
||||||
|
mergedPoints,
|
||||||
|
mergeDist,
|
||||||
|
false, // verbosity
|
||||||
|
oldToNew,
|
||||||
|
newPoints
|
||||||
|
);
|
||||||
|
|
||||||
|
if (hasMerged)
|
||||||
|
{
|
||||||
|
// Store point mapping
|
||||||
|
pointMergeMap.transfer(oldToNew);
|
||||||
|
|
||||||
|
// Copy points
|
||||||
|
mergedPoints.transfer(newPoints);
|
||||||
|
|
||||||
|
// Relabel faces
|
||||||
|
List<Face>& faces = mergedFaces;
|
||||||
|
|
||||||
|
forAll(faces, faceI)
|
||||||
|
{
|
||||||
|
inplaceRenumber(pointMergeMap, faces[faceI]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -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) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -28,9 +28,8 @@ License
|
|||||||
#include "dictionary.H"
|
#include "dictionary.H"
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
#include "IOmanip.H"
|
#include "IOmanip.H"
|
||||||
#include "ListListOps.H"
|
|
||||||
#include "mergePoints.H"
|
|
||||||
#include "volPointInterpolation.H"
|
#include "volPointInterpolation.H"
|
||||||
|
#include "PatchTools.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -38,34 +37,6 @@ defineTypeNameAndDebug(Foam::sampledSurfaces, 0);
|
|||||||
bool Foam::sampledSurfaces::verbose_ = false;
|
bool Foam::sampledSurfaces::verbose_ = false;
|
||||||
Foam::scalar Foam::sampledSurfaces::mergeTol_ = 1e-10;
|
Foam::scalar Foam::sampledSurfaces::mergeTol_ = 1e-10;
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
//- Used to offset faces in Pstream::combineOffset
|
|
||||||
template <>
|
|
||||||
class offsetOp<face>
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
face operator()
|
|
||||||
(
|
|
||||||
const face& x,
|
|
||||||
const label offset
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
face result(x.size());
|
|
||||||
|
|
||||||
forAll(x, xI)
|
|
||||||
{
|
|
||||||
result[xI] = x[xI] + offset;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::sampledSurfaces::writeGeometry() const
|
void Foam::sampledSurfaces::writeGeometry() const
|
||||||
@ -379,80 +350,18 @@ bool Foam::sampledSurfaces::update()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PatchTools::gatherAndMerge
|
||||||
// Collect points from all processors
|
|
||||||
List<pointField> gatheredPoints(Pstream::nProcs());
|
|
||||||
gatheredPoints[Pstream::myProcNo()] = s.points();
|
|
||||||
Pstream::gatherList(gatheredPoints);
|
|
||||||
|
|
||||||
if (Pstream::master())
|
|
||||||
{
|
|
||||||
mergeList_[surfI].points = ListListOps::combine<pointField>
|
|
||||||
(
|
|
||||||
gatheredPoints,
|
|
||||||
accessOp<pointField>()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Collect faces from all processors and renumber using sizes of
|
|
||||||
// gathered points
|
|
||||||
List<faceList> gatheredFaces(Pstream::nProcs());
|
|
||||||
gatheredFaces[Pstream::myProcNo()] = s.faces();
|
|
||||||
Pstream::gatherList(gatheredFaces);
|
|
||||||
|
|
||||||
if (Pstream::master())
|
|
||||||
{
|
|
||||||
mergeList_[surfI].faces = static_cast<const faceList&>
|
|
||||||
(
|
|
||||||
ListListOps::combineOffset<faceList>
|
|
||||||
(
|
|
||||||
gatheredFaces,
|
|
||||||
ListListOps::subSizes
|
|
||||||
(
|
|
||||||
gatheredPoints,
|
|
||||||
accessOp<pointField>()
|
|
||||||
),
|
|
||||||
accessOp<faceList>(),
|
|
||||||
offsetOp<face>()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
pointField newPoints;
|
|
||||||
labelList oldToNew;
|
|
||||||
|
|
||||||
bool hasMerged = mergePoints
|
|
||||||
(
|
(
|
||||||
mergeList_[surfI].points,
|
|
||||||
mergeDim,
|
mergeDim,
|
||||||
false, // verbosity
|
primitivePatch
|
||||||
oldToNew,
|
(
|
||||||
newPoints
|
SubList<face>(s.faces(), s.faces().size()),
|
||||||
|
s.points()
|
||||||
|
),
|
||||||
|
mergeList_[surfI].points,
|
||||||
|
mergeList_[surfI].faces,
|
||||||
|
mergeList_[surfI].pointsMap
|
||||||
);
|
);
|
||||||
|
|
||||||
if (hasMerged)
|
|
||||||
{
|
|
||||||
// Store point mapping
|
|
||||||
mergeList_[surfI].pointsMap.transfer(oldToNew);
|
|
||||||
|
|
||||||
// Copy points
|
|
||||||
mergeList_[surfI].points.transfer(newPoints);
|
|
||||||
|
|
||||||
// Relabel faces
|
|
||||||
faceList& faces = mergeList_[surfI].faces;
|
|
||||||
|
|
||||||
forAll(faces, faceI)
|
|
||||||
{
|
|
||||||
inplaceRenumber(mergeList_[surfI].pointsMap, faces[faceI]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Pstream::master() && debug)
|
|
||||||
{
|
|
||||||
Pout<< "For surface " << surfI << " merged from "
|
|
||||||
<< mergeList_[surfI].pointsMap.size() << " points down to "
|
|
||||||
<< mergeList_[surfI].points.size() << " points" << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return updated;
|
return updated;
|
||||||
|
|||||||
Reference in New Issue
Block a user