mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: scalarTransport: have regIOobject member data
functionObjects only get detroyed when the runTime gets destroyed. So the mesh is already destroyed and we cannot hold e.g. a volScalarField since that will try to 'checkOut' from the objectRegistry(=mesh) upon destruction. Note that we only see this in chtMultiRegionFoam.
This commit is contained in:
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -70,6 +70,34 @@ Foam::wordList Foam::scalarTransport::boundaryTypes() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::volScalarField& Foam::scalarTransport::transportedField()
|
||||||
|
{
|
||||||
|
if (!mesh_.foundObject<volScalarField>(name()))
|
||||||
|
{
|
||||||
|
volScalarField* fldPtr = new volScalarField
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
name(),
|
||||||
|
mesh_.time().timeName(),
|
||||||
|
mesh_,
|
||||||
|
IOobject::READ_IF_PRESENT,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
mesh_,
|
||||||
|
dimensionedScalar("zero", dimless, 0.0),
|
||||||
|
boundaryTypes()
|
||||||
|
);
|
||||||
|
fldPtr->store();
|
||||||
|
}
|
||||||
|
|
||||||
|
return const_cast<volScalarField&>
|
||||||
|
(
|
||||||
|
mesh_.lookupObject<volScalarField>(name())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::tmp<Foam::volScalarField> Foam::scalarTransport::DT
|
Foam::tmp<Foam::volScalarField> Foam::scalarTransport::DT
|
||||||
(
|
(
|
||||||
const surfaceScalarField& phi
|
const surfaceScalarField& phi
|
||||||
@ -158,27 +186,13 @@ Foam::scalarTransport::scalarTransport
|
|||||||
resetOnStartUp_(false),
|
resetOnStartUp_(false),
|
||||||
nCorr_(0),
|
nCorr_(0),
|
||||||
autoSchemes_(false),
|
autoSchemes_(false),
|
||||||
fvOptions_(mesh_),
|
fvOptions_(mesh_)
|
||||||
T_
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
name,
|
|
||||||
mesh_.time().timeName(),
|
|
||||||
mesh_,
|
|
||||||
IOobject::READ_IF_PRESENT,
|
|
||||||
IOobject::AUTO_WRITE
|
|
||||||
),
|
|
||||||
mesh_,
|
|
||||||
dimensionedScalar("zero", dimless, 0.0),
|
|
||||||
boundaryTypes()
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
read(dict);
|
read(dict);
|
||||||
|
|
||||||
if (resetOnStartUp_)
|
if (resetOnStartUp_)
|
||||||
{
|
{
|
||||||
T_ == dimensionedScalar("zero", dimless, 0.0);
|
transportedField() == dimensionedScalar("zero", dimless, 0.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,11 +241,13 @@ void Foam::scalarTransport::execute()
|
|||||||
const surfaceScalarField& phi =
|
const surfaceScalarField& phi =
|
||||||
mesh_.lookupObject<surfaceScalarField>(phiName_);
|
mesh_.lookupObject<surfaceScalarField>(phiName_);
|
||||||
|
|
||||||
|
volScalarField& T = transportedField();
|
||||||
|
|
||||||
// calculate the diffusivity
|
// calculate the diffusivity
|
||||||
volScalarField DT(this->DT(phi));
|
volScalarField DT(this->DT(phi));
|
||||||
|
|
||||||
// set schemes
|
// set schemes
|
||||||
word schemeVar = T_.name();
|
word schemeVar = T.name();
|
||||||
if (autoSchemes_)
|
if (autoSchemes_)
|
||||||
{
|
{
|
||||||
schemeVar = UName_;
|
schemeVar = UName_;
|
||||||
@ -257,11 +273,11 @@ void Foam::scalarTransport::execute()
|
|||||||
{
|
{
|
||||||
fvScalarMatrix TEqn
|
fvScalarMatrix TEqn
|
||||||
(
|
(
|
||||||
fvm::ddt(rho, T_)
|
fvm::ddt(rho, T)
|
||||||
+ fvm::div(phi, T_, divScheme)
|
+ fvm::div(phi, T, divScheme)
|
||||||
- fvm::laplacian(DT, T_, laplacianScheme)
|
- fvm::laplacian(DT, T, laplacianScheme)
|
||||||
==
|
==
|
||||||
fvOptions_(rho, T_)
|
fvOptions_(rho, T)
|
||||||
);
|
);
|
||||||
|
|
||||||
TEqn.relax(relaxCoeff);
|
TEqn.relax(relaxCoeff);
|
||||||
@ -278,11 +294,11 @@ void Foam::scalarTransport::execute()
|
|||||||
{
|
{
|
||||||
fvScalarMatrix TEqn
|
fvScalarMatrix TEqn
|
||||||
(
|
(
|
||||||
fvm::ddt(T_)
|
fvm::ddt(T)
|
||||||
+ fvm::div(phi, T_, divScheme)
|
+ fvm::div(phi, T, divScheme)
|
||||||
- fvm::laplacian(DT, T_, laplacianScheme)
|
- fvm::laplacian(DT, T, laplacianScheme)
|
||||||
==
|
==
|
||||||
fvOptions_(T_)
|
fvOptions_(T)
|
||||||
);
|
);
|
||||||
|
|
||||||
TEqn.relax(relaxCoeff);
|
TEqn.relax(relaxCoeff);
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -108,15 +108,15 @@ class scalarTransport
|
|||||||
//- Run-time selectable finite volume options, e.g. sources, constraints
|
//- Run-time selectable finite volume options, e.g. sources, constraints
|
||||||
fv::optionList fvOptions_;
|
fv::optionList fvOptions_;
|
||||||
|
|
||||||
//- The scalar field
|
|
||||||
volScalarField T_;
|
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Return the boundary types for the scalar field
|
//- Return the boundary types for the scalar field
|
||||||
wordList boundaryTypes() const;
|
wordList boundaryTypes() const;
|
||||||
|
|
||||||
|
//- Return reference to registered transported field
|
||||||
|
volScalarField& transportedField();
|
||||||
|
|
||||||
//- Return the diffusivity field
|
//- Return the diffusivity field
|
||||||
tmp<volScalarField> DT(const surfaceScalarField& phi) const;
|
tmp<volScalarField> DT(const surfaceScalarField& phi) const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user