Commit 9887c8f5 authored by sergio's avatar sergio Committed by Andrew Heather
Browse files

ENH: adding thermo changes to handle multiphase T based thermos

parent 017213de
EXE_INC = -I$(OBJECTS_DIR)
EXE_INC = \
-I$(OBJECTS_DIR)
LIB_LIBS = \
$(FOAM_LIBBIN)/libOSspecific.o \
......
......@@ -95,7 +95,18 @@ Foam::tmp<Foam::Field<Type>> Foam::Function1Types::Constant<Type>::value
template<class Type>
<<<<<<< HEAD
Foam::tmp<Foam::Field<Type>> Foam::Function1Types::Constant<Type>::integrate
=======
bool Foam::Function1Types::Constant<Type>::isConstant() const
{
return true;
}
template<class Type>
Type Foam::Function1Types::Constant<Type>::integrate
>>>>>>> c61dc5e... ENH: adding thermo changes to handle multiphase T based thermos
(
const scalarField& x1,
const scalarField& x2
......@@ -104,7 +115,6 @@ Foam::tmp<Foam::Field<Type>> Foam::Function1Types::Constant<Type>::integrate
return (x2 - x1)*value_;
}
template<class Type>
void Foam::Function1Types::Constant<Type>::writeData(Ostream& os) const
{
......
......@@ -121,6 +121,9 @@ public:
const scalarField& x2
) const;
//- Return true for Constant type
virtual bool isConstant() const;
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
};
......
......@@ -157,6 +157,13 @@ Foam::FieldFunction1<Function1Type>::integrate
}
template<class Type>
bool Foam::Function1<Type>::isConstant() const
{
return false;
}
template<class Type>
void Foam::Function1<Type>::writeData(Ostream& os) const
{
......
......@@ -154,6 +154,9 @@ public:
const scalarField& x2
) const;
//- Return true for Constant type
virtual bool isConstant() const;
// I/O
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "Constant.H"
#include "PolynomialEntry.H"
#include "Sine.H"
#include "Square.H"
#include "CSV.H"
#include "Table.H"
#include "TableFile.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define makeFunction1s(Type) \
makeFunction1(Type); \
makeFunction1Type(Constant, Type); \
makeFunction1Type(Polynomial, Type); \
makeFunction1Type(Sine, Type); \
makeFunction1Type(Square, Type); \
makeFunction1Type(CSV, Type); \
makeFunction1Type(Table, Type); \
makeFunction1Type(TableFile, Type);
namespace Foam
{
makeFunction1(label);
//makeFunction1Type(Constant, label);
// Polynomial functions and interpolation do evaluate to label
// Instead evaluate a scalar and convert to label as appropriate
makeFunction1s(scalar);
makeFunction1s(vector);
makeFunction1s(sphericalTensor);
makeFunction1s(symmTensor);
makeFunction1s(tensor);
}
// ************************************************************************* //
......@@ -119,6 +119,12 @@ Type Foam::TimeFunction1<Type>::integrate
}
template<class Type>
bool Foam::TimeFunction1<Type>::isConstant() const
{
return entry_->isConstant();
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class Type>
......
......@@ -121,6 +121,9 @@ public:
//- Integrate between two (scalar) values
virtual Type integrate(const scalar x1, const scalar x2) const;
//- Return true for Constant type
virtual bool isConstant() const;
// I/O
......
......@@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -167,6 +167,13 @@ Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::kappa
return thermo.kappa(patchi);
}
else if (mesh.foundObject<basicThermo>("phaseProperties"))
{
const basicThermo& thermo =
mesh.lookupObject<basicThermo>("phaseProperties");
return thermo.kappa(patchi);
}
else
{
FatalErrorInFunction
......
......@@ -10,7 +10,8 @@ EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \
-I$(LIB_SRC)/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude
-I$(LIB_SRC)/regionModels/regionModel/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude
LIB_LIBS = \
-lfiniteVolume \
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
......@@ -40,6 +40,7 @@ namespace Foam
{
defineTypeNameAndDebug(basicThermo, 0);
defineRunTimeSelectionTable(basicThermo, fvMesh);
defineRunTimeSelectionTable(basicThermo, fvMeshDictPhase);
}
const Foam::word Foam::basicThermo::dictName("thermophysicalProperties");
......@@ -125,7 +126,7 @@ Foam::wordList Foam::basicThermo::heBoundaryTypes()
Foam::volScalarField& Foam::basicThermo::lookupOrConstruct
(
const fvMesh& mesh,
const char* name
const word& name
) const
{
if (!mesh.objectRegistry::foundObject<volScalarField>(name))
......@@ -188,18 +189,7 @@ Foam::basicThermo::basicThermo
p_(lookupOrConstruct(mesh, "p")),
T_
(
IOobject
(
phasePropertyName("T"),
mesh.time().timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
),
T_(lookupOrConstruct(mesh, phasePropertyName("T"))),
alpha_
(
......@@ -220,7 +210,9 @@ Foam::basicThermo::basicThermo
)
),
dpdt_(lookupOrDefault<Switch>("dpdt", true))
dpdt_(lookupOrDefault<Switch>("dpdt", true)),
tempBased_(lookupOrDefault<Switch>("tempBased", false))
{}
......@@ -248,24 +240,60 @@ Foam::basicThermo::basicThermo
p_(lookupOrConstruct(mesh, "p")),
T_
T_(lookupOrConstruct(mesh, phasePropertyName("T"))),
alpha_
(
IOobject
(
phasePropertyName("T"),
phasePropertyName("thermo:alpha"),
mesh.time().timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh
mesh,
dimensionedScalar
(
"zero",
dimensionSet(1, -1, -1, 0, 0),
Zero
)
),
tempBased_(lookupOrDefault<Switch>("tempBased", false))
{}
Foam::basicThermo::basicThermo
(
const fvMesh& mesh,
const word& phaseName,
const word& dictionaryName
)
:
IOdictionary
(
IOobject
(
dictionaryName,
mesh.time().constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
),
phaseName_(phaseName),
p_(lookupOrConstruct(mesh, "p")),
T_(lookupOrConstruct(mesh, "T")),
alpha_
(
IOobject
(
phasePropertyName("thermo:alpha"),
"thermo:alpha",
mesh.time().timeName(),
mesh,
IOobject::READ_IF_PRESENT,
......@@ -278,7 +306,11 @@ Foam::basicThermo::basicThermo
dimensionSet(1, -1, -1, 0, 0),
Zero
)
)
),
dpdt_(lookupOrDefault<Switch>("dpdt", true)),
tempBased_(lookupOrDefault<Switch>("tempBased", true))
{}
......
......@@ -69,7 +69,7 @@ protected:
volScalarField& p_;
//- Temperature [K]
volScalarField T_;
volScalarField& T_;
//- Laminar thermal diffusivity [kg/m/s]
volScalarField alpha_;
......@@ -77,6 +77,9 @@ protected:
//- Should the dpdt term be included in the enthalpy equation
Switch dpdt_;
//- Temperature based thermo
Switch tempBased_;
// Protected Member Functions
......@@ -87,7 +90,7 @@ protected:
volScalarField& lookupOrConstruct
(
const fvMesh& mesh,
const char* name
const word&
) const;
//- Lookup and check out field
......@@ -119,6 +122,17 @@ public:
);
//- Declare run-time constructor selection table for dictionary based
declareRunTimeSelectionTable
(
autoPtr,
basicThermo,
fvMeshDictPhase,
(const fvMesh& mesh, const word& phaseName, const word& dictName),
(mesh, phaseName, dictName)
);
// Constructors
//- Construct from mesh and phase name
......@@ -136,6 +150,15 @@ public:
const word& phaseName
);
//- Construct from mesh,dictionary,phase name with a single temperature
// solved on the top level solver (tempBased = true)
basicThermo
(
const fvMesh&,
const word& phaseName,
const word& dictionaryName
);
// Selectors
......@@ -175,6 +198,15 @@ public:
const word& phaseName=word::null
);
//- Generic New for each of the related thermodynamics packages
template<class Thermo>
static autoPtr<Thermo> New
(
const fvMesh&,
const word& phaseName,
const word& dictName
);
//- Specialisation of the Generic New for basicThermo
static autoPtr<basicThermo> New
(
......@@ -272,6 +304,12 @@ public:
return dpdt_;
}
//- Is the thermo T based
Switch tempBased() const
{
return tempBased_;
}
// Access to thermodynamic state variables
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -247,4 +247,37 @@ Foam::autoPtr<Thermo> Foam::basicThermo::New
}
template<class Thermo>
Foam::autoPtr<Thermo> Foam::basicThermo::New
(
const fvMesh& mesh,
const word& phaseName,
const word& dictName
)
{
IOdictionary thermoDict
(
IOobject
(
dictName,
mesh.time().constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
);
typename Thermo::fvMeshDictPhaseConstructorTable::iterator cstrIter =
lookupThermo<Thermo, typename Thermo::fvMeshDictPhaseConstructorTable>
(
thermoDict,
Thermo::fvMeshDictPhaseConstructorTablePtr_
);
return autoPtr<Thermo>(cstrIter()(mesh, phaseName, dictName));
}
// ************************************************************************* //
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -31,6 +31,7 @@ namespace Foam
{
defineTypeNameAndDebug(fluidThermo, 0);
defineRunTimeSelectionTable(fluidThermo, fvMesh);
defineRunTimeSelectionTable(fluidThermo, fvMeshDictPhase);
}
......@@ -54,6 +55,17 @@ Foam::fluidThermo::fluidThermo
{}
Foam::fluidThermo::fluidThermo
(
const fvMesh& mesh,
const word& phaseName,
const word& dictionaryName
)
:
basicThermo(mesh, phaseName, dictionaryName)
{}
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::fluidThermo> Foam::fluidThermo::New
......@@ -66,6 +78,17 @@ Foam::autoPtr<Foam::fluidThermo> Foam::fluidThermo::New
}
Foam::autoPtr<Foam::fluidThermo> Foam::fluidThermo::New
(
const fvMesh& mesh,
const word& phaseName,
const word& dictName
)
{
return basicThermo::New<fluidThermo>(mesh, phaseName, dictName);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fluidThermo::~fluidThermo()
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -69,6 +69,17 @@ public:
(mesh, phaseName)
);
//- Declare run-time constructor selection table for dictionary based
declareRunTimeSelectionTable
(
autoPtr,
fluidThermo,
fvMeshDictPhase,
(const fvMesh& mesh, const word& phaseName, const word& dictName),
(mesh, phaseName, dictName)
);
// Constructors
//- Construct from mesh and phase name
......@@ -87,6 +98,15 @@ public:
);
//- Construct from mesh,dictionary,phase name with a single temperature
fluidThermo
(
const fvMesh&,
const word& phaseName,
const word& dictionaryName
);
//- Selector
static autoPtr<fluidThermo> New
(
......@@ -95,6 +115,15 @@ public:
);
//- Selector
static autoPtr<fluidThermo> New
(
const fvMesh&,
const word& phaseName,
const word& dictName
);
//- Destructor
virtual ~fluidThermo();
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -83,6 +83,13 @@ Description
CThermoMixtureThermoPhys, \
fvMesh \
); \
\
addToRunTimeSelectionTable \
( \
BaseThermo, \
CThermoMixtureThermoPhys, \
fvMeshDictPhase \
);
#define makeThermoPhysicsThermo(BaseThermo,CThermo,Mixture,ThermoPhys) \
......@@ -96,6 +103,7 @@ Description
\