Skip to content
Snippets Groups Projects
Commit 469f00e6 authored by Sergio Ferraris's avatar Sergio Ferraris
Browse files

BUG: Modifications to thermalBaffle1D for parallel consistent treatment

of scalarFields specified only on the master patch of the baffle
parent 19ae0c6d
Branches
Tags
No related merge requests found
......@@ -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;
......
......@@ -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;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment