Skip to content
Snippets Groups Projects
Commit 18983950 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

ENH: group bools together, relocate override of updateT (basicThermo)

- all flags before loaders. Avoids "uninitialized when used here"
  warning while preserving the field ownership logic.

- relocate override of updateT basicThermo into constructor body
  for clearer logic and initialization

STYLE: plain bool instead of Switch for dpdt flag
parent 252326df
Branches
Tags
No related merge requests found
......@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -60,7 +60,7 @@ class phaseModel
:
public volScalarField
{
// Private data
// Private Data
//- Reference to the phaseSystem to which this phase belongs
const phaseSystem& fluid_;
......@@ -209,8 +209,8 @@ public:
const label patchi
) const;
//- Query each thermo for dpdt
Switch dpdt() const
//- Query thermo for dpdt
bool dpdt() const
{
return thermo().dpdt();
}
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -36,8 +36,7 @@ License
#include "energyJumpFvPatchScalarField.H"
#include "energyJumpAMIFvPatchScalarField.H"
/* * * * * * * * * * * * * * * private static data * * * * * * * * * * * * * */
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
......@@ -55,7 +54,7 @@ Foam::wordList Foam::basicThermo::heBoundaryBaseTypes()
{
const volScalarField::Boundary& tbf = this->T_.boundaryField();
wordList hbt(tbf.size(), word::null);
wordList hbt(tbf.size());
forAll(tbf, patchi)
{
......@@ -86,7 +85,7 @@ Foam::wordList Foam::basicThermo::heBoundaryTypes()
{
const volScalarField::Boundary& tbf = this->T_.boundaryField();
wordList hbt = tbf.types();
wordList hbt(tbf.types());
forAll(tbf, patchi)
{
......@@ -120,17 +119,16 @@ Foam::wordList Foam::basicThermo::heBoundaryTypes()
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
Foam::volScalarField& Foam::basicThermo::lookupOrConstruct
(
const fvMesh& mesh,
const word& name,
const word& fieldName,
bool& isOwner
)
{
volScalarField* ptr =
mesh.objectRegistry::getObjectPtr<volScalarField>(name);
auto* ptr = mesh.objectRegistry::getObjectPtr<volScalarField>(fieldName);
isOwner = !ptr;
......@@ -140,7 +138,7 @@ Foam::volScalarField& Foam::basicThermo::lookupOrConstruct
(
IOobject
(
name,
fieldName,
mesh.time().timeName(),
mesh,
IOobject::MUST_READ,
......@@ -157,6 +155,8 @@ Foam::volScalarField& Foam::basicThermo::lookupOrConstruct
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::basicThermo::basicThermo
(
const fvMesh& mesh,
......@@ -177,10 +177,12 @@ Foam::basicThermo::basicThermo
phaseName_(phaseName),
p_(lookupOrConstruct(mesh, "p", pOwner_)),
pOwner_(false),
TOwner_(false),
dpdt_(getOrDefault<bool>("dpdt", true)),
p_(lookupOrConstruct(mesh, "p", pOwner_)),
T_(lookupOrConstruct(mesh, phasePropertyName("T"), TOwner_)),
TOwner_(getOrDefault<Switch>("updateT", TOwner_)),
alpha_
(
......@@ -194,10 +196,10 @@ Foam::basicThermo::basicThermo
),
mesh,
dimensionedScalar(dimensionSet(1, -1, -1, 0, 0), Zero)
),
dpdt_(getOrDefault<Switch>("dpdt", true))
{}
)
{
this->readIfPresent("updateT", TOwner_); // Manual override
}
Foam::basicThermo::basicThermo
......@@ -222,10 +224,12 @@ Foam::basicThermo::basicThermo
phaseName_(phaseName),
p_(lookupOrConstruct(mesh, "p", pOwner_)),
pOwner_(false),
TOwner_(false),
dpdt_(getOrDefault<bool>("dpdt", true)),
p_(lookupOrConstruct(mesh, "p", pOwner_)),
T_(lookupOrConstruct(mesh, phasePropertyName("T"), TOwner_)),
TOwner_(getOrDefault<Switch>("updateT", TOwner_)),
alpha_
(
......@@ -239,10 +243,10 @@ Foam::basicThermo::basicThermo
),
mesh,
dimensionedScalar(dimensionSet(1, -1, -1, 0, 0), Zero)
),
dpdt_(getOrDefault<Switch>("dpdt", true))
{}
)
{
this->readIfPresent("updateT", TOwner_); // Manual override
}
Foam::basicThermo::basicThermo
......@@ -266,10 +270,12 @@ Foam::basicThermo::basicThermo
phaseName_(phaseName),
p_(lookupOrConstruct(mesh, "p", pOwner_)),
pOwner_(false),
TOwner_(false),
dpdt_(getOrDefault<bool>("dpdt", true)),
p_(lookupOrConstruct(mesh, "p", pOwner_)),
T_(lookupOrConstruct(mesh, "T", TOwner_)),
TOwner_(getOrDefault<Switch>("updateT", TOwner_)),
alpha_
(
......@@ -283,10 +289,10 @@ Foam::basicThermo::basicThermo
),
mesh,
dimensionedScalar(dimensionSet(1, -1, -1, 0, 0), Zero)
),
dpdt_(getOrDefault<Switch>("dpdt", true))
)
{
this->readIfPresent("updateT", TOwner_); // Manual override
if (debug)
{
Pout<< "Constructed shared thermo : mesh:" << mesh.name()
......@@ -384,7 +390,7 @@ void Foam::basicThermo::validate
)
{
FatalErrorInFunction
<< "Supported energy types are " << phasePropertyName(a)
<< "Supported energy types: " << phasePropertyName(a)
<< " and " << phasePropertyName(b)
<< ", thermodynamics package provides " << he().name()
<< exit(FatalError);
......@@ -409,7 +415,7 @@ void Foam::basicThermo::validate
)
{
FatalErrorInFunction
<< "Supported energy types are " << phasePropertyName(a)
<< "Supported energy types: " << phasePropertyName(a)
<< ", " << phasePropertyName(b)
<< " and " << phasePropertyName(c)
<< ", thermodynamics package provides " << he().name()
......@@ -437,7 +443,7 @@ void Foam::basicThermo::validate
)
{
FatalErrorInFunction
<< "Supported energy types are " << phasePropertyName(a)
<< "Supported energy types: " << phasePropertyName(a)
<< ", " << phasePropertyName(b)
<< ", " << phasePropertyName(c)
<< " and " << phasePropertyName(d)
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -65,55 +65,56 @@ class basicThermo
:
public IOdictionary
{
protected:
// Protected data
// Protected Data
//- Phase-name
const word& phaseName_;
//- Pressure created and stored by this instance
bool pOwner_;
// Fields
//- Temperature created and stored by this instance
bool TOwner_;
//- Pressure [Pa]
volScalarField& p_;
//- Include dpdt term in the enthalpy equation?
bool dpdt_;
bool pOwner_;
//- Temperature [K]
volScalarField& T_;
// Fields
bool TOwner_;
//- Pressure [Pa]
volScalarField& p_;
//- Laminar thermal diffusivity [kg/m/s]
volScalarField alpha_;
//- Temperature [K]
volScalarField& T_;
//- Should the dpdt term be included in the enthalpy equation
Switch dpdt_;
//- Laminar thermal diffusivity [kg/m/s]
volScalarField alpha_;
// Protected Member Functions
//- Construct as copy (not implemented)
basicThermo(const basicThermo&);
//- Look up or construct field
//- Look up field from registry or construct and store
static volScalarField& lookupOrConstruct
(
const fvMesh& mesh,
const word&,
bool& isOwner
const word& fieldName,
bool& isOwner //!< Stored to registry by this instance
);
//- Return the enthalpy/internal energy field boundary types
// by interrogating the temperature field boundary types
//- by interrogating the temperature field boundary types
wordList heBoundaryTypes();
//- Return the enthalpy/internal energy field boundary base types
// by interrogating the temperature field boundary types
//- by interrogating the temperature field boundary types
wordList heBoundaryBaseTypes();
//- No copy construct
basicThermo(const basicThermo&) = delete;
public:
......@@ -161,7 +162,7 @@ public:
);
//- Construct from mesh, phase name and explicit naming of the
// dictionary (so it can be shared amongst phases).
//- dictionary (so it can be shared amongst phases).
basicThermo
(
const fvMesh&,
......@@ -228,7 +229,7 @@ public:
virtual ~basicThermo();
// Member functions
// Member Functions
static const word dictName;
......@@ -243,7 +244,7 @@ public:
word phasePropertyName(const word& name) const
{
return basicThermo::phasePropertyName(name, phaseName_);
return IOobject::groupName(name, phaseName_);
}
static const basicThermo& lookupThermo(const fvPatchScalarField& pf);
......@@ -307,14 +308,14 @@ public:
// i.e. rho = const
virtual bool isochoric() const = 0;
//- Should the dpdt term be included in the enthalpy equation
Switch dpdt() const
//- True if dpdt term should be included in enthalpy equation
bool dpdt() const noexcept
{
return dpdt_;
}
//- Should T be updated
Switch updateT() const
//- True if T should be updated
bool updateT() const noexcept
{
return TOwner_;
}
......
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