mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: simplify patchCellsSource name handling, enforce single field name
BUG: inconsistent "U" name on re-read (buoyancyEnergy) STYLE: fix spelling inconsistencies
This commit is contained in:
@ -289,7 +289,7 @@ void Foam::pressurePIDControlInletVelocityFvPatchVectorField::updateCoeffs()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
WarningInFunction
|
WarningInFunction
|
||||||
<< "The pressure field name, \"pName\", is \"" << pName_ << "\", "
|
<< "The pressure field name, 'p' is \"" << pName_ << "\", "
|
||||||
<< "but a field of that name was not found. The inlet velocity "
|
<< "but a field of that name was not found. The inlet velocity "
|
||||||
<< "will be set to an analytical value calculated from the "
|
<< "will be set to an analytical value calculated from the "
|
||||||
<< "specified pressure drop. No PID control will be done and "
|
<< "specified pressure drop. No PID control will be done and "
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2015-2016 OpenFOAM Foundation
|
Copyright (C) 2015-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -90,7 +90,7 @@ bool Foam::fv::buoyancyEnergy::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
if (fv::option::read(dict))
|
if (fv::option::read(dict))
|
||||||
{
|
{
|
||||||
coeffs_.readIfPresent("UName", UName_);
|
coeffs_.readIfPresent("U", UName_);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,9 +26,9 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "patchCellsSource.H"
|
#include "patchCellsSource.H"
|
||||||
|
#include "boundarySourcePatch.H"
|
||||||
#include "fvMatrices.H"
|
#include "fvMatrices.H"
|
||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
#include "boundarySourcePatch.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -54,46 +54,46 @@ Foam::fv::patchCellsSource::patchCellsSource
|
|||||||
:
|
:
|
||||||
fv::option(sourceName, modelType, dict, mesh),
|
fv::option(sourceName, modelType, dict, mesh),
|
||||||
curTimeIndex_(-1),
|
curTimeIndex_(-1),
|
||||||
UName_(coeffs_.getOrDefault<word>("U", "none")),
|
isEnergySource_(false)
|
||||||
hName_(coeffs_.getOrDefault<word>("he", "none")),
|
|
||||||
speciesName_(coeffs_.getOrDefault<word>("species", "none"))
|
|
||||||
{
|
{
|
||||||
label nFields = 0;
|
|
||||||
if (UName_ != "none")
|
|
||||||
{
|
|
||||||
nFields++;
|
|
||||||
}
|
|
||||||
if (hName_ != "none")
|
|
||||||
{
|
|
||||||
nFields++;
|
|
||||||
}
|
|
||||||
if (speciesName_ != "none")
|
|
||||||
{
|
|
||||||
nFields++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nFields > 1)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "patchCellsSource : "
|
|
||||||
<< " cannot be used for more than one field."
|
|
||||||
<< exit(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
fieldNames_.resize(1);
|
fieldNames_.resize(1);
|
||||||
if (speciesName_ != "none")
|
|
||||||
|
label nFields = 0;
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
coeffs_.readIfPresent("U", fieldNames_[0])
|
||||||
|
&& fieldNames_[0] != "none"
|
||||||
|
)
|
||||||
{
|
{
|
||||||
fieldNames_[0] = speciesName_;
|
++nFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UName_ != "none")
|
if
|
||||||
|
(
|
||||||
|
coeffs_.readIfPresent("he", fieldNames_[0])
|
||||||
|
&& fieldNames_[0] != "none"
|
||||||
|
)
|
||||||
{
|
{
|
||||||
fieldNames_[0] = UName_;
|
isEnergySource_ = true;
|
||||||
|
++nFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hName_ != "none")
|
if
|
||||||
|
(
|
||||||
|
coeffs_.readIfPresent("species", fieldNames_[0])
|
||||||
|
&& fieldNames_[0] != "none"
|
||||||
|
)
|
||||||
{
|
{
|
||||||
fieldNames_[0] = hName_;
|
++nFields;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nFields != 1)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(coeffs_)
|
||||||
|
<< "Must be specified for one field (U | he | species), but "
|
||||||
|
<< nFields << " fields were specified!" << endl
|
||||||
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
fv::option::resetApplied();
|
fv::option::resetApplied();
|
||||||
@ -109,75 +109,56 @@ void Foam::fv::patchCellsSource::addSup
|
|||||||
const label fieldi
|
const label fieldi
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
if (curTimeIndex_ == mesh_.time().timeIndex())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
curTimeIndex_ = mesh_.time().timeIndex();
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< type() << ": applying source to " << eqn.psi().name() << endl;
|
Info<< type() << ": applying source to " << eqn.psi().name() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curTimeIndex_ == mesh_.time().timeIndex())
|
auto tsu = DimensionedField<scalar, volMesh>::New
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
volScalarField* psiPtr;
|
|
||||||
|
|
||||||
// If source applied to he, we need to loop over T for BC's
|
|
||||||
if (hName_ != "none")
|
|
||||||
{
|
|
||||||
psiPtr = mesh_.getObjectPtr<volScalarField>("T");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto* psi =
|
|
||||||
mesh_.getObjectPtr<volScalarField>(eqn.psi().name());
|
|
||||||
|
|
||||||
psiPtr = psi;
|
|
||||||
}
|
|
||||||
|
|
||||||
const volScalarField::Boundary& psib = psiPtr->boundaryField();
|
|
||||||
|
|
||||||
volScalarField mDot
|
|
||||||
(
|
(
|
||||||
IOobject
|
name_ + eqn.psi().name() + "Su",
|
||||||
(
|
|
||||||
"mDot",
|
|
||||||
mesh_.time().timeName(),
|
|
||||||
mesh_,
|
|
||||||
IOobject::NO_READ,
|
|
||||||
IOobject::NO_WRITE
|
|
||||||
),
|
|
||||||
mesh_,
|
mesh_,
|
||||||
dimensionedScalar(eqn.dimensions()/dimVolume, Zero)
|
dimensionedScalar(eqn.dimensions()/dimVolume, Zero)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// If source applied to he, we need to loop over T for BC's
|
||||||
|
const volScalarField& psi =
|
||||||
|
(
|
||||||
|
isEnergySource_
|
||||||
|
? mesh_.lookupObject<volScalarField>("T")
|
||||||
|
: mesh_.lookupObject<volScalarField>(eqn.psi().name())
|
||||||
|
);
|
||||||
|
const auto& psib = psi.boundaryField();
|
||||||
|
|
||||||
forAll(psib, patchi)
|
forAll(psib, patchi)
|
||||||
{
|
{
|
||||||
if (isA<boundarySourcePatch>(psib[patchi]))
|
const auto* bpatchPtr = isA<boundarySourcePatch>(psib[patchi]);
|
||||||
|
|
||||||
|
if (bpatchPtr)
|
||||||
{
|
{
|
||||||
const boundarySourcePatch& pp =
|
tmp<scalarField> tsbnd = bpatchPtr->patchSource();
|
||||||
refCast<const boundarySourcePatch>(psib[patchi]);
|
const auto& sbnd = tsbnd.cref();
|
||||||
|
|
||||||
const labelUList& fc = mesh_.boundary()[patchi].faceCells();
|
UIndirectList<scalar>
|
||||||
|
(
|
||||||
tmp<scalarField> tsb = pp.patchSource();
|
tsu.ref().field(),
|
||||||
const scalarField& sb = tsb.cref();
|
mesh_.boundary()[patchi].faceCells()
|
||||||
|
) = sbnd;
|
||||||
forAll(fc, facei)
|
|
||||||
{
|
|
||||||
const label celli = fc[facei];
|
|
||||||
mDot[celli] += sb[facei];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
eqn += mDot;
|
|
||||||
|
|
||||||
curTimeIndex_ = mesh_.time().timeIndex();
|
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< " Field source rate min/max : "
|
Info<< "Field source rate min/max : " << gMinMax(tsu()) << endl;
|
||||||
<< gMin(mDot) << " / " << gMax(mDot) << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eqn += tsu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -42,7 +42,7 @@ Usage
|
|||||||
// Mandatory entries
|
// Mandatory entries
|
||||||
type patchCellsSource;
|
type patchCellsSource;
|
||||||
|
|
||||||
// Optional entries
|
// Optional entries (one only!)
|
||||||
U <word>;
|
U <word>;
|
||||||
he <word>;
|
he <word>;
|
||||||
species <word>;
|
species <word>;
|
||||||
@ -56,13 +56,13 @@ Usage
|
|||||||
\table
|
\table
|
||||||
Property | Description | Type | Reqd | Deflt
|
Property | Description | Type | Reqd | Deflt
|
||||||
type | Type name: patchCellsSource | word | yes | -
|
type | Type name: patchCellsSource | word | yes | -
|
||||||
U | Name of operand velocity field | word | no | none
|
U | Name of operand velocity field | word | choice | -
|
||||||
he | Name of operand energy field | word | no | none
|
he | Name of operand energy field | word | choice | -
|
||||||
species | Name of operand species field | word | no | none
|
species | Name of operand species field | word | choice | -
|
||||||
\endtable
|
\endtable
|
||||||
|
|
||||||
The inherited entries are elaborated in:
|
The inherited entries are elaborated in:
|
||||||
- \link cellSetOption.H \endlink
|
- \link fvOption.H \endlink
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
patchCellsSource.C
|
patchCellsSource.C
|
||||||
@ -96,14 +96,8 @@ class patchCellsSource
|
|||||||
//- Current time index (used for updating)
|
//- Current time index (used for updating)
|
||||||
label curTimeIndex_;
|
label curTimeIndex_;
|
||||||
|
|
||||||
//- Name of operand velocity field
|
//- Special handling energy field
|
||||||
word UName_;
|
bool isEnergySource_;
|
||||||
|
|
||||||
//- Name of operand energy field
|
|
||||||
word hName_;
|
|
||||||
|
|
||||||
//- Name of operand species field
|
|
||||||
word speciesName_;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -136,7 +130,8 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Add explicit contribution to compressible enthalpy equation
|
//- Add explicit contribution to compressible
|
||||||
|
//- (momentum, enthalpy, species) equation
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
|
|||||||
@ -237,14 +237,14 @@ patchSource() const
|
|||||||
|
|
||||||
const basicSpecieMixture& composition = thermo.composition();
|
const basicSpecieMixture& composition = thermo.composition();
|
||||||
|
|
||||||
const label speicesId =
|
const label speciesId =
|
||||||
thermo.composition().species()[speciesName_];
|
thermo.composition().species()[speciesName_];
|
||||||
|
|
||||||
scalarField hsp(this->patch().size(), 0);
|
scalarField hsp(this->patch().size(), 0);
|
||||||
|
|
||||||
forAll(pp, facei)
|
forAll(pp, facei)
|
||||||
{
|
{
|
||||||
hsp[facei] = composition.Hs(speicesId, pp[facei], Tp[facei]);
|
hsp[facei] = composition.Hs(speciesId, pp[facei], Tp[facei]);
|
||||||
}
|
}
|
||||||
|
|
||||||
dhdt += hsp*massb;
|
dhdt += hsp*massb;
|
||||||
|
|||||||
@ -58,8 +58,8 @@ Foam::speciesSorptionFvPatchScalarField::kinematicModelTypeNames
|
|||||||
Foam::tmp<Foam::scalarField>
|
Foam::tmp<Foam::scalarField>
|
||||||
Foam::speciesSorptionFvPatchScalarField::calcMoleFractions() const
|
Foam::speciesSorptionFvPatchScalarField::calcMoleFractions() const
|
||||||
{
|
{
|
||||||
auto tMole = tmp<scalarField>::New(patch().size(), 0);
|
auto tMole = tmp<scalarField>::New(patch().size(), Zero);
|
||||||
scalarField& Mole = tMole.ref();
|
auto& Mole = tMole.ref();
|
||||||
|
|
||||||
if (db().foundObject<rhoReactionThermo>(basicThermo::dictName))
|
if (db().foundObject<rhoReactionThermo>(basicThermo::dictName))
|
||||||
{
|
{
|
||||||
@ -74,16 +74,16 @@ Foam::speciesSorptionFvPatchScalarField::calcMoleFractions() const
|
|||||||
|
|
||||||
const labelUList& faceCells = patch().faceCells();
|
const labelUList& faceCells = patch().faceCells();
|
||||||
|
|
||||||
const label speicesId =
|
const label speciesId =
|
||||||
thermo.composition().species()[this->internalField().name()];
|
thermo.composition().species()[this->internalField().name()];
|
||||||
|
|
||||||
const dimensionedScalar Wi
|
const dimensionedScalar Wi
|
||||||
(
|
(
|
||||||
dimMass/dimMoles,
|
dimMass/dimMoles,
|
||||||
thermo.composition().W(speicesId)
|
thermo.composition().W(speciesId)
|
||||||
);
|
);
|
||||||
|
|
||||||
const volScalarField X(W*Y[speicesId]/Wi);
|
const volScalarField X(W*Y[speciesId]/Wi);
|
||||||
|
|
||||||
forAll(faceCells, i)
|
forAll(faceCells, i)
|
||||||
{
|
{
|
||||||
@ -309,10 +309,10 @@ patchSource() const
|
|||||||
basicThermo::dictName
|
basicThermo::dictName
|
||||||
);
|
);
|
||||||
|
|
||||||
const label speicesId =
|
const label speciesId =
|
||||||
thermo.composition().species()[this->internalField().name()];
|
thermo.composition().species()[this->internalField().name()];
|
||||||
|
|
||||||
const scalar Wi(thermo.composition().W(speicesId));
|
const scalar Wi(thermo.composition().W(speciesId));
|
||||||
|
|
||||||
const scalar t = db().time().timeOutputValue();
|
const scalar t = db().time().timeOutputValue();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user