* src/finiteVolume/fields/fvPatchFields/derived/timeVaryingUniformTotalPressure/:
Added new BC (untested).
This commit is contained in:
parent
a38d55881a
commit
be6fd90b92
@ -99,6 +99,7 @@ $(derivedFvPatchFields)/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueF
|
||||
$(derivedFvPatchFields)/timeVaryingMassFlowRateInletVelocity/timeVaryingMassFlowRateInletVelocityFvPatchVectorField.C
|
||||
$(derivedFvPatchFields)/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchFields.C
|
||||
$(derivedFvPatchFields)/totalPressure/totalPressureFvPatchScalarField.C
|
||||
$(derivedFvPatchFields)/timeVaryingUniformTotalPressure/timeVaryingUniformTotalPressureFvPatchScalarField.C
|
||||
$(derivedFvPatchFields)/totalTemperature/totalTemperatureFvPatchScalarField.C
|
||||
$(derivedFvPatchFields)/turbulentInlet/turbulentInletFvPatchFields.C
|
||||
$(derivedFvPatchFields)/turbulentIntensityKineticEnergyInlet/turbulentIntensityKineticEnergyInletFvPatchScalarField.C
|
||||
|
@ -0,0 +1,301 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "timeVaryingUniformTotalPressureFvPatchScalarField.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "fvPatchFieldMapper.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "IFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::timeVaryingUniformTotalPressureFvPatchScalarField::
|
||||
timeVaryingUniformTotalPressureFvPatchScalarField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(p, iF),
|
||||
UName_("undefined"),
|
||||
phiName_("undefined"),
|
||||
rhoName_("undefined"),
|
||||
psiName_("undefined"),
|
||||
gamma_(0.0),
|
||||
p0_(0.0)
|
||||
|
||||
{}
|
||||
|
||||
|
||||
Foam::timeVaryingUniformTotalPressureFvPatchScalarField::
|
||||
timeVaryingUniformTotalPressureFvPatchScalarField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(p, iF),
|
||||
UName_(dict.lookup("U")),
|
||||
phiName_(dict.lookup("phi")),
|
||||
rhoName_(dict.lookup("rho")),
|
||||
psiName_(dict.lookup("psi")),
|
||||
gamma_(readScalar(dict.lookup("gamma"))),
|
||||
p0_(readScalar(dict.lookup("p0"))),
|
||||
totalPressureDataFileName_(dict.lookup("totalPressureDataFileName")),
|
||||
totalPressureTimeSeries_(word(dict.lookup("timeBounding")))
|
||||
{
|
||||
if (dict.found("value"))
|
||||
{
|
||||
fvPatchField<scalar>::operator=
|
||||
(
|
||||
scalarField("value", dict, p.size())
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
fvPatchField<scalar>::operator=(p0_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::timeVaryingUniformTotalPressureFvPatchScalarField::
|
||||
timeVaryingUniformTotalPressureFvPatchScalarField
|
||||
(
|
||||
const timeVaryingUniformTotalPressureFvPatchScalarField& ptf,
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF,
|
||||
const fvPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
|
||||
UName_(ptf.UName_),
|
||||
phiName_(ptf.phiName_),
|
||||
rhoName_(ptf.rhoName_),
|
||||
psiName_(ptf.psiName_),
|
||||
gamma_(ptf.gamma_),
|
||||
p0_(ptf.p0_),
|
||||
totalPressureDataFileName_(ptf.totalPressureDataFileName_),
|
||||
totalPressureTimeSeries_(ptf.timeBounding())
|
||||
{}
|
||||
|
||||
|
||||
Foam::timeVaryingUniformTotalPressureFvPatchScalarField::
|
||||
timeVaryingUniformTotalPressureFvPatchScalarField
|
||||
(
|
||||
const timeVaryingUniformTotalPressureFvPatchScalarField& tppsf
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(tppsf),
|
||||
UName_(tppsf.UName_),
|
||||
phiName_(tppsf.phiName_),
|
||||
rhoName_(tppsf.rhoName_),
|
||||
psiName_(tppsf.psiName_),
|
||||
gamma_(tppsf.gamma_),
|
||||
p0_(tppsf.p0_),
|
||||
totalPressureDataFileName_(tppsf.totalPressureDataFileName_),
|
||||
totalPressureTimeSeries_(tppsf.timeBounding())
|
||||
{}
|
||||
|
||||
|
||||
Foam::timeVaryingUniformTotalPressureFvPatchScalarField::
|
||||
timeVaryingUniformTotalPressureFvPatchScalarField
|
||||
(
|
||||
const timeVaryingUniformTotalPressureFvPatchScalarField& tppsf,
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(tppsf, iF),
|
||||
UName_(tppsf.UName_),
|
||||
phiName_(tppsf.phiName_),
|
||||
rhoName_(tppsf.rhoName_),
|
||||
psiName_(tppsf.psiName_),
|
||||
gamma_(tppsf.gamma_),
|
||||
p0_(tppsf.p0_),
|
||||
totalPressureDataFileName_(tppsf.totalPressureDataFileName_),
|
||||
totalPressureTimeSeries_(tppsf.timeBounding())
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::timeVaryingUniformTotalPressureFvPatchScalarField::
|
||||
currentValue()
|
||||
{
|
||||
if (totalPressureTimeSeries_.size() == 0)
|
||||
{
|
||||
fileName fName(totalPressureDataFileName_);
|
||||
fName.expand();
|
||||
|
||||
if (fName.size() == 0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"timeVaryingUniformFixedValueFvPatchField::currentValue()"
|
||||
) << "timeDataFile not specified for Patch "
|
||||
<< patch().name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
else
|
||||
{
|
||||
// relative path
|
||||
if (fName[0] != '/')
|
||||
{
|
||||
fName = db().path()/fName;
|
||||
}
|
||||
|
||||
// just in case we change the interface to timeSeries
|
||||
word boundType = timeBounding();
|
||||
|
||||
IFstream(fName)() >> totalPressureTimeSeries_;
|
||||
totalPressureTimeSeries_.bounding(boundType);
|
||||
|
||||
// be a bit paranoid and check that the list is okay
|
||||
totalPressureTimeSeries_.check();
|
||||
}
|
||||
|
||||
if (totalPressureTimeSeries_.size() == 0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"timeVaryingUniformFixedValueFvPatchField"
|
||||
"::currentValue()"
|
||||
) << "empty time series for Patch "
|
||||
<< this->patch().name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
return totalPressureTimeSeries_(this->db().time().timeOutputValue());
|
||||
}
|
||||
|
||||
|
||||
void Foam::timeVaryingUniformTotalPressureFvPatchScalarField::updateCoeffs
|
||||
(
|
||||
const vectorField& Up
|
||||
)
|
||||
{
|
||||
if (updated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
p0_ = currentValue();
|
||||
|
||||
const fvsPatchField<scalar>& phip =
|
||||
patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
|
||||
|
||||
if (psiName_ == "none" && rhoName_ == "none")
|
||||
{
|
||||
operator==(p0_ - 0.5*(1.0 - pos(phip))*magSqr(Up));
|
||||
}
|
||||
else if (rhoName_ == "none")
|
||||
{
|
||||
const fvPatchField<scalar>& psip =
|
||||
patch().lookupPatchField<volScalarField, scalar>(psiName_);
|
||||
|
||||
if (gamma_ > 1.0)
|
||||
{
|
||||
scalar gM1ByG = (gamma_ - 1.0)/gamma_;
|
||||
|
||||
operator==
|
||||
(
|
||||
p0_
|
||||
/pow
|
||||
(
|
||||
(1.0 + 0.5*psip*gM1ByG*(1.0 - pos(phip))*magSqr(Up)),
|
||||
1.0/gM1ByG
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
operator==(p0_/(1.0 + 0.5*psip*(1.0 - pos(phip))*magSqr(Up)));
|
||||
}
|
||||
}
|
||||
else if (psiName_ == "none")
|
||||
{
|
||||
const fvPatchField<scalar>& rho =
|
||||
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
|
||||
|
||||
operator==(p0_ - 0.5*rho*(1.0 - pos(phip))*magSqr(Up));
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"timeVaryingUniformTotalPressureFvPatchScalarField::updateCoeffs()"
|
||||
) << " rho or psi set inconsitently, rho = " << rhoName_
|
||||
<< ", psi = " << psiName_ << '.' << nl
|
||||
<< " Set either rho or psi or neither depending on the "
|
||||
"definition of total pressure." << nl
|
||||
<< " Set the unused variables to 'none'."
|
||||
<< "\n on patch " << this->patch().name()
|
||||
<< " of field " << this->dimensionedInternalField().name()
|
||||
<< " in file " << this->dimensionedInternalField().objectPath()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
fixedValueFvPatchScalarField::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
void Foam::timeVaryingUniformTotalPressureFvPatchScalarField::updateCoeffs()
|
||||
{
|
||||
updateCoeffs(patch().lookupPatchField<volVectorField, vector>(UName_));
|
||||
}
|
||||
|
||||
|
||||
void Foam::timeVaryingUniformTotalPressureFvPatchScalarField::write(Ostream& os) const
|
||||
{
|
||||
fvPatchScalarField::write(os);
|
||||
os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("p0") << p0_ << token::END_STATEMENT << endl;
|
||||
os.writeKeyword("totalPressureDataFileName")
|
||||
<< totalPressureDataFileName_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("timeBounding")
|
||||
<< timeBounding() << token::END_STATEMENT << nl;
|
||||
writeEntry("value", os);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makePatchTypeField
|
||||
(
|
||||
fvPatchScalarField,
|
||||
timeVaryingUniformTotalPressureFvPatchScalarField
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
@ -0,0 +1,228 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::timeVaryingUniformTotalPressureFvPatchScalarField
|
||||
|
||||
Description
|
||||
See timeVaryingUniformFixedValueFvPatchField.H
|
||||
and totalPressureFvPatchScalarField.H
|
||||
|
||||
SourceFiles
|
||||
timeVaryingUniformTotalPressureFvPatchScalarField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef timeVaryingUniformTotalPressureFvPatchScalarField_H
|
||||
#define timeVaryingUniformTotalPressureFvPatchScalarField_H
|
||||
|
||||
#include "fixedValueFvPatchFields.H"
|
||||
#include "timeSeries.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class timeVaryingTotalPressureFvPatch Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class timeVaryingUniformTotalPressureFvPatchScalarField
|
||||
:
|
||||
public fixedValueFvPatchScalarField
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of the velocity field
|
||||
word UName_;
|
||||
|
||||
//- Name of the flux transporting the field
|
||||
word phiName_;
|
||||
|
||||
//- Name of the density field used to normalise the mass flux
|
||||
// if neccessary
|
||||
word rhoName_;
|
||||
|
||||
//- Name of the compressibility field used to calculate the wave speed
|
||||
word psiName_;
|
||||
|
||||
//- Heat capacity ratio
|
||||
scalar gamma_;
|
||||
|
||||
//- Total pressure
|
||||
scalar p0_;
|
||||
|
||||
fileName totalPressureDataFileName_;
|
||||
timeSeries<scalar> totalPressureTimeSeries_;
|
||||
|
||||
//- Interpolate the value at the current time
|
||||
scalar currentValue();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("timeVaryingTotalPressure");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch and internal field
|
||||
timeVaryingUniformTotalPressureFvPatchScalarField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct from patch, internal field and dictionary
|
||||
timeVaryingUniformTotalPressureFvPatchScalarField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
//- Construct by mapping given patch field onto a new patch
|
||||
timeVaryingUniformTotalPressureFvPatchScalarField
|
||||
(
|
||||
const timeVaryingUniformTotalPressureFvPatchScalarField&,
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&,
|
||||
const fvPatchFieldMapper&
|
||||
);
|
||||
|
||||
//- Construct as copy
|
||||
timeVaryingUniformTotalPressureFvPatchScalarField
|
||||
(
|
||||
const timeVaryingUniformTotalPressureFvPatchScalarField&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<fvPatchScalarField> clone() const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
(
|
||||
new timeVaryingUniformTotalPressureFvPatchScalarField(*this)
|
||||
);
|
||||
}
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
timeVaryingUniformTotalPressureFvPatchScalarField
|
||||
(
|
||||
const timeVaryingUniformTotalPressureFvPatchScalarField&,
|
||||
const DimensionedField<scalar, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone setting internal field reference
|
||||
virtual tmp<fvPatchScalarField> clone
|
||||
(
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
) const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
(
|
||||
new timeVaryingUniformTotalPressureFvPatchScalarField(*this, iF)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the name of the velocity field
|
||||
const word& UName() const
|
||||
{
|
||||
return UName_;
|
||||
}
|
||||
|
||||
//- Return reference to the name of the velocity field
|
||||
// to allow adjustment
|
||||
word& UName()
|
||||
{
|
||||
return UName_;
|
||||
}
|
||||
|
||||
//- Return the heat capacity ratio
|
||||
scalar gamma() const
|
||||
{
|
||||
return gamma_;
|
||||
}
|
||||
|
||||
//- Return reference to the heat capacity ratio to allow adjustment
|
||||
scalar& gamma()
|
||||
{
|
||||
return gamma_;
|
||||
}
|
||||
|
||||
//- Return the total pressure
|
||||
scalar p0() const
|
||||
{
|
||||
return p0_;
|
||||
}
|
||||
|
||||
//- Return reference to the total pressure to allow adjustment
|
||||
scalar p0()
|
||||
{
|
||||
return p0_;
|
||||
}
|
||||
|
||||
//- Return the out-of-bounds treatment as a word
|
||||
word timeBounding() const
|
||||
{
|
||||
return totalPressureTimeSeries_.bounding();
|
||||
}
|
||||
|
||||
//- Return the time series used
|
||||
const timeSeries<scalar>& totalPressureTimeSeries() const
|
||||
{
|
||||
return totalPressureTimeSeries_;
|
||||
}
|
||||
|
||||
|
||||
// Evaluation functions
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
// using the given patch velocity field
|
||||
virtual void updateCoeffs(const vectorField& Up);
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
Loading…
Reference in New Issue
Block a user