mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: blockMesh: stabilise multi-surface intersection. Fixes #730.
This commit is contained in:
@ -3,7 +3,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-2017 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -483,67 +483,70 @@ void Foam::searchableSurfacesQueries::findNearest
|
|||||||
near[i] = info[i].hitPoint();
|
near[i] = info[i].hitPoint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store normal as constraint
|
||||||
constraint.setSize(near.size());
|
constraint.setSize(near.size());
|
||||||
|
constraint = pointConstraint();
|
||||||
|
forAll(constraint, i)
|
||||||
if (surfacesToTest.size() == 1)
|
|
||||||
{
|
{
|
||||||
constraint = pointConstraint();
|
if (info[i].hit())
|
||||||
forAll(info, i)
|
|
||||||
{
|
{
|
||||||
if (info[i].hit())
|
constraint[i].applyConstraint(normal[i]);
|
||||||
{
|
|
||||||
constraint[i].applyConstraint(normal[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (surfacesToTest.size() >= 2)
|
|
||||||
|
if (surfacesToTest.size() >= 2)
|
||||||
{
|
{
|
||||||
// Work space
|
// Work space
|
||||||
pointField near1;
|
//pointField near1;
|
||||||
vectorField normal1;
|
vectorField normal1;
|
||||||
|
|
||||||
label surfi = 1;
|
label surfi = 1;
|
||||||
for (label iter = 0; iter < nIter; iter++)
|
for (label iter = 0; iter < nIter; iter++)
|
||||||
{
|
{
|
||||||
constraint = pointConstraint();
|
// Find nearest on next surface
|
||||||
forAll(constraint, i)
|
|
||||||
{
|
|
||||||
if (info[i].hit())
|
|
||||||
{
|
|
||||||
constraint[i].applyConstraint(normal[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find intersection with next surface
|
|
||||||
const searchableSurface& s = allSurfaces[surfacesToTest[surfi]];
|
const searchableSurface& s = allSurfaces[surfacesToTest[surfi]];
|
||||||
|
|
||||||
|
// Update: info, normal1
|
||||||
s.findNearest(near, distSqr, info);
|
s.findNearest(near, distSqr, info);
|
||||||
s.getNormal(info, normal1);
|
s.getNormal(info, normal1);
|
||||||
near1.setSize(info.size());
|
|
||||||
forAll(info, i)
|
// Move to intersection of
|
||||||
|
// - previous surface(s) : near+normal
|
||||||
|
// - current surface : info+normal1
|
||||||
|
forAll(near, i)
|
||||||
{
|
{
|
||||||
if (info[i].hit())
|
if (info[i].hit() && normal[i] != vector::zero)
|
||||||
{
|
{
|
||||||
near1[i] = info[i].hitPoint();
|
if (mag(normal[i]&normal1[i]) < 1.0-1e-6)
|
||||||
}
|
{
|
||||||
}
|
plane pl0(near[i], normal[i], false);
|
||||||
|
plane pl1(info[i].hitPoint(), normal1[i], false);
|
||||||
|
|
||||||
// Move to intersection
|
plane::ray r(pl0.planeIntersect(pl1));
|
||||||
forAll(near, pointi)
|
vector n = r.dir() / mag(r.dir());
|
||||||
{
|
|
||||||
if (info[pointi].hit())
|
|
||||||
{
|
|
||||||
plane pl0(near[pointi], normal[pointi]);
|
|
||||||
plane pl1(near1[pointi], normal1[pointi]);
|
|
||||||
plane::ray r(pl0.planeIntersect(pl1));
|
|
||||||
vector n = r.dir() / mag(r.dir());
|
|
||||||
|
|
||||||
vector d(r.refPoint()-near[pointi]);
|
// Calculate vector to move onto intersection line
|
||||||
d -= (d&n)*n;
|
vector d(r.refPoint()-near[i]);
|
||||||
|
d -= (d&n)*n;
|
||||||
|
|
||||||
near[pointi] += d;
|
// Trim the max distance
|
||||||
normal[pointi] = normal1[pointi];
|
scalar magD = mag(d);
|
||||||
constraint[pointi].applyConstraint(normal1[pointi]);
|
if (magD > SMALL)
|
||||||
|
{
|
||||||
|
scalar maxDist = Foam::sqrt(distSqr[i]);
|
||||||
|
if (magD > maxDist)
|
||||||
|
{
|
||||||
|
// Clip
|
||||||
|
d /= magD;
|
||||||
|
d *= maxDist;
|
||||||
|
}
|
||||||
|
|
||||||
|
near[i] += d;
|
||||||
|
normal[i] = normal1[i];
|
||||||
|
constraint[i].applyConstraint(normal1[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user