From 1fd5416dfc47d638f4be8edb87b7117909c103d4 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Mon, 17 Jun 2019 11:11:49 +0100 Subject: [PATCH] Fixed read and mapping errors on turbulence boundary conditions --- ...aryEpsilonWallFunctionFvPatchScalarField.C | 47 +++++++++++++++++-- ...ersedBoundaryKqRWallFunctionFvPatchField.C | 12 +++-- ...oundaryNutWallFunctionFvPatchScalarField.C | 35 +++++++++++++- ...ndaryOmegaWallFunctionFvPatchScalarField.C | 35 ++++++++++++-- 4 files changed, 115 insertions(+), 14 deletions(-) diff --git a/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryEpsilonWallFunction/immersedBoundaryEpsilonWallFunctionFvPatchScalarField.C b/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryEpsilonWallFunction/immersedBoundaryEpsilonWallFunctionFvPatchScalarField.C index 164aa35f7..102fc5f8c 100644 --- a/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryEpsilonWallFunction/immersedBoundaryEpsilonWallFunctionFvPatchScalarField.C +++ b/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryEpsilonWallFunction/immersedBoundaryEpsilonWallFunctionFvPatchScalarField.C @@ -62,14 +62,31 @@ immersedBoundaryEpsilonWallFunctionFvPatchScalarField const dictionary& dict ) : - epsilonWallFunctionFvPatchScalarField(p, iF, dict), + epsilonWallFunctionFvPatchScalarField(p, iF), // Do not read mixed data immersedBoundaryFieldBase ( p, Switch(dict.lookup("setDeadValue")), readScalar(dict.lookup("deadValue")) ) -{} +{ + // Since patch does not read a dictionary, the patch type needs to be read + // manually. HJ, 6/Sep/2018 + this->readPatchType(dict); + + if (!isType(p)) + { + FatalIOErrorInFunction(dict) + << "\n patch type '" << p.type() + << "' not constraint type '" << typeName << "'" + << "\n for patch " << p.name() + << " of field " << this->dimensionedInternalField().name() + << " in file " << this->dimensionedInternalField().objectPath() + << exit(FatalIOError); + } + + scalarField::operator=(this->patchInternalField()); +} immersedBoundaryEpsilonWallFunctionFvPatchScalarField:: @@ -81,14 +98,35 @@ immersedBoundaryEpsilonWallFunctionFvPatchScalarField const fvPatchFieldMapper& mapper ) : - epsilonWallFunctionFvPatchScalarField(ptf, p, iF, mapper), + epsilonWallFunctionFvPatchScalarField(p, iF), // Do not map mixed data. Set patchType later immersedBoundaryFieldBase ( p, ptf.setDeadValue(), ptf.deadValue() ) -{} +{ + // Note: NO MAPPING. Fields are created on the immersed boundary + // HJ, 12/Apr/2012 + if (!isType(p)) + { + FatalErrorInFunction + << "\n patch type '" << p.type() + << "' not constraint type '" << typeName << "'" + << "\n for patch " << p.name() + << " of field " << this->dimensionedInternalField().name() + << " in file " << this->dimensionedInternalField().objectPath() + << exit(FatalIOError); + } + + // Copy the patch type since mixed data was not mapped + this->setPatchType(ptf); + + // On creation of the mapped field, the internal field is dummy and + // cannot be used. Initialise the value to avoid errors + // HJ, 1/Dec/2017 + scalarField::operator=(SMALL); +} immersedBoundaryEpsilonWallFunctionFvPatchScalarField:: @@ -182,7 +220,6 @@ void immersedBoundaryEpsilonWallFunctionFvPatchScalarField::updateCoeffs() // HJ, 20/May/2018 if (db().foundObject(GName())) { - Info<< "Updating epsilon" << endl; epsilonWallFunctionFvPatchScalarField::updateCoeffs(); } } diff --git a/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryKqRWallFunction/immersedBoundaryKqRWallFunctionFvPatchField.C b/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryKqRWallFunction/immersedBoundaryKqRWallFunctionFvPatchField.C index 29eb8f5a3..72c36fe28 100644 --- a/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryKqRWallFunction/immersedBoundaryKqRWallFunctionFvPatchField.C +++ b/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryKqRWallFunction/immersedBoundaryKqRWallFunctionFvPatchField.C @@ -82,7 +82,7 @@ immersedBoundaryKqRWallFunctionFvPatchField const dictionary& dict ) : - kqRWallFunctionFvPatchField(p, iF, dict), + kqRWallFunctionFvPatchField(p, iF), // Do not read mixed data immersedBoundaryFieldBase ( p, @@ -90,10 +90,10 @@ immersedBoundaryKqRWallFunctionFvPatchField pTraits(dict.lookup("deadValue")) ) { - this->checkType(); this->readPatchType(dict); + this->checkType(); - *this == this->patchInternalField(); + Field::operator=(this->patchInternalField()); } @@ -107,7 +107,7 @@ immersedBoundaryKqRWallFunctionFvPatchField const fvPatchFieldMapper& mapper ) : - kqRWallFunctionFvPatchField(ptf, p, iF, mapper), + kqRWallFunctionFvPatchField(p, iF), // Do not map mixed data. Set patchType later immersedBoundaryFieldBase ( p, @@ -117,6 +117,10 @@ immersedBoundaryKqRWallFunctionFvPatchField { this->setPatchType(ptf); this->checkType(); + + // cannot be used. Initialise the value to avoid errors + // HJ, 1/Dec/2017 + Field::operator=(pTraits::zero); } diff --git a/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryNutWallFunction/immersedBoundaryNutWallFunctionFvPatchScalarField.C b/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryNutWallFunction/immersedBoundaryNutWallFunctionFvPatchScalarField.C index f40fb15fe..b934e90c0 100644 --- a/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryNutWallFunction/immersedBoundaryNutWallFunctionFvPatchScalarField.C +++ b/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryNutWallFunction/immersedBoundaryNutWallFunctionFvPatchScalarField.C @@ -61,10 +61,23 @@ immersedBoundaryNutWallFunctionFvPatchScalarField const dictionary& dict ) : - nutkWallFunctionFvPatchScalarField(p, iF, dict), + nutkWallFunctionFvPatchScalarField(p, iF), // Do not read mixed data immersedBoundaryFieldBase(p, true, 1e-6) { this->readPatchType(dict); + + if (!isType(p)) + { + FatalIOErrorInFunction(dict) + << "\n patch type '" << p.type() + << "' not constraint type '" << typeName << "'" + << "\n for patch " << p.name() + << " of field " << this->dimensionedInternalField().name() + << " in file " << this->dimensionedInternalField().objectPath() + << exit(FatalIOError); + } + + scalarField::operator=(this->patchInternalField()); } @@ -77,10 +90,28 @@ immersedBoundaryNutWallFunctionFvPatchScalarField const fvPatchFieldMapper& mapper ) : - nutkWallFunctionFvPatchScalarField(ptf, p, iF, mapper), + nutkWallFunctionFvPatchScalarField(p, iF), // Do not map mixed data. Set patchType later immersedBoundaryFieldBase(p, true, 1e-6) { + // Note: NO MAPPING. Fields are created on the immersed boundary + // HJ, 12/Apr/2012 + if (!isType(p)) + { + FatalErrorInFunction + << "\n patch type '" << p.type() + << "' not constraint type '" << typeName << "'" + << "\n for patch " << p.name() + << " of field " << this->dimensionedInternalField().name() + << " in file " << this->dimensionedInternalField().objectPath() + << exit(FatalIOError); + } + this->setPatchType(ptf); + + // On creation of the mapped field, the internal field is dummy and + // cannot be used. Initialise the value to avoid errors + // HJ, 1/Dec/2017 + scalarField::operator=(scalar(0)); } diff --git a/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryOmegaWallFunctions/immersedBoundaryOmegaWallFunctionFvPatchScalarField.C b/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryOmegaWallFunctions/immersedBoundaryOmegaWallFunctionFvPatchScalarField.C index e7de251ed..48953a408 100644 --- a/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryOmegaWallFunctions/immersedBoundaryOmegaWallFunctionFvPatchScalarField.C +++ b/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryOmegaWallFunctions/immersedBoundaryOmegaWallFunctionFvPatchScalarField.C @@ -60,7 +60,7 @@ immersedBoundaryOmegaWallFunctionFvPatchScalarField const dictionary& dict ) : - omegaWallFunctionFvPatchScalarField(p, iF, dict), + omegaWallFunctionFvPatchScalarField(p, iF), // Do not read mixed data immersedBoundaryFieldBase ( p, @@ -70,7 +70,18 @@ immersedBoundaryOmegaWallFunctionFvPatchScalarField { this->readPatchType(dict); - *this == this->patchInternalField(); + if (!isType(p)) + { + FatalIOErrorInFunction(dict) + << "\n patch type '" << p.type() + << "' not constraint type '" << typeName << "'" + << "\n for patch " << p.name() + << " of field " << this->dimensionedInternalField().name() + << " in file " << this->dimensionedInternalField().objectPath() + << exit(FatalIOError); + } + + scalarField::operator=(this->patchInternalField()); } @@ -83,7 +94,7 @@ immersedBoundaryOmegaWallFunctionFvPatchScalarField const fvPatchFieldMapper& mapper ) : - omegaWallFunctionFvPatchScalarField(ptf, p, iF, mapper), + omegaWallFunctionFvPatchScalarField(p, iF), // Do not map mixed data. Set patchType later immersedBoundaryFieldBase ( p, @@ -91,7 +102,25 @@ immersedBoundaryOmegaWallFunctionFvPatchScalarField ptf.deadValue() ) { + // Note: NO MAPPING. Fields are created on the immersed boundary + // HJ, 12/Apr/2012 + if (!isType(p)) + { + FatalErrorInFunction + << "\n patch type '" << p.type() + << "' not constraint type '" << typeName << "'" + << "\n for patch " << p.name() + << " of field " << this->dimensionedInternalField().name() + << " in file " << this->dimensionedInternalField().objectPath() + << exit(FatalIOError); + } + this->setPatchType(ptf); + + // On creation of the mapped field, the internal field is dummy and + // cannot be used. Initialise the value to avoid errors + // HJ, 1/Dec/2017 + scalarField::operator=(SMALL); }