diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C index 1548c37e62..b3eeac0b08 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -177,17 +177,22 @@ void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::updateCoeffs() // Calculate the temperature by harmonic averaging // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const turbulentTemperatureCoupledBaffleMixedFvPatchScalarField& nbrField = - refCast - < - const turbulentTemperatureCoupledBaffleMixedFvPatchScalarField - > - ( - nbrPatch.lookupPatchField - ( - TnbrName_ - ) - ); + typedef turbulentTemperatureCoupledBaffleMixedFvPatchScalarField thisType; + + const fvPatchScalarField& nbrTp = + nbrPatch.lookupPatchField(TnbrName_); + + if (!isA(nbrTp)) + { + FatalErrorInFunction + << "Patch field for " << internalField().name() << " on " + << patch().name() << " is of type " << thisType::typeName + << endl << "The neighbouring patch field " << TnbrName_ << " on " + << nbrPatch.name() << " is of type " << nbrTp.type() << endl + << "They need to be the same type" << exit(FatalError); + } + + const thisType& nbrField = refCast(nbrTp); // Swap to obtain full local values of neighbour internal field tmp nbrIntFld(new scalarField(nbrField.size(), 0.0)); diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C index d238c6fc90..809bc954a4 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -186,12 +186,22 @@ void turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs() scalarField Tc(patchInternalField()); scalarField& Tp = *this; - const turbulentTemperatureRadCoupledMixedFvPatchScalarField& - nbrField = refCast - - ( - nbrPatch.lookupPatchField(TnbrName_) - ); + typedef turbulentTemperatureRadCoupledMixedFvPatchScalarField thisType; + + const fvPatchScalarField& nbrTp = + nbrPatch.lookupPatchField(TnbrName_); + + if (!isA(nbrTp)) + { + FatalErrorInFunction + << "Patch field for " << internalField().name() << " on " + << patch().name() << " is of type " << thisType::typeName + << endl << "The neighbouring patch field " << TnbrName_ << " on " + << nbrPatch.name() << " is of type " << nbrTp.type() << endl + << "They need to be the same type" << exit(FatalError); + } + + const thisType& nbrField = refCast(nbrTp); // Swap to obtain full local values of neighbour internal field scalarField TcNbr(nbrField.patchInternalField());