ENH: Adding eddyDissipationDiffusionModel, thermocouple probe and thermocoupleTestCase

This commit is contained in:
sergio
2016-10-07 10:17:43 -07:00
parent 3c790e2316
commit b9b2ac694a
32 changed files with 1720 additions and 71 deletions

View File

@ -25,4 +25,6 @@ writeDictionary/writeDictionary.C
writeObjects/writeObjects.C
thermoCoupleProbes/thermoCoupleProbes.C
LIB = $(FOAM_LIBBIN)/libutilityFunctionObjects

View File

@ -1,5 +1,12 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/ODE/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude
LIB_LIBS = \
-lfiniteVolume
-lfiniteVolume \
-lfluidThermophysicalModels \
-lcompressibleTransportModels \
-lODE

View File

@ -0,0 +1,219 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\/ 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 "thermoCoupleProbes.H"
#include "mathematicalConstants.H"
#include "constants.H"
#include "addToRunTimeSelectionTable.H"
using namespace Foam::constant;
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(thermoCoupleProbes, 0);
addToRunTimeSelectionTable(functionObject, thermoCoupleProbes, dictionary);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::thermoCoupleProbes::readDict(const dictionary& dict)
{
rho_ = readScalar(dict.lookup("rho"));
Cp_ = readScalar(dict.lookup("Cp"));
d_ = readScalar(dict.lookup("d"));
epsilon_ = readScalar(dict.lookup("epsilon"));
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::thermoCoupleProbes::thermoCoupleProbes
(
const word& name,
const Time& runTime,
const dictionary& dict,
const bool loadFromFiles,
const bool doFindElements
)
:
probes(name, runTime, dict, loadFromFiles, doFindElements),
ODESystem(),
radName_(dict.lookup("radName")),
thermo_
(
mesh_.lookupObject<fluidThermo>(basicThermo::dictName)
),
odeSolver_(ODESolver::New(*this, dict)),
Ttc_(this->size(), 0.0)
{
readDict(dict);
// Check if the property exist (resume old calculation)
// or of it is new.
if (foundProperty(typeName))
{
const dictionary& dict =
this->stateDict().subDict(this->name()).subDict(typeName);
dict.lookup("Tc") >> Ttc_;
}
else
{
Ttc_ = probes::sample(thermo_.T());
}
// Initialize thermocouple at initial T (room temperature)
if (doFindElements)
{
// Find the elements
findElements(mesh_);
// Open the probe streams
prepare();
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::thermoCoupleProbes::~thermoCoupleProbes()
{}
Foam::label Foam::thermoCoupleProbes::nEqns() const
{
return this->size();
}
void Foam::thermoCoupleProbes::derivatives
(
const scalar x,
const scalarField& y,
scalarField& dydx
) const
{
scalarField G(y.size(), 0.0);
scalarField Tc(y.size(), 0.0);
scalarField Uc(y.size(), 0.0);
scalarField rhoc(y.size(), 0.0);
scalarField muc(y.size(), 0.0);
scalarField Cpc(y.size(), 0.0);
scalarField kappac(y.size(), 0.0);
if (radName_ != "none")
{
G = sample(mesh_.lookupObject<volScalarField>(radName_));
}
Tc = probes::sample(thermo_.T());
Uc = mag(this->sample(mesh_.lookupObject<volVectorField>("U")));
rhoc = this->sample(thermo_.rho()());
kappac = this->sample(thermo_.kappa()());
muc = this->sample(thermo_.mu()());
Cpc = this->sample(thermo_.Cp()());
scalarField Re(rhoc*Uc*d_/(muc + ROOTVSMALL));
scalarField Pr(Cpc*muc/(kappac + ROOTVSMALL));
//scalarField Nu(2.0 + 0.6*sqrt(Re)*cbrt(Pr));
scalarField Nu(2.0 + (0.4*sqrt(Re) + 0.06*pow(Re, 2/3))*pow(Pr, 0.4));
scalarField htc(Nu*kappac/d_);
const scalar sigma = physicoChemical::sigma.value();
scalar area = 4*constant::mathematical::pi*sqr(d_/2);
scalar volume = (4/3)*constant::mathematical::pi*pow(d_/2, 3);
dydx =
(epsilon_*(G/4 - sigma*pow(y, 4.0))*area + htc*(Tc - y)*area)
/ (rho_*Cp_*volume);
}
void Foam::thermoCoupleProbes::jacobian
(
const scalar x,
const scalarField& y,
scalarField& dfdt,
scalarSquareMatrix& dfdy
) const
{
derivatives(x, y, dfdt);
for (label i=0; i<nEqns(); i++)
{
for (label j=0; j<nEqns(); j++)
{
dfdy(i, j) = 0.0;
}
}
}
bool Foam::thermoCoupleProbes::write()
{
if (this->size())
{
sampleAndWrite<scalar>(thermo_.T());
dictionary probeDict;
probeDict.add("Tc", Ttc_);
setProperty(typeName, probeDict);
return true;
}
return false;
}
bool Foam::thermoCoupleProbes::execute()
{
if (this->size())
{
scalar dt = mesh_.time().deltaTValue();
scalar t = mesh_.time().value();
odeSolver_->solve(t, t+dt, Ttc_, dt);
return true;
}
return false;
}
bool Foam::thermoCoupleProbes::read(const dictionary& dict)
{
readDict(dict);
probes::read(dict);
return true;
}
// ************************************************************************* //

View File

@ -0,0 +1,217 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD.Ltd
\\/ 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/>.
Class
Foam::functionObjects::thermoCoupleProbes
Description
Sample probe for temperature using a thermocouple. Uses the correlation:
Nu = 2.0 + (0.4*sqrt(Re) + 0.06*pow(Re, 2/3))*pow(Pr, 0.4)
Example of function object specification:
\verbatim
probes
{
type thermoCoupleProbes;
solver rodas23;
absTol 1e-12;
relTol 1e-8;
interpolationScheme cellPoint;
// thermocouple properties
rho 8908;
Cp 440;
d 1e-3;
epsilon 0.85;
radName G;
functionObjectLibs ("libsampling.so");
outputControl timeStep;
outputInterval 1;
probeLocations
(
( 0.5 0.5 0.5 )
);
fields
(
T
);
}
\endverbatim
SourceFiles
thermoCoupleProbes.C
\*---------------------------------------------------------------------------*/
#ifndef thermoCoupleProbes_H
#define thermoCoupleProbes_H
#include "probes.H"
#include "ODESystem.H"
#include "ODESolver.H"
#include "basicThermo.H"
#include "fluidThermo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class thermoCoupleProbes Declaration
\*---------------------------------------------------------------------------*/
class thermoCoupleProbes
:
public probes,
public ODESystem
{
protected:
// Protected data
//- Thermocouple density
scalar rho_;
//- Thermocouple heat capacity
scalar Cp_;
//- Thermocouple diameter
scalar d_;
//- Thermocouple emissivity
scalar epsilon_;
//- Name for the incident radiation field
word radName_;
//- Fluid thermo reference
const fluidThermo& thermo_;
//- ODESolver
autoPtr<ODESolver> odeSolver_;
//- Cached thermocouple temperature
scalarField Ttc_;
// Protected Member Functions
//- Sample and write a particular volume field
template<class Type>
void sampleAndWrite
(
const GeometricField<Type, fvPatchField, volMesh>&
);
//- Read dictionary settings
void readDict(const dictionary& dict);
private:
//- Disallow default bitwise copy construct
thermoCoupleProbes(const thermoCoupleProbes&);
//- Disallow default bitwise assignment
void operator=(const thermoCoupleProbes&);
public:
//- Runtime type information
TypeName("thermoCoupleProbes");
// Constructors
//- Construct for given objectRegistry and dictionary.
// Allow the possibility to load fields from files
thermoCoupleProbes
(
const word& name,
const Time& runTime,
const dictionary& dict,
const bool loadFromFiles = false,
const bool findElements = true
);
//- Destructor
virtual ~thermoCoupleProbes();
// ODE functions (overriding abstract functions in ODE.H)
//- Number of ODE's to solve
virtual label nEqns() const;
virtual void derivatives
(
const scalar t,
const scalarField& c,
scalarField& dcdt
) const;
virtual void jacobian
(
const scalar t,
const scalarField& c,
scalarField& dcdt,
scalarSquareMatrix& dfdc
) const;
//- Public members
//- Sample and write
virtual bool write();
//- Execute, currently does nothing
virtual bool execute();
//- Read
virtual bool read(const dictionary&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "thermoCoupleProbesTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,53 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD.Ltd
\\/ 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 "thermoCoupleProbes.H"
#include "volFields.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::thermoCoupleProbes::sampleAndWrite
(
const GeometricField<Type, fvPatchField, volMesh>& vField
)
{
if (Pstream::master())
{
unsigned int w = IOstream::defaultPrecision() + 7;
OFstream& probeStream = *probeFilePtrs_[vField.name()];
probeStream
<< setw(w)
<< vField.time().timeToUserTime(vField.time().value());
forAll(*this, probeI)
{
probeStream << ' ' << setw(w) << Ttc_[probeI];
}
probeStream << endl;
}
}
// ************************************************************************* //