Skip to content
Snippets Groups Projects
Commit 91511116 authored by laurence's avatar laurence
Browse files

BUG: triad.C operator+=(): Do not assign to elements that are preset

parent 986efe0a
No related merge requests found
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -149,19 +149,19 @@ void Foam::triad::orthogonalize()
void Foam::triad::operator+=(const triad& t2)
{
if (t2.set(0) && !set(0))
{
operator[](0) = t2.operator[](0);
}
if (t2.set(1) && !set(1))
{
operator[](1) = t2.operator[](1);
}
bool preset[3];
if (t2.set(2) && !set(2))
for (direction i=0; i<3; i++)
{
operator[](2) = t2.operator[](2);
if (t2.set(i) && !set(i))
{
operator[](i) = t2.operator[](i);
preset[i] = true;
}
else
{
preset[i] = false;
}
}
if (set() && t2.set())
......@@ -171,6 +171,12 @@ void Foam::triad::operator+=(const triad& t2)
for (direction i=0; i<3; i++)
{
if (preset[i])
{
signd[i] = 0;
continue;
}
scalar mostAligned = -1;
for (direction j=0; j<3; j++)
{
......@@ -197,10 +203,7 @@ void Foam::triad::operator+=(const triad& t2)
}
}
}
}
for (direction i=0; i<3; i++)
{
operator[](i) += signd[i]*t2.operator[](correspondance[i]);
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment