Skip to content
Snippets Groups Projects
Commit 713b1dc7 authored by mattijs's avatar mattijs
Browse files

BUG: handle transformations in addSeparated correctly.

It was overwriting results which were getting used then by other side.
It now does both sides on the owner side so it can swap the data.
parent 512a1ed6
Branches
Tags
No related merge requests found
......@@ -26,6 +26,7 @@ License
#include "cyclicPointPatchField.H"
#include "Swap.H"
#include "transformField.H"
#include "pointFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -131,30 +132,54 @@ void cyclicPointPatchField<Type>::swapAddSeparated
// Get neighbouring pointPatch
const cyclicPointPatch& nbrPatch = cyclicPatch_.neighbPatch();
// Get neighbouring patch internal field. Written out since cannot get
// access to neighbouring patch field.
Field<Type> nbrPf(pField, nbrPatch.meshPoints());
if (cyclicPatch_.cyclicPatch().owner())
{
// We inplace modify pField. To prevent the other side (which gets
// evaluated at a later date) using already changed values we do
// all swaps on the side that gets evaluated first.
Field<Type> pf(this->patchInternalField(pField));
// Get neighbouring pointPatchField
const GeometricField<Type, pointPatchField, pointMesh>& fld =
refCast<const GeometricField<Type, pointPatchField, pointMesh> >
(
this->dimensionedInternalField()
);
const edgeList& pairs = cyclicPatch_.transformPairs();
const cyclicPointPatchField<Type>& nbr =
refCast<const cyclicPointPatchField<Type> >
(
fld.boundaryField()[nbrPatch.index()]
);
if (doTransform())
{
forAll(pairs, pairi)
Field<Type> pf(this->patchInternalField(pField));
Field<Type> nbrPf(nbr.patchInternalField(pField));
const edgeList& pairs = cyclicPatch_.transformPairs();
if (doTransform())
{
pf[pairs[pairi][0]] = transform(forwardT()[0], nbrPf[pairs[pairi][1]]);
// Transform both sides.
forAll(pairs, pairi)
{
label pointi = pairs[pairi][0];
label nbrPointi = pairs[pairi][1];
Type tmp = pf[pointi];
pf[pointi] = transform(forwardT()[0], nbrPf[nbrPointi]);
nbrPf[nbrPointi] = transform(reverseT()[0], tmp);
}
}
}
else
{
forAll(pairs, pairi)
else
{
pf[pairs[pairi][0]] = nbrPf[pairs[pairi][1]];
forAll(pairs, pairi)
{
Swap(pf[pairs[pairi][0]], nbrPf[pairs[pairi][1]]);
}
}
addToInternalField(pField, pf);
nbr.addToInternalField(pField, nbrPf);
}
addToInternalField(pField, pf);
}
......
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