From 469f00e664f712a48369c20bf1daa171b892304b Mon Sep 17 00:00:00 2001 From: Sergio Ferraris Date: Fri, 15 Nov 2013 15:29:56 +0000 Subject: [PATCH 1/2] BUG: Modifications to thermalBaffle1D for parallel consistent treatment of scalarFields specified only on the master patch of the baffle --- .../thermalBaffle1DFvPatchScalarField.C | 85 +++++++++++++------ .../thermalBaffle1DFvPatchScalarField.H | 4 +- 2 files changed, 59 insertions(+), 30 deletions(-) diff --git a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C index 30ccbc2fd1..8cd35c5166 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("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::solid() const template -const scalarField& thermalBaffle1DFvPatchScalarField:: +tmp thermalBaffle1DFvPatchScalarField:: baffleThickness() const { if (this->owner()) { - if (thickness_.size() > 0) + if (thickness_.size() != patch().size()) { - return thickness_; - } - else - { - thickness_ = scalarField("thickness", solidDict_, patch().size()); - return thickness_; + FatalErrorIn + ( + " template" + " tmp thermalBaffle1DFvPatchScalarField + " 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(TName_) ); - return nbrField.thickness_; + tmp tthickness + ( + new scalarField(nbrField.baffleThickness()) + ); + scalarField& thickness = tthickness(); + mapDist.distribute(thickness); + return tthickness; } } template -const scalarField& thermalBaffle1DFvPatchScalarField::Qs() const +tmp thermalBaffle1DFvPatchScalarField::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::Qs() const nbrPatch.template lookupPatchField(TName_) ); - return nbrField.Qs_; + tmp tQs(new scalarField(nbrField.Qs())); + scalarField& Qs = tQs(); + mapDist.distribute(Qs); + return tQs; } } @@ -293,8 +318,11 @@ void thermalBaffle1DFvPatchScalarField::rmap const thermalBaffle1DFvPatchScalarField& tiptf = refCast(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::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 d2ab8bc2d5..7a9f0f1d7e 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 Qs() const; //- Return thickness from master - const scalarField& baffleThickness() const; + tmp baffleThickness() const; //- Is Owner bool owner() const; From 72d709fa5ce0b28a7304c047c5223c5e0f175975 Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 16 Nov 2013 10:28:41 +0000 Subject: [PATCH 2/2] interFoam: add support for p-relaxation --- applications/solvers/multiphase/interFoam/pEqn.H | 2 ++ 1 file changed, 2 insertions(+) diff --git a/applications/solvers/multiphase/interFoam/pEqn.H b/applications/solvers/multiphase/interFoam/pEqn.H index 1194f97099..227c075fa2 100644 --- a/applications/solvers/multiphase/interFoam/pEqn.H +++ b/applications/solvers/multiphase/interFoam/pEqn.H @@ -49,6 +49,8 @@ { phi = phiHbyA - p_rghEqn.flux(); + p_rgh.relax(); + U = HbyA + rAU*fvc::reconstruct((phig - p_rghEqn.flux())/rAUf); U.correctBoundaryConditions(); fvOptions.correct(U);