diff --git a/src/finiteVolume/fields/fvPatchFields/basic/fixedGradient/fixedGradientFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/basic/fixedGradient/fixedGradientFvPatchField.C index fa1a73466..3e8437239 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/fixedGradient/fixedGradientFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/basic/fixedGradient/fixedGradientFvPatchField.C @@ -67,11 +67,20 @@ fixedGradientFvPatchField::fixedGradientFvPatchField const dictionary& dict ) : - // HR 15.12.18: Must not call evaluate during construction. Read value - // instead. This is needed for PLB. - fvPatchField(p, iF, dict, true), + fvPatchField(p, iF, dict), gradient_("gradient", dict, p.size()) -{} +{ + // Call evaluate only if the value is not found. Used to avoid evaluating + // when we have incomplete meshes during Parallel Load Balancing. When + // shipping the field over to another processor, we first call write, making + // sure that the value is written and read it on the other side (see + // write member function). If this proves to be problematic, we can always + // initialize with patch internal field for the start-up. VV, 12/Apr/2019. + if (!dict.found("value")) + { + evaluate(); + } +} template @@ -190,6 +199,11 @@ void fixedGradientFvPatchField::write(Ostream& os) const { fvPatchField::write(os); gradient_.writeEntry("gradient", os); + + // Write value along with the gradient in order to avoid calling evaluate + // on construction (from dictionary constructor) for Parallel Load Balancing + // runs. See dictionary constructor for details. VV, 12/Apr/2019. + this->writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/basic/mixed/mixedFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/basic/mixed/mixedFvPatchField.C index e542db57b..2223cc6d4 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/mixed/mixedFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/basic/mixed/mixedFvPatchField.C @@ -54,13 +54,22 @@ mixedFvPatchField::mixedFvPatchField const dictionary& dict ) : - // HR 15.12.18: Must not call evaluate during construction. Read value - // instead. This is needed for PLB. - fvPatchField(p, iF, dict, true), + fvPatchField(p, iF, dict), refValue_("refValue", dict, p.size()), refGrad_("refGradient", dict, p.size()), valueFraction_("valueFraction", dict, p.size()) -{} +{ + // Call evaluate only if the value is not found. Used to avoid evaluating + // when we have incomplete meshes during Parallel Load Balancing. When + // shipping the field over to another processor, we first call write, making + // sure that the value is written and read it on the other side (see + // write member function). If this proves to be problematic, we can always + // initialize with patch internal field for the start-up. VV, 12/Apr/2019. + if (!dict.found("value")) + { + evaluate(); + } +} template diff --git a/src/finiteVolume/fields/fvPatchFields/basic/transform/transformFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/basic/transform/transformFvPatchField.C index 27d6dd2c2..1199f4e87 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/transform/transformFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/basic/transform/transformFvPatchField.C @@ -41,7 +41,7 @@ transformFvPatchField::transformFvPatchField const DimensionedField& iF ) : - fvPatchField(p, iF) + fvPatchField(p, iF) {}