multicomponentThermo: Construct Yslicer on demand
This fixes a crash caused by the pointers to the mass fraction boundary fields being invalidated by mesh-to-mesh mapping
This commit is contained in:
@ -53,9 +53,11 @@ Foam::BasicThermo<MixtureType, BasicThermoType>::volScalarFieldProperty
|
||||
|
||||
volScalarField& psi = tPsi.ref();
|
||||
|
||||
auto Yslicer = this->Yslicer();
|
||||
|
||||
forAll(psi, celli)
|
||||
{
|
||||
auto composition = this->cellComposition(celli);
|
||||
auto composition = this->cellComposition(Yslicer, celli);
|
||||
|
||||
psi[celli] =
|
||||
((this->*mixture)(composition).*psiMethod)(args[celli] ...);
|
||||
@ -67,7 +69,8 @@ Foam::BasicThermo<MixtureType, BasicThermoType>::volScalarFieldProperty
|
||||
{
|
||||
forAll(psiBf[patchi], patchFacei)
|
||||
{
|
||||
auto composition = this->patchFaceComposition(patchi, patchFacei);
|
||||
auto composition =
|
||||
this->patchFaceComposition(Yslicer, patchi, patchFacei);
|
||||
|
||||
psiBf[patchi][patchFacei] =
|
||||
((this->*mixture)(composition).*psiMethod)
|
||||
@ -98,9 +101,11 @@ Foam::BasicThermo<MixtureType, BasicThermoType>::cellSetProperty
|
||||
tmp<scalarField> tPsi(new scalarField(cells.size()));
|
||||
scalarField& psi = tPsi.ref();
|
||||
|
||||
auto Yslicer = this->Yslicer();
|
||||
|
||||
forAll(cells, celli)
|
||||
{
|
||||
auto composition = this->cellComposition(cells[celli]);
|
||||
auto composition = this->cellComposition(Yslicer, cells[celli]);
|
||||
|
||||
psi[celli] =
|
||||
((this->*mixture)(composition).*psiMethod)(args[celli] ...);
|
||||
@ -127,9 +132,12 @@ Foam::BasicThermo<MixtureType, BasicThermoType>::patchFieldProperty
|
||||
);
|
||||
scalarField& psi = tPsi.ref();
|
||||
|
||||
auto Yslicer = this->Yslicer();
|
||||
|
||||
forAll(psi, patchFacei)
|
||||
{
|
||||
auto composition = this->patchFaceComposition(patchi, patchFacei);
|
||||
auto composition =
|
||||
this->patchFaceComposition(Yslicer, patchi, patchFacei);
|
||||
|
||||
psi[patchFacei] =
|
||||
((this->*mixture)(composition).*psiMethod)(args[patchFacei] ...);
|
||||
|
||||
@ -40,9 +40,11 @@ void Foam::PsiThermo<BaseThermo>::calculate()
|
||||
scalarField& muCells = this->mu_.primitiveFieldRef();
|
||||
scalarField& kappaCells = this->kappa_.primitiveFieldRef();
|
||||
|
||||
auto Yslicer = this->Yslicer();
|
||||
|
||||
forAll(TCells, celli)
|
||||
{
|
||||
auto composition = this->cellComposition(celli);
|
||||
auto composition = this->cellComposition(Yslicer, celli);
|
||||
|
||||
const typename BaseThermo::mixtureType::thermoMixtureType&
|
||||
thermoMixture = this->thermoMixture(composition);
|
||||
@ -106,7 +108,8 @@ void Foam::PsiThermo<BaseThermo>::calculate()
|
||||
{
|
||||
forAll(pT, facei)
|
||||
{
|
||||
auto composition = this->patchFaceComposition(patchi, facei);
|
||||
auto composition =
|
||||
this->patchFaceComposition(Yslicer, patchi, facei);
|
||||
|
||||
const typename BaseThermo::mixtureType::thermoMixtureType&
|
||||
thermoMixture = this->thermoMixture(composition);
|
||||
@ -129,7 +132,8 @@ void Foam::PsiThermo<BaseThermo>::calculate()
|
||||
{
|
||||
forAll(pT, facei)
|
||||
{
|
||||
auto composition = this->patchFaceComposition(patchi, facei);
|
||||
auto composition =
|
||||
this->patchFaceComposition(Yslicer, patchi, facei);
|
||||
|
||||
const typename BaseThermo::mixtureType::thermoMixtureType&
|
||||
thermoMixture = this->thermoMixture(composition);
|
||||
|
||||
@ -61,12 +61,20 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Get the slicer
|
||||
inline nil Yslicer() const;
|
||||
|
||||
//- Get the composition of an internal cell
|
||||
inline nil cellComposition(const label celli) const;
|
||||
inline nil cellComposition
|
||||
(
|
||||
const nil,
|
||||
const label celli
|
||||
) const;
|
||||
|
||||
//- Get the composition of a boundary face
|
||||
inline nil patchFaceComposition
|
||||
(
|
||||
const nil,
|
||||
const label patchi,
|
||||
const label facei
|
||||
) const;
|
||||
|
||||
@ -27,7 +27,17 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::nil Foam::pureThermo::cellComposition(const label celli) const
|
||||
inline Foam::nil Foam::pureThermo::Yslicer() const
|
||||
{
|
||||
return nil();
|
||||
}
|
||||
|
||||
|
||||
inline Foam::nil Foam::pureThermo::cellComposition
|
||||
(
|
||||
const nil,
|
||||
const label celli
|
||||
) const
|
||||
{
|
||||
return nil();
|
||||
}
|
||||
@ -35,6 +45,7 @@ inline Foam::nil Foam::pureThermo::cellComposition(const label celli) const
|
||||
|
||||
inline Foam::nil Foam::pureThermo::patchFaceComposition
|
||||
(
|
||||
const nil,
|
||||
const label patchi,
|
||||
const label facei
|
||||
) const
|
||||
|
||||
@ -41,9 +41,11 @@ void Foam::RhoFluidThermo<BaseThermo>::calculate()
|
||||
scalarField& muCells = this->mu_.primitiveFieldRef();
|
||||
scalarField& kappaCells = this->kappa_.primitiveFieldRef();
|
||||
|
||||
auto Yslicer = this->Yslicer();
|
||||
|
||||
forAll(TCells, celli)
|
||||
{
|
||||
auto composition = this->cellComposition(celli);
|
||||
auto composition = this->cellComposition(Yslicer, celli);
|
||||
|
||||
const typename BaseThermo::mixtureType::thermoMixtureType&
|
||||
thermoMixture = this->thermoMixture(composition);
|
||||
@ -112,7 +114,8 @@ void Foam::RhoFluidThermo<BaseThermo>::calculate()
|
||||
{
|
||||
forAll(pT, facei)
|
||||
{
|
||||
auto composition = this->patchFaceComposition(patchi, facei);
|
||||
auto composition =
|
||||
this->patchFaceComposition(Yslicer, patchi, facei);
|
||||
|
||||
const typename BaseThermo::mixtureType::thermoMixtureType&
|
||||
thermoMixture = this->thermoMixture(composition);
|
||||
@ -136,7 +139,8 @@ void Foam::RhoFluidThermo<BaseThermo>::calculate()
|
||||
{
|
||||
forAll(pT, facei)
|
||||
{
|
||||
auto composition = this->patchFaceComposition(patchi, facei);
|
||||
auto composition =
|
||||
this->patchFaceComposition(Yslicer, patchi, facei);
|
||||
|
||||
const typename BaseThermo::mixtureType::thermoMixtureType&
|
||||
thermoMixture = this->thermoMixture(composition);
|
||||
|
||||
@ -56,6 +56,7 @@ class GeometricFieldListSlicer
|
||||
// Type of the geometric field
|
||||
typedef GeometricField<Type, PatchField, GeoMesh> geoFieldType;
|
||||
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Pointers to the internal fields
|
||||
|
||||
@ -90,8 +90,7 @@ Foam::multicomponentThermo::implementation::implementation
|
||||
: -1
|
||||
),
|
||||
active_(species_.size(), true),
|
||||
Y_(species_.size()),
|
||||
Yslicer_()
|
||||
Y_(species_.size())
|
||||
{
|
||||
if (species_.size() && defaultSpeciei_ == -1)
|
||||
{
|
||||
@ -203,8 +202,6 @@ Foam::multicomponentThermo::implementation::implementation
|
||||
}
|
||||
}
|
||||
|
||||
Yslicer_.set(Y_);
|
||||
|
||||
correctMassFractions();
|
||||
}
|
||||
|
||||
|
||||
@ -294,9 +294,6 @@ protected:
|
||||
//- Species mass fractions
|
||||
PtrList<volScalarField> Y_;
|
||||
|
||||
//- Species mass fractions slicing engine
|
||||
volScalarFieldListSlicer Yslicer_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
@ -339,12 +336,20 @@ public:
|
||||
//- Access the mass-fraction fields
|
||||
virtual const PtrList<volScalarField>& Y() const;
|
||||
|
||||
//- Get the slicer
|
||||
inline volScalarFieldListSlicer Yslicer() const;
|
||||
|
||||
//- Get the composition of an internal cell
|
||||
inline scalarFieldListSlice cellComposition(const label celli) const;
|
||||
inline scalarFieldListSlice cellComposition
|
||||
(
|
||||
const volScalarFieldListSlicer& Yslicer,
|
||||
const label celli
|
||||
) const;
|
||||
|
||||
//- Get the composition of a boundary face
|
||||
inline scalarFieldListSlice patchFaceComposition
|
||||
(
|
||||
const volScalarFieldListSlicer& Yslicer,
|
||||
const label patchi,
|
||||
const label facei
|
||||
) const;
|
||||
|
||||
@ -104,24 +104,33 @@ inline Foam::label Foam::multicomponentThermo::specieIndex
|
||||
}
|
||||
|
||||
|
||||
inline Foam::volScalarFieldListSlicer
|
||||
Foam::multicomponentThermo::implementation::Yslicer() const
|
||||
{
|
||||
return volScalarFieldListSlicer(Y_);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalarFieldListSlice
|
||||
Foam::multicomponentThermo::implementation::cellComposition
|
||||
(
|
||||
const volScalarFieldListSlicer& Yslicer,
|
||||
const label celli
|
||||
) const
|
||||
{
|
||||
return Yslicer_.slice(celli);
|
||||
return Yslicer.slice(celli);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalarFieldListSlice
|
||||
Foam::multicomponentThermo::implementation::patchFaceComposition
|
||||
(
|
||||
const volScalarFieldListSlicer& Yslicer,
|
||||
const label patchi,
|
||||
const label facei
|
||||
) const
|
||||
{
|
||||
return Yslicer_.patchSlice(patchi, facei);
|
||||
return Yslicer.patchSlice(patchi, facei);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -44,9 +44,11 @@ void Foam::PsiuMulticomponentThermo<BaseThermo>::calculate()
|
||||
scalarField& muCells = this->mu_.primitiveFieldRef();
|
||||
scalarField& kappaCells = this->kappa_.primitiveFieldRef();
|
||||
|
||||
auto Yslicer = this->Yslicer();
|
||||
|
||||
forAll(TCells, celli)
|
||||
{
|
||||
auto composition = this->cellComposition(celli);
|
||||
auto composition = this->cellComposition(Yslicer, celli);
|
||||
|
||||
const typename BaseThermo::mixtureType::thermoMixtureType&
|
||||
thermoMixture = this->thermoMixture(composition);
|
||||
@ -125,7 +127,8 @@ void Foam::PsiuMulticomponentThermo<BaseThermo>::calculate()
|
||||
{
|
||||
forAll(pT, facei)
|
||||
{
|
||||
auto composition = this->patchFaceComposition(patchi, facei);
|
||||
auto composition =
|
||||
this->patchFaceComposition(Yslicer, patchi, facei);
|
||||
|
||||
const typename BaseThermo::mixtureType::thermoMixtureType&
|
||||
thermoMixture = this->thermoMixture(composition);
|
||||
@ -147,7 +150,8 @@ void Foam::PsiuMulticomponentThermo<BaseThermo>::calculate()
|
||||
{
|
||||
forAll(pT, facei)
|
||||
{
|
||||
auto composition = this->patchFaceComposition(patchi, facei);
|
||||
auto composition =
|
||||
this->patchFaceComposition(Yslicer, patchi, facei);
|
||||
|
||||
const typename BaseThermo::mixtureType::thermoMixtureType&
|
||||
thermoMixture = this->thermoMixture(composition);
|
||||
|
||||
@ -112,8 +112,7 @@ Foam::psiuMulticomponentThermo::implementation::implementation
|
||||
)
|
||||
:
|
||||
species_(specieNames),
|
||||
Y_(species_.size()),
|
||||
Yslicer_()
|
||||
Y_(species_.size())
|
||||
{
|
||||
forAll(species_, i)
|
||||
{
|
||||
@ -134,8 +133,6 @@ Foam::psiuMulticomponentThermo::implementation::implementation
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Yslicer_.set(Y_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -223,9 +223,6 @@ protected:
|
||||
//- Species mass fractions
|
||||
PtrList<volScalarField> Y_;
|
||||
|
||||
//- Species mass fractions slicing engine
|
||||
volScalarFieldListSlicer Yslicer_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -256,12 +253,20 @@ public:
|
||||
//- Access the mass-fraction fields
|
||||
virtual const PtrList<volScalarField>& Y() const;
|
||||
|
||||
//- Get the slicer
|
||||
inline volScalarFieldListSlicer Yslicer() const;
|
||||
|
||||
//- Get the composition of an internal cell
|
||||
inline scalarFieldListSlice cellComposition(const label celli) const;
|
||||
inline scalarFieldListSlice cellComposition
|
||||
(
|
||||
const volScalarFieldListSlicer& Yslicer,
|
||||
const label celli
|
||||
) const;
|
||||
|
||||
//- Get the composition of a boundary face
|
||||
inline scalarFieldListSlice patchFaceComposition
|
||||
(
|
||||
const volScalarFieldListSlicer& Yslicer,
|
||||
const label patchi,
|
||||
const label facei
|
||||
) const;
|
||||
|
||||
@ -55,24 +55,33 @@ inline const Foam::volScalarField& Foam::psiuMulticomponentThermo::Y
|
||||
}
|
||||
|
||||
|
||||
inline Foam::volScalarFieldListSlicer
|
||||
Foam::psiuMulticomponentThermo::implementation::Yslicer() const
|
||||
{
|
||||
return volScalarFieldListSlicer(Y_);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalarFieldListSlice
|
||||
Foam::psiuMulticomponentThermo::implementation::cellComposition
|
||||
(
|
||||
const volScalarFieldListSlicer& Yslicer,
|
||||
const label celli
|
||||
) const
|
||||
{
|
||||
return Yslicer_.slice(celli);
|
||||
return Yslicer.slice(celli);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalarFieldListSlice
|
||||
Foam::psiuMulticomponentThermo::implementation::patchFaceComposition
|
||||
(
|
||||
const volScalarFieldListSlicer& Yslicer,
|
||||
const label patchi,
|
||||
const label facei
|
||||
) const
|
||||
{
|
||||
return Yslicer_.patchSlice(patchi, facei);
|
||||
return Yslicer.patchSlice(patchi, facei);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -42,9 +42,11 @@ void Foam::SolidThermo<BaseThermo>::calculate()
|
||||
scalarField& kappaCells = this->kappa_.primitiveFieldRef();
|
||||
vectorField& KappaCells = this->Kappa_.primitiveFieldRef();
|
||||
|
||||
auto Yslicer = this->Yslicer();
|
||||
|
||||
forAll(TCells, celli)
|
||||
{
|
||||
auto composition = this->cellComposition(celli);
|
||||
auto composition = this->cellComposition(Yslicer, celli);
|
||||
|
||||
const typename BaseThermo::mixtureType::thermoMixtureType&
|
||||
thermoMixture = this->thermoMixture(composition);
|
||||
@ -115,7 +117,8 @@ void Foam::SolidThermo<BaseThermo>::calculate()
|
||||
{
|
||||
forAll(pT, facei)
|
||||
{
|
||||
auto composition = this->patchFaceComposition(patchi, facei);
|
||||
auto composition =
|
||||
this->patchFaceComposition(Yslicer, patchi, facei);
|
||||
|
||||
const typename BaseThermo::mixtureType::thermoMixtureType&
|
||||
thermoMixture = this->thermoMixture(composition);
|
||||
@ -146,7 +149,8 @@ void Foam::SolidThermo<BaseThermo>::calculate()
|
||||
{
|
||||
forAll(pT, facei)
|
||||
{
|
||||
auto composition = this->patchFaceComposition(patchi, facei);
|
||||
auto composition =
|
||||
this->patchFaceComposition(Yslicer, patchi, facei);
|
||||
|
||||
const typename BaseThermo::mixtureType::thermoMixtureType&
|
||||
thermoMixture = this->thermoMixture(composition);
|
||||
|
||||
Reference in New Issue
Block a user