mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: PatchTools: parallel synced edge normals
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-2012 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -221,8 +221,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//- Return parallel consistent point normals for patches (on boundary faces)
|
//- Return parallel consistent point normals for patches using mesh points.
|
||||||
// using mesh points.
|
|
||||||
template
|
template
|
||||||
<
|
<
|
||||||
class Face,
|
class Face,
|
||||||
@ -231,10 +230,27 @@ public:
|
|||||||
class PointType
|
class PointType
|
||||||
>
|
>
|
||||||
static tmp<pointField> pointNormals
|
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 polyMesh&,
|
||||||
const PrimitivePatch<Face, FaceList, PointField, PointType>&,
|
const PrimitivePatch<Face, FaceList, PointField, PointType>&,
|
||||||
const labelList& meshFaces
|
const labelList& patchEdges,
|
||||||
|
const labelList& coupledEdges
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -79,8 +79,7 @@ Foam::tmp<Foam::pointField>
|
|||||||
Foam::PatchTools::pointNormals
|
Foam::PatchTools::pointNormals
|
||||||
(
|
(
|
||||||
const polyMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
|
const PrimitivePatch<Face, FaceList, PointField, PointType>& p
|
||||||
const labelList& meshFaces
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Assume patch is smaller than the globalData().coupledPatch() (?) so
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -1464,15 +1464,7 @@ void Foam::autoLayerDriver::getPatchDisplacement
|
|||||||
// Determine pointNormal
|
// Determine pointNormal
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
pointField pointNormals
|
pointField pointNormals(PatchTools::pointNormals(mesh, pp));
|
||||||
(
|
|
||||||
PatchTools::pointNormals
|
|
||||||
(
|
|
||||||
mesh,
|
|
||||||
pp,
|
|
||||||
pp.addressing()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// Determine local length scale on patch
|
// Determine local length scale on patch
|
||||||
|
|||||||
@ -826,15 +826,7 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
|
|||||||
// Determine pointNormal
|
// Determine pointNormal
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
pointField pointNormals
|
pointField pointNormals(PatchTools::pointNormals(mesh, pp));
|
||||||
(
|
|
||||||
PatchTools::pointNormals
|
|
||||||
(
|
|
||||||
mesh,
|
|
||||||
pp,
|
|
||||||
pp.addressing()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// pointNormals
|
// pointNormals
|
||||||
if (debug&meshRefinement::MESH || debug&meshRefinement::LAYERINFO)
|
if (debug&meshRefinement::MESH || debug&meshRefinement::LAYERINFO)
|
||||||
@ -1074,15 +1066,7 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
|
|||||||
<< featureAngle << " degrees." << endl;
|
<< featureAngle << " degrees." << endl;
|
||||||
|
|
||||||
scalar featureAngleCos = Foam::cos(degToRad(featureAngle));
|
scalar featureAngleCos = Foam::cos(degToRad(featureAngle));
|
||||||
pointField pointNormals
|
pointField pointNormals(PatchTools::pointNormals(mesh, pp));
|
||||||
(
|
|
||||||
PatchTools::pointNormals
|
|
||||||
(
|
|
||||||
mesh,
|
|
||||||
pp,
|
|
||||||
identity(pp.size())+pp.start()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
forAll(meshPoints, i)
|
forAll(meshPoints, i)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user