ENH: globalIndex: handling 180 degree periodic

This commit is contained in:
mattijs
2013-08-16 16:13:28 +01:00
parent 61ce6eec5d
commit 5414ff8f31
3 changed files with 57 additions and 21 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -90,6 +90,11 @@ Foam::labelPairList Foam::globalPoints::addSendTransform
const labelPairList& info
) const
{
scalar tol = refCast<const coupledPolyPatch>
(
mesh_.boundaryMesh()[patchI]
).matchTolerance();
labelPairList sendInfo(info.size());
forAll(info, i)
@ -111,7 +116,8 @@ Foam::labelPairList Foam::globalPoints::addSendTransform
(
globalIndexAndTransform::transformIndex(info[i]),
patchI,
true // patchI is sending side
true, // patchI is sending side
tol // tolerance for comparison
)
);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -195,7 +195,8 @@ public:
(
const label transformIndex,
const label patchI,
const bool isSendingSide = true
const bool isSendingSide = true,
const scalar tol = SMALL
) const;
//- Combine two transformIndices

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -190,7 +190,8 @@ Foam::label Foam::globalIndexAndTransform::addToTransformIndex
(
const label transformIndex,
const label patchI,
const bool isSendingSide
const bool isSendingSide,
const scalar tol
) const
{
const Pair<label>& transSign = patchTransformSign_[patchI];
@ -228,21 +229,49 @@ Foam::label Foam::globalIndexAndTransform::addToTransformIndex
}
else if (sign == permutation[matchTransI])
{
FatalErrorIn
(
"Foam::label "
"Foam::globalIndexAndTransform::addToTransformIndex\n"
"(\n"
"const label,\n"
"const label,\n"
"const bool\n"
") const\n"
) << "More than one patch accessing the same transform "
<< "but not of the same sign." << endl
<< "patch:" << mesh_.boundaryMesh()[patchI].name()
<< " transform:" << matchTransI << " sign:" << sign
<< " current transforms:" << permutation
<< exit(FatalError);
// This is usually illegal. The only exception is for points
// on the axis of a 180 degree cyclic wedge when the
// transformation is going to be (-1 0 0 0 -1 0 0 0 +1)
// (or a different permutation but always two times -1 and
// once +1)
bool antiCyclic = false;
const vectorTensorTransform& vt = transforms_[matchTransI];
if (mag(vt.t()) < SMALL && vt.hasR())
{
const tensor& R = vt.R();
scalar sumDiag = tr(R);
scalar sumMagDiag = mag(R.xx())+mag(R.yy())+mag(R.zz());
if (mag(sumMagDiag-3) < tol && mag(sumDiag+1) < tol)
{
antiCyclic = true;
}
}
if (antiCyclic)
{
// 180 degree rotational. Reset transformation.
permutation[matchTransI] = 0;
}
else
{
FatalErrorIn
(
"Foam::label "
"Foam::globalIndexAndTransform::addToTransformIndex\n"
"(\n"
"const label,\n"
"const label,\n"
"const bool\n"
") const\n"
) << "More than one patch accessing the same transform "
<< "but not of the same sign." << endl
<< "patch:" << mesh_.boundaryMesh()[patchI].name()
<< " transform:" << matchTransI << " sign:" << sign
<< " current transforms:" << permutation
<< exit(FatalError);
}
}
else
{