mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Using all of the surface alignment directions to perform near surface alignment.
This commit is contained in:
@ -194,6 +194,11 @@ void Foam::CV3D::setVertexAlignmentDirections()
|
|||||||
// Tertiary alignment
|
// Tertiary alignment
|
||||||
vector nt = ns ^ np;
|
vector nt = ns ^ np;
|
||||||
|
|
||||||
|
// this normalisation is not necessary if np and ns are
|
||||||
|
// perpendicular unit vectors.
|
||||||
|
|
||||||
|
nt /= mag(nt);
|
||||||
|
|
||||||
alignmentDirections.setSize(3);
|
alignmentDirections.setSize(3);
|
||||||
|
|
||||||
alignmentDirections[0] = np;
|
alignmentDirections[0] = np;
|
||||||
@ -676,7 +681,115 @@ void Foam::CV3D::relaxPoints(const scalar relaxation)
|
|||||||
|| vB->alignmentDirections().size() > 0
|
|| vB->alignmentDirections().size() > 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
vector alignmentDir;
|
Field<vector> alignmentDirs;
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
vA->alignmentDirections().size() == 3
|
||||||
|
|| vB->alignmentDirections().size() == 3
|
||||||
|
)
|
||||||
|
{
|
||||||
|
alignmentDirs.setSize(3);
|
||||||
|
|
||||||
|
if (vB->alignmentDirections().size() == 0)
|
||||||
|
{
|
||||||
|
alignmentDirs = vA->alignmentDirections();
|
||||||
|
}
|
||||||
|
else if (vA->alignmentDirections().size() == 0)
|
||||||
|
{
|
||||||
|
alignmentDirs = vB->alignmentDirections();
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
vA->alignmentDirections().size() == 3
|
||||||
|
&& vB->alignmentDirections().size() == 3
|
||||||
|
)
|
||||||
|
{
|
||||||
|
forAll(vA->alignmentDirections(), aA)
|
||||||
|
{
|
||||||
|
const vector& a(vA->alignmentDirections()[aA]);
|
||||||
|
|
||||||
|
scalar maxDotProduct = 0.0;
|
||||||
|
|
||||||
|
forAll(vB->alignmentDirections(), aB)
|
||||||
|
{
|
||||||
|
const vector& b(vB->alignmentDirections()[aB]);
|
||||||
|
|
||||||
|
if (mag(a & b) > maxDotProduct)
|
||||||
|
{
|
||||||
|
maxDotProduct = mag(a & b);
|
||||||
|
|
||||||
|
alignmentDirs[aA] = a + sign(a & b)*b;
|
||||||
|
|
||||||
|
alignmentDirs[aA] /= mag(alignmentDirs[aA]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// One of the vertices has 3 alignments and the other
|
||||||
|
// has 1
|
||||||
|
|
||||||
|
vector otherAlignment;
|
||||||
|
|
||||||
|
if (vA->alignmentDirections().size() == 3)
|
||||||
|
{
|
||||||
|
alignmentDirs = vA->alignmentDirections();
|
||||||
|
|
||||||
|
otherAlignment = vB->alignmentDirections()[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
alignmentDirs = vB->alignmentDirections();
|
||||||
|
|
||||||
|
otherAlignment = vA->alignmentDirections()[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
label matchingDirection = -1;
|
||||||
|
|
||||||
|
scalar maxDotProduct = 0.0;
|
||||||
|
|
||||||
|
forAll(alignmentDirs, aD)
|
||||||
|
{
|
||||||
|
const vector& a(alignmentDirs[aD]);
|
||||||
|
|
||||||
|
if (mag(a & otherAlignment) > maxDotProduct)
|
||||||
|
{
|
||||||
|
maxDotProduct = mag(a & otherAlignment);
|
||||||
|
|
||||||
|
matchingDirection = aD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vector& matchingAlignment =
|
||||||
|
alignmentDirs[matchingDirection];
|
||||||
|
|
||||||
|
matchingAlignment = matchingAlignment
|
||||||
|
+ sign(matchingAlignment & otherAlignment)
|
||||||
|
*otherAlignment;
|
||||||
|
|
||||||
|
matchingAlignment /= mag(matchingAlignment);
|
||||||
|
}
|
||||||
|
|
||||||
|
// vector midpoint = 0.5*(dVA + dVB);
|
||||||
|
|
||||||
|
// Info<< "midpoint " << midpoint
|
||||||
|
// << nl << alignmentDirs
|
||||||
|
// << nl << "v " << midpoint + alignmentDirs[0]
|
||||||
|
// << nl << "v " << midpoint + alignmentDirs[1]
|
||||||
|
// << nl << "v " << midpoint + alignmentDirs[2]
|
||||||
|
// << nl << "v " << midpoint
|
||||||
|
// << nl << "f 4 1"
|
||||||
|
// << nl << "f 4 2"
|
||||||
|
// << nl << "f 4 3"
|
||||||
|
// << nl << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
alignmentDirs.setSize(1);
|
||||||
|
|
||||||
|
vector& alignmentDir = alignmentDirs[0];
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
@ -698,29 +811,53 @@ void Foam::CV3D::relaxPoints(const scalar relaxation)
|
|||||||
{
|
{
|
||||||
// Both vertices have an alignment
|
// Both vertices have an alignment
|
||||||
|
|
||||||
alignmentDir = vA->alignmentDirections()[0]
|
const vector& a(vA->alignmentDirections()[0]);
|
||||||
- vB->alignmentDirections()[0];
|
|
||||||
|
|
||||||
if (mag(alignmentDir) < SMALL)
|
const vector& b(vB->alignmentDirections()[0]);
|
||||||
|
|
||||||
|
Info<< mag(a & b) << endl;
|
||||||
|
|
||||||
|
if (mag(a & b) < 1 - SMALL)
|
||||||
{
|
{
|
||||||
alignmentDir = vA->alignmentDirections()[0];
|
alignmentDirs.setSize(3);
|
||||||
|
|
||||||
|
alignmentDirs[0] = a + b;
|
||||||
|
|
||||||
|
alignmentDirs[1] = a - b;
|
||||||
|
|
||||||
|
alignmentDirs[2] =
|
||||||
|
alignmentDirs[0] ^ alignmentDirs[1];
|
||||||
|
|
||||||
|
alignmentDirs /= mag(alignmentDirs);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
alignmentDir = a + sign(a & b)*b;
|
||||||
|
|
||||||
alignmentDir /= mag(alignmentDir);
|
alignmentDir /= mag(alignmentDir);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// alignmentDirs found, now apply them
|
||||||
|
|
||||||
vector rAB = dVA - dVB;
|
vector rAB = dVA - dVB;
|
||||||
|
|
||||||
scalar rABMag = mag(rAB);
|
scalar rABMag = mag(rAB);
|
||||||
|
|
||||||
|
forAll(alignmentDirs, aD)
|
||||||
|
{
|
||||||
|
vector& alignmentDir = alignmentDirs[aD];
|
||||||
|
|
||||||
if ((rAB & alignmentDir) < 0)
|
if ((rAB & alignmentDir) < 0)
|
||||||
{
|
{
|
||||||
// swap the direction of the alignment so that has the same
|
// swap the direction of the alignment so that has the
|
||||||
// sense as rAB
|
// same sense as rAB
|
||||||
alignmentDir *= -1;
|
alignmentDir *= -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
scalar cosAcceptanceAngle = 0.743;
|
// scalar cosAcceptanceAngle = 0.743;
|
||||||
|
scalar cosAcceptanceAngle = 0.67;
|
||||||
|
|
||||||
if (((rAB/rABMag) & alignmentDir) > cosAcceptanceAngle)
|
if (((rAB/rABMag) & alignmentDir) > cosAcceptanceAngle)
|
||||||
{
|
{
|
||||||
@ -744,6 +881,7 @@ void Foam::CV3D::relaxPoints(const scalar relaxation)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
@ -751,7 +889,7 @@ void Foam::CV3D::relaxPoints(const scalar relaxation)
|
|||||||
scalar totalDist = sum(mag(displacementAccumulator));
|
scalar totalDist = sum(mag(displacementAccumulator));
|
||||||
|
|
||||||
Info<< "Total displacement = " << totalDisp
|
Info<< "Total displacement = " << totalDisp
|
||||||
<< " total distance = " << totalDist << endl;
|
<< nl << "Total distance = " << totalDist << endl;
|
||||||
|
|
||||||
displacementAccumulator *= relaxation;
|
displacementAccumulator *= relaxation;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user