ENH: PatchTools: parallel synced edge normals

This commit is contained in:
mattijs 2013-01-21 11:48:01 +00:00
parent 5b0d85c3ff
commit 6d8bf52876
4 changed files with 111 additions and 34 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -221,8 +221,7 @@ public:
);
//- Return parallel consistent point normals for patches (on boundary faces)
// using mesh points.
//- Return parallel consistent point normals for patches using mesh points.
template
<
class Face,
@ -231,10 +230,27 @@ public:
class PointType
>
static tmp<pointField> pointNormals
(
const polyMesh&,
const PrimitivePatch<Face, FaceList, PointField, PointType>&
);
//- Return parallel consistent edge normals for patches using mesh points.
// Supply with patch matching info from matchEdges.
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
static tmp<pointField> edgeNormals
(
const polyMesh&,
const PrimitivePatch<Face, FaceList, PointField, PointType>&,
const labelList& meshFaces
const labelList& patchEdges,
const labelList& coupledEdges
);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -79,8 +79,7 @@ Foam::tmp<Foam::pointField>
Foam::PatchTools::pointNormals
(
const polyMesh& mesh,
const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
const labelList& meshFaces
const PrimitivePatch<Face, FaceList, PointField, PointType>& p
)
{
// Assume patch is smaller than the globalData().coupledPatch() (?) so
@ -224,4 +223,90 @@ Foam::PatchTools::pointNormals
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
Foam::tmp<Foam::pointField>
Foam::PatchTools::edgeNormals
(
const polyMesh& mesh,
const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
const labelList& patchEdges,
const labelList& coupledEdges
)
{
// 1. Start off with local normals
tmp<pointField> tedgeNormals(new pointField(p.nEdges(), vector::zero));
pointField& edgeNormals = tedgeNormals();
{
const labelListList& edgeFaces = p.edgeFaces();
const vectorField& faceNormals = p.faceNormals();
forAll(edgeFaces, edgeI)
{
const labelList& eFaces = edgeFaces[edgeI];
forAll(eFaces, i)
{
edgeNormals[edgeI] += faceNormals[eFaces[i]];
}
}
edgeNormals /= mag(edgeNormals)+VSMALL;
}
const globalMeshData& globalData = mesh.globalData();
const mapDistribute& map = globalData.globalEdgeSlavesMap();
// Convert patch-edge data into cpp-edge data
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//- Construct with all data in consistent orientation
pointField cppEdgeData(map.constructSize(), vector::zero);
forAll(patchEdges, i)
{
label patchEdgeI = patchEdges[i];
label coupledEdgeI = coupledEdges[i];
cppEdgeData[coupledEdgeI] = edgeNormals[patchEdgeI];
}
// Synchronise
// ~~~~~~~~~~~
globalData.syncData
(
cppEdgeData,
globalData.globalEdgeSlaves(),
globalData.globalEdgeTransformedSlaves(),
map,
globalData.globalTransforms(),
plusEqOp<point>(), // add since normalised later on
mapDistribute::transform()
);
cppEdgeData /= mag(cppEdgeData)+VSMALL;
// Back from cpp-edge to patch-edge data
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
forAll(patchEdges, i)
{
label patchEdgeI = patchEdges[i];
label coupledEdgeI = coupledEdges[i];
edgeNormals[patchEdgeI] = cppEdgeData[coupledEdgeI];
}
return tedgeNormals;
}
// ************************************************************************* //

View File

@ -1464,15 +1464,7 @@ void Foam::autoLayerDriver::getPatchDisplacement
// Determine pointNormal
// ~~~~~~~~~~~~~~~~~~~~~
pointField pointNormals
(
PatchTools::pointNormals
(
mesh,
pp,
pp.addressing()
)
);
pointField pointNormals(PatchTools::pointNormals(mesh, pp));
// Determine local length scale on patch

View File

@ -826,15 +826,7 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
// Determine pointNormal
// ~~~~~~~~~~~~~~~~~~~~~
pointField pointNormals
(
PatchTools::pointNormals
(
mesh,
pp,
pp.addressing()
)
);
pointField pointNormals(PatchTools::pointNormals(mesh, pp));
// pointNormals
if (debug&meshRefinement::MESH || debug&meshRefinement::LAYERINFO)
@ -1074,15 +1066,7 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
<< featureAngle << " degrees." << endl;
scalar featureAngleCos = Foam::cos(degToRad(featureAngle));
pointField pointNormals
(
PatchTools::pointNormals
(
mesh,
pp,
identity(pp.size())+pp.start()
)
);
pointField pointNormals(PatchTools::pointNormals(mesh, pp));
forAll(meshPoints, i)
{