BUG: Completing autoMap and rMap fucntions for private scalarFields.

Correcting write function for solidThermo Ptr
This commit is contained in:
Sergio Ferraris
2013-05-08 09:27:48 +01:00
parent b6b6bbef89
commit 7dd14d82e0
2 changed files with 45 additions and 6 deletions

View File

@ -51,6 +51,7 @@ thermalBaffle1DFvPatchScalarField
baffleActivated_(true), baffleActivated_(true),
thickness_(p.size()), thickness_(p.size()),
Qs_(p.size()), Qs_(p.size()),
solidDict_(),
solidPtr_(NULL) solidPtr_(NULL)
{} {}
@ -70,6 +71,7 @@ thermalBaffle1DFvPatchScalarField
baffleActivated_(ptf.baffleActivated_), baffleActivated_(ptf.baffleActivated_),
thickness_(ptf.thickness_), thickness_(ptf.thickness_),
Qs_(ptf.Qs_), Qs_(ptf.Qs_),
solidDict_(ptf.solidDict_),
solidPtr_(ptf.solidPtr_) solidPtr_(ptf.solidPtr_)
{} {}
@ -88,6 +90,7 @@ thermalBaffle1DFvPatchScalarField
baffleActivated_(readBool(dict.lookup("baffleActivated"))), baffleActivated_(readBool(dict.lookup("baffleActivated"))),
thickness_(scalarField("thickness", dict, p.size())), thickness_(scalarField("thickness", dict, p.size())),
Qs_(scalarField("Qs", dict, p.size())), Qs_(scalarField("Qs", dict, p.size())),
solidDict_(dict),
solidPtr_(new solidType(dict)) solidPtr_(new solidType(dict))
{ {
if (!isA<mappedPatchBase>(this->patch().patch())) if (!isA<mappedPatchBase>(this->patch().patch()))
@ -141,6 +144,7 @@ thermalBaffle1DFvPatchScalarField
baffleActivated_(ptf.baffleActivated_), baffleActivated_(ptf.baffleActivated_),
thickness_(ptf.thickness_), thickness_(ptf.thickness_),
Qs_(ptf.Qs_), Qs_(ptf.Qs_),
solidDict_(ptf.solidDict_),
solidPtr_(ptf.solidPtr_) solidPtr_(ptf.solidPtr_)
{} {}
@ -158,12 +162,28 @@ thermalBaffle1DFvPatchScalarField
baffleActivated_(ptf.baffleActivated_), baffleActivated_(ptf.baffleActivated_),
thickness_(ptf.thickness_), thickness_(ptf.thickness_),
Qs_(ptf.Qs_), Qs_(ptf.Qs_),
solidDict_(ptf.solidDict_),
solidPtr_(ptf.solidPtr_) solidPtr_(ptf.solidPtr_)
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class solidType>
const solidType& thermalBaffle1DFvPatchScalarField<solidType>::solidPtr() const
{
if (!solidPtr_.empty())
{
return solidPtr_();
}
else
{
solidPtr_.reset(new solidType(solidDict_));
return solidPtr_();
}
}
template<class solidType> template<class solidType>
void thermalBaffle1DFvPatchScalarField<solidType>::autoMap void thermalBaffle1DFvPatchScalarField<solidType>::autoMap
( (
@ -171,6 +191,8 @@ void thermalBaffle1DFvPatchScalarField<solidType>::autoMap
) )
{ {
mixedFvPatchScalarField::autoMap(m); mixedFvPatchScalarField::autoMap(m);
thickness_.autoMap(m);
Qs_.autoMap(m);
} }
template<class solidType> template<class solidType>
@ -181,6 +203,12 @@ void thermalBaffle1DFvPatchScalarField<solidType>::rmap
) )
{ {
mixedFvPatchScalarField::rmap(ptf, addr); mixedFvPatchScalarField::rmap(ptf, addr);
const thermalBaffle1DFvPatchScalarField& tiptf =
refCast<const thermalBaffle1DFvPatchScalarField>(ptf);
thickness_.rmap(tiptf.thickness_, addr);
Qs_.rmap(tiptf.Qs_, addr);
} }
@ -264,7 +292,7 @@ void thermalBaffle1DFvPatchScalarField<solidType>::updateCoeffs()
forAll(KDeltaw, i) forAll(KDeltaw, i)
{ {
KDeltaw[i] = KDeltaw[i] =
solidPtr_().kappa(0.0, (Tp[i] + nbrTw[i])/2.0)/thickness_[i]; solidPtr().kappa(0.0, (Tp[i] + nbrTw[i])/2.0)/thickness_[i];
} }
const scalarField q const scalarField q
@ -338,8 +366,7 @@ void thermalBaffle1DFvPatchScalarField<solidType>::updateCoeffs()
} }
template<class solidType> template<class solidType>
void thermalBaffle1DFvPatchScalarField<solidType>:: void thermalBaffle1DFvPatchScalarField<solidType>:: write(Ostream& os) const
write(Ostream& os) const
{ {
mixedFvPatchScalarField::write(os); mixedFvPatchScalarField::write(os);
os.writeKeyword("TName") os.writeKeyword("TName")
@ -348,7 +375,7 @@ write(Ostream& os) const
os.writeKeyword("baffleActivated") os.writeKeyword("baffleActivated")
<< baffleActivated_ << token::END_STATEMENT << nl; << baffleActivated_ << token::END_STATEMENT << nl;
Qs_.writeEntry("Qs", os); Qs_.writeEntry("Qs", os);
solidPtr_->write(os); solidPtr().write(os);
} }

View File

@ -70,8 +70,17 @@ class thermalBaffle1DFvPatchScalarField
//- Superficial heat source [W/m2] //- Superficial heat source [W/m2]
scalarField Qs_; scalarField Qs_;
// Solid thermo //- Solid dictionary
autoPtr<solidType> solidPtr_; dictionary solidDict_;
//- Solid thermo
mutable autoPtr<solidType> solidPtr_;
// Private members
//- Return non const solid thermo autoMap
const solidType& solidPtr() const;
public: public:
@ -144,6 +153,7 @@ public:
// Member functions // Member functions
// Mapping functions // Mapping functions
//- Map (and resize as needed) from self given a mapping object //- Map (and resize as needed) from self given a mapping object
@ -160,6 +170,8 @@ public:
); );
//- Update the coefficients associated with the patch field //- Update the coefficients associated with the patch field
virtual void updateCoeffs(); virtual void updateCoeffs();