mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: PatchTools: fix normals calculation if coupled point not on provided patch
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -45,9 +45,6 @@ Foam::PatchTools::pointNormals
|
||||
const PrimitivePatch<Face, FaceList, PointField, PointType>& p
|
||||
)
|
||||
{
|
||||
// Assume patch is smaller than the globalData().coupledPatch() (?) so
|
||||
// loop over patch meshPoints.
|
||||
|
||||
const globalMeshData& globalData = mesh.globalData();
|
||||
const indirectPrimitivePatch& coupledPatch = globalData.coupledPatch();
|
||||
const Map<label>& coupledPatchMP = coupledPatch.meshPointMap();
|
||||
@ -56,29 +53,16 @@ Foam::PatchTools::pointNormals
|
||||
globalData.globalTransforms();
|
||||
|
||||
|
||||
// 1. Start off with local normals (note:without calculating pointNormals
|
||||
// to avoid them being stored)
|
||||
|
||||
tmp<pointField> textrudeN(new pointField(p.nPoints(), vector::zero));
|
||||
pointField& extrudeN = textrudeN();
|
||||
|
||||
// Combine normals. Note: do on all master points. Cannot just use
|
||||
// patch points since the master point does not have to be on the
|
||||
// patch!
|
||||
|
||||
pointField coupledPointNormals(map.constructSize(), vector::zero);
|
||||
|
||||
{
|
||||
const faceList& localFaces = p.localFaces();
|
||||
const vectorField& faceNormals = p.faceNormals();
|
||||
|
||||
forAll(localFaces, faceI)
|
||||
{
|
||||
const face& f = localFaces[faceI];
|
||||
const vector& n = faceNormals[faceI];
|
||||
forAll(f, fp)
|
||||
{
|
||||
extrudeN[f[fp]] += n;
|
||||
}
|
||||
}
|
||||
extrudeN /= mag(extrudeN)+VSMALL;
|
||||
}
|
||||
|
||||
|
||||
// Collect local pointFaces
|
||||
// Collect local pointFaces (sized on patch points only)
|
||||
List<List<point> > pointFaceNormals(map.constructSize());
|
||||
forAll(p.meshPoints(), patchPointI)
|
||||
{
|
||||
@ -108,34 +92,32 @@ Foam::PatchTools::pointNormals
|
||||
);
|
||||
|
||||
|
||||
// Combine normals
|
||||
// Combine all face normals (-local, -remote,untransformed,
|
||||
// -remote,transformed)
|
||||
|
||||
const labelListList& slaves = globalData.globalPointSlaves();
|
||||
const labelListList& transformedSlaves =
|
||||
globalData.globalPointTransformedSlaves();
|
||||
|
||||
|
||||
pointField coupledPointNormals(map.constructSize(), vector::zero);
|
||||
|
||||
forAll(p.meshPoints(), patchPointI)
|
||||
forAll(slaves, coupledPointI)
|
||||
{
|
||||
label meshPointI = p.meshPoints()[patchPointI];
|
||||
Map<label>::const_iterator fnd = coupledPatchMP.find(meshPointI);
|
||||
if (fnd != coupledPatchMP.end())
|
||||
{
|
||||
label coupledPointI = fnd();
|
||||
const labelList& slaveSlots =
|
||||
slaves[coupledPointI];
|
||||
const labelList& slaveSlots = slaves[coupledPointI];
|
||||
const labelList& transformedSlaveSlots =
|
||||
transformedSlaves[coupledPointI];
|
||||
|
||||
label nFaces = slaveSlots.size()+transformedSlaveSlots.size();
|
||||
if (nFaces > 0)
|
||||
{
|
||||
// Combine
|
||||
point& n = coupledPointNormals[coupledPointI];
|
||||
|
||||
n += sum(pointFaceNormals[coupledPointI]);
|
||||
// Local entries
|
||||
const List<point>& local = pointFaceNormals[coupledPointI];
|
||||
|
||||
label nFaces =
|
||||
local.size()
|
||||
+ slaveSlots.size()
|
||||
+ transformedSlaveSlots.size();
|
||||
|
||||
n = sum(local);
|
||||
|
||||
// Add any remote face normals
|
||||
forAll(slaveSlots, i)
|
||||
{
|
||||
n += sum(pointFaceNormals[slaveSlots[i]]);
|
||||
@ -144,7 +126,11 @@ Foam::PatchTools::pointNormals
|
||||
{
|
||||
n += sum(pointFaceNormals[transformedSlaveSlots[i]]);
|
||||
}
|
||||
|
||||
if (nFaces >= 1)
|
||||
{
|
||||
n /= mag(n)+VSMALL;
|
||||
}
|
||||
|
||||
// Put back into slave slots
|
||||
forAll(slaveSlots, i)
|
||||
@ -156,8 +142,6 @@ Foam::PatchTools::pointNormals
|
||||
coupledPointNormals[transformedSlaveSlots[i]] = n;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Send back
|
||||
@ -168,9 +152,32 @@ Foam::PatchTools::pointNormals
|
||||
coupledPointNormals,
|
||||
mapDistribute::transform()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Override patch normals
|
||||
// 1. Start off with local normals (note:without calculating pointNormals
|
||||
// to avoid them being stored)
|
||||
|
||||
tmp<pointField> textrudeN(new pointField(p.nPoints(), vector::zero));
|
||||
pointField& extrudeN = textrudeN();
|
||||
{
|
||||
const faceList& localFaces = p.localFaces();
|
||||
const vectorField& faceNormals = p.faceNormals();
|
||||
|
||||
forAll(localFaces, faceI)
|
||||
{
|
||||
const face& f = localFaces[faceI];
|
||||
const vector& n = faceNormals[faceI];
|
||||
forAll(f, fp)
|
||||
{
|
||||
extrudeN[f[fp]] += n;
|
||||
}
|
||||
}
|
||||
extrudeN /= mag(extrudeN)+VSMALL;
|
||||
}
|
||||
|
||||
|
||||
// 2. Override patch normals on coupled points
|
||||
forAll(p.meshPoints(), patchPointI)
|
||||
{
|
||||
label meshPointI = p.meshPoints()[patchPointI];
|
||||
|
||||
Reference in New Issue
Block a user