diff --git a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C index 30ccbc2fd1f71560c057e09f1046f961ef9e8dff..8cd35c516658ad3cd9dbf6fe58b2b5173837f144 100644 --- a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C @@ -74,11 +74,11 @@ thermalBaffle1DFvPatchScalarField mixedFvPatchScalarField(ptf, p, iF, mapper), TName_(ptf.TName_), baffleActivated_(ptf.baffleActivated_), - thickness_(ptf.thickness_), - Qs_(ptf.Qs_), + thickness_(ptf.thickness_, mapper), + Qs_(ptf.Qs_, mapper), solidDict_(ptf.solidDict_), solidPtr_(ptf.solidPtr_), - QrPrevious_(ptf.QrPrevious_), + QrPrevious_(ptf.QrPrevious_, mapper), QrRelaxation_(ptf.QrRelaxation_), QrName_(ptf.QrName_) {} @@ -98,7 +98,7 @@ thermalBaffle1DFvPatchScalarField TName_("T"), baffleActivated_(dict.lookupOrDefault<bool>("baffleActivated", true)), thickness_(), - Qs_(), + Qs_(p.size(), 0), solidDict_(dict), solidPtr_(), QrPrevious_(p.size(), 0.0), @@ -107,6 +107,21 @@ thermalBaffle1DFvPatchScalarField { fvPatchScalarField::operator=(scalarField("value", dict, p.size())); + if (dict.found("thickness")) + { + thickness_ = scalarField("thickness", dict, p.size()); + } + + if (dict.found("Qs")) + { + Qs_ = scalarField("Qs", dict, p.size()); + } + + if (dict.found("QrPrevious")) + { + QrPrevious_ = scalarField("QrPrevious", dict, p.size()); + } + if (dict.found("refValue") && baffleActivated_) { // Full restart @@ -209,23 +224,30 @@ const solidType& thermalBaffle1DFvPatchScalarField<solidType>::solid() const template<class solidType> -const scalarField& thermalBaffle1DFvPatchScalarField<solidType>:: +tmp<scalarField> thermalBaffle1DFvPatchScalarField<solidType>:: baffleThickness() const { if (this->owner()) { - if (thickness_.size() > 0) - { - return thickness_; - } - else + if (thickness_.size() != patch().size()) { - thickness_ = scalarField("thickness", solidDict_, patch().size()); - return thickness_; + FatalErrorIn + ( + " template<class solidType>" + " tmp<scalarField> thermalBaffle1DFvPatchScalarField<solidType> + " baffleThickness() const" + )<< " Field thickness has not been specified " + << " for patch " << this->patch().name() + << " in dictionary " << solidDict_ + << abort(FatalError); } + + return thickness_; } else { + const mapDistribute& mapDist = this->mappedPatchBase::map(); + const fvPatch& nbrPatch = patch().boundaryMesh()[samplePolyPatch().index()]; const thermalBaffle1DFvPatchScalarField& nbrField = @@ -234,28 +256,28 @@ baffleThickness() const nbrPatch.template lookupPatchField<volScalarField, scalar>(TName_) ); - return nbrField.thickness_; + tmp<scalarField> tthickness + ( + new scalarField(nbrField.baffleThickness()) + ); + scalarField& thickness = tthickness(); + mapDist.distribute(thickness); + return tthickness; } } template<class solidType> -const scalarField& thermalBaffle1DFvPatchScalarField<solidType>::Qs() const +tmp<scalarField> thermalBaffle1DFvPatchScalarField<solidType>::Qs() const { if (this->owner()) { - if (Qs_.size() > 0) - { - return Qs_; - } - else - { - Qs_ = scalarField("Qs", solidDict_, patch().size()); - return Qs_; - } + return Qs_; } else { + const mapDistribute& mapDist = this->mappedPatchBase::map(); + const fvPatch& nbrPatch = patch().boundaryMesh()[samplePolyPatch().index()]; @@ -265,7 +287,10 @@ const scalarField& thermalBaffle1DFvPatchScalarField<solidType>::Qs() const nbrPatch.template lookupPatchField<volScalarField, scalar>(TName_) ); - return nbrField.Qs_; + tmp<scalarField> tQs(new scalarField(nbrField.Qs())); + scalarField& Qs = tQs(); + mapDist.distribute(Qs); + return tQs; } } @@ -293,8 +318,11 @@ void thermalBaffle1DFvPatchScalarField<solidType>::rmap const thermalBaffle1DFvPatchScalarField& tiptf = refCast<const thermalBaffle1DFvPatchScalarField>(ptf); - thickness_.rmap(tiptf.thickness_, addr); - Qs_.rmap(tiptf.Qs_, addr); + if (this->owner()) + { + thickness_.rmap(tiptf.thickness_, addr); + Qs_.rmap(tiptf.Qs_, addr); + } } @@ -399,11 +427,12 @@ void thermalBaffle1DFvPatchScalarField<solidType>::write(Ostream& os) const if (this->owner()) { - baffleThickness().writeEntry("thickness", os); - Qs().writeEntry("Qs", os); + baffleThickness()().writeEntry("thickness", os); + Qs()().writeEntry("Qs", os); solid().write(os); } + QrPrevious_.writeEntry("QrPrevious", os); os.writeKeyword("Qr")<< QrName_ << token::END_STATEMENT << nl; os.writeKeyword("QrRelaxation")<< QrRelaxation_ << token::END_STATEMENT << nl; diff --git a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.H b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.H index d2ab8bc2d51ab217f2f7d8e23367abc2d4441478..7a9f0f1d7efa66ab7b0b83650f642bba457b8ec4 100644 --- a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.H @@ -152,10 +152,10 @@ class thermalBaffle1DFvPatchScalarField const solidType& solid() const; //- Return Qs from master - const scalarField& Qs() const; + tmp<scalarField> Qs() const; //- Return thickness from master - const scalarField& baffleThickness() const; + tmp<scalarField> baffleThickness() const; //- Is Owner bool owner() const;