From 721a2397775fd6a2bea379d0a7687aba2257a034 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Thu, 10 Apr 2014 18:16:30 +0100 Subject: [PATCH] correctImplicitBoundarySource bug fix for non-parallel coupled patches: cyclic, cyclicGgi --- .../fvMatrices/fvMatrix/fvMatrix.C | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C index ca046d953..1c10647b7 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C @@ -28,6 +28,7 @@ License #include "calculatedFvPatchFields.H" #include "zeroGradientFvPatchFields.H" #include "coupledFvPatchFields.H" +#include "transformField.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -163,8 +164,7 @@ void Foam::fvMatrix::addBoundarySource } else if (couples) { - tmp > tpnf = ptf.patchNeighbourField(); - const Field& pnf = tpnf(); + Field pnf = ptf.patchNeighbourField(); const unallocLabelList& addr = lduAddr().patchAddr(patchI); @@ -192,11 +192,36 @@ void Foam::fvMatrix::correctImplicitBoundarySource if (ptf.coupled()) { - scalarField pnf = ptf.patchNeighbourField()().component(cmpt); - + // Get access to transformation data const lduInterfaceField& lf = refCast(ptf); + const coupledFvPatch& cfvp = + refCast(ptf.patch()); + + // Get the component of "other side" field that will be handled + // implicitly. Note that patchNeighbourField function gives + // the neighbour field AFTER transform, where the implicit + // components are mis-aligned: it needs to be transformed back + // HJ, 10/Apr/2014 + scalarField pnf; + + if (cfvp.parallel()) + { + // No transformation needed + pnf = ptf.patchNeighbourField()().component(cmpt); + } + else + { + // Transform back to this side to get the implicit component + pnf = transform + ( + cfvp.reverseT(), + ptf.patchNeighbourField() + )().component(cmpt); + } + + // Identical implicitness transformation (back) lf.transformCoupleField(pnf, cmpt); const unallocLabelList& addr = lduAddr().patchAddr(patchI); @@ -526,7 +551,7 @@ void Foam::fvMatrix::setReference if ((forceReference || psi_.needReference()) && celli >= 0) { // HR, 9/Jul/2013 - // Very early versions could produce memory violations if celli is read + // Very early versions could produce memory violations if celli is read // from dictionary, however, the proposed fix produced unpredictable // results in parallel. Keeping in mind that topologically changing // meshes will complicate the matter to level that cannot possibly be