diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C index 9fa08201ea..9cdbff68e2 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -154,11 +154,11 @@ Foam::cyclicACMIFvPatchField::patchNeighbourField() const const Field& iField = this->internalField(); const labelUList& nbrFaceCellsCoupled = cyclicACMIPatch_.cyclicACMIPatch().neighbPatch().faceCells(); - const labelUList& nbrFaceCellsNonOverlap = + const labelUList& faceCellsNonOverlap = cyclicACMIPatch_.cyclicACMIPatch().nonOverlapPatch().faceCells(); Field pnfCoupled(iField, nbrFaceCellsCoupled); - Field pnfNonOverlap(iField, nbrFaceCellsNonOverlap); + Field pfNonOverlap(iField, faceCellsNonOverlap); tmp > tpnf ( @@ -167,7 +167,7 @@ Foam::cyclicACMIFvPatchField::patchNeighbourField() const cyclicACMIPatch_.interpolate ( pnfCoupled, - pnfNonOverlap + pfNonOverlap ) ) ); @@ -287,10 +287,14 @@ Foam::tmp > Foam::cyclicACMIFvPatchField::snGrad template void Foam::cyclicACMIFvPatchField::updateCoeffs() { - const scalarField& mask = cyclicACMIPatch_.cyclicACMIPatch().mask(); + // update non-overlap patch - some will implement updateCoeffs, and + // others will implement evaluate + // scale neighbour field by (1 - mask) + + const scalarField& mask = cyclicACMIPatch_.cyclicACMIPatch().mask(); const fvPatchField& npf = nonOverlapPatchField(); - const_cast&>(npf).updateCoeffs(mask); + const_cast&>(npf).updateCoeffs(1.0 - mask); } @@ -300,9 +304,21 @@ void Foam::cyclicACMIFvPatchField::initEvaluate const Pstream::commsTypes comms ) { - // update non-overlap patch - const fvPatchField& npf = nonOverlapPatchField(); - const_cast&>(npf).evaluate(comms); + // update non-overlap patch (if not already updated by updateCoeffs) + + // scale neighbour field by (1 - mask) + + fvPatchField& npf = + const_cast&>(nonOverlapPatchField()); + + if (!npf.updated()) + { + const scalarField& mask = cyclicACMIPatch_.cyclicACMIPatch().mask(); + + npf.evaluate(comms); + + npf *= 1.0 - mask; + } } @@ -313,13 +329,16 @@ void Foam::cyclicACMIFvPatchField::evaluate ) { // blend contributions from the coupled and non-overlap patches + + // neighbour patch field is updated via updateCoeffs or initEvaluate + // and is already scaled by (1 - mask) const fvPatchField& npf = nonOverlapPatchField(); coupledFvPatchField::evaluate(comms); const Field& cpf = *this; const scalarField& mask = cyclicACMIPatch_.cyclicACMIPatch().mask(); - Field::operator=(mask*cpf + (1.0 - mask)*npf); + Field::operator=(mask*cpf + npf); fvPatchField::evaluate(); } @@ -333,7 +352,7 @@ Foam::cyclicACMIFvPatchField::valueInternalCoeffs ) const { // note: do not blend based on mask field - // - when applied this is scaled by the areas which area already scaled + // - when applied this is scaled by the areas which are already scaled return coupledFvPatchField::valueInternalCoeffs(w); } @@ -346,7 +365,7 @@ Foam::cyclicACMIFvPatchField::valueBoundaryCoeffs ) const { // note: do not blend based on mask field - // - when applied this is scaled by the areas which area already scaled + // - when applied this is scaled by the areas which are already scaled return coupledFvPatchField::valueBoundaryCoeffs(w); } @@ -359,7 +378,7 @@ Foam::cyclicACMIFvPatchField::gradientInternalCoeffs ) const { // note: do not blend based on mask field - // - when applied this is scaled by the areas which area already scaled + // - when applied this is scaled by the areas which are already scaled return coupledFvPatchField::gradientInternalCoeffs(deltaCoeffs); } @@ -369,7 +388,7 @@ Foam::tmp > Foam::cyclicACMIFvPatchField::gradientInternalCoeffs() const { // note: do not blend based on mask field - // - when applied this is scaled by the areas which area already scaled + // - when applied this is scaled by the areas which are already scaled return coupledFvPatchField::gradientInternalCoeffs(); } @@ -382,7 +401,7 @@ Foam::cyclicACMIFvPatchField::gradientBoundaryCoeffs ) const { // note: do not blend based on mask field - // - when applied this is scaled by the areas which area already scaled + // - when applied this is scaled by the areas which are already scaled return coupledFvPatchField::gradientBoundaryCoeffs(deltaCoeffs); } @@ -392,7 +411,7 @@ Foam::tmp > Foam::cyclicACMIFvPatchField::gradientBoundaryCoeffs() const { // note: do not blend based on mask field - // - when applied this is scaled by the areas which area already scaled + // - when applied this is scaled by the areas which are already scaled return coupledFvPatchField::gradientBoundaryCoeffs(); } @@ -403,11 +422,13 @@ void Foam::cyclicACMIFvPatchField::manipulateMatrix fvMatrix& matrix ) { - // blend contributions from the coupled and non-overlap patches + const scalarField& mask = cyclicACMIPatch_.cyclicACMIPatch().mask(); + + // nothing to be done by the AMI, but re-direct to non-overlap patch + // with non-overlap patch weights const fvPatchField& npf = nonOverlapPatchField(); - const scalarField& mask = cyclicACMIPatch_.cyclicACMIPatch().mask(); - const_cast&>(npf).manipulateMatrix(matrix, mask); + const_cast&>(npf).manipulateMatrix(matrix, 1.0 - mask); } diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H index 3a8198a95b..dd2d8d751b 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -166,9 +166,30 @@ public: // Evaluation functions //- Return true if coupled. Note that the underlying patch - // is not coupled() - the points don't align. + // is not coupled() - the points don't align virtual bool coupled() const; + //- Return true if this patch field fixes a value + // Needed to check if a level has to be specified while solving + // Poissons equations + virtual bool fixesValue() const + { + const scalarField& mask = + cyclicACMIPatch_.cyclicACMIPatch().mask(); + + if (gMax(mask) > 1e-5) + { + // regions connected + return false; + } + else + { + // fully separated + return nonOverlapPatchField().fixesValue(); + } + } + + //- Return neighbour coupled internal cell data virtual tmp > patchNeighbourField() const;