diff --git a/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatch/immersedBoundaryFvPatch.C b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatch/immersedBoundaryFvPatch.C index 8fef40031..fb9c894fb 100644 --- a/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatch/immersedBoundaryFvPatch.C +++ b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatch/immersedBoundaryFvPatch.C @@ -360,6 +360,18 @@ Foam::label Foam::immersedBoundaryFvPatch::size() const { // Immersed boundary patch size equals to the number of intersected cells // HJ, 28/Nov/2017 + + // Note: asking for patch size triggers the cutting which involves + // parallel communication. This should be avoided under read/write, ie + // when the ibPolyPatch_ is not initialised. + // Initialisation happens when the fvMesh is initialised, which should be + // sufficient + // HJ, 12/Dec/2018 + if (!ibPolyPatch_.active()) + { + return 0; + } + return ibPolyPatch_.ibCells().size(); } @@ -371,16 +383,4 @@ Foam::immersedBoundaryFvPatch::faceCells() const } -// Foam::tmp Foam::immersedBoundaryFvPatch::nf() const -// { -// return ibPolyPatch_.ibPatch().faceNormals(); -// } - - -// Foam::tmp Foam::immersedBoundaryFvPatch::delta() const -// { -// return ibPolyPatch_.ibPatch().faceCentres() - ibPolyPatch_.ibCellCentres(); -// } - - // ************************************************************************* // diff --git a/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatch/immersedBoundaryFvPatch.H b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatch/immersedBoundaryFvPatch.H index 8c8b20e27..20f3a2798 100644 --- a/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatch/immersedBoundaryFvPatch.H +++ b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatch/immersedBoundaryFvPatch.H @@ -153,6 +153,9 @@ public: // Access //- Return size equal to number of intersected cells + // Note: if the ibPolyPatch is not initialised, return zero size + // to avoid triggering cutting (with parallel communications). + // HJ, 12/Dec/2018 virtual label size() const; //- Return patch slice size @@ -167,17 +170,6 @@ public: virtual const unallocLabelList& faceCells() const; - // Access functions for geometrical data - - // //- Return face normals - // // Reconsider. HJ, 11/Dec/2017 - // tmp nf() const; - - // //- Return cell-centre to face-centre vector - // // Reconsider. HJ, 11/Dec/2017 - // virtual tmp delta() const; - - // Access to immersed boundary components //- Return reference to immersed boundary polyPatch diff --git a/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/basic/fixedValueIbFvPatchField/fixedValueIbFvPatchField.C b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/basic/fixedValueIbFvPatchField/fixedValueIbFvPatchField.C index e6e1c92b6..9cdc3e107 100644 --- a/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/basic/fixedValueIbFvPatchField/fixedValueIbFvPatchField.C +++ b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/basic/fixedValueIbFvPatchField/fixedValueIbFvPatchField.C @@ -66,7 +66,7 @@ fixedValueIbFvPatchField::fixedValueIbFvPatchField const dictionary& dict ) : - fixedValueFvPatchField(p, iF), // Do not read mixed data + fixedValueFvPatchField(p, iF, dict), immersedBoundaryFieldBase ( p, @@ -115,7 +115,7 @@ fixedValueIbFvPatchField::fixedValueIbFvPatchField const fvPatchFieldMapper& mapper ) : - fixedValueFvPatchField(p, iF), // Do not map mixed data + fixedValueFvPatchField(p, iF), // Do not map fixed data immersedBoundaryFieldBase ( p, diff --git a/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/basic/mixedIbFvPatchField/mixedIbFvPatchField.C b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/basic/mixedIbFvPatchField/mixedIbFvPatchField.C index 0be92ad98..c8abaaea7 100644 --- a/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/basic/mixedIbFvPatchField/mixedIbFvPatchField.C +++ b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/basic/mixedIbFvPatchField/mixedIbFvPatchField.C @@ -70,7 +70,7 @@ mixedIbFvPatchField::mixedIbFvPatchField const dictionary& dict ) : - mixedFvPatchField(p, iF), // Do not read mixed data + mixedFvPatchField(p, iF), immersedBoundaryFieldBase ( p, @@ -105,15 +105,17 @@ mixedIbFvPatchField::mixedIbFvPatchField << exit(FatalIOError); } - // Re-interpolate the data related to immersed boundary - this->updateIbValues(); - - // mixedFvPatchField::evaluate(); - - // On creation of the field, intersection cannot be called. + // On creation of the field, intersection cannot be called unless + // the patch is active // Initialise the value to avoid errors // HJ, 1/Dec/2017 - Field::operator=(pTraits::zero); + if (this->ibPatch().ibPolyPatch().active()) + { + // Re-interpolate the data related to immersed boundary + this->updateIbValues(); + + mixedFvPatchField::evaluate(); + } } diff --git a/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/derived/movingImmersedBoundaryVelocity/movingImmersedBoundaryVelocityFvPatchVectorField.C b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/derived/movingImmersedBoundaryVelocity/movingImmersedBoundaryVelocityFvPatchVectorField.C index c79ac392d..1a61704a5 100644 --- a/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/derived/movingImmersedBoundaryVelocity/movingImmersedBoundaryVelocityFvPatchVectorField.C +++ b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatchFields/derived/movingImmersedBoundaryVelocity/movingImmersedBoundaryVelocityFvPatchVectorField.C @@ -65,7 +65,7 @@ movingImmersedBoundaryVelocityFvPatchVectorField const dictionary& dict ) : - fixedValueFvPatchVectorField(p, iF), // Do not read data + fixedValueFvPatchVectorField(p, iF, dict), immersedBoundaryFieldBase ( p, diff --git a/src/immersedBoundary/immersedBoundary/immersedBoundaryFvsPatchFields/immersedBoundaryFvsPatchField/immersedBoundaryFvsPatchField.C b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvsPatchFields/immersedBoundaryFvsPatchField/immersedBoundaryFvsPatchField.C index 675580dfa..255d29b3d 100644 --- a/src/immersedBoundary/immersedBoundary/immersedBoundaryFvsPatchFields/immersedBoundaryFvsPatchField/immersedBoundaryFvsPatchField.C +++ b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvsPatchFields/immersedBoundaryFvsPatchField/immersedBoundaryFvsPatchField.C @@ -66,11 +66,9 @@ immersedBoundaryFvsPatchField::immersedBoundaryFvsPatchField const dictionary& dict ) : - fvsPatchField(p, iF), // Do not read base data + fvsPatchField(p, iF, dict), ibPatch_(refCast(p)) -{ - operator=(pTraits::zero); -} +{} template diff --git a/src/immersedBoundary/immersedBoundary/immersedBoundaryPolyPatch/immersedBoundaryPolyPatch.H b/src/immersedBoundary/immersedBoundary/immersedBoundaryPolyPatch/immersedBoundaryPolyPatch.H index f02fe7d3f..e25da5a6f 100644 --- a/src/immersedBoundary/immersedBoundary/immersedBoundaryPolyPatch/immersedBoundaryPolyPatch.H +++ b/src/immersedBoundary/immersedBoundary/immersedBoundaryPolyPatch/immersedBoundaryPolyPatch.H @@ -308,6 +308,13 @@ public: // Immersed boundary patch data + //- Is the immersed boundary patch active? + // (is the intersection patch calculated?) + bool active() const + { + return ibPatchPtr_ != NULL; + } + //- Return primitivePatch of cell-intersected faces // Faces are calculated as intesection between the volume mesh // and the ibMesh