fvOptions: Remove type restrictions and rewrite of field-name handling
A number of fvOptions that apply to a user-derined field can now
automatically work what primitive type they apply to. These options can
apply to any field type, and in some cases even multiple fields of
differing type. Example usage of the options to which this change
applies are shown below:
codedSource1
{
type codedSource;
name codedSource1;
field h;
...
}
fixedValueConstraint1
{
type fixedValueConstraint;
fieldValues
{
R (1 0 0 1 0 1);
epsilon 150;
}
...
}
phaseLimitStabilization11
{
type phaseLimitStabilization;
field sigma.liquid;
...
}
Previously to apply to a given type, these options had to be selected
with the name of the type prepended to the option name (e.g., "type
symmTensorPhaseLimitStabilization;") and those that operated on multiple
fields were restricted to those fields being of the same type.
A number of other options have had improvements made to their handling
of user specification of fields. Where possible, the option will now
attempt to work out what field the option applies to automatically. The
following options, therefore, no longer require "field" or "fields"
entries:
actuationDiskSource
buoyancyEnergy
buoyancyForce
meanVelocityForce
rotorDiskSource
volumeFractionSource
constantHeatTransfer
function2HeatTransfer
variableHeatTransfer
Non-standard field names can be overridden in the same way as in
boundary conditions; e.g., the velocity name can be overridden with a "U
<UName>;" entry if it does not have the default name, "U". The name of
the energy field is now always determined from the thermodynamics
model and should always be correct. Some options that can be applied to
an individual phase also support a "phase <phaseName>;" entry;
fvOptions field-name handling has been rewritten to increase its
flexibility and to improve warning messages. The flexibility now allows
for options that apply to all fields, or all fields of a given phase,
rather than being limited to a specific list of field names. Messages
warning about options that have not been applied now always print just
once per time-step.
This commit is contained in:
@ -1,6 +1,5 @@
|
|||||||
VoFPatchTransfer/VoFPatchTransfer.C
|
VoFPatchTransfer/VoFPatchTransfer.C
|
||||||
VoFSolidificationMeltingSource/VoFSolidificationMeltingSource.C
|
VoFSolidificationMeltingSource/VoFSolidificationMeltingSource.C
|
||||||
VoFSolidificationMeltingSource/VoFSolidificationMeltingSourceIO.C
|
|
||||||
compressibleInterFilmFoam.C
|
compressibleInterFilmFoam.C
|
||||||
|
|
||||||
EXE = $(FOAM_APPBIN)/compressibleInterFilmFoam
|
EXE = $(FOAM_APPBIN)/compressibleInterFilmFoam
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2017-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2017-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -48,6 +48,16 @@ namespace Foam
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fv::VoFSolidificationMeltingSource::readCoeffs()
|
||||||
|
{
|
||||||
|
alphaSolidT_.reset(Function1<scalar>::New("alphaSolidT", coeffs_).ptr());
|
||||||
|
L_ = dimensionedScalar("L", dimEnergy/dimMass, coeffs_);
|
||||||
|
relax_ = coeffs_.lookupOrDefault<scalar>("relax", 0.9);
|
||||||
|
Cu_ = coeffs_.lookupOrDefault<scalar>("Cu", 100000);
|
||||||
|
q_ = coeffs_.lookupOrDefault<scalar>("q", 0.001);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::VoFSolidificationMeltingSource::update() const
|
void Foam::fv::VoFSolidificationMeltingSource::update() const
|
||||||
{
|
{
|
||||||
if (curTimeIndex_ == mesh_.time().timeIndex())
|
if (curTimeIndex_ == mesh_.time().timeIndex())
|
||||||
@ -122,11 +132,11 @@ Foam::fv::VoFSolidificationMeltingSource::VoFSolidificationMeltingSource
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
cellSetOption(sourceName, modelType, dict, mesh),
|
cellSetOption(sourceName, modelType, dict, mesh),
|
||||||
alphaSolidT_(Function1<scalar>::New("alphaSolidT", coeffs_)),
|
alphaSolidT_(),
|
||||||
L_("L", dimEnergy/dimMass, coeffs_),
|
L_("L", dimEnergy/dimMass, NaN),
|
||||||
relax_(coeffs_.lookupOrDefault("relax", 0.9)),
|
relax_(NaN),
|
||||||
Cu_(coeffs_.lookupOrDefault<scalar>("Cu", 100000)),
|
Cu_(NaN),
|
||||||
q_(coeffs_.lookupOrDefault("q", 0.001)),
|
q_(NaN),
|
||||||
alphaSolid_
|
alphaSolid_
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
@ -143,19 +153,22 @@ Foam::fv::VoFSolidificationMeltingSource::VoFSolidificationMeltingSource
|
|||||||
),
|
),
|
||||||
curTimeIndex_(-1)
|
curTimeIndex_(-1)
|
||||||
{
|
{
|
||||||
fieldNames_.setSize(2);
|
readCoeffs();
|
||||||
fieldNames_[0] = "U";
|
|
||||||
fieldNames_[1] = "T";
|
|
||||||
applied_.setSize(fieldNames_.size(), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::wordList Foam::fv::VoFSolidificationMeltingSource::addedToFields() const
|
||||||
|
{
|
||||||
|
return wordList({"U", "T"});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::VoFSolidificationMeltingSource::addSup
|
void Foam::fv::VoFSolidificationMeltingSource::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
apply(geometricOneField(), eqn);
|
apply(geometricOneField(), eqn);
|
||||||
@ -166,7 +179,7 @@ void Foam::fv::VoFSolidificationMeltingSource::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
apply(rho, eqn);
|
apply(rho, eqn);
|
||||||
@ -176,7 +189,7 @@ void Foam::fv::VoFSolidificationMeltingSource::addSup
|
|||||||
void Foam::fv::VoFSolidificationMeltingSource::addSup
|
void Foam::fv::VoFSolidificationMeltingSource::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
@ -208,11 +221,27 @@ void Foam::fv::VoFSolidificationMeltingSource::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// Momentum source uses a Boussinesq approximation - redirect
|
// Momentum source uses a Boussinesq approximation - redirect
|
||||||
addSup(eqn, fieldi);
|
addSup(eqn, fieldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::fv::VoFSolidificationMeltingSource::read(const dictionary& dict)
|
||||||
|
{
|
||||||
|
if (cellSetOption::read(dict))
|
||||||
|
{
|
||||||
|
readCoeffs();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2017-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2017-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -124,6 +124,9 @@ class VoFSolidificationMeltingSource
|
|||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
//- Return the name of the solid phase fraction
|
//- Return the name of the solid phase fraction
|
||||||
word alphaSolidName() const;
|
word alphaSolidName() const;
|
||||||
|
|
||||||
@ -161,20 +164,27 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
// Checks
|
||||||
|
|
||||||
|
//- Return the list of fields for which the option adds source term
|
||||||
|
// to the transport equation
|
||||||
|
virtual wordList addedToFields() const;
|
||||||
|
|
||||||
|
|
||||||
// Add explicit and implicit contributions
|
// Add explicit and implicit contributions
|
||||||
|
|
||||||
//- Add explicit contribution to enthalpy equation
|
//- Add explicit contribution to enthalpy equation
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Add implicit contribution to momentum equation
|
//- Add implicit contribution to momentum equation
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
@ -185,7 +195,7 @@ public:
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Add implicit contribution to compressible momentum equation
|
//- Add implicit contribution to compressible momentum equation
|
||||||
@ -193,7 +203,7 @@ public:
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,51 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration | Website: https://openfoam.org
|
|
||||||
\\ / A nd | Copyright (C) 2017-2018 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 "VoFSolidificationMeltingSource.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
|
||||||
|
|
||||||
bool Foam::fv::VoFSolidificationMeltingSource::read(const dictionary& dict)
|
|
||||||
{
|
|
||||||
if (cellSetOption::read(dict))
|
|
||||||
{
|
|
||||||
alphaSolidT_ = Function1<scalar>::New("alphaSolidT", coeffs_);
|
|
||||||
coeffs_.lookup("L") >> L_;
|
|
||||||
coeffs_.readIfPresent("relax", relax_);
|
|
||||||
coeffs_.readIfPresent("Cu", Cu_);
|
|
||||||
coeffs_.readIfPresent("q", q_);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -61,7 +61,7 @@ PtrList<fvScalarMatrix> pEqnComps(phases.size());
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Option sources
|
// Option sources
|
||||||
if (fvOptions.appliesToField(rho.name()))
|
if (fvOptions.addsToField(rho.name()))
|
||||||
{
|
{
|
||||||
pEqnComp -= (fvOptions(alpha, rho) & rho)/rho;
|
pEqnComp -= (fvOptions(alpha, rho) & rho)/rho;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -764,7 +764,7 @@ void Foam::phaseSystem::correctContinuityError()
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (fvOptions().appliesToField(rho.name()))
|
if (fvOptions().addsToField(rho.name()))
|
||||||
{
|
{
|
||||||
source += fvOptions()(alpha, rho)ρ
|
source += fvOptions()(alpha, rho)ρ
|
||||||
}
|
}
|
||||||
|
|||||||
@ -124,26 +124,10 @@ ${typeName}FvOption${SourceType}::
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void ${typeName}FvOption${SourceType}::correct
|
|
||||||
(
|
|
||||||
GeometricField<${TemplateType}, fvPatchField, volMesh>& fld
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
if (${verbose:-false})
|
|
||||||
{
|
|
||||||
Info<<"${typeName}FvOption${SourceType}::correct()\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
//{{{ begin code
|
|
||||||
${codeCorrect}
|
|
||||||
//}}} end code
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ${typeName}FvOption${SourceType}::addSup
|
void ${typeName}FvOption${SourceType}::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<${TemplateType}>& eqn,
|
fvMatrix<${TemplateType}>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (${verbose:-false})
|
if (${verbose:-false})
|
||||||
@ -161,7 +145,7 @@ void ${typeName}FvOption${SourceType}::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<${TemplateType}>& eqn,
|
fvMatrix<${TemplateType}>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (${verbose:-false})
|
if (${verbose:-false})
|
||||||
@ -180,7 +164,7 @@ void ${typeName}FvOption${SourceType}::addSup
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<${TemplateType}>& eqn,
|
fvMatrix<${TemplateType}>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (${verbose:-false})
|
if (${verbose:-false})
|
||||||
@ -194,26 +178,9 @@ void ${typeName}FvOption${SourceType}::addSup
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ${typeName}FvOption${SourceType}::constrain
|
|
||||||
(
|
|
||||||
fvMatrix<${TemplateType}>& eqn,
|
|
||||||
const label fieldi
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
if (${verbose:-false})
|
|
||||||
{
|
|
||||||
Info<<"${typeName}FvOption${SourceType}::constrain()\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
//{{{ begin code
|
|
||||||
${codeSetValue}
|
|
||||||
//}}} end code
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|
||||||
} // End namespace fv
|
} // End namespace fv
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -70,23 +70,20 @@ public:
|
|||||||
const fvMesh& mesh
|
const fvMesh& mesh
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~${typeName}FvOption${SourceType}();
|
virtual ~${typeName}FvOption${SourceType}();
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Correct field
|
// Evaluation
|
||||||
virtual void correct
|
|
||||||
(
|
|
||||||
GeometricField<${TemplateType}, fvPatchField, volMesh>&
|
|
||||||
) const;
|
|
||||||
|
|
||||||
//- Explicit and implicit matrix contributions
|
//- Explicit and implicit matrix contributions
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<${TemplateType}>& eqn,
|
fvMatrix<${TemplateType}>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Explicit and implicit matrix contributions for compressible
|
//- Explicit and implicit matrix contributions for compressible
|
||||||
@ -95,7 +92,7 @@ public:
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<${TemplateType}>& eqn,
|
fvMatrix<${TemplateType}>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Explicit and implicit matrix contributions for phase equations
|
//- Explicit and implicit matrix contributions for phase equations
|
||||||
@ -104,14 +101,7 @@ public:
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<${TemplateType}>& eqn,
|
fvMatrix<${TemplateType}>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
|
||||||
|
|
||||||
//- Set value
|
|
||||||
virtual void constrain
|
|
||||||
(
|
|
||||||
fvMatrix<${TemplateType}>& eqn,
|
|
||||||
const label fieldi
|
|
||||||
) const;
|
) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -86,7 +86,8 @@ public:
|
|||||||
const word& name,
|
const word& name,
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
const word& objectName,
|
const word& objectName,
|
||||||
const objectRegistry& db
|
const objectRegistry& db,
|
||||||
|
const bool error = true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -50,7 +50,8 @@ Foam::autoPtr<Foam::objectFunction1> Foam::objectFunction1::New
|
|||||||
const word& name,
|
const word& name,
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
const word& objectName,
|
const word& objectName,
|
||||||
const objectRegistry& db
|
const objectRegistry& db,
|
||||||
|
const bool error
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
autoPtr<objectFunction1> ptr
|
autoPtr<objectFunction1> ptr
|
||||||
@ -68,7 +69,7 @@ Foam::autoPtr<Foam::objectFunction1> Foam::objectFunction1::New
|
|||||||
: nullptr
|
: nullptr
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!ptr.valid())
|
if (error && !ptr.valid())
|
||||||
{
|
{
|
||||||
// Spit lookup error
|
// Spit lookup error
|
||||||
db.lookupObject<regIOobject>(objectName);
|
db.lookupObject<regIOobject>(objectName);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -52,9 +52,7 @@ Foam::fv::option::option
|
|||||||
modelType_(modelType),
|
modelType_(modelType),
|
||||||
mesh_(mesh),
|
mesh_(mesh),
|
||||||
dict_(dict),
|
dict_(dict),
|
||||||
coeffs_(dict.optionalSubDict(modelType + "Coeffs")),
|
coeffs_(dict.optionalSubDict(modelType + "Coeffs"))
|
||||||
fieldNames_(),
|
|
||||||
applied_()
|
|
||||||
{
|
{
|
||||||
Info<< incrIndent << indent << "Source: " << name_ << endl << decrIndent;
|
Info<< incrIndent << indent << "Source: " << name_ << endl << decrIndent;
|
||||||
}
|
}
|
||||||
@ -103,30 +101,46 @@ Foam::fv::option::~option()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::label Foam::fv::option::applyToField(const word& fieldName) const
|
Foam::wordList Foam::fv::option::addedToFields() const
|
||||||
{
|
{
|
||||||
return findIndex(fieldNames_, fieldName);
|
return wordList::null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::option::checkApplied() const
|
Foam::wordList Foam::fv::option::constrainedFields() const
|
||||||
{
|
{
|
||||||
forAll(applied_, i)
|
return wordList::null();
|
||||||
{
|
}
|
||||||
if (!applied_[i])
|
|
||||||
{
|
|
||||||
WarningInFunction
|
Foam::wordList Foam::fv::option::correctedFields() const
|
||||||
<< "Source " << name_ << " defined for field "
|
{
|
||||||
<< fieldNames_[i] << " but never used" << endl;
|
return wordList::null();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
bool Foam::fv::option::addsToField(const word& fieldName) const
|
||||||
|
{
|
||||||
|
return findIndex(addedToFields(), fieldName) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::fv::option::constrainsField(const word& fieldName) const
|
||||||
|
{
|
||||||
|
return findIndex(constrainedFields(), fieldName) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::fv::option::correctsField(const word& fieldName) const
|
||||||
|
{
|
||||||
|
return findIndex(correctedFields(), fieldName) != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::option::addSup
|
void Foam::fv::option::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -134,7 +148,7 @@ void Foam::fv::option::addSup
|
|||||||
void Foam::fv::option::addSup
|
void Foam::fv::option::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -142,7 +156,7 @@ void Foam::fv::option::addSup
|
|||||||
void Foam::fv::option::addSup
|
void Foam::fv::option::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<sphericalTensor>& eqn,
|
fvMatrix<sphericalTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -150,7 +164,7 @@ void Foam::fv::option::addSup
|
|||||||
void Foam::fv::option::addSup
|
void Foam::fv::option::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<symmTensor>& eqn,
|
fvMatrix<symmTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -158,7 +172,7 @@ void Foam::fv::option::addSup
|
|||||||
void Foam::fv::option::addSup
|
void Foam::fv::option::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<tensor>& eqn,
|
fvMatrix<tensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -167,7 +181,7 @@ void Foam::fv::option::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -176,7 +190,7 @@ void Foam::fv::option::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -185,7 +199,7 @@ void Foam::fv::option::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<sphericalTensor>& eqn,
|
fvMatrix<sphericalTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -194,7 +208,7 @@ void Foam::fv::option::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<symmTensor>& eqn,
|
fvMatrix<symmTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -203,7 +217,7 @@ void Foam::fv::option::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<tensor>& eqn,
|
fvMatrix<tensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -213,10 +227,10 @@ void Foam::fv::option::addSup
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addSup(alpha*rho, eqn, fieldi);
|
addSup(alpha*rho, eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -225,10 +239,10 @@ void Foam::fv::option::addSup
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addSup(alpha*rho, eqn, fieldi);
|
addSup(alpha*rho, eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -237,10 +251,10 @@ void Foam::fv::option::addSup
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<sphericalTensor>& eqn,
|
fvMatrix<sphericalTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addSup(alpha*rho, eqn, fieldi);
|
addSup(alpha*rho, eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -249,10 +263,10 @@ void Foam::fv::option::addSup
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<symmTensor>& eqn,
|
fvMatrix<symmTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addSup(alpha*rho, eqn, fieldi);
|
addSup(alpha*rho, eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -261,17 +275,17 @@ void Foam::fv::option::addSup
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<tensor>& eqn,
|
fvMatrix<tensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addSup(alpha*rho, eqn, fieldi);
|
addSup(alpha*rho, eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::option::constrain
|
void Foam::fv::option::constrain
|
||||||
(
|
(
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -279,7 +293,7 @@ void Foam::fv::option::constrain
|
|||||||
void Foam::fv::option::constrain
|
void Foam::fv::option::constrain
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -287,7 +301,7 @@ void Foam::fv::option::constrain
|
|||||||
void Foam::fv::option::constrain
|
void Foam::fv::option::constrain
|
||||||
(
|
(
|
||||||
fvMatrix<sphericalTensor>& eqn,
|
fvMatrix<sphericalTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -295,14 +309,15 @@ void Foam::fv::option::constrain
|
|||||||
void Foam::fv::option::constrain
|
void Foam::fv::option::constrain
|
||||||
(
|
(
|
||||||
fvMatrix<symmTensor>& eqn,
|
fvMatrix<symmTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::option::constrain
|
void Foam::fv::option::constrain
|
||||||
(
|
(
|
||||||
fvMatrix<tensor>& eqn, const label fieldi
|
fvMatrix<tensor>& eqn,
|
||||||
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|||||||
@ -85,12 +85,6 @@ protected:
|
|||||||
//- Dictionary containing source coefficients
|
//- Dictionary containing source coefficients
|
||||||
dictionary coeffs_;
|
dictionary coeffs_;
|
||||||
|
|
||||||
//- Field names to apply source to - populated by derived models
|
|
||||||
wordList fieldNames_;
|
|
||||||
|
|
||||||
//- Applied flag list - corresponds to each fieldNames_ entry
|
|
||||||
mutable List<bool> applied_;
|
|
||||||
|
|
||||||
|
|
||||||
// Protected Member Functions
|
// Protected Member Functions
|
||||||
|
|
||||||
@ -235,17 +229,28 @@ public:
|
|||||||
//- Return dictionary
|
//- Return dictionary
|
||||||
inline const dictionary& coeffs() const;
|
inline const dictionary& coeffs() const;
|
||||||
|
|
||||||
//- Set the applied flag to true for field index fieldi
|
|
||||||
inline void setApplied(const label fieldi) const;
|
|
||||||
|
|
||||||
|
|
||||||
// Checks
|
// Checks
|
||||||
|
|
||||||
//- Return index of field name if found in fieldNames list
|
//- Return the list of fields for which the option adds source term
|
||||||
virtual label applyToField(const word& fieldName) const;
|
// to the transport equation
|
||||||
|
virtual wordList addedToFields() const;
|
||||||
|
|
||||||
//- Check that the source has been applied
|
//- Return the list of fields constrained by the option
|
||||||
virtual void checkApplied() const;
|
virtual wordList constrainedFields() const;
|
||||||
|
|
||||||
|
//- Return the list of fields corrected by the option
|
||||||
|
virtual wordList correctedFields() const;
|
||||||
|
|
||||||
|
//- Return true if the option adds a source term to the given
|
||||||
|
// field's transport equation
|
||||||
|
virtual bool addsToField(const word& fieldName) const;
|
||||||
|
|
||||||
|
//- Return true if the option constrains the given field
|
||||||
|
virtual bool constrainsField(const word& fieldName) const;
|
||||||
|
|
||||||
|
//- Return true if the option corrects the given field
|
||||||
|
virtual bool correctsField(const word& fieldName) const;
|
||||||
|
|
||||||
|
|
||||||
// Evaluation
|
// Evaluation
|
||||||
@ -255,31 +260,31 @@ public:
|
|||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<symmTensor>& eqn,
|
fvMatrix<symmTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<sphericalTensor>& eqn,
|
fvMatrix<sphericalTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<tensor>& eqn,
|
fvMatrix<tensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
@ -289,35 +294,35 @@ public:
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<symmTensor>& eqn,
|
fvMatrix<symmTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<sphericalTensor>& eqn,
|
fvMatrix<sphericalTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<tensor>& eqn,
|
fvMatrix<tensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
@ -328,7 +333,7 @@ public:
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
@ -336,7 +341,7 @@ public:
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
@ -344,7 +349,7 @@ public:
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<symmTensor>& eqn,
|
fvMatrix<symmTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
@ -352,7 +357,7 @@ public:
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<sphericalTensor>& eqn,
|
fvMatrix<sphericalTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
@ -360,7 +365,7 @@ public:
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<tensor>& eqn,
|
fvMatrix<tensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
@ -417,31 +422,31 @@ public:
|
|||||||
virtual void constrain
|
virtual void constrain
|
||||||
(
|
(
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void constrain
|
virtual void constrain
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void constrain
|
virtual void constrain
|
||||||
(
|
(
|
||||||
fvMatrix<sphericalTensor>& eqn,
|
fvMatrix<sphericalTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void constrain
|
virtual void constrain
|
||||||
(
|
(
|
||||||
fvMatrix<symmTensor>& eqn,
|
fvMatrix<symmTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void constrain
|
virtual void constrain
|
||||||
(
|
(
|
||||||
fvMatrix<tensor>& eqn,
|
fvMatrix<tensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -43,10 +43,4 @@ inline const Foam::dictionary& Foam::fv::option::coeffs() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void Foam::fv::option::setApplied(const label fieldi) const
|
|
||||||
{
|
|
||||||
applied_[fieldi] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -59,7 +59,7 @@ bool Foam::fv::optionList::readOptions(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
const dictionary& optionsDict(this->optionsDict(dict));
|
const dictionary& optionsDict(this->optionsDict(dict));
|
||||||
|
|
||||||
checkTimeIndex_ = mesh_.time().timeIndex() + 2;
|
checkTimeIndex_ = mesh_.time().timeIndex() + 1;
|
||||||
|
|
||||||
bool allOk = true;
|
bool allOk = true;
|
||||||
forAll(*this, i)
|
forAll(*this, i)
|
||||||
@ -74,13 +74,44 @@ bool Foam::fv::optionList::readOptions(const dictionary& dict)
|
|||||||
|
|
||||||
void Foam::fv::optionList::checkApplied() const
|
void Foam::fv::optionList::checkApplied() const
|
||||||
{
|
{
|
||||||
if (mesh_.time().timeIndex() == checkTimeIndex_)
|
if (mesh_.time().timeIndex() > checkTimeIndex_)
|
||||||
{
|
{
|
||||||
forAll(*this, i)
|
forAll(*this, i)
|
||||||
{
|
{
|
||||||
const option& bs = this->operator[](i);
|
const option& source = this->operator[](i);
|
||||||
bs.checkApplied();
|
|
||||||
|
wordHashSet notAddedToFields(source.addedToFields());
|
||||||
|
notAddedToFields -= addedToFields_[i];
|
||||||
|
|
||||||
|
forAllConstIter(wordHashSet, notAddedToFields, iter)
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "Source " << source.name() << " defined for field "
|
||||||
|
<< iter.key() << " but never used" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
wordHashSet notConstrainedFields(source.constrainedFields());
|
||||||
|
notConstrainedFields -= constrainedFields_[i];
|
||||||
|
|
||||||
|
forAllConstIter(wordHashSet, notConstrainedFields, iter)
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "Constraint " << source.name() << " defined for field "
|
||||||
|
<< iter.key() << " but never used" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
wordHashSet notCorrectedFields(source.correctedFields());
|
||||||
|
notCorrectedFields -= correctedFields_[i];
|
||||||
|
|
||||||
|
forAllConstIter(wordHashSet, notCorrectedFields, iter)
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "Correction " << source.name() << " defined for field "
|
||||||
|
<< iter.key() << " but never used" << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkTimeIndex_ = mesh_.time().timeIndex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +122,10 @@ Foam::fv::optionList::optionList(const fvMesh& mesh, const dictionary& dict)
|
|||||||
:
|
:
|
||||||
PtrListDictionary<option>(0),
|
PtrListDictionary<option>(0),
|
||||||
mesh_(mesh),
|
mesh_(mesh),
|
||||||
checkTimeIndex_(mesh_.time().startTimeIndex() + 2)
|
checkTimeIndex_(mesh_.time().timeIndex() + 1),
|
||||||
|
addedToFields_(),
|
||||||
|
constrainedFields_(),
|
||||||
|
correctedFields_()
|
||||||
{
|
{
|
||||||
reset(dict);
|
reset(dict);
|
||||||
}
|
}
|
||||||
@ -101,7 +135,10 @@ Foam::fv::optionList::optionList(const fvMesh& mesh)
|
|||||||
:
|
:
|
||||||
PtrListDictionary<option>(0),
|
PtrListDictionary<option>(0),
|
||||||
mesh_(mesh),
|
mesh_(mesh),
|
||||||
checkTimeIndex_(mesh_.time().startTimeIndex() + 2)
|
checkTimeIndex_(mesh_.time().timeIndex() + 1),
|
||||||
|
addedToFields_(),
|
||||||
|
constrainedFields_(),
|
||||||
|
correctedFields_()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -122,6 +159,11 @@ void Foam::fv::optionList::reset(const dictionary& dict)
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->setSize(count);
|
this->setSize(count);
|
||||||
|
|
||||||
|
addedToFields_.setSize(count);
|
||||||
|
constrainedFields_.setSize(count);
|
||||||
|
correctedFields_.setSize(count);
|
||||||
|
|
||||||
label i = 0;
|
label i = 0;
|
||||||
forAllConstIter(dictionary, optionsDict, iter)
|
forAllConstIter(dictionary, optionsDict, iter)
|
||||||
{
|
{
|
||||||
@ -132,24 +174,54 @@ void Foam::fv::optionList::reset(const dictionary& dict)
|
|||||||
|
|
||||||
this->set
|
this->set
|
||||||
(
|
(
|
||||||
i++,
|
i,
|
||||||
name,
|
name,
|
||||||
option::New(name, sourceDict, mesh_).ptr()
|
option::New(name, sourceDict, mesh_).ptr()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
addedToFields_.set(i, new wordHashSet());
|
||||||
|
constrainedFields_.set(i, new wordHashSet());
|
||||||
|
correctedFields_.set(i, new wordHashSet());
|
||||||
|
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::fv::optionList::appliesToField(const word& fieldName) const
|
bool Foam::fv::optionList::addsToField(const word& fieldName) const
|
||||||
{
|
{
|
||||||
forAll(*this, i)
|
forAll(*this, i)
|
||||||
{
|
{
|
||||||
const option& source = this->operator[](i);
|
if (this->operator[](i).addsToField(fieldName))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
label fieldi = source.applyToField(fieldName);
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (fieldi != -1)
|
|
||||||
|
bool Foam::fv::optionList::constrainsField(const word& fieldName) const
|
||||||
|
{
|
||||||
|
forAll(*this, i)
|
||||||
|
{
|
||||||
|
if (this->operator[](i).constrainsField(fieldName))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::fv::optionList::correctsField(const word& fieldName) const
|
||||||
|
{
|
||||||
|
forAll(*this, i)
|
||||||
|
{
|
||||||
|
if (this->operator[](i).correctsField(fieldName))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,7 +74,16 @@ protected:
|
|||||||
const fvMesh& mesh_;
|
const fvMesh& mesh_;
|
||||||
|
|
||||||
//- Time index to check that all defined sources have been applied
|
//- Time index to check that all defined sources have been applied
|
||||||
label checkTimeIndex_;
|
mutable label checkTimeIndex_;
|
||||||
|
|
||||||
|
//- Sets of the fields that have had sources added by the options
|
||||||
|
mutable PtrList<wordHashSet> addedToFields_;
|
||||||
|
|
||||||
|
//- Sets of the fields that have been constrained by the options
|
||||||
|
mutable PtrList<wordHashSet> constrainedFields_;
|
||||||
|
|
||||||
|
//- Sets of the fields that have been corrected by the options
|
||||||
|
mutable PtrList<wordHashSet> correctedFields_;
|
||||||
|
|
||||||
|
|
||||||
// Protected Member Functions
|
// Protected Member Functions
|
||||||
@ -82,7 +91,7 @@ protected:
|
|||||||
//- Read options dictionary
|
//- Read options dictionary
|
||||||
bool readOptions(const dictionary& dict);
|
bool readOptions(const dictionary& dict);
|
||||||
|
|
||||||
//- Check that all sources have been applied
|
//- Check that all options have been applied
|
||||||
void checkApplied() const;
|
void checkApplied() const;
|
||||||
|
|
||||||
//- Return source for equation with specified name and dimensions
|
//- Return source for equation with specified name and dimensions
|
||||||
@ -132,8 +141,18 @@ public:
|
|||||||
//- Reset the source list
|
//- Reset the source list
|
||||||
void reset(const dictionary& dict);
|
void reset(const dictionary& dict);
|
||||||
|
|
||||||
//- Return whether there is something to apply to the field
|
|
||||||
bool appliesToField(const word& fieldName) const;
|
// Checks
|
||||||
|
|
||||||
|
//- Return true if an option adds a source term to the given
|
||||||
|
// field's transport equation
|
||||||
|
virtual bool addsToField(const word& fieldName) const;
|
||||||
|
|
||||||
|
//- Return true if an option constrains the given field
|
||||||
|
virtual bool constrainsField(const word& fieldName) const;
|
||||||
|
|
||||||
|
//- Return true if an option corrects the given field
|
||||||
|
virtual bool correctsField(const word& fieldName) const;
|
||||||
|
|
||||||
|
|
||||||
// Sources
|
// Sources
|
||||||
|
|||||||
@ -50,11 +50,9 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::source
|
|||||||
{
|
{
|
||||||
const option& source = this->operator[](i);
|
const option& source = this->operator[](i);
|
||||||
|
|
||||||
const label fieldi = source.applyToField(fieldName);
|
if (source.addsToField(fieldName))
|
||||||
|
|
||||||
if (fieldi != -1)
|
|
||||||
{
|
{
|
||||||
source.setApplied(fieldi);
|
addedToFields_[i].insert(fieldName);
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
@ -62,7 +60,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::source
|
|||||||
<< fieldName << endl;
|
<< fieldName << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
source.addSup(alphaRhos ..., mtx, fieldi);
|
source.addSup(alphaRhos ..., mtx, fieldName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,21 +220,19 @@ void Foam::fv::optionList::constrain(fvMatrix<Type>& eqn) const
|
|||||||
|
|
||||||
forAll(*this, i)
|
forAll(*this, i)
|
||||||
{
|
{
|
||||||
const option& source = this->operator[](i);
|
const option& constraint = this->operator[](i);
|
||||||
|
|
||||||
label fieldi = source.applyToField(eqn.psi().name());
|
if (constraint.constrainsField(eqn.psi().name()))
|
||||||
|
|
||||||
if (fieldi != -1)
|
|
||||||
{
|
{
|
||||||
source.setApplied(fieldi);
|
constrainedFields_[i].insert(eqn.psi().name());
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "Applying constraint " << source.name()
|
Info<< "Applying constraint " << constraint.name()
|
||||||
<< " to field " << eqn.psi().name() << endl;
|
<< " to field " << eqn.psi().name() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
source.constrain(eqn, fieldi);
|
constraint.constrain(eqn, eqn.psi().name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -252,21 +248,19 @@ void Foam::fv::optionList::correct
|
|||||||
|
|
||||||
forAll(*this, i)
|
forAll(*this, i)
|
||||||
{
|
{
|
||||||
const option& source = this->operator[](i);
|
const option& correction = this->operator[](i);
|
||||||
|
|
||||||
label fieldi = source.applyToField(fieldName);
|
if (correction.correctsField(fieldName))
|
||||||
|
|
||||||
if (fieldi != -1)
|
|
||||||
{
|
{
|
||||||
source.setApplied(fieldi);
|
correctedFields_[i].insert(fieldName);
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "Correcting source " << source.name()
|
Info<< "Applying correction " << correction.name()
|
||||||
<< " for field " << fieldName << endl;
|
<< " for field " << fieldName << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
source.correct(field);
|
correction.correct(field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,11 +70,9 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::option::source
|
|||||||
);
|
);
|
||||||
fvMatrix<Type>& mtx = tmtx.ref();
|
fvMatrix<Type>& mtx = tmtx.ref();
|
||||||
|
|
||||||
const label fieldi = applyToField(fieldName);
|
if (addsToField(fieldName))
|
||||||
|
|
||||||
if (fieldi != -1)
|
|
||||||
{
|
{
|
||||||
addSup(alphaRhos ..., mtx, fieldi);
|
addSup(alphaRhos ..., mtx, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return tmtx;
|
return tmtx;
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -75,6 +75,7 @@ public:
|
|||||||
//- Disallow default bitwise copy construction
|
//- Disallow default bitwise copy construction
|
||||||
options(const options&) = delete;
|
options(const options&) = delete;
|
||||||
|
|
||||||
|
//- Inherit the base New method
|
||||||
using MeshObject<fvMesh, UpdateableMeshObject, options>::New;
|
using MeshObject<fvMesh, UpdateableMeshObject, options>::New;
|
||||||
|
|
||||||
|
|
||||||
@ -101,6 +102,7 @@ public:
|
|||||||
//- ReadData function required for regIOobject read operation
|
//- ReadData function required for regIOobject read operation
|
||||||
virtual bool readData(Istream&);
|
virtual bool readData(Istream&);
|
||||||
|
|
||||||
|
//- Inherit the base read method
|
||||||
using optionList::read;
|
using optionList::read;
|
||||||
|
|
||||||
//- Read dictionary
|
//- Read dictionary
|
||||||
|
|||||||
@ -1,52 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration | Website: https://openfoam.org
|
|
||||||
\\ / A nd | Copyright (C) 2011-2018 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/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef makeFvOption_H
|
|
||||||
#define makeFvOption_H
|
|
||||||
|
|
||||||
#include "fvOption.H"
|
|
||||||
#include "addToRunTimeSelectionTable.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#define makeFvOption(Option, Type) \
|
|
||||||
\
|
|
||||||
defineTemplateTypeNameAndDebugWithName \
|
|
||||||
( \
|
|
||||||
Foam::fv::Option<Foam::Type>, \
|
|
||||||
#Type#Option, \
|
|
||||||
0 \
|
|
||||||
); \
|
|
||||||
\
|
|
||||||
Foam::fv::option::adddictionaryConstructorToTable \
|
|
||||||
<Foam::fv::Option<Foam::Type>> \
|
|
||||||
add##Option##Type##dictionary##ConstructorTooptionTable_
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,8 +1,6 @@
|
|||||||
cellSetOption/cellSetOption.C
|
cellSetOption/cellSetOption.C
|
||||||
cellSetOption/cellSetOptionIO.C
|
|
||||||
|
|
||||||
interRegionOption/interRegionOption.C
|
interRegionOption/interRegionOption.C
|
||||||
interRegionOption/interRegionOptionIO.C
|
|
||||||
|
|
||||||
|
|
||||||
# Sources
|
# Sources
|
||||||
@ -16,7 +14,6 @@ $(derivedSources)/actuationDiskSource/actuationDiskSource.C
|
|||||||
$(derivedSources)/effectivenessHeatExchangerSource/effectivenessHeatExchangerSource.C
|
$(derivedSources)/effectivenessHeatExchangerSource/effectivenessHeatExchangerSource.C
|
||||||
$(derivedSources)/explicitPorositySource/explicitPorositySource.C
|
$(derivedSources)/explicitPorositySource/explicitPorositySource.C
|
||||||
$(derivedSources)/meanVelocityForce/meanVelocityForce.C
|
$(derivedSources)/meanVelocityForce/meanVelocityForce.C
|
||||||
$(derivedSources)/meanVelocityForce/meanVelocityForceIO.C
|
|
||||||
$(derivedSources)/meanVelocityForce/patchMeanVelocityForce/patchMeanVelocityForce.C
|
$(derivedSources)/meanVelocityForce/patchMeanVelocityForce/patchMeanVelocityForce.C
|
||||||
$(derivedSources)/radialActuationDiskSource/radialActuationDiskSource.C
|
$(derivedSources)/radialActuationDiskSource/radialActuationDiskSource.C
|
||||||
$(derivedSources)/rotorDiskSource/rotorDiskSource.C
|
$(derivedSources)/rotorDiskSource/rotorDiskSource.C
|
||||||
@ -30,12 +27,9 @@ $(derivedSources)/rotorDiskSource/trimModel/trimModel/trimModelNew.C
|
|||||||
$(derivedSources)/rotorDiskSource/trimModel/fixed/fixedTrim.C
|
$(derivedSources)/rotorDiskSource/trimModel/fixed/fixedTrim.C
|
||||||
$(derivedSources)/rotorDiskSource/trimModel/targetCoeff/targetCoeffTrim.C
|
$(derivedSources)/rotorDiskSource/trimModel/targetCoeff/targetCoeffTrim.C
|
||||||
$(derivedSources)/solidificationMeltingSource/solidificationMeltingSource.C
|
$(derivedSources)/solidificationMeltingSource/solidificationMeltingSource.C
|
||||||
$(derivedSources)/solidificationMeltingSource/solidificationMeltingSourceIO.C
|
|
||||||
$(derivedSources)/sixDoFAccelerationSource/sixDoFAccelerationSource.C
|
$(derivedSources)/sixDoFAccelerationSource/sixDoFAccelerationSource.C
|
||||||
$(derivedSources)/buoyancyForce/buoyancyForce.C
|
$(derivedSources)/buoyancyForce/buoyancyForce.C
|
||||||
$(derivedSources)/buoyancyForce/buoyancyForceIO.C
|
|
||||||
$(derivedSources)/buoyancyEnergy/buoyancyEnergy.C
|
$(derivedSources)/buoyancyEnergy/buoyancyEnergy.C
|
||||||
$(derivedSources)/buoyancyEnergy/buoyancyEnergyIO.C
|
|
||||||
$(derivedSources)/damping/damping/damping.C
|
$(derivedSources)/damping/damping/damping.C
|
||||||
$(derivedSources)/damping/isotropicDamping/isotropicDamping.C
|
$(derivedSources)/damping/isotropicDamping/isotropicDamping.C
|
||||||
$(derivedSources)/damping/verticalDamping/verticalDamping.C
|
$(derivedSources)/damping/verticalDamping/verticalDamping.C
|
||||||
@ -46,7 +40,6 @@ $(derivedSources)/solidEquilibriumEnergySource/solidEquilibriumEnergySource.C
|
|||||||
|
|
||||||
interRegion = sources/interRegion
|
interRegion = sources/interRegion
|
||||||
$(interRegion)/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModel.C
|
$(interRegion)/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModel.C
|
||||||
$(interRegion)/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModelIO.C
|
|
||||||
$(interRegion)/interRegionHeatTransfer/constantHeatTransfer/constantHeatTransfer.C
|
$(interRegion)/interRegionHeatTransfer/constantHeatTransfer/constantHeatTransfer.C
|
||||||
$(interRegion)/interRegionHeatTransfer/function2HeatTransfer/function2HeatTransfer.C
|
$(interRegion)/interRegionHeatTransfer/function2HeatTransfer/function2HeatTransfer.C
|
||||||
$(interRegion)/interRegionHeatTransfer/variableHeatTransfer/variableHeatTransfer.C
|
$(interRegion)/interRegionHeatTransfer/variableHeatTransfer/variableHeatTransfer.C
|
||||||
@ -55,7 +48,7 @@ $(interRegion)/interRegionExplicitPorositySource/interRegionExplicitPorositySour
|
|||||||
|
|
||||||
# Constraints
|
# Constraints
|
||||||
|
|
||||||
constraints/fixedValueConstraint/fixedValueConstraints.C
|
constraints/fixedValueConstraint/fixedValueConstraint.C
|
||||||
constraints/fixedTemperatureConstraint/fixedTemperatureConstraint.C
|
constraints/fixedTemperatureConstraint/fixedTemperatureConstraint.C
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -52,28 +52,31 @@ namespace Foam
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::fv::cellSetOption::setSelection(const dictionary& dict)
|
void Foam::fv::cellSetOption::readCoeffs()
|
||||||
{
|
{
|
||||||
|
selectionMode_ =
|
||||||
|
selectionModeTypeNames_.read(coeffs_.lookup("selectionMode"));
|
||||||
|
|
||||||
switch (selectionMode_)
|
switch (selectionMode_)
|
||||||
{
|
{
|
||||||
case smPoints:
|
case selectionModeType::points:
|
||||||
{
|
{
|
||||||
dict.lookup("points") >> points_;
|
coeffs_.lookup("points") >> points_;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case smCellSet:
|
case selectionModeType::cellSet:
|
||||||
{
|
{
|
||||||
dict.lookup("cellSet") >> cellSetName_;
|
coeffs_.lookup("cellSet") >> cellSetName_;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case smCellZone:
|
case selectionModeType::cellZone:
|
||||||
{
|
{
|
||||||
dict.lookup("cellZone") >> cellSetName_;
|
coeffs_.lookup("cellZone") >> cellSetName_;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case smAll:
|
case selectionModeType::all:
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -91,9 +94,11 @@ void Foam::fv::cellSetOption::setSelection(const dictionary& dict)
|
|||||||
|
|
||||||
void Foam::fv::cellSetOption::setCellSet()
|
void Foam::fv::cellSetOption::setCellSet()
|
||||||
{
|
{
|
||||||
|
Info<< incrIndent;
|
||||||
|
|
||||||
switch (selectionMode_)
|
switch (selectionMode_)
|
||||||
{
|
{
|
||||||
case smPoints:
|
case selectionModeType::points:
|
||||||
{
|
{
|
||||||
Info<< indent << "- selecting cells using points" << endl;
|
Info<< indent << "- selecting cells using points" << endl;
|
||||||
|
|
||||||
@ -121,7 +126,7 @@ void Foam::fv::cellSetOption::setCellSet()
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case smCellSet:
|
case selectionModeType::cellSet:
|
||||||
{
|
{
|
||||||
Info<< indent
|
Info<< indent
|
||||||
<< "- selecting cells using cellSet " << cellSetName_ << endl;
|
<< "- selecting cells using cellSet " << cellSetName_ << endl;
|
||||||
@ -131,7 +136,7 @@ void Foam::fv::cellSetOption::setCellSet()
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case smCellZone:
|
case selectionModeType::cellZone:
|
||||||
{
|
{
|
||||||
Info<< indent
|
Info<< indent
|
||||||
<< "- selecting cells using cellZone " << cellSetName_ << endl;
|
<< "- selecting cells using cellZone " << cellSetName_ << endl;
|
||||||
@ -148,25 +153,17 @@ void Foam::fv::cellSetOption::setCellSet()
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case smAll:
|
case selectionModeType::all:
|
||||||
{
|
{
|
||||||
Info<< indent << "- selecting all cells" << endl;
|
Info<< indent << "- selecting all cells" << endl;
|
||||||
cells_ = identity(mesh_.nCells());
|
cells_ = identity(mesh_.nCells());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Unknown selectionMode "
|
|
||||||
<< selectionModeTypeNames_[selectionMode_]
|
|
||||||
<< ". Valid selectionMode types are" << selectionModeTypeNames_
|
|
||||||
<< exit(FatalError);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set volume information
|
// Set volume information
|
||||||
V_ = 0.0;
|
V_ = 0;
|
||||||
forAll(cells_, i)
|
forAll(cells_, i)
|
||||||
{
|
{
|
||||||
V_ += mesh_.V()[cells_[i]];
|
V_ += mesh_.V()[cells_[i]];
|
||||||
@ -176,6 +173,8 @@ void Foam::fv::cellSetOption::setCellSet()
|
|||||||
Info<< indent
|
Info<< indent
|
||||||
<< "- selected " << returnReduce(cells_.size(), sumOp<label>())
|
<< "- selected " << returnReduce(cells_.size(), sumOp<label>())
|
||||||
<< " cell(s) with volume " << V_ << endl;
|
<< " cell(s) with volume " << V_ << endl;
|
||||||
|
|
||||||
|
Info<< decrIndent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -190,20 +189,12 @@ Foam::fv::cellSetOption::cellSetOption
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
option(name, modelType, dict, mesh),
|
option(name, modelType, dict, mesh),
|
||||||
timeStart_(-1.0),
|
selectionMode_(selectionModeType::all),
|
||||||
duration_(0.0),
|
cellSetName_(word::null),
|
||||||
selectionMode_
|
V_(NaN)
|
||||||
(
|
|
||||||
selectionModeTypeNames_.read(coeffs_.lookup("selectionMode"))
|
|
||||||
),
|
|
||||||
cellSetName_("none"),
|
|
||||||
V_(0.0)
|
|
||||||
{
|
{
|
||||||
Info<< incrIndent;
|
readCoeffs();
|
||||||
read(dict);
|
|
||||||
setSelection(coeffs_);
|
|
||||||
setCellSet();
|
setCellSet();
|
||||||
Info<< decrIndent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -227,4 +218,19 @@ bool Foam::fv::cellSetOption::movePoints()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::fv::cellSetOption::read(const dictionary& dict)
|
||||||
|
{
|
||||||
|
if (option::read(dict))
|
||||||
|
{
|
||||||
|
readCoeffs();
|
||||||
|
setCellSet();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -25,25 +25,37 @@ Class
|
|||||||
Foam::fv::cellSetOption
|
Foam::fv::cellSetOption
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Cell-set options abstract base class. Provides a base set of controls,
|
Cell-set options abstract base class. Provides a base set of controls
|
||||||
e.g.:
|
regarding the location where the option is applied.
|
||||||
|
|
||||||
|
Usage
|
||||||
|
Example usage:
|
||||||
\verbatim
|
\verbatim
|
||||||
type scalarExplicitSource // Source type
|
option1
|
||||||
|
{
|
||||||
|
type <optionType>
|
||||||
|
|
||||||
timeStart 0.0; // Start time
|
// Apply everywhere
|
||||||
duration 1000.0; // Duration
|
selectionMode all;
|
||||||
selectionMode cellSet; // cellSet, points, cellZone
|
|
||||||
.
|
// // Apply within a given cell set
|
||||||
.
|
// selectionMode cellSet;
|
||||||
.
|
// cellSet c0;
|
||||||
|
|
||||||
|
// // Apply in cells containing a list of points
|
||||||
|
// selectionMode points;
|
||||||
|
// points
|
||||||
|
// (
|
||||||
|
// (2.25 0.5 0)
|
||||||
|
// (2.75 0.5 0)
|
||||||
|
// );
|
||||||
|
|
||||||
|
...
|
||||||
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
Note
|
|
||||||
Source/sink options are to be added to the equation R.H.S.
|
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
cellSetOption.C
|
cellSetOption.C
|
||||||
cellSetOptionIO.C
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -75,12 +87,12 @@ public:
|
|||||||
// Public data
|
// Public data
|
||||||
|
|
||||||
//- Enumeration for selection mode types
|
//- Enumeration for selection mode types
|
||||||
enum selectionModeType
|
enum class selectionModeType
|
||||||
{
|
{
|
||||||
smPoints,
|
points,
|
||||||
smCellSet,
|
cellSet,
|
||||||
smCellZone,
|
cellZone,
|
||||||
smAll
|
all
|
||||||
};
|
};
|
||||||
|
|
||||||
//- Word list of selection mode type names
|
//- Word list of selection mode type names
|
||||||
@ -90,13 +102,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Protected data
|
// Private data
|
||||||
|
|
||||||
//- Time start
|
|
||||||
scalar timeStart_;
|
|
||||||
|
|
||||||
//- Duration
|
|
||||||
scalar duration_;
|
|
||||||
|
|
||||||
//- Cell selection mode
|
//- Cell selection mode
|
||||||
selectionModeType selectionMode_;
|
selectionModeType selectionMode_;
|
||||||
@ -114,10 +120,10 @@ private:
|
|||||||
mutable scalar V_;
|
mutable scalar V_;
|
||||||
|
|
||||||
|
|
||||||
// Protected functions
|
// Private functions
|
||||||
|
|
||||||
//- Set the cellSet or points selection
|
//- Non-virtual read
|
||||||
void setSelection(const dictionary& dict);
|
void readCoeffs();
|
||||||
|
|
||||||
//- Set the cell set based on the user input selection mode
|
//- Set the cell set based on the user input selection mode
|
||||||
void setCellSet();
|
void setCellSet();
|
||||||
@ -149,15 +155,6 @@ public:
|
|||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
//- Return const access to the time start
|
|
||||||
inline scalar timeStart() const;
|
|
||||||
|
|
||||||
//- Return const access to the duration
|
|
||||||
inline scalar duration() const;
|
|
||||||
|
|
||||||
//- Return true if within time limits
|
|
||||||
inline bool inTimeLimits(const scalar time) const;
|
|
||||||
|
|
||||||
//- Return const access to the cell selection mode
|
//- Return const access to the cell selection mode
|
||||||
inline const selectionModeType& selectionMode() const;
|
inline const selectionModeType& selectionMode() const;
|
||||||
|
|
||||||
@ -172,15 +169,6 @@ public:
|
|||||||
inline const labelList& cells() const;
|
inline const labelList& cells() const;
|
||||||
|
|
||||||
|
|
||||||
// Edit
|
|
||||||
|
|
||||||
//- Return access to the time start
|
|
||||||
inline scalar& timeStart();
|
|
||||||
|
|
||||||
//- Return access to the duration
|
|
||||||
inline scalar& duration();
|
|
||||||
|
|
||||||
|
|
||||||
// Mesh changes
|
// Mesh changes
|
||||||
|
|
||||||
//- Update for mesh changes
|
//- Update for mesh changes
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -25,32 +25,6 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline Foam::scalar Foam::fv::cellSetOption::timeStart() const
|
|
||||||
{
|
|
||||||
return timeStart_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline Foam::scalar Foam::fv::cellSetOption::duration() const
|
|
||||||
{
|
|
||||||
return duration_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::fv::cellSetOption::inTimeLimits(const scalar time) const
|
|
||||||
{
|
|
||||||
return
|
|
||||||
(
|
|
||||||
(timeStart_ < 0)
|
|
||||||
||
|
|
||||||
(
|
|
||||||
(mesh_.time().value() >= timeStart_)
|
|
||||||
&& (mesh_.time().value() <= (timeStart_ + duration_))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline const Foam::fv::cellSetOption::selectionModeType&
|
inline const Foam::fv::cellSetOption::selectionModeType&
|
||||||
Foam::fv::cellSetOption::selectionMode() const
|
Foam::fv::cellSetOption::selectionMode() const
|
||||||
{
|
{
|
||||||
@ -76,16 +50,4 @@ inline const Foam::labelList& Foam::fv::cellSetOption::cells() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::scalar& Foam::fv::cellSetOption::timeStart()
|
|
||||||
{
|
|
||||||
return timeStart_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline Foam::scalar& Foam::fv::cellSetOption::duration()
|
|
||||||
{
|
|
||||||
return duration_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -1,44 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration | Website: https://openfoam.org
|
|
||||||
\\ / A nd | Copyright (C) 2011-2018 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 "cellSetOption.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
bool Foam::fv::cellSetOption::read(const dictionary& dict)
|
|
||||||
{
|
|
||||||
if (option::read(dict))
|
|
||||||
{
|
|
||||||
if (coeffs_.readIfPresent("timeStart", timeStart_))
|
|
||||||
{
|
|
||||||
coeffs_.lookup("duration") >> duration_;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -54,7 +54,34 @@ namespace Foam
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Foam::NamedEnum<Foam::fv::fixedTemperatureConstraint::temperatureMode, 2>
|
const Foam::NamedEnum<Foam::fv::fixedTemperatureConstraint::temperatureMode, 2>
|
||||||
Foam::fv::fixedTemperatureConstraint::temperatureModeNames_;
|
Foam::fv::fixedTemperatureConstraint::modeNames_;
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fv::fixedTemperatureConstraint::readCoeffs()
|
||||||
|
{
|
||||||
|
mode_ = modeNames_.read(coeffs_.lookup("mode"));
|
||||||
|
|
||||||
|
switch (mode_)
|
||||||
|
{
|
||||||
|
case temperatureMode::uniform:
|
||||||
|
{
|
||||||
|
TValue_.reset
|
||||||
|
(
|
||||||
|
Function1<scalar>::New("temperature", coeffs_).ptr()
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case temperatureMode::lookup:
|
||||||
|
{
|
||||||
|
TName_ = coeffs_.lookupOrDefault<word>("T", "T");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
phaseName_ = coeffs_.lookupOrDefault<word>("phase", word::null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
@ -68,85 +95,58 @@ Foam::fv::fixedTemperatureConstraint::fixedTemperatureConstraint
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
cellSetOption(name, modelType, dict, mesh),
|
cellSetOption(name, modelType, dict, mesh),
|
||||||
mode_(temperatureModeNames_.read(coeffs_.lookup("mode"))),
|
mode_(temperatureMode::uniform),
|
||||||
Tuniform_(nullptr),
|
TValue_(nullptr),
|
||||||
TName_("T"),
|
TName_(word::null),
|
||||||
phase_(coeffs_.lookupOrDefault<word>("phase", word::null))
|
phaseName_(word::null)
|
||||||
{
|
{
|
||||||
switch (mode_)
|
readCoeffs();
|
||||||
{
|
|
||||||
case tmUniform:
|
|
||||||
{
|
|
||||||
Tuniform_.reset
|
|
||||||
(
|
|
||||||
Function1<scalar>::New("temperature", coeffs_).ptr()
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case tmLookup:
|
|
||||||
{
|
|
||||||
TName_ = coeffs_.lookupOrDefault<word>("T", "T");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
// error handling done by NamedEnum
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the field name to that of the energy field from which the temperature
|
|
||||||
// is obtained
|
|
||||||
|
|
||||||
const basicThermo& thermo =
|
|
||||||
mesh_.lookupObject<basicThermo>
|
|
||||||
(
|
|
||||||
IOobject::groupName(basicThermo::dictName, phase_)
|
|
||||||
);
|
|
||||||
|
|
||||||
fieldNames_.setSize(1, thermo.he().name());
|
|
||||||
|
|
||||||
applied_.setSize(1, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::wordList Foam::fv::fixedTemperatureConstraint::constrainedFields() const
|
||||||
|
{
|
||||||
|
const basicThermo& thermo =
|
||||||
|
mesh_.lookupObject<basicThermo>
|
||||||
|
(
|
||||||
|
IOobject::groupName(basicThermo::dictName, phaseName_)
|
||||||
|
);
|
||||||
|
|
||||||
|
return wordList(1, thermo.he().name());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::fixedTemperatureConstraint::constrain
|
void Foam::fv::fixedTemperatureConstraint::constrain
|
||||||
(
|
(
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const basicThermo& thermo =
|
const basicThermo& thermo =
|
||||||
mesh_.lookupObject<basicThermo>
|
mesh_.lookupObject<basicThermo>
|
||||||
(
|
(
|
||||||
IOobject::groupName(basicThermo::dictName, phase_)
|
IOobject::groupName(basicThermo::dictName, phaseName_)
|
||||||
);
|
);
|
||||||
|
|
||||||
switch (mode_)
|
switch (mode_)
|
||||||
{
|
{
|
||||||
case tmUniform:
|
case temperatureMode::uniform:
|
||||||
{
|
{
|
||||||
const scalar t = mesh_.time().value();
|
const scalar t = mesh_.time().value();
|
||||||
scalarField Tuni(cells().size(), Tuniform_->value(t));
|
scalarField Tuni(cells().size(), TValue_->value(t));
|
||||||
eqn.setValues(cells(), thermo.he(Tuni, cells()));
|
eqn.setValues(cells(), thermo.he(Tuni, cells()));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case tmLookup:
|
case temperatureMode::lookup:
|
||||||
{
|
{
|
||||||
const volScalarField& T =
|
const volScalarField& T =
|
||||||
mesh().lookupObject<volScalarField>(TName_);
|
mesh().lookupObject<volScalarField>(TName_);
|
||||||
|
|
||||||
scalarField Tlkp(T, cells());
|
scalarField Tlkp(T, cells());
|
||||||
eqn.setValues(cells(), thermo.he(Tlkp, cells()));
|
eqn.setValues(cells(), thermo.he(Tlkp, cells()));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
{
|
|
||||||
// error handling done by NamedEnum
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,16 +155,7 @@ bool Foam::fv::fixedTemperatureConstraint::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
if (cellSetOption::read(dict))
|
if (cellSetOption::read(dict))
|
||||||
{
|
{
|
||||||
if (coeffs_.found(Tuniform_->name()))
|
readCoeffs();
|
||||||
{
|
|
||||||
Tuniform_.reset
|
|
||||||
(
|
|
||||||
Function1<scalar>::New(Tuniform_->name(), dict).ptr()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
coeffs_.readIfPresent("T", TName_);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -33,25 +33,23 @@ Usage
|
|||||||
{
|
{
|
||||||
type fixedTemperatureConstraint;
|
type fixedTemperatureConstraint;
|
||||||
|
|
||||||
mode uniform; // uniform or lookup
|
selectionMode all;
|
||||||
|
|
||||||
// For uniform option
|
phase gas; // Optional phase name
|
||||||
temperature constant 500; // fixed temperature with time [K]
|
|
||||||
|
|
||||||
// For lookup option
|
// Uniform temperature constraint
|
||||||
// T <Tname>; // optional temperature field name
|
mode uniform;
|
||||||
|
temperature constant 500; // Uniform temperature
|
||||||
|
|
||||||
phase gas; // optional
|
// // Looked-up field temperature constraint
|
||||||
|
// T T; // Temperature field name
|
||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
Note:
|
Note
|
||||||
The 'uniform' option allows the use of a time-varying uniform temperature
|
The 'uniform' option allows the use of a time-varying uniform temperature
|
||||||
by means of the Function1 type.
|
by means of the Function1 type.
|
||||||
|
|
||||||
See also
|
|
||||||
Foam::fvOption
|
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
fixedTemperatureConstraint.C
|
fixedTemperatureConstraint.C
|
||||||
|
|
||||||
@ -82,32 +80,37 @@ class fixedTemperatureConstraint
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
//- Temperature mode
|
//- Temperature mode
|
||||||
enum temperatureMode
|
enum class temperatureMode
|
||||||
{
|
{
|
||||||
tmUniform,
|
uniform,
|
||||||
tmLookup
|
lookup
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//- String representation of mode enums
|
||||||
//- String representation of temperatureMode enums
|
static const NamedEnum<temperatureMode, 2> modeNames_;
|
||||||
static const NamedEnum<temperatureMode, 2> temperatureModeNames_;
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
|
|
||||||
// Protected data
|
// Private Data
|
||||||
|
|
||||||
//- Operation mode
|
//- Operation mode
|
||||||
temperatureMode mode_;
|
temperatureMode mode_;
|
||||||
|
|
||||||
//- Uniform temperature [K]
|
//- Uniform temperature [K]
|
||||||
autoPtr<Function1<scalar>> Tuniform_;
|
autoPtr<Function1<scalar>> TValue_;
|
||||||
|
|
||||||
//- Temperature field name
|
//- Temperature field name
|
||||||
word TName_;
|
word TName_;
|
||||||
|
|
||||||
//- Optional phase name
|
//- Optional phase name
|
||||||
word phase_;
|
word phaseName_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -138,11 +141,14 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- Return the list of fields constrained by the option
|
||||||
|
virtual wordList constrainedFields() const;
|
||||||
|
|
||||||
//- Constrain energy equation to fix the temperature
|
//- Constrain energy equation to fix the temperature
|
||||||
virtual void constrain
|
virtual void constrain
|
||||||
(
|
(
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Read dictionary
|
//- Read dictionary
|
||||||
|
|||||||
@ -1,95 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration | Website: https://openfoam.org
|
|
||||||
\\ / A nd | Copyright (C) 2016-2020 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 "FixedValueConstraint.H"
|
|
||||||
#include "fvMesh.H"
|
|
||||||
#include "fvMatrices.H"
|
|
||||||
#include "DimensionedField.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
Foam::fv::FixedValueConstraint<Type>::FixedValueConstraint
|
|
||||||
(
|
|
||||||
const word& name,
|
|
||||||
const word& modelType,
|
|
||||||
const dictionary& dict,
|
|
||||||
const fvMesh& mesh
|
|
||||||
)
|
|
||||||
:
|
|
||||||
cellSetOption(name, modelType, dict, mesh)
|
|
||||||
{
|
|
||||||
read(dict);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
bool Foam::fv::FixedValueConstraint<Type>::read(const dictionary& dict)
|
|
||||||
{
|
|
||||||
if (cellSetOption::read(dict))
|
|
||||||
{
|
|
||||||
const dictionary& fieldValuesDict = coeffs_.subDict("fieldValues");
|
|
||||||
|
|
||||||
fieldNames_.setSize(fieldValuesDict.size());
|
|
||||||
fieldValues_.setSize(fieldNames_.size());
|
|
||||||
|
|
||||||
label i = 0;
|
|
||||||
forAllConstIter(dictionary, fieldValuesDict, iter)
|
|
||||||
{
|
|
||||||
fieldNames_[i] = iter().keyword();
|
|
||||||
fieldValuesDict.lookup(iter().keyword()) >> fieldValues_[i];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
applied_.setSize(fieldNames_.size(), false);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::fv::FixedValueConstraint<Type>::constrain
|
|
||||||
(
|
|
||||||
fvMatrix<Type>& eqn,
|
|
||||||
const label fieldi
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
DebugInfo
|
|
||||||
<< "FixedValueConstraint<"
|
|
||||||
<< pTraits<Type>::typeName
|
|
||||||
<< ">::constrain for source " << name_ << endl;
|
|
||||||
|
|
||||||
eqn.setValues(cells(), List<Type>(cells().size(), fieldValues_[fieldi]));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -0,0 +1,177 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration | Website: https://openfoam.org
|
||||||
|
\\ / A nd | Copyright (C) 2016-2021 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 "fixedValueConstraint.H"
|
||||||
|
#include "fvMesh.H"
|
||||||
|
#include "fvMatrices.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace fv
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(fixedValueConstraint, 0);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
cellSetOption,
|
||||||
|
fixedValueConstraint,
|
||||||
|
dictionary
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fv::fixedValueConstraint::readCoeffs()
|
||||||
|
{
|
||||||
|
fieldValues_.clear();
|
||||||
|
forAllConstIter(dictionary, coeffs_.subDict("fieldValues"), iter)
|
||||||
|
{
|
||||||
|
fieldValues_.set
|
||||||
|
(
|
||||||
|
iter().keyword(),
|
||||||
|
objectFunction1::New<VolField>
|
||||||
|
(
|
||||||
|
iter().keyword(),
|
||||||
|
coeffs_.subDict("fieldValues"),
|
||||||
|
iter().keyword(),
|
||||||
|
mesh_,
|
||||||
|
false
|
||||||
|
).ptr()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::fv::fixedValueConstraint::constrainType
|
||||||
|
(
|
||||||
|
fvMatrix<Type>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const scalar t = mesh_.time().value();
|
||||||
|
|
||||||
|
eqn.setValues
|
||||||
|
(
|
||||||
|
cells(),
|
||||||
|
List<Type>(cells().size(), fieldValues_[fieldName]->value<Type>(t))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::fv::fixedValueConstraint::fixedValueConstraint
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const word& modelType,
|
||||||
|
const dictionary& dict,
|
||||||
|
const fvMesh& mesh
|
||||||
|
)
|
||||||
|
:
|
||||||
|
cellSetOption(name, modelType, dict, mesh)
|
||||||
|
{
|
||||||
|
readCoeffs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::wordList Foam::fv::fixedValueConstraint::constrainedFields() const
|
||||||
|
{
|
||||||
|
return fieldValues_.toc();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fv::fixedValueConstraint::constrain
|
||||||
|
(
|
||||||
|
fvMatrix<scalar>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
constrainType(eqn, fieldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fv::fixedValueConstraint::constrain
|
||||||
|
(
|
||||||
|
fvMatrix<vector>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
constrainType(eqn, fieldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fv::fixedValueConstraint::constrain
|
||||||
|
(
|
||||||
|
fvMatrix<symmTensor>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
constrainType(eqn, fieldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fv::fixedValueConstraint::constrain
|
||||||
|
(
|
||||||
|
fvMatrix<sphericalTensor>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
constrainType(eqn, fieldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fv::fixedValueConstraint::constrain
|
||||||
|
(
|
||||||
|
fvMatrix<tensor>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
constrainType(eqn, fieldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::fv::fixedValueConstraint::read(const dictionary& dict)
|
||||||
|
{
|
||||||
|
if (cellSetOption::read(dict))
|
||||||
|
{
|
||||||
|
readCoeffs();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2016-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -22,7 +22,7 @@ License
|
|||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::fv::FixedValueConstraint
|
Foam::fv::fixedValueConstraint
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Constrain the field values within a specified region.
|
Constrain the field values within a specified region.
|
||||||
@ -32,10 +32,11 @@ Usage
|
|||||||
\verbatim
|
\verbatim
|
||||||
porosityTurbulence
|
porosityTurbulence
|
||||||
{
|
{
|
||||||
type scalarFixedValueConstraint;
|
type fixedValueConstraint;
|
||||||
|
|
||||||
selectionMode cellZone;
|
selectionMode cellZone;
|
||||||
cellZone porosity;
|
cellZone porosity;
|
||||||
|
|
||||||
fieldValues
|
fieldValues
|
||||||
{
|
{
|
||||||
k 1;
|
k 1;
|
||||||
@ -44,19 +45,17 @@ Usage
|
|||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
See also
|
|
||||||
Foam::fvOption
|
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
FixedValueConstraint.C
|
fixedValueConstraint.C
|
||||||
fixedValueConstraints.C
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef FixedValueConstraint_H
|
#ifndef fixedValueConstraint_H
|
||||||
#define FixedValueConstraint_H
|
#define fixedValueConstraint_H
|
||||||
|
|
||||||
#include "cellSetOption.H"
|
#include "cellSetOption.H"
|
||||||
|
#include "objectFunction1.H"
|
||||||
|
#include "HashPtrTable.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -66,30 +65,39 @@ namespace fv
|
|||||||
{
|
{
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class FixedValueConstraint Declaration
|
Class fixedValueConstraint Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
template<class Type>
|
class fixedValueConstraint
|
||||||
class FixedValueConstraint
|
|
||||||
:
|
:
|
||||||
public cellSetOption
|
public cellSetOption
|
||||||
{
|
{
|
||||||
// Private member data
|
// Private Member Data
|
||||||
|
|
||||||
//- Field values
|
//- Field values
|
||||||
List<Type> fieldValues_;
|
HashPtrTable<objectFunction1> fieldValues_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
|
//- Set value on a field
|
||||||
|
template<class Type>
|
||||||
|
void constrainType(fvMatrix<Type>& eqn, const word& fieldName) const;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
TypeName("FixedValueConstraint");
|
TypeName("fixedValueConstraint");
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
FixedValueConstraint
|
fixedValueConstraint
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const word& modelType,
|
const word& modelType,
|
||||||
@ -100,11 +108,51 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Read source dictionary
|
// Checks
|
||||||
virtual bool read(const dictionary& dict);
|
|
||||||
|
|
||||||
//- Set value on field
|
//- Return the list of fields constrained by the option
|
||||||
virtual void constrain(fvMatrix<Type>& eqn, const label fieldi) const;
|
virtual wordList constrainedFields() const;
|
||||||
|
|
||||||
|
|
||||||
|
// Evaluation
|
||||||
|
|
||||||
|
// Constraints
|
||||||
|
|
||||||
|
virtual void constrain
|
||||||
|
(
|
||||||
|
fvMatrix<scalar>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const;
|
||||||
|
|
||||||
|
virtual void constrain
|
||||||
|
(
|
||||||
|
fvMatrix<vector>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const;
|
||||||
|
|
||||||
|
virtual void constrain
|
||||||
|
(
|
||||||
|
fvMatrix<symmTensor>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const;
|
||||||
|
|
||||||
|
virtual void constrain
|
||||||
|
(
|
||||||
|
fvMatrix<sphericalTensor>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const;
|
||||||
|
|
||||||
|
virtual void constrain
|
||||||
|
(
|
||||||
|
fvMatrix<tensor>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
// IO
|
||||||
|
|
||||||
|
//- Read source dictionary
|
||||||
|
virtual bool read(const dictionary& dict);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -115,12 +163,6 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#ifdef NoRepository
|
|
||||||
#include "FixedValueConstraint.C"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
@ -1,37 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration | Website: https://openfoam.org
|
|
||||||
\\ / A nd | Copyright (C) 2016-2018 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 "makeFvOption.H"
|
|
||||||
#include "FixedValueConstraint.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
makeFvOption(FixedValueConstraint, scalar);
|
|
||||||
makeFvOption(FixedValueConstraint, vector);
|
|
||||||
makeFvOption(FixedValueConstraint, sphericalTensor);
|
|
||||||
makeFvOption(FixedValueConstraint, symmTensor);
|
|
||||||
makeFvOption(FixedValueConstraint, tensor);
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -45,6 +45,16 @@ namespace fv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fv::limitTemperature::readCoeffs()
|
||||||
|
{
|
||||||
|
Tmin_ = coeffs_.lookup<scalar>("min");
|
||||||
|
Tmax_ = coeffs_.lookup<scalar>("max");
|
||||||
|
phaseName_ = coeffs_.lookupOrDefault<word>("phase", word::null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::fv::limitTemperature::limitTemperature
|
Foam::fv::limitTemperature::limitTemperature
|
||||||
@ -56,39 +66,25 @@ Foam::fv::limitTemperature::limitTemperature
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
cellSetOption(name, modelType, dict, mesh),
|
cellSetOption(name, modelType, dict, mesh),
|
||||||
Tmin_(coeffs_.lookup<scalar>("min")),
|
Tmin_(-vGreat),
|
||||||
Tmax_(coeffs_.lookup<scalar>("max")),
|
Tmax_(vGreat),
|
||||||
phase_(coeffs_.lookupOrDefault<word>("phase", word::null))
|
phaseName_(word::null)
|
||||||
{
|
{
|
||||||
// Set the field name to that of the energy field from which the temperature
|
readCoeffs();
|
||||||
// is obtained
|
|
||||||
const basicThermo& thermo =
|
|
||||||
mesh_.lookupObject<basicThermo>
|
|
||||||
(
|
|
||||||
IOobject::groupName(basicThermo::dictName, phase_)
|
|
||||||
);
|
|
||||||
|
|
||||||
fieldNames_.setSize(1, thermo.he().name());
|
|
||||||
|
|
||||||
applied_.setSize(1, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::fv::limitTemperature::read(const dictionary& dict)
|
Foam::wordList Foam::fv::limitTemperature::correctedFields() const
|
||||||
{
|
{
|
||||||
if (cellSetOption::read(dict))
|
const basicThermo& thermo =
|
||||||
{
|
mesh_.lookupObject<basicThermo>
|
||||||
coeffs_.lookup("min") >> Tmin_;
|
(
|
||||||
coeffs_.lookup("max") >> Tmax_;
|
IOobject::groupName(basicThermo::dictName, phaseName_)
|
||||||
|
);
|
||||||
|
|
||||||
return true;
|
return wordList(1, thermo.he().name());
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -97,7 +93,7 @@ void Foam::fv::limitTemperature::correct(volScalarField& he) const
|
|||||||
const basicThermo& thermo =
|
const basicThermo& thermo =
|
||||||
mesh_.lookupObject<basicThermo>
|
mesh_.lookupObject<basicThermo>
|
||||||
(
|
(
|
||||||
IOobject::groupName(basicThermo::dictName, phase_)
|
IOobject::groupName(basicThermo::dictName, phaseName_)
|
||||||
);
|
);
|
||||||
|
|
||||||
scalarField Tmin(cells().size(), Tmin_);
|
scalarField Tmin(cells().size(), Tmin_);
|
||||||
@ -117,7 +113,7 @@ void Foam::fv::limitTemperature::correct(volScalarField& he) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handle boundaries in the case of 'all'
|
// handle boundaries in the case of 'all'
|
||||||
if (selectionMode() == smAll)
|
if (selectionMode() == selectionModeType::all)
|
||||||
{
|
{
|
||||||
volScalarField::Boundary& bf = he.boundaryFieldRef();
|
volScalarField::Boundary& bf = he.boundaryFieldRef();
|
||||||
|
|
||||||
@ -144,4 +140,18 @@ void Foam::fv::limitTemperature::correct(volScalarField& he) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::fv::limitTemperature::read(const dictionary& dict)
|
||||||
|
{
|
||||||
|
if (cellSetOption::read(dict))
|
||||||
|
{
|
||||||
|
readCoeffs();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -36,9 +36,11 @@ Usage
|
|||||||
type limitTemperature;
|
type limitTemperature;
|
||||||
|
|
||||||
selectionMode all;
|
selectionMode all;
|
||||||
|
|
||||||
|
phase gas; // Optional phase name
|
||||||
|
|
||||||
min 200;
|
min 200;
|
||||||
max 500;
|
max 500;
|
||||||
phase gas; // optional
|
|
||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
@ -67,9 +69,7 @@ class limitTemperature
|
|||||||
:
|
:
|
||||||
public cellSetOption
|
public cellSetOption
|
||||||
{
|
{
|
||||||
protected:
|
// Private data
|
||||||
|
|
||||||
// Protected data
|
|
||||||
|
|
||||||
//- Minimum temperature limit [K]
|
//- Minimum temperature limit [K]
|
||||||
scalar Tmin_;
|
scalar Tmin_;
|
||||||
@ -78,7 +78,13 @@ protected:
|
|||||||
scalar Tmax_;
|
scalar Tmax_;
|
||||||
|
|
||||||
//- Optional phase name
|
//- Optional phase name
|
||||||
word phase_;
|
word phaseName_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -109,12 +115,15 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Read dictionary
|
//- Return the list of fields corrected by the option
|
||||||
virtual bool read(const dictionary& dict);
|
virtual wordList correctedFields() const;
|
||||||
|
|
||||||
//- Correct the energy field
|
//- Correct the energy field
|
||||||
virtual void correct(volScalarField& he) const;
|
virtual void correct(volScalarField& he) const;
|
||||||
|
|
||||||
|
//- Read dictionary
|
||||||
|
virtual bool read(const dictionary& dict);
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2016-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -44,6 +44,15 @@ namespace fv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fv::limitVelocity::readCoeffs()
|
||||||
|
{
|
||||||
|
UName_ = coeffs_.lookupOrDefault<word>("U", "U");
|
||||||
|
max_ = coeffs_.lookup<scalar>("max");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::fv::limitVelocity::limitVelocity
|
Foam::fv::limitVelocity::limitVelocity
|
||||||
@ -55,28 +64,18 @@ Foam::fv::limitVelocity::limitVelocity
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
cellSetOption(name, modelType, dict, mesh),
|
cellSetOption(name, modelType, dict, mesh),
|
||||||
UName_(coeffs_.lookupOrDefault<word>("U", "U")),
|
UName_(word::null),
|
||||||
max_(coeffs_.lookup<scalar>("max"))
|
max_(vGreat)
|
||||||
{
|
{
|
||||||
fieldNames_.setSize(1, UName_);
|
readCoeffs();
|
||||||
applied_.setSize(1, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::fv::limitVelocity::read(const dictionary& dict)
|
Foam::wordList Foam::fv::limitVelocity::correctedFields() const
|
||||||
{
|
{
|
||||||
if (cellSetOption::read(dict))
|
return wordList(1, UName_);
|
||||||
{
|
|
||||||
coeffs_.lookup("max") >> max_;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -101,7 +100,7 @@ void Foam::fv::limitVelocity::correct(volVectorField& U) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handle boundaries in the case of 'all'
|
// handle boundaries in the case of 'all'
|
||||||
if (selectionMode() == smAll)
|
if (selectionMode() == selectionModeType::all)
|
||||||
{
|
{
|
||||||
volVectorField::Boundary& Ubf = U.boundaryFieldRef();
|
volVectorField::Boundary& Ubf = U.boundaryFieldRef();
|
||||||
|
|
||||||
@ -126,4 +125,18 @@ void Foam::fv::limitVelocity::correct(volVectorField& U) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::fv::limitVelocity::read(const dictionary& dict)
|
||||||
|
{
|
||||||
|
if (cellSetOption::read(dict))
|
||||||
|
{
|
||||||
|
readCoeffs();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2016-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -25,7 +25,7 @@ Class
|
|||||||
Foam::fv::limitVelocity
|
Foam::fv::limitVelocity
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Limits the maximum velocity magnitude to the specified \c max value.
|
Limits the velocity magnitude to the specified \c max value.
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
Example usage:
|
Example usage:
|
||||||
@ -35,6 +35,7 @@ Usage
|
|||||||
type limitVelocity;
|
type limitVelocity;
|
||||||
|
|
||||||
selectionMode all;
|
selectionMode all;
|
||||||
|
|
||||||
max 100;
|
max 100;
|
||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
@ -64,9 +65,7 @@ class limitVelocity
|
|||||||
:
|
:
|
||||||
public cellSetOption
|
public cellSetOption
|
||||||
{
|
{
|
||||||
protected:
|
// Private data
|
||||||
|
|
||||||
// Protected data
|
|
||||||
|
|
||||||
//- Velocity field name, default = U
|
//- Velocity field name, default = U
|
||||||
word UName_;
|
word UName_;
|
||||||
@ -75,6 +74,12 @@ protected:
|
|||||||
scalar max_;
|
scalar max_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
@ -103,12 +108,15 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- Return the list of fields corrected by the option
|
||||||
|
virtual wordList correctedFields() const;
|
||||||
|
|
||||||
|
//- Correct the velocity field
|
||||||
|
virtual void correct(volVectorField& U) const;
|
||||||
|
|
||||||
//- Read dictionary
|
//- Read dictionary
|
||||||
virtual bool read(const dictionary& dict);
|
virtual bool read(const dictionary& dict);
|
||||||
|
|
||||||
//- Correct the energy field
|
|
||||||
virtual void correct(volVectorField& U) const;
|
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -36,10 +36,26 @@ namespace fv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * Protected member functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::fv::interRegionOption::setMapper()
|
void Foam::fv::interRegionOption::readCoeffs()
|
||||||
{
|
{
|
||||||
|
master_ = coeffs_.lookupOrDefault<bool>("master", true);
|
||||||
|
|
||||||
|
nbrRegionName_ = coeffs_.lookup<word>("nbrRegionName");
|
||||||
|
|
||||||
|
interpolationMethod_ =
|
||||||
|
meshToMesh::interpolationMethodNames_.read
|
||||||
|
(
|
||||||
|
coeffs_.lookup("interpolationMethod")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fv::interRegionOption::setMapper() const
|
||||||
|
{
|
||||||
|
Info<< incrIndent;
|
||||||
|
|
||||||
if (master_)
|
if (master_)
|
||||||
{
|
{
|
||||||
Info<< indent << "- selecting inter region mapping" << endl;
|
Info<< indent << "- selecting inter region mapping" << endl;
|
||||||
@ -65,10 +81,7 @@ void Foam::fv::interRegionOption::setMapper()
|
|||||||
(
|
(
|
||||||
mesh_,
|
mesh_,
|
||||||
nbrMesh,
|
nbrMesh,
|
||||||
meshToMesh::interpolationMethodNames_.read
|
interpolationMethod_,
|
||||||
(
|
|
||||||
coeffs_.lookup("interpolationMethod")
|
|
||||||
),
|
|
||||||
false // not interpolating patches
|
false // not interpolating patches
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -81,6 +94,8 @@ void Foam::fv::interRegionOption::setMapper()
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Info<< decrIndent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -94,18 +109,13 @@ Foam::fv::interRegionOption::interRegionOption
|
|||||||
const fvMesh& mesh
|
const fvMesh& mesh
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
option
|
option(name, modelType, dict, mesh),
|
||||||
(
|
master_(false),
|
||||||
name,
|
nbrRegionName_(word::null),
|
||||||
modelType,
|
interpolationMethod_(meshToMesh::imDirect),
|
||||||
dict,
|
|
||||||
mesh
|
|
||||||
),
|
|
||||||
master_(coeffs_.lookupOrDefault<bool>("master", true)),
|
|
||||||
nbrRegionName_(coeffs_.lookup("nbrRegionName")),
|
|
||||||
meshInterpPtr_()
|
meshInterpPtr_()
|
||||||
{
|
{
|
||||||
setMapper();
|
readCoeffs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -115,4 +125,21 @@ Foam::fv::interRegionOption::~interRegionOption()
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::fv::interRegionOption::read(const dictionary& dict)
|
||||||
|
{
|
||||||
|
if (option::read(dict))
|
||||||
|
{
|
||||||
|
readCoeffs();
|
||||||
|
setMapper();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -53,9 +53,7 @@ class interRegionOption
|
|||||||
:
|
:
|
||||||
public option
|
public option
|
||||||
{
|
{
|
||||||
protected:
|
// Private data
|
||||||
|
|
||||||
// Protected data
|
|
||||||
|
|
||||||
//- Master or slave region
|
//- Master or slave region
|
||||||
bool master_;
|
bool master_;
|
||||||
@ -63,14 +61,20 @@ protected:
|
|||||||
//- Name of the neighbour region to map
|
//- Name of the neighbour region to map
|
||||||
word nbrRegionName_;
|
word nbrRegionName_;
|
||||||
|
|
||||||
|
//- Interpolation method
|
||||||
|
meshToMesh::interpolationMethod interpolationMethod_;
|
||||||
|
|
||||||
//- Mesh to mesh interpolation object
|
//- Mesh to mesh interpolation object
|
||||||
autoPtr<meshToMesh> meshInterpPtr_;
|
mutable autoPtr<meshToMesh> meshInterpPtr_;
|
||||||
|
|
||||||
|
|
||||||
// Protected member functions
|
// Private member functions
|
||||||
|
|
||||||
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
//- Set the mesh to mesh interpolation object
|
//- Set the mesh to mesh interpolation object
|
||||||
void setMapper();
|
void setMapper() const;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -99,6 +103,9 @@ public:
|
|||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
|
//- Return whether the master region
|
||||||
|
inline bool master() const;
|
||||||
|
|
||||||
//- Return const access to the neighbour region name
|
//- Return const access to the neighbour region name
|
||||||
inline const word& nbrRegionName() const;
|
inline const word& nbrRegionName() const;
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -25,6 +25,12 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline bool Foam::fv::interRegionOption::master() const
|
||||||
|
{
|
||||||
|
return master_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const Foam::word&
|
inline const Foam::word&
|
||||||
Foam::fv::interRegionOption::nbrRegionName() const
|
Foam::fv::interRegionOption::nbrRegionName() const
|
||||||
{
|
{
|
||||||
@ -37,14 +43,11 @@ Foam::fv::interRegionOption::meshInterp() const
|
|||||||
{
|
{
|
||||||
if (!meshInterpPtr_.valid())
|
if (!meshInterpPtr_.valid())
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
setMapper();
|
||||||
<< "Interpolation object not set"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return meshInterpPtr_();
|
return meshInterpPtr_();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -1,43 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration | Website: https://openfoam.org
|
|
||||||
\\ / A nd | Copyright (C) 2011-2018 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 "interRegionOption.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
bool Foam::fv::interRegionOption::read(const dictionary& dict)
|
|
||||||
{
|
|
||||||
if (option::read(dict))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2018-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2018-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -41,6 +41,16 @@ namespace fv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fv::accelerationSource::readCoeffs()
|
||||||
|
{
|
||||||
|
UName_ = coeffs_.lookupOrDefault<word>("U", "U");
|
||||||
|
|
||||||
|
velocity_ = Function1<vector>::New("velocity", coeffs_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::fv::accelerationSource::accelerationSource
|
Foam::fv::accelerationSource::accelerationSource
|
||||||
@ -52,21 +62,28 @@ Foam::fv::accelerationSource::accelerationSource
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
cellSetOption(name, modelType, dict, mesh),
|
cellSetOption(name, modelType, dict, mesh),
|
||||||
|
UName_(word::null),
|
||||||
velocity_(nullptr)
|
velocity_(nullptr)
|
||||||
{
|
{
|
||||||
read(dict);
|
readCoeffs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::wordList Foam::fv::accelerationSource::addedToFields() const
|
||||||
|
{
|
||||||
|
return wordList(1, UName_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::accelerationSource::addSup
|
void Foam::fv::accelerationSource::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
add(geometricOneField(), eqn, fieldi);
|
add(geometricOneField(), eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -74,10 +91,10 @@ void Foam::fv::accelerationSource::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
add(rho, eqn, fieldi);
|
add(rho, eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -86,10 +103,10 @@ void Foam::fv::accelerationSource::addSup
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
add((alpha*rho)(), eqn, fieldi);
|
add((alpha*rho)(), eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -97,12 +114,7 @@ bool Foam::fv::accelerationSource::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
if (cellSetOption::read(dict))
|
if (cellSetOption::read(dict))
|
||||||
{
|
{
|
||||||
fieldNames_ = wordList(1, coeffs_.lookupOrDefault<word>("U", "U"));
|
readCoeffs();
|
||||||
|
|
||||||
applied_.setSize(1, false);
|
|
||||||
|
|
||||||
velocity_ = Function1<vector>::New("velocity", dict);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2018-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2018-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -31,19 +31,21 @@ Description
|
|||||||
Usage
|
Usage
|
||||||
Example usage:
|
Example usage:
|
||||||
\verbatim
|
\verbatim
|
||||||
accelerationSource
|
accelerationSource1
|
||||||
{
|
{
|
||||||
type accelerationSource;
|
type accelerationSource;
|
||||||
|
|
||||||
selectionMode all;
|
selectionMode all;
|
||||||
U U;
|
|
||||||
velocity scale;
|
U U;
|
||||||
value (-2.572 0 0);
|
|
||||||
|
velocity scale;
|
||||||
|
value (-2.572 0 0);
|
||||||
scale
|
scale
|
||||||
{
|
{
|
||||||
type halfCosineRamp;
|
type halfCosineRamp;
|
||||||
start 0;
|
start 0;
|
||||||
duration 10;
|
duration 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
@ -76,19 +78,25 @@ class accelerationSource
|
|||||||
{
|
{
|
||||||
// Private Data
|
// Private Data
|
||||||
|
|
||||||
|
//- Name of the velocity field
|
||||||
|
word UName_;
|
||||||
|
|
||||||
//- Time-varying velocity
|
//- Time-varying velocity
|
||||||
autoPtr<Function1<vector>> velocity_;
|
autoPtr<Function1<vector>> velocity_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
//- Source term to momentum equation
|
//- Source term to momentum equation
|
||||||
template<class AlphaRhoFieldType>
|
template<class AlphaRhoFieldType>
|
||||||
void add
|
void add
|
||||||
(
|
(
|
||||||
const AlphaRhoFieldType& rho,
|
const AlphaRhoFieldType& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
@ -117,13 +125,20 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
// Checks
|
||||||
|
|
||||||
|
//- Return the list of fields for which the option adds source term
|
||||||
|
// to the transport equation
|
||||||
|
virtual wordList addedToFields() const;
|
||||||
|
|
||||||
|
|
||||||
// Add explicit and implicit contributions
|
// Add explicit and implicit contributions
|
||||||
|
|
||||||
//- Source term to momentum equation
|
//- Source term to momentum equation
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Source term to compressible momentum equation
|
//- Source term to compressible momentum equation
|
||||||
@ -131,7 +146,7 @@ public:
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Source term to phase momentum equation
|
//- Source term to phase momentum equation
|
||||||
@ -140,7 +155,7 @@ public:
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2018-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2018-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -30,7 +30,7 @@ void Foam::fv::accelerationSource::add
|
|||||||
(
|
(
|
||||||
const AlphaRhoFieldType& alphaRho,
|
const AlphaRhoFieldType& alphaRho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const DimensionedField<scalar, volMesh>& V = mesh_.V();
|
const DimensionedField<scalar, volMesh>& V = mesh_.V();
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -48,26 +48,37 @@ namespace fv
|
|||||||
|
|
||||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::fv::actuationDiskSource::checkData() const
|
void Foam::fv::actuationDiskSource::readCoeffs()
|
||||||
{
|
{
|
||||||
if (magSqr(diskArea_) <= vSmall)
|
UName_ = coeffs_.lookupOrDefault<word>("U", "U");
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
diskDir_ = coeffs_.lookup<vector>("diskDir");
|
||||||
<< "diskArea is approximately zero"
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
if (Cp_ <= vSmall || Ct_ <= vSmall)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Cp and Ct must be greater than zero"
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
if (mag(diskDir_) < vSmall)
|
if (mag(diskDir_) < vSmall)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "disk direction vector is approximately zero"
|
<< "disk direction vector is approximately zero"
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Cp_ = coeffs_.lookup<scalar>("Cp");
|
||||||
|
Ct_ = coeffs_.lookup<scalar>("Ct");
|
||||||
|
if (Cp_ <= vSmall || Ct_ <= vSmall)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Cp and Ct must be greater than zero"
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
diskArea_ = coeffs_.lookup<scalar>("diskArea");
|
||||||
|
if (magSqr(diskArea_) <= vSmall)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "diskArea is approximately zero"
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
upstreamPoint_ = coeffs_.lookup<point>("upstreamPoint");
|
||||||
|
upstreamCellId_ = mesh_.findCell(upstreamPoint_);
|
||||||
if (returnReduce(upstreamCellId_, maxOp<label>()) == -1)
|
if (returnReduce(upstreamCellId_, maxOp<label>()) == -1)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
@ -88,31 +99,30 @@ Foam::fv::actuationDiskSource::actuationDiskSource
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
cellSetOption(name, modelType, dict, mesh),
|
cellSetOption(name, modelType, dict, mesh),
|
||||||
diskDir_(coeffs_.lookup("diskDir")),
|
UName_(word::null),
|
||||||
Cp_(coeffs_.lookup<scalar>("Cp")),
|
diskDir_(vector::uniform(NaN)),
|
||||||
Ct_(coeffs_.lookup<scalar>("Ct")),
|
Cp_(NaN),
|
||||||
diskArea_(coeffs_.lookup<scalar>("diskArea")),
|
Ct_(NaN),
|
||||||
upstreamPoint_(coeffs_.lookup("upstreamPoint")),
|
diskArea_(NaN),
|
||||||
|
upstreamPoint_(vector::uniform(NaN)),
|
||||||
upstreamCellId_(-1)
|
upstreamCellId_(-1)
|
||||||
{
|
{
|
||||||
coeffs_.lookup("fields") >> fieldNames_;
|
readCoeffs();
|
||||||
applied_.setSize(fieldNames_.size(), false);
|
|
||||||
|
|
||||||
Info<< " - creating actuation disk zone: "
|
|
||||||
<< this->name() << endl;
|
|
||||||
|
|
||||||
upstreamCellId_ = mesh.findCell(upstreamPoint_);
|
|
||||||
|
|
||||||
checkData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::wordList Foam::fv::actuationDiskSource::addedToFields() const
|
||||||
|
{
|
||||||
|
return wordList(1, UName_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::actuationDiskSource::addSup
|
void Foam::fv::actuationDiskSource::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const scalarField& cellsV = mesh_.V();
|
const scalarField& cellsV = mesh_.V();
|
||||||
@ -137,7 +147,7 @@ void Foam::fv::actuationDiskSource::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const scalarField& cellsV = mesh_.V();
|
const scalarField& cellsV = mesh_.V();
|
||||||
@ -162,13 +172,7 @@ bool Foam::fv::actuationDiskSource::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
if (cellSetOption::read(dict))
|
if (cellSetOption::read(dict))
|
||||||
{
|
{
|
||||||
coeffs_.readIfPresent("diskDir", diskDir_);
|
readCoeffs();
|
||||||
coeffs_.readIfPresent("Cp", Cp_);
|
|
||||||
coeffs_.readIfPresent("Ct", Ct_);
|
|
||||||
coeffs_.readIfPresent("diskArea", diskArea_);
|
|
||||||
|
|
||||||
checkData();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -47,12 +47,21 @@ Description
|
|||||||
Usage
|
Usage
|
||||||
Example usage:
|
Example usage:
|
||||||
\verbatim
|
\verbatim
|
||||||
fields (U); // names of fields to apply source
|
actuationDiskSource1
|
||||||
diskDir (-1 0 0); // disk direction
|
{
|
||||||
Cp 0.1; // power coefficient
|
type actuationDiskSource;
|
||||||
Ct 0.5; // thrust coefficient
|
|
||||||
diskArea 5.0; // disk area
|
selectionMode cellSet;
|
||||||
upstreamPoint (0 0 0); // upstream point
|
cellSet actuationDisk1;
|
||||||
|
|
||||||
|
U U; // Name of the velocity field
|
||||||
|
|
||||||
|
diskDir (-1 0 0); // Disk direction
|
||||||
|
Cp 0.1; // Power coefficient
|
||||||
|
Ct 0.5; // Thrust coefficient
|
||||||
|
diskArea 5.0; // Disk area
|
||||||
|
upstreamPoint (0 0 0); // Upstream point
|
||||||
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
|
|
||||||
@ -82,11 +91,13 @@ class actuationDiskSource
|
|||||||
:
|
:
|
||||||
public cellSetOption
|
public cellSetOption
|
||||||
{
|
{
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// Protected data
|
// Protected data
|
||||||
|
|
||||||
|
//- Name of the velocity field
|
||||||
|
word UName_;
|
||||||
|
|
||||||
//- Disk area normal
|
//- Disk area normal
|
||||||
vector diskDir_;
|
vector diskDir_;
|
||||||
|
|
||||||
@ -110,8 +121,8 @@ private:
|
|||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Check data
|
//- Non-virtual read
|
||||||
void checkData() const;
|
void readCoeffs();
|
||||||
|
|
||||||
//- Add resistance to the UEqn
|
//- Add resistance to the UEqn
|
||||||
template<class RhoFieldType>
|
template<class RhoFieldType>
|
||||||
@ -153,31 +164,11 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
// Access
|
// Checks
|
||||||
|
|
||||||
//- Return Cp
|
//- Return the list of fields for which the option adds source term
|
||||||
scalar Cp() const
|
// to the transport equation
|
||||||
{
|
virtual wordList addedToFields() const;
|
||||||
return Cp_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return Ct
|
|
||||||
scalar Ct() const
|
|
||||||
{
|
|
||||||
return Ct_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Normal disk direction
|
|
||||||
const vector& diskDir() const
|
|
||||||
{
|
|
||||||
return diskDir_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Disk area
|
|
||||||
scalar diskArea() const
|
|
||||||
{
|
|
||||||
return diskArea_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Add explicit and implicit contributions
|
// Add explicit and implicit contributions
|
||||||
@ -186,7 +177,7 @@ public:
|
|||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Source term to compressible momentum equation
|
//- Source term to compressible momentum equation
|
||||||
@ -194,7 +185,7 @@ public:
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2015-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2015-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -25,6 +25,7 @@ License
|
|||||||
|
|
||||||
#include "buoyancyEnergy.H"
|
#include "buoyancyEnergy.H"
|
||||||
#include "fvMatrices.H"
|
#include "fvMatrices.H"
|
||||||
|
#include "basicThermo.H"
|
||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
@ -45,6 +46,21 @@ namespace fv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fv::buoyancyEnergy::readCoeffs()
|
||||||
|
{
|
||||||
|
phaseName_ = coeffs_.lookupOrDefault<word>("phase", word::null);
|
||||||
|
|
||||||
|
UName_ =
|
||||||
|
coeffs_.lookupOrDefault<word>
|
||||||
|
(
|
||||||
|
"U",
|
||||||
|
IOobject::groupName("U", phaseName_)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::fv::buoyancyEnergy::buoyancyEnergy
|
Foam::fv::buoyancyEnergy::buoyancyEnergy
|
||||||
@ -56,27 +72,32 @@ Foam::fv::buoyancyEnergy::buoyancyEnergy
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
option(sourceName, modelType, dict, mesh),
|
option(sourceName, modelType, dict, mesh),
|
||||||
UName_(coeffs_.lookupOrDefault<word>("U", "U"))
|
phaseName_(word::null),
|
||||||
|
UName_(word::null)
|
||||||
{
|
{
|
||||||
coeffs_.lookup("fields") >> fieldNames_;
|
readCoeffs();
|
||||||
|
|
||||||
if (fieldNames_.size() != 1)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "settings are:" << fieldNames_ << exit(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
applied_.setSize(fieldNames_.size(), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::wordList Foam::fv::buoyancyEnergy::addedToFields() const
|
||||||
|
{
|
||||||
|
const basicThermo& thermo =
|
||||||
|
mesh_.lookupObject<basicThermo>
|
||||||
|
(
|
||||||
|
IOobject::groupName(basicThermo::dictName, phaseName_)
|
||||||
|
);
|
||||||
|
|
||||||
|
return wordList(1, thermo.he().name());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::buoyancyEnergy::addSup
|
void Foam::fv::buoyancyEnergy::addSup
|
||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const uniformDimensionedVectorField& g =
|
const uniformDimensionedVectorField& g =
|
||||||
@ -88,4 +109,35 @@ void Foam::fv::buoyancyEnergy::addSup
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fv::buoyancyEnergy::addSup
|
||||||
|
(
|
||||||
|
const volScalarField& alpha,
|
||||||
|
const volScalarField& rho,
|
||||||
|
fvMatrix<scalar>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const uniformDimensionedVectorField& g =
|
||||||
|
mesh_.lookupObject<uniformDimensionedVectorField>("g");
|
||||||
|
|
||||||
|
const volVectorField& U = mesh_.lookupObject<volVectorField>(UName_);
|
||||||
|
|
||||||
|
eqn += alpha*rho*(U&g);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::fv::buoyancyEnergy::read(const dictionary& dict)
|
||||||
|
{
|
||||||
|
if (option::read(dict))
|
||||||
|
{
|
||||||
|
readCoeffs();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2015-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2015-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -31,7 +31,12 @@ Description
|
|||||||
Usage
|
Usage
|
||||||
Example usage:
|
Example usage:
|
||||||
\verbatim
|
\verbatim
|
||||||
fields (h); // Name of energy field
|
buoyancyEnergy1
|
||||||
|
{
|
||||||
|
type buoyancyEnergy;
|
||||||
|
|
||||||
|
U U; // Name of the velocity field
|
||||||
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
@ -62,10 +67,19 @@ class buoyancyEnergy
|
|||||||
{
|
{
|
||||||
// Private Data
|
// Private Data
|
||||||
|
|
||||||
//- Name of velocity field; default = U
|
//- Optional phase name
|
||||||
|
word phaseName_;
|
||||||
|
|
||||||
|
//- Name of velocity field; default = U.<phase>
|
||||||
word UName_;
|
word UName_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
@ -89,6 +103,13 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
// Checks
|
||||||
|
|
||||||
|
//- Return the list of fields for which the option adds source term
|
||||||
|
// to the transport equation
|
||||||
|
virtual wordList addedToFields() const;
|
||||||
|
|
||||||
|
|
||||||
// Evaluate
|
// Evaluate
|
||||||
|
|
||||||
//- Add explicit contribution to compressible momentum equation
|
//- Add explicit contribution to compressible momentum equation
|
||||||
@ -96,7 +117,16 @@ public:
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Add explicit contribution to phase momentum equation
|
||||||
|
virtual void addSup
|
||||||
|
(
|
||||||
|
const volScalarField& alpha,
|
||||||
|
const volScalarField& rho,
|
||||||
|
fvMatrix<scalar>& eqn,
|
||||||
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,38 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration | Website: https://openfoam.org
|
|
||||||
\\ / A nd | Copyright (C) 2015-2018 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 "buoyancyEnergy.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
|
||||||
|
|
||||||
bool Foam::fv::buoyancyEnergy::read(const dictionary& dict)
|
|
||||||
{
|
|
||||||
NotImplemented;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2015-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2015-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -45,6 +45,21 @@ namespace fv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fv::buoyancyForce::readCoeffs()
|
||||||
|
{
|
||||||
|
phaseName_ = coeffs_.lookupOrDefault<word>("phase", word::null);
|
||||||
|
|
||||||
|
UName_ =
|
||||||
|
coeffs_.lookupOrDefault<word>
|
||||||
|
(
|
||||||
|
"U",
|
||||||
|
IOobject::groupName("U", phaseName_)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::fv::buoyancyForce::buoyancyForce
|
Foam::fv::buoyancyForce::buoyancyForce
|
||||||
@ -56,6 +71,8 @@ Foam::fv::buoyancyForce::buoyancyForce
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
option(sourceName, modelType, dict, mesh),
|
option(sourceName, modelType, dict, mesh),
|
||||||
|
phaseName_(word::null),
|
||||||
|
UName_(word::null),
|
||||||
g_
|
g_
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
@ -68,24 +85,22 @@ Foam::fv::buoyancyForce::buoyancyForce
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
coeffs_.lookup("fields") >> fieldNames_;
|
readCoeffs();
|
||||||
|
|
||||||
if (fieldNames_.size() != 1)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "settings are:" << fieldNames_ << exit(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
applied_.setSize(fieldNames_.size(), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::wordList Foam::fv::buoyancyForce::addedToFields() const
|
||||||
|
{
|
||||||
|
return wordList(1, UName_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::buoyancyForce::addSup
|
void Foam::fv::buoyancyForce::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
eqn += g_;
|
eqn += g_;
|
||||||
@ -96,11 +111,37 @@ void Foam::fv::buoyancyForce::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
eqn += rho*g_;
|
eqn += rho*g_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fv::buoyancyForce::addSup
|
||||||
|
(
|
||||||
|
const volScalarField& alpha,
|
||||||
|
const volScalarField& rho,
|
||||||
|
fvMatrix<vector>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
eqn += alpha*rho*g_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::fv::buoyancyForce::read(const dictionary& dict)
|
||||||
|
{
|
||||||
|
if (option::read(dict))
|
||||||
|
{
|
||||||
|
readCoeffs();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2015-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2015-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -31,7 +31,12 @@ Description
|
|||||||
Usage
|
Usage
|
||||||
Example usage:
|
Example usage:
|
||||||
\verbatim
|
\verbatim
|
||||||
fields (U); // Name of velocity field
|
buoyancyForce1
|
||||||
|
{
|
||||||
|
type buoyancyForce;
|
||||||
|
|
||||||
|
U U; // Name of the velocity field
|
||||||
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
@ -62,9 +67,22 @@ class buoyancyForce
|
|||||||
{
|
{
|
||||||
// Private Data
|
// Private Data
|
||||||
|
|
||||||
|
//- Optional phase name
|
||||||
|
word phaseName_;
|
||||||
|
|
||||||
|
//- Name of the velocity field
|
||||||
|
word UName_;
|
||||||
|
|
||||||
|
//- Gravitational acceleration
|
||||||
uniformDimensionedVectorField g_;
|
uniformDimensionedVectorField g_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
@ -88,13 +106,20 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
// Checks
|
||||||
|
|
||||||
|
//- Return the list of fields for which the option adds source term
|
||||||
|
// to the transport equation
|
||||||
|
virtual wordList addedToFields() const;
|
||||||
|
|
||||||
|
|
||||||
// Evaluate
|
// Evaluate
|
||||||
|
|
||||||
//- Add explicit contribution to incompressible momentum equation
|
//- Add explicit contribution to incompressible momentum equation
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Add explicit contribution to compressible momentum equation
|
//- Add explicit contribution to compressible momentum equation
|
||||||
@ -102,7 +127,16 @@ public:
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Add explicit contribution to phase momentum equation
|
||||||
|
virtual void addSup
|
||||||
|
(
|
||||||
|
const volScalarField& alpha,
|
||||||
|
const volScalarField& rho,
|
||||||
|
fvMatrix<vector>& eqn,
|
||||||
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,38 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration | Website: https://openfoam.org
|
|
||||||
\\ / A nd | Copyright (C) 2015-2018 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 "buoyancyForce.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
|
||||||
|
|
||||||
bool Foam::fv::buoyancyForce::read(const dictionary& dict)
|
|
||||||
{
|
|
||||||
NotImplemented;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2017-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -40,6 +40,84 @@ namespace fv
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fv::damping::readCoeffs()
|
||||||
|
{
|
||||||
|
UName_ = coeffs_.lookupOrDefault<word>("U", "U");
|
||||||
|
|
||||||
|
lambda_ =
|
||||||
|
dimensionedScalar
|
||||||
|
(
|
||||||
|
lambda_.name(),
|
||||||
|
lambda_.dimensions(),
|
||||||
|
coeffs_.lookup(lambda_.name())
|
||||||
|
);
|
||||||
|
|
||||||
|
const bool foundScale = coeffs_.found("scale");
|
||||||
|
const bool foundOgn = coeffs_.found("origin");
|
||||||
|
const bool foundDir = coeffs_.found("direction");
|
||||||
|
const bool foundOgns = coeffs_.found("origins");
|
||||||
|
const bool foundDirs = coeffs_.found("directions");
|
||||||
|
const bool foundAll =
|
||||||
|
foundScale
|
||||||
|
&& (
|
||||||
|
(foundOgn && foundDir && !foundOgns && !foundDirs)
|
||||||
|
|| (!foundOgn && !foundDir && foundOgns && foundDirs)
|
||||||
|
);
|
||||||
|
const bool foundAny =
|
||||||
|
foundScale || foundOgn || foundDir || foundOgns || foundDirs;
|
||||||
|
|
||||||
|
if (!foundAll)
|
||||||
|
{
|
||||||
|
scale_ = autoPtr<Function1<scalar>>();
|
||||||
|
origins_.clear();
|
||||||
|
directions_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (foundAll)
|
||||||
|
{
|
||||||
|
scale_ = Function1<scalar>::New("scale", coeffs_);
|
||||||
|
if (foundOgn)
|
||||||
|
{
|
||||||
|
origins_.setSize(1);
|
||||||
|
directions_.setSize(1);
|
||||||
|
coeffs_.lookup("origin") >> origins_.last();
|
||||||
|
coeffs_.lookup("direction") >> directions_.last();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
coeffs_.lookup("origins") >> origins_;
|
||||||
|
coeffs_.lookup("directions") >> directions_;
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
origins_.size() == 0
|
||||||
|
|| directions_.size() == 0
|
||||||
|
|| origins_.size() != directions_.size()
|
||||||
|
)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "The same, non-zero number of origins and "
|
||||||
|
<< "directions must be provided" << exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
forAll(directions_, i)
|
||||||
|
{
|
||||||
|
directions_[i] /= mag(directions_[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!foundAll && foundAny)
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "The scaling specification is incomplete. \"scale\", "
|
||||||
|
<< "\"origin\" and \"direction\" (or \"origins\" and "
|
||||||
|
<< "\"directions\"), must all be specified in order to scale "
|
||||||
|
<< "the damping. The damping will be applied uniformly across "
|
||||||
|
<< "the cell set." << endl << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::tmp<Foam::volScalarField::Internal> Foam::fv::damping::forceCoeff() const
|
Foam::tmp<Foam::volScalarField::Internal> Foam::fv::damping::forceCoeff() const
|
||||||
{
|
{
|
||||||
tmp<volScalarField::Internal> tforceCoeff
|
tmp<volScalarField::Internal> tforceCoeff
|
||||||
@ -102,97 +180,29 @@ Foam::fv::damping::damping
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
cellSetOption(name, modelType, dict, mesh),
|
cellSetOption(name, modelType, dict, mesh),
|
||||||
lambda_("lambda", dimless/dimTime, coeffs_.lookup("lambda")),
|
UName_(word::null),
|
||||||
scale_(),
|
lambda_("lambda", dimless/dimTime, NaN),
|
||||||
|
scale_(nullptr),
|
||||||
origins_(),
|
origins_(),
|
||||||
directions_()
|
directions_()
|
||||||
{
|
{
|
||||||
read(dict);
|
readCoeffs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::wordList Foam::fv::damping::addedToFields() const
|
||||||
|
{
|
||||||
|
return wordList(1, UName_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::fv::damping::read(const dictionary& dict)
|
bool Foam::fv::damping::read(const dictionary& dict)
|
||||||
{
|
{
|
||||||
if (cellSetOption::read(dict))
|
if (cellSetOption::read(dict))
|
||||||
{
|
{
|
||||||
lambda_ =
|
readCoeffs();
|
||||||
dimensionedScalar
|
|
||||||
(
|
|
||||||
lambda_.name(),
|
|
||||||
lambda_.dimensions(),
|
|
||||||
coeffs_.lookup(lambda_.name())
|
|
||||||
);
|
|
||||||
|
|
||||||
const bool foundScale = coeffs_.found("scale");
|
|
||||||
const bool foundOgn = coeffs_.found("origin");
|
|
||||||
const bool foundDir = coeffs_.found("direction");
|
|
||||||
const bool foundOgns = coeffs_.found("origins");
|
|
||||||
const bool foundDirs = coeffs_.found("directions");
|
|
||||||
const bool foundAll =
|
|
||||||
foundScale
|
|
||||||
&& (
|
|
||||||
(foundOgn && foundDir && !foundOgns && !foundDirs)
|
|
||||||
|| (!foundOgn && !foundDir && foundOgns && foundDirs)
|
|
||||||
);
|
|
||||||
const bool foundAny =
|
|
||||||
foundScale || foundOgn || foundDir || foundOgns || foundDirs;
|
|
||||||
|
|
||||||
if (!foundAll)
|
|
||||||
{
|
|
||||||
scale_ = autoPtr<Function1<scalar>>();
|
|
||||||
origins_.clear();
|
|
||||||
directions_.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (foundAll)
|
|
||||||
{
|
|
||||||
scale_ = Function1<scalar>::New("scale", coeffs_);
|
|
||||||
if (foundOgn)
|
|
||||||
{
|
|
||||||
origins_.setSize(1);
|
|
||||||
directions_.setSize(1);
|
|
||||||
coeffs_.lookup("origin") >> origins_.last();
|
|
||||||
coeffs_.lookup("direction") >> directions_.last();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
coeffs_.lookup("origins") >> origins_;
|
|
||||||
coeffs_.lookup("directions") >> directions_;
|
|
||||||
|
|
||||||
if
|
|
||||||
(
|
|
||||||
origins_.size() == 0
|
|
||||||
|| directions_.size() == 0
|
|
||||||
|| origins_.size() != directions_.size()
|
|
||||||
)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "The same, non-zero number of origins and "
|
|
||||||
<< "directions must be provided" << exit(FatalError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
forAll(directions_, i)
|
|
||||||
{
|
|
||||||
directions_[i] /= mag(directions_[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!foundAll && foundAny)
|
|
||||||
{
|
|
||||||
WarningInFunction
|
|
||||||
<< "The scaling specification is incomplete. \"scale\", "
|
|
||||||
<< "\"origin\" and \"direction\" (or \"origins\" and "
|
|
||||||
<< "\"directions\"), must all be specified in order to scale "
|
|
||||||
<< "the damping. The damping will be applied uniformly across "
|
|
||||||
<< "the cell set." << endl << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
fieldNames_ = wordList(1, coeffs_.lookupOrDefault<word>("U", "U"));
|
|
||||||
|
|
||||||
applied_.setSize(1, false);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2017-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2017-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -62,6 +62,9 @@ protected:
|
|||||||
|
|
||||||
// Protected Data
|
// Protected Data
|
||||||
|
|
||||||
|
//- Name of the velocity field
|
||||||
|
word UName_;
|
||||||
|
|
||||||
//- Damping coefficient [1/s]
|
//- Damping coefficient [1/s]
|
||||||
dimensionedScalar lambda_;
|
dimensionedScalar lambda_;
|
||||||
|
|
||||||
@ -77,6 +80,10 @@ protected:
|
|||||||
|
|
||||||
// Protected Member Functions
|
// Protected Member Functions
|
||||||
|
|
||||||
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
|
//- Return the force coefficient
|
||||||
tmp<volScalarField::Internal> forceCoeff() const;
|
tmp<volScalarField::Internal> forceCoeff() const;
|
||||||
|
|
||||||
|
|
||||||
@ -105,6 +112,13 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
// Checks
|
||||||
|
|
||||||
|
//- Return the list of fields for which the option adds source term
|
||||||
|
// to the transport equation
|
||||||
|
virtual wordList addedToFields() const;
|
||||||
|
|
||||||
|
|
||||||
// IO
|
// IO
|
||||||
|
|
||||||
//- Read dictionary
|
//- Read dictionary
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2019-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2019-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -42,6 +42,18 @@ namespace fv
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fv::isotropicDamping::readCoeffs()
|
||||||
|
{
|
||||||
|
value_ =
|
||||||
|
dimensionedVector
|
||||||
|
(
|
||||||
|
value_.name(),
|
||||||
|
value_.dimensions(),
|
||||||
|
coeffs_.lookup(value_.name())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::isotropicDamping::add
|
void Foam::fv::isotropicDamping::add
|
||||||
(
|
(
|
||||||
const volScalarField::Internal& forceCoeff,
|
const volScalarField::Internal& forceCoeff,
|
||||||
@ -64,9 +76,9 @@ Foam::fv::isotropicDamping::isotropicDamping
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
damping(name, modelType, dict, mesh),
|
damping(name, modelType, dict, mesh),
|
||||||
value_("value", dimVelocity, coeffs_.lookup("value"))
|
value_("value", dimVelocity, vector::uniform(NaN))
|
||||||
{
|
{
|
||||||
read(dict);
|
readCoeffs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -75,7 +87,7 @@ Foam::fv::isotropicDamping::isotropicDamping
|
|||||||
void Foam::fv::isotropicDamping::addSup
|
void Foam::fv::isotropicDamping::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
add(this->forceCoeff(), eqn);
|
add(this->forceCoeff(), eqn);
|
||||||
@ -86,7 +98,7 @@ void Foam::fv::isotropicDamping::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
add(rho*forceCoeff(), eqn);
|
add(rho*forceCoeff(), eqn);
|
||||||
@ -98,7 +110,7 @@ void Foam::fv::isotropicDamping::addSup
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
add(alpha()*rho()*this->forceCoeff(), eqn);
|
add(alpha()*rho()*this->forceCoeff(), eqn);
|
||||||
@ -109,14 +121,7 @@ bool Foam::fv::isotropicDamping::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
if (damping::read(dict))
|
if (damping::read(dict))
|
||||||
{
|
{
|
||||||
value_ =
|
readCoeffs();
|
||||||
dimensionedVector
|
|
||||||
(
|
|
||||||
value_.name(),
|
|
||||||
value_.dimensions(),
|
|
||||||
coeffs_.lookup(value_.name())
|
|
||||||
);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2019-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2019-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -25,7 +25,6 @@ Class
|
|||||||
Foam::fv::isotropicDamping
|
Foam::fv::isotropicDamping
|
||||||
|
|
||||||
Description
|
Description
|
||||||
|
|
||||||
This fvOption applies an implicit damping force to all components of the
|
This fvOption applies an implicit damping force to all components of the
|
||||||
vector field to relax the field towards a specified uniform value. Its
|
vector field to relax the field towards a specified uniform value. Its
|
||||||
intended purpose is to damp the motions of an interface in the region
|
intended purpose is to damp the motions of an interface in the region
|
||||||
@ -50,12 +49,8 @@ Usage
|
|||||||
|
|
||||||
value (2 0 0); // Value towards which the field it relaxed
|
value (2 0 0); // Value towards which the field it relaxed
|
||||||
lambda [0 0 -1 0 0 0 0] 1; // Damping coefficient
|
lambda [0 0 -1 0 0 0 0] 1; // Damping coefficient
|
||||||
|
|
||||||
timeStart 0;
|
|
||||||
duration 1e6;
|
|
||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
Example usage with graduated onset:
|
Example usage with graduated onset:
|
||||||
\verbatim
|
\verbatim
|
||||||
isotropicDamping1
|
isotropicDamping1
|
||||||
@ -68,7 +63,7 @@ Usage
|
|||||||
origin (1200 0 0);
|
origin (1200 0 0);
|
||||||
direction (1 0 0);
|
direction (1 0 0);
|
||||||
|
|
||||||
// Or, define multiple lines
|
// // Or, define multiple lines
|
||||||
// origins ((1200 0 0) (1200 -300 0) (1200 300 0));
|
// origins ((1200 0 0) (1200 -300 0) (1200 300 0));
|
||||||
// directions ((1 0 0) (0 -1 0) (0 1 0));
|
// directions ((1 0 0) (0 -1 0) (0 1 0));
|
||||||
|
|
||||||
@ -79,11 +74,9 @@ Usage
|
|||||||
duration 600;
|
duration 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
value (2 0 0); // Value towards which the field it relaxed
|
value (2 0 0); // Value towards which the field is
|
||||||
|
// relaxed
|
||||||
lambda [0 0 -1 0 0 0 0] 1; // Damping coefficient
|
lambda [0 0 -1 0 0 0 0] 1; // Damping coefficient
|
||||||
|
|
||||||
timeStart 0;
|
|
||||||
duration 1e6;
|
|
||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
@ -124,6 +117,9 @@ class isotropicDamping
|
|||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
//- Source term to momentum equation
|
//- Source term to momentum equation
|
||||||
void add
|
void add
|
||||||
(
|
(
|
||||||
@ -163,7 +159,7 @@ public:
|
|||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Source term to compressible momentum equation
|
//- Source term to compressible momentum equation
|
||||||
@ -171,7 +167,7 @@ public:
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Source term to phase momentum equation
|
//- Source term to phase momentum equation
|
||||||
@ -180,7 +176,7 @@ public:
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2017-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2017-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -68,9 +68,7 @@ Foam::fv::verticalDamping::verticalDamping
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
damping(name, modelType, dict, mesh)
|
damping(name, modelType, dict, mesh)
|
||||||
{
|
{}
|
||||||
read(dict);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
@ -78,7 +76,7 @@ Foam::fv::verticalDamping::verticalDamping
|
|||||||
void Foam::fv::verticalDamping::addSup
|
void Foam::fv::verticalDamping::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
add(eqn.psi(), eqn);
|
add(eqn.psi(), eqn);
|
||||||
@ -89,7 +87,7 @@ void Foam::fv::verticalDamping::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
add(rho*eqn.psi(), eqn);
|
add(rho*eqn.psi(), eqn);
|
||||||
@ -101,7 +99,7 @@ void Foam::fv::verticalDamping::addSup
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
add(alpha*rho*eqn.psi(), eqn);
|
add(alpha*rho*eqn.psi(), eqn);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2017-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2017-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -66,7 +66,6 @@ Usage
|
|||||||
duration 1e6;
|
duration 1e6;
|
||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
Example usage with graduated onset:
|
Example usage with graduated onset:
|
||||||
\verbatim
|
\verbatim
|
||||||
verticalDamping1
|
verticalDamping1
|
||||||
@ -167,7 +166,7 @@ public:
|
|||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Source term to compressible momentum equation
|
//- Source term to compressible momentum equation
|
||||||
@ -175,7 +174,7 @@ public:
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Source term to phase momentum equation
|
//- Source term to phase momentum equation
|
||||||
@ -184,7 +183,7 @@ public:
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -48,8 +48,34 @@ namespace fv
|
|||||||
|
|
||||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::fv::effectivenessHeatExchangerSource::initialise()
|
void Foam::fv::effectivenessHeatExchangerSource::readCoeffs()
|
||||||
{
|
{
|
||||||
|
secondaryMassFlowRate_ = coeffs_.lookup<scalar>("secondaryMassFlowRate");
|
||||||
|
secondaryInletT_ = coeffs_.lookup<scalar>("secondaryInletT");
|
||||||
|
primaryInletT_ = coeffs_.lookup<scalar>("primaryInletT");
|
||||||
|
|
||||||
|
eTable_.reset(Function2<scalar>::New("effectiveness", coeffs_).ptr());
|
||||||
|
|
||||||
|
UName_ = coeffs_.lookupOrDefault<word>("U", "U");
|
||||||
|
TName_ = coeffs_.lookupOrDefault<word>("T", "T");
|
||||||
|
phiName_ = coeffs_.lookupOrDefault<word>("phi", "phi");
|
||||||
|
|
||||||
|
faceZoneName_ = coeffs_.lookup<word>("faceZone");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fv::effectivenessHeatExchangerSource::setZone()
|
||||||
|
{
|
||||||
|
zoneID_ = mesh_.faceZones().findZoneID(faceZoneName_);
|
||||||
|
if (zoneID_ < 0)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< type() << " " << this->name() << ": "
|
||||||
|
<< " Unknown face zone name: " << faceZoneName_
|
||||||
|
<< ". Valid face zones are: " << mesh_.faceZones().names()
|
||||||
|
<< nl << exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
const faceZone& fZone = mesh_.faceZones()[zoneID_];
|
const faceZone& fZone = mesh_.faceZones()[zoneID_];
|
||||||
|
|
||||||
faceId_.setSize(fZone.size());
|
faceId_.setSize(fZone.size());
|
||||||
@ -150,50 +176,41 @@ Foam::fv::effectivenessHeatExchangerSource::effectivenessHeatExchangerSource
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
cellSetOption(name, modelType, dict, mesh),
|
cellSetOption(name, modelType, dict, mesh),
|
||||||
secondaryMassFlowRate_(coeffs_.lookup<scalar>("secondaryMassFlowRate")),
|
secondaryMassFlowRate_(NaN),
|
||||||
secondaryInletT_(coeffs_.lookup<scalar>("secondaryInletT")),
|
secondaryInletT_(NaN),
|
||||||
primaryInletT_(coeffs_.lookup<scalar>("primaryInletT")),
|
primaryInletT_(NaN),
|
||||||
eTable_(Function2<scalar>::New("effectiveness", coeffs_)),
|
eTable_(nullptr),
|
||||||
UName_(coeffs_.lookupOrDefault<word>("U", "U")),
|
UName_(word::null),
|
||||||
TName_(coeffs_.lookupOrDefault<word>("T", "T")),
|
TName_(word::null),
|
||||||
phiName_(coeffs_.lookupOrDefault<word>("phi", "phi")),
|
phiName_(word::null),
|
||||||
faceZoneName_(coeffs_.lookup("faceZone")),
|
faceZoneName_(word::null),
|
||||||
zoneID_(mesh_.faceZones().findZoneID(faceZoneName_)),
|
zoneID_(-1),
|
||||||
faceId_(),
|
faceId_(),
|
||||||
facePatchId_(),
|
facePatchId_(),
|
||||||
faceSign_(),
|
faceSign_(),
|
||||||
faceZoneArea_(0)
|
faceZoneArea_(NaN)
|
||||||
{
|
{
|
||||||
if (zoneID_ < 0)
|
readCoeffs();
|
||||||
{
|
setZone();
|
||||||
FatalErrorInFunction
|
|
||||||
<< type() << " " << this->name() << ": "
|
|
||||||
<< " Unknown face zone name: " << faceZoneName_
|
|
||||||
<< ". Valid face zones are: " << mesh_.faceZones().names()
|
|
||||||
<< nl << exit(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the field name to that of the energy field from which the temperature
|
|
||||||
// is obtained
|
|
||||||
|
|
||||||
const basicThermo& thermo =
|
|
||||||
mesh_.lookupObject<basicThermo>(basicThermo::dictName);
|
|
||||||
|
|
||||||
fieldNames_.setSize(1, thermo.he().name());
|
|
||||||
|
|
||||||
applied_.setSize(1, false);
|
|
||||||
|
|
||||||
initialise();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::wordList Foam::fv::effectivenessHeatExchangerSource::addedToFields() const
|
||||||
|
{
|
||||||
|
const basicThermo& thermo =
|
||||||
|
mesh_.lookupObject<basicThermo>(basicThermo::dictName);
|
||||||
|
|
||||||
|
return wordList(1, thermo.he().name());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::effectivenessHeatExchangerSource::addSup
|
void Foam::fv::effectivenessHeatExchangerSource::addSup
|
||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const basicThermo& thermo =
|
const basicThermo& thermo =
|
||||||
@ -297,10 +314,8 @@ bool Foam::fv::effectivenessHeatExchangerSource::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
if (cellSetOption::read(dict))
|
if (cellSetOption::read(dict))
|
||||||
{
|
{
|
||||||
coeffs_.lookup("secondaryMassFlowRate") >> secondaryMassFlowRate_;
|
readCoeffs();
|
||||||
coeffs_.lookup("secondaryInletT") >> secondaryInletT_;
|
setZone();
|
||||||
coeffs_.lookup("primaryInletT") >> primaryInletT_;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -64,23 +64,21 @@ Usage
|
|||||||
\verbatim
|
\verbatim
|
||||||
effectivenessHeatExchangerSource1
|
effectivenessHeatExchangerSource1
|
||||||
{
|
{
|
||||||
type effectivenessHeatExchangerSource;
|
type effectivenessHeatExchangerSource;
|
||||||
|
|
||||||
selectionMode cellZone;
|
selectionMode cellZone;
|
||||||
cellZone porosity;
|
cellZone porosity;
|
||||||
|
|
||||||
secondaryMassFlowRate 1.0;
|
secondaryMassFlowRate 1.0;
|
||||||
secondaryInletT 336;
|
secondaryInletT 336;
|
||||||
primaryInletT 293;
|
primaryInletT 293;
|
||||||
|
|
||||||
faceZone facesZoneInletOriented;
|
faceZone facesZoneInletOriented;
|
||||||
|
|
||||||
effectiveness <function2>;
|
effectiveness <function2>;
|
||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
The effectiveness Function2 is described in terms of the primary and
|
|
||||||
secondary mass flow rates and has the same units as the secondary mass flow
|
|
||||||
rate and kg/s for phi.
|
|
||||||
|
|
||||||
Note
|
Note
|
||||||
- The effectiveness Function2 is described in terms of the primary and
|
- The effectiveness Function2 is described in terms of the primary and
|
||||||
secondary mass flow rates and has the same units as the secondary mass
|
secondary mass flow rates and has the same units as the secondary mass
|
||||||
@ -115,10 +113,7 @@ class effectivenessHeatExchangerSource
|
|||||||
:
|
:
|
||||||
public cellSetOption
|
public cellSetOption
|
||||||
{
|
{
|
||||||
|
// Private data
|
||||||
protected:
|
|
||||||
|
|
||||||
// Protected data
|
|
||||||
|
|
||||||
//- Secondary flow mass rate [kg/s]
|
//- Secondary flow mass rate [kg/s]
|
||||||
scalar secondaryMassFlowRate_;
|
scalar secondaryMassFlowRate_;
|
||||||
@ -165,8 +160,11 @@ private:
|
|||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Initialise heat exchanger source model
|
//- Non-virtual read
|
||||||
void initialise();
|
void readCoeffs();
|
||||||
|
|
||||||
|
//- Set the zone information
|
||||||
|
void setZone();
|
||||||
|
|
||||||
//- Calculate total area of faceZone across processors
|
//- Calculate total area of faceZone across processors
|
||||||
void calculateTotalArea(scalar& area) const;
|
void calculateTotalArea(scalar& area) const;
|
||||||
@ -203,22 +201,16 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Explicit and implicit source
|
//- Return the list of fields for which the option adds source term
|
||||||
virtual void addSup
|
// to the transport equation
|
||||||
(
|
virtual wordList addedToFields() const;
|
||||||
fvMatrix<scalar>& eqn,
|
|
||||||
const label fieldi
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
NotImplemented;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Explicit and implicit source for compressible equation
|
//- Explicit and implicit source for compressible equation
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Read dictionary
|
//- Read dictionary
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -46,20 +46,18 @@ namespace fv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::fv::explicitPorositySource::explicitPorositySource
|
void Foam::fv::explicitPorositySource::readCoeffs()
|
||||||
(
|
|
||||||
const word& name,
|
|
||||||
const word& modelType,
|
|
||||||
const dictionary& dict,
|
|
||||||
const fvMesh& mesh
|
|
||||||
)
|
|
||||||
:
|
|
||||||
cellSetOption(name, modelType, dict, mesh),
|
|
||||||
porosityPtr_(nullptr)
|
|
||||||
{
|
{
|
||||||
read(dict);
|
if (coeffs_.found("UNames"))
|
||||||
|
{
|
||||||
|
UNames_ = wordList(coeffs_.lookup("UNames"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UNames_ = wordList(1, coeffs_.lookupOrDefault<word>("U", "U"));
|
||||||
|
}
|
||||||
|
|
||||||
porosityPtr_.reset
|
porosityPtr_.reset
|
||||||
(
|
(
|
||||||
@ -74,12 +72,37 @@ Foam::fv::explicitPorositySource::explicitPorositySource
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::fv::explicitPorositySource::explicitPorositySource
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const word& modelType,
|
||||||
|
const dictionary& dict,
|
||||||
|
const fvMesh& mesh
|
||||||
|
)
|
||||||
|
:
|
||||||
|
cellSetOption(name, modelType, dict, mesh),
|
||||||
|
UNames_(),
|
||||||
|
porosityPtr_(nullptr)
|
||||||
|
{
|
||||||
|
readCoeffs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::wordList Foam::fv::explicitPorositySource::addedToFields() const
|
||||||
|
{
|
||||||
|
return UNames_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::explicitPorositySource::addSup
|
void Foam::fv::explicitPorositySource::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
|
fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
|
||||||
@ -92,7 +115,7 @@ void Foam::fv::explicitPorositySource::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
|
fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
|
||||||
@ -106,7 +129,7 @@ void Foam::fv::explicitPorositySource::addSup
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
|
fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
|
||||||
@ -119,22 +142,7 @@ bool Foam::fv::explicitPorositySource::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
if (cellSetOption::read(dict))
|
if (cellSetOption::read(dict))
|
||||||
{
|
{
|
||||||
if (coeffs_.found("UNames"))
|
readCoeffs();
|
||||||
{
|
|
||||||
coeffs_.lookup("UNames") >> fieldNames_;
|
|
||||||
}
|
|
||||||
else if (coeffs_.found("U"))
|
|
||||||
{
|
|
||||||
word UName(coeffs_.lookup("U"));
|
|
||||||
fieldNames_ = wordList(1, UName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fieldNames_ = wordList(1, "U");
|
|
||||||
}
|
|
||||||
|
|
||||||
applied_.setSize(fieldNames_.size(), false);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -54,7 +54,7 @@ Usage
|
|||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
Note:
|
Note
|
||||||
The porous region must be selected as a cellZone.
|
The porous region must be selected as a cellZone.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
@ -86,14 +86,21 @@ class explicitPorositySource
|
|||||||
:
|
:
|
||||||
public cellSetOption
|
public cellSetOption
|
||||||
{
|
{
|
||||||
protected:
|
// Private data
|
||||||
|
|
||||||
// Protected data
|
//- Names of the velocity fields
|
||||||
|
wordList UNames_;
|
||||||
|
|
||||||
//- Run-time selectable porosity model
|
//- Run-time selectable porosity model
|
||||||
mutable autoPtr<porosityModel> porosityPtr_;
|
mutable autoPtr<porosityModel> porosityPtr_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
@ -122,10 +129,21 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
const porosityModel& model() const
|
// Access
|
||||||
{
|
|
||||||
return porosityPtr_();
|
//- Return the porosity model
|
||||||
}
|
const porosityModel& model() const
|
||||||
|
{
|
||||||
|
return porosityPtr_();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Checks
|
||||||
|
|
||||||
|
//- Return the list of fields for which the option adds source term
|
||||||
|
// to the transport equation
|
||||||
|
virtual wordList addedToFields() const;
|
||||||
|
|
||||||
|
|
||||||
// Add explicit and implicit contributions
|
// Add explicit and implicit contributions
|
||||||
|
|
||||||
@ -133,7 +151,7 @@ public:
|
|||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Add implicit contribution to compressible momentum equation
|
//- Add implicit contribution to compressible momentum equation
|
||||||
@ -141,7 +159,7 @@ public:
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Add implicit contribution to phase momentum equation
|
//- Add implicit contribution to phase momentum equation
|
||||||
@ -150,7 +168,7 @@ public:
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -47,7 +47,17 @@ namespace fv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fv::meanVelocityForce::readCoeffs()
|
||||||
|
{
|
||||||
|
UName_ = coeffs_.lookupOrDefault<word>("U", "U");
|
||||||
|
|
||||||
|
Ubar_ = coeffs_.lookup<vector>("Ubar");
|
||||||
|
|
||||||
|
relaxation_ = coeffs_.lookupOrDefault<scalar>("relaxation", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::meanVelocityForce::writeProps
|
void Foam::fv::meanVelocityForce::writeProps
|
||||||
(
|
(
|
||||||
@ -86,29 +96,18 @@ Foam::fv::meanVelocityForce::meanVelocityForce
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
cellSetOption(sourceName, modelType, dict, mesh),
|
cellSetOption(sourceName, modelType, dict, mesh),
|
||||||
Ubar_(coeffs_.lookup("Ubar")),
|
UName_(word::null),
|
||||||
gradP0_(0.0),
|
Ubar_(vector::uniform(NaN)),
|
||||||
dGradP_(0.0),
|
relaxation_(NaN),
|
||||||
flowDir_(Ubar_/mag(Ubar_)),
|
gradP0_(0),
|
||||||
relaxation_(coeffs_.lookupOrDefault<scalar>("relaxation", 1.0)),
|
dGradP_(0),
|
||||||
rAPtr_(nullptr)
|
rAPtr_(nullptr)
|
||||||
{
|
{
|
||||||
coeffs_.lookup("fields") >> fieldNames_;
|
|
||||||
|
|
||||||
if (fieldNames_.size() != 1)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "settings are:" << fieldNames_ << exit(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
applied_.setSize(fieldNames_.size(), false);
|
|
||||||
|
|
||||||
// Read the initial pressure gradient from file if it exists
|
// Read the initial pressure gradient from file if it exists
|
||||||
IFstream propsFile
|
IFstream propsFile
|
||||||
(
|
(
|
||||||
mesh_.time().timePath()/"uniform"/(name_ + "Properties")
|
mesh_.time().timePath()/"uniform"/(name_ + "Properties")
|
||||||
);
|
);
|
||||||
|
|
||||||
if (propsFile.good())
|
if (propsFile.good())
|
||||||
{
|
{
|
||||||
Info<< " Reading pressure gradient from file" << endl;
|
Info<< " Reading pressure gradient from file" << endl;
|
||||||
@ -122,25 +121,27 @@ Foam::fv::meanVelocityForce::meanVelocityForce
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::wordList Foam::fv::meanVelocityForce::addedToFields() const
|
||||||
|
{
|
||||||
|
return wordList(1, UName_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::scalar Foam::fv::meanVelocityForce::magUbarAve
|
Foam::scalar Foam::fv::meanVelocityForce::magUbarAve
|
||||||
(
|
(
|
||||||
const volVectorField& U
|
const volVectorField& U
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
scalar magUbarAve = 0.0;
|
const labelList& cells = this->cells();
|
||||||
|
|
||||||
const scalarField& cv = mesh_.V();
|
const scalarField& cv = mesh_.V();
|
||||||
|
|
||||||
const labelList& cells = this->cells();
|
scalar magUbarAve = 0;
|
||||||
|
|
||||||
forAll(cells, i)
|
forAll(cells, i)
|
||||||
{
|
{
|
||||||
const label celli = cells[i];
|
const label celli = cells[i];
|
||||||
magUbarAve += (flowDir_ & U[celli])*cv[celli];
|
magUbarAve += (normalised(Ubar_) & U[celli])*cv[celli];
|
||||||
}
|
}
|
||||||
|
|
||||||
reduce(magUbarAve, sumOp<scalar>());
|
reduce(magUbarAve, sumOp<scalar>());
|
||||||
|
|
||||||
magUbarAve /= V();
|
magUbarAve /= V();
|
||||||
|
|
||||||
return magUbarAve;
|
return magUbarAve;
|
||||||
@ -151,25 +152,20 @@ void Foam::fv::meanVelocityForce::correct(volVectorField& U) const
|
|||||||
{
|
{
|
||||||
const scalarField& rAU = rAPtr_();
|
const scalarField& rAU = rAPtr_();
|
||||||
|
|
||||||
// Integrate flow variables over cell set
|
const labelList& cells = this->cells();
|
||||||
scalar rAUave = 0.0;
|
|
||||||
const scalarField& cv = mesh_.V();
|
const scalarField& cv = mesh_.V();
|
||||||
|
|
||||||
const labelList& cells = this->cells();
|
// Average rAU over the cell set
|
||||||
|
scalar rAUave = 0;
|
||||||
forAll(cells, i)
|
forAll(cells, i)
|
||||||
{
|
{
|
||||||
const label celli = cells[i];
|
const label celli = cells[i];
|
||||||
rAUave += rAU[celli]*cv[celli];
|
rAUave += rAU[celli]*cv[celli];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect across all processors
|
|
||||||
reduce(rAUave, sumOp<scalar>());
|
reduce(rAUave, sumOp<scalar>());
|
||||||
|
|
||||||
// Volume averages
|
|
||||||
rAUave /= V();
|
rAUave /= V();
|
||||||
|
|
||||||
scalar magUbarAve = this->magUbarAve(U);
|
const scalar magUbarAve = this->magUbarAve(U);
|
||||||
|
|
||||||
// Calculate the pressure gradient increment needed to adjust the average
|
// Calculate the pressure gradient increment needed to adjust the average
|
||||||
// flow-rate to the desired value
|
// flow-rate to the desired value
|
||||||
@ -179,10 +175,10 @@ void Foam::fv::meanVelocityForce::correct(volVectorField& U) const
|
|||||||
forAll(cells, i)
|
forAll(cells, i)
|
||||||
{
|
{
|
||||||
label celli = cells[i];
|
label celli = cells[i];
|
||||||
U[celli] += flowDir_*rAU[celli]*dGradP_;
|
U[celli] += normalised(Ubar_)*rAU[celli]*dGradP_;
|
||||||
}
|
}
|
||||||
|
|
||||||
scalar gradP = gradP0_ + dGradP_;
|
const scalar gradP = gradP0_ + dGradP_;
|
||||||
|
|
||||||
Info<< "Pressure gradient source: uncorrected Ubar = " << magUbarAve
|
Info<< "Pressure gradient source: uncorrected Ubar = " << magUbarAve
|
||||||
<< ", pressure gradient = " << gradP << endl;
|
<< ", pressure gradient = " << gradP << endl;
|
||||||
@ -194,14 +190,14 @@ void Foam::fv::meanVelocityForce::correct(volVectorField& U) const
|
|||||||
void Foam::fv::meanVelocityForce::addSup
|
void Foam::fv::meanVelocityForce::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
volVectorField::Internal Su
|
volVectorField::Internal Su
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name_ + fieldNames_[fieldi] + "Sup",
|
name_ + fieldName + "Sup",
|
||||||
mesh_.time().timeName(),
|
mesh_.time().timeName(),
|
||||||
mesh_,
|
mesh_,
|
||||||
IOobject::NO_READ,
|
IOobject::NO_READ,
|
||||||
@ -211,9 +207,9 @@ void Foam::fv::meanVelocityForce::addSup
|
|||||||
dimensionedVector(eqn.dimensions()/dimVolume, Zero)
|
dimensionedVector(eqn.dimensions()/dimVolume, Zero)
|
||||||
);
|
);
|
||||||
|
|
||||||
scalar gradP = gradP0_ + dGradP_;
|
const scalar gradP = gradP0_ + dGradP_;
|
||||||
|
|
||||||
UIndirectList<vector>(Su, cells()) = flowDir_*gradP;
|
UIndirectList<vector>(Su, cells()) = normalised(Ubar_)*gradP;
|
||||||
|
|
||||||
eqn += Su;
|
eqn += Su;
|
||||||
}
|
}
|
||||||
@ -223,17 +219,17 @@ void Foam::fv::meanVelocityForce::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
this->addSup(eqn, fieldi);
|
this->addSup(eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::meanVelocityForce::constrain
|
void Foam::fv::meanVelocityForce::constrain
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (rAPtr_.empty())
|
if (rAPtr_.empty())
|
||||||
@ -251,18 +247,30 @@ void Foam::fv::meanVelocityForce::constrain
|
|||||||
IOobject::NO_WRITE,
|
IOobject::NO_WRITE,
|
||||||
false
|
false
|
||||||
),
|
),
|
||||||
1.0/eqn.A()
|
1/eqn.A()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rAPtr_() = 1.0/eqn.A();
|
rAPtr_() = 1/eqn.A();
|
||||||
}
|
}
|
||||||
|
|
||||||
gradP0_ += dGradP_;
|
gradP0_ += dGradP_;
|
||||||
dGradP_ = 0.0;
|
dGradP_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::fv::meanVelocityForce::read(const dictionary& dict)
|
||||||
|
{
|
||||||
|
if (cellSetOption::read(dict))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -28,17 +28,25 @@ Description
|
|||||||
Calculates and applies the force necessary to maintain the specified mean
|
Calculates and applies the force necessary to maintain the specified mean
|
||||||
velocity.
|
velocity.
|
||||||
|
|
||||||
Note: Currently only handles kinematic pressure (incompressible solvers).
|
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
Example usage:
|
Example usage:
|
||||||
\verbatim
|
\verbatim
|
||||||
selectionMode all; // Apply force to all cells
|
meanVelocitySource1
|
||||||
fields (U); // Name of velocity field
|
{
|
||||||
Ubar (10.0 0 0); // Desired mean velocity
|
type meanVelocitySource;
|
||||||
relaxation 0.2; // Optional relaxation factor
|
|
||||||
|
selectionMode all;
|
||||||
|
|
||||||
|
U U; // Name of velocity field
|
||||||
|
|
||||||
|
Ubar (10.0 0 0); // Desired mean velocity
|
||||||
|
relaxation 0.2; // Optional relaxation factor
|
||||||
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
|
Note
|
||||||
|
Currently only handles kinematic pressure (incompressible solvers).
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
meanVelocityForce.C
|
meanVelocityForce.C
|
||||||
|
|
||||||
@ -69,30 +77,31 @@ class meanVelocityForce
|
|||||||
:
|
:
|
||||||
public cellSetOption
|
public cellSetOption
|
||||||
{
|
{
|
||||||
protected:
|
// Private data
|
||||||
|
|
||||||
// Protected data
|
//- Name of the velocity field
|
||||||
|
word UName_;
|
||||||
|
|
||||||
//- Average velocity
|
//- Average velocity
|
||||||
vector Ubar_;
|
vector Ubar_;
|
||||||
|
|
||||||
|
//- Relaxation factor
|
||||||
|
scalar relaxation_;
|
||||||
|
|
||||||
//- Pressure gradient before correction
|
//- Pressure gradient before correction
|
||||||
mutable scalar gradP0_;
|
mutable scalar gradP0_;
|
||||||
|
|
||||||
//- Change in pressure gradient
|
//- Change in pressure gradient
|
||||||
mutable scalar dGradP_;
|
mutable scalar dGradP_;
|
||||||
|
|
||||||
//- Flow direction
|
|
||||||
vector flowDir_;
|
|
||||||
|
|
||||||
//- Relaxation factor
|
|
||||||
scalar relaxation_;
|
|
||||||
|
|
||||||
//- Matrix 1/A coefficients field pointer
|
//- Matrix 1/A coefficients field pointer
|
||||||
mutable autoPtr<volScalarField> rAPtr_;
|
mutable autoPtr<volScalarField> rAPtr_;
|
||||||
|
|
||||||
|
|
||||||
// Protected Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
//- Calculate and return the magnitude of the mean velocity
|
//- Calculate and return the magnitude of the mean velocity
|
||||||
// averaged over the selected cellSet
|
// averaged over the selected cellSet
|
||||||
@ -128,6 +137,22 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
|
//- Return the average velocity
|
||||||
|
const vector& Ubar() const
|
||||||
|
{
|
||||||
|
return Ubar_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Checks
|
||||||
|
|
||||||
|
//- Return the list of fields for which the option adds source term
|
||||||
|
// to the transport equation
|
||||||
|
virtual wordList addedToFields() const;
|
||||||
|
|
||||||
|
|
||||||
// Evaluate
|
// Evaluate
|
||||||
|
|
||||||
//- Correct the pressure gradient
|
//- Correct the pressure gradient
|
||||||
@ -137,7 +162,7 @@ public:
|
|||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Add explicit contribution to compressible momentum equation
|
//- Add explicit contribution to compressible momentum equation
|
||||||
@ -145,14 +170,14 @@ public:
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Set 1/A coefficient
|
//- Set 1/A coefficient
|
||||||
virtual void constrain
|
virtual void constrain
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,38 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration | Website: https://openfoam.org
|
|
||||||
\\ / A nd | Copyright (C) 2011-2018 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 "meanVelocityForce.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
|
||||||
|
|
||||||
bool Foam::fv::meanVelocityForce::read(const dictionary& dict)
|
|
||||||
{
|
|
||||||
NotImplemented;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2015-2018 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2015-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -45,6 +45,21 @@ namespace fv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fv::patchMeanVelocityForce::readCoeffs()
|
||||||
|
{
|
||||||
|
patch_ = coeffs_.lookup<word>("patch");
|
||||||
|
|
||||||
|
if (mesh_.boundaryMesh().findPatchID(patch_) < 0)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Cannot find patch " << patch_
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::fv::patchMeanVelocityForce::patchMeanVelocityForce
|
Foam::fv::patchMeanVelocityForce::patchMeanVelocityForce
|
||||||
@ -56,15 +71,9 @@ Foam::fv::patchMeanVelocityForce::patchMeanVelocityForce
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
meanVelocityForce(sourceName, modelType, dict, mesh),
|
meanVelocityForce(sourceName, modelType, dict, mesh),
|
||||||
patch_(coeffs_.lookup("patch")),
|
patch_(word::null)
|
||||||
patchi_(mesh.boundaryMesh().findPatchID(patch_))
|
|
||||||
{
|
{
|
||||||
if (patchi_ < 0)
|
readCoeffs();
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Cannot find patch " << patch_
|
|
||||||
<< exit(FatalError);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -75,25 +84,23 @@ Foam::scalar Foam::fv::patchMeanVelocityForce::magUbarAve
|
|||||||
const volVectorField& U
|
const volVectorField& U
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
vector2D sumAmagUsumA
|
const label patchi = mesh_.boundaryMesh().findPatchID(patch_);
|
||||||
(
|
|
||||||
|
scalar sumA = sum(mesh_.boundary()[patchi].magSf());
|
||||||
|
scalar sumAmagU =
|
||||||
sum
|
sum
|
||||||
(
|
(
|
||||||
(flowDir_ & U.boundaryField()[patchi_])
|
mesh_.boundary()[patchi].magSf()
|
||||||
*mesh_.boundary()[patchi_].magSf()
|
*(normalised(Ubar()) & U.boundaryField()[patchi])
|
||||||
),
|
);
|
||||||
sum(mesh_.boundary()[patchi_].magSf())
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// If the mean velocity force is applied to a cyclic patch
|
// If the mean velocity force is applied to a cyclic patch
|
||||||
// for parallel runs include contributions from processorCyclic patches
|
// for parallel runs include contributions from processorCyclic patches
|
||||||
// generated from the decomposition of the cyclic patch
|
// generated from the decomposition of the cyclic patch
|
||||||
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
||||||
|
if (Pstream::parRun() && isA<cyclicPolyPatch>(patches[patchi]))
|
||||||
if (Pstream::parRun() && isA<cyclicPolyPatch>(patches[patchi_]))
|
|
||||||
{
|
{
|
||||||
labelList processorCyclicPatches
|
const labelList processorCyclicPatches
|
||||||
(
|
(
|
||||||
processorCyclicPolyPatch::patchIDs(patch_, patches)
|
processorCyclicPolyPatch::patchIDs(patch_, patches)
|
||||||
);
|
);
|
||||||
@ -102,20 +109,34 @@ Foam::scalar Foam::fv::patchMeanVelocityForce::magUbarAve
|
|||||||
{
|
{
|
||||||
const label patchi = processorCyclicPatches[pcpi];
|
const label patchi = processorCyclicPatches[pcpi];
|
||||||
|
|
||||||
sumAmagUsumA.x() +=
|
sumA += sum(mesh_.boundary()[patchi].magSf());
|
||||||
|
sumAmagU +=
|
||||||
sum
|
sum
|
||||||
(
|
(
|
||||||
(flowDir_ & U.boundaryField()[patchi])
|
mesh_.boundary()[patchi].magSf()
|
||||||
*mesh_.boundary()[patchi].magSf()
|
*(normalised(Ubar()) & U.boundaryField()[patchi])
|
||||||
);
|
);
|
||||||
|
|
||||||
sumAmagUsumA.y() += sum(mesh_.boundary()[patchi].magSf());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mesh_.reduce(sumAmagUsumA, sumOp<vector2D>());
|
mesh_.reduce(sumA, sumOp<scalar>());
|
||||||
|
mesh_.reduce(sumAmagU, sumOp<scalar>());
|
||||||
|
|
||||||
return sumAmagUsumA.x()/sumAmagUsumA.y();
|
return sumAmagU/sumA;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::fv::patchMeanVelocityForce::read(const dictionary& dict)
|
||||||
|
{
|
||||||
|
if (cellSetOption::read(dict))
|
||||||
|
{
|
||||||
|
readCoeffs();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2015-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2015-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -28,17 +28,26 @@ Description
|
|||||||
Calculates and applies the force necessary to maintain the specified mean
|
Calculates and applies the force necessary to maintain the specified mean
|
||||||
velocity averaged over the specified patch.
|
velocity averaged over the specified patch.
|
||||||
|
|
||||||
Note: Currently only handles kinematic pressure (incompressible solvers).
|
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
Example usage:
|
Example usage:
|
||||||
\verbatim
|
\verbatim
|
||||||
selectionMode all; // Apply force to all cells
|
patchMeanVelocityForce1
|
||||||
fields (U); // Name of velocity field
|
{
|
||||||
patch inlet; // Name of the patch
|
type patchMeanVelocityForce;
|
||||||
Ubar (10.0 0 0); // Desired mean velocity
|
|
||||||
relaxation 0.2; // Optional relaxation factor
|
selectionMode all;
|
||||||
\endverbatim
|
|
||||||
|
U U; // Name of velocity field
|
||||||
|
|
||||||
|
patch inlet; // Name of the patch
|
||||||
|
|
||||||
|
Ubar (10.0 0 0); // Desired mean velocity
|
||||||
|
relaxation 0.2; // Optional relaxation factor
|
||||||
|
}
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
|
Note
|
||||||
|
Currently only handles kinematic pressure (incompressible solvers).
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
patchMeanVelocityForce.C
|
patchMeanVelocityForce.C
|
||||||
@ -65,18 +74,16 @@ class patchMeanVelocityForce
|
|||||||
:
|
:
|
||||||
public meanVelocityForce
|
public meanVelocityForce
|
||||||
{
|
{
|
||||||
protected:
|
// Private data
|
||||||
|
|
||||||
// Protected data
|
|
||||||
|
|
||||||
//- Patch name
|
//- Patch name
|
||||||
word patch_;
|
word patch_;
|
||||||
|
|
||||||
//- Patch index
|
|
||||||
label patchi_;
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
// Protected Member Functions
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
//- Calculate and return the magnitude of the mean velocity
|
//- Calculate and return the magnitude of the mean velocity
|
||||||
// averaged over the specified patch
|
// averaged over the specified patch
|
||||||
@ -100,14 +107,13 @@ public:
|
|||||||
const fvMesh& mesh
|
const fvMesh& mesh
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Disallow default bitwise copy construction
|
|
||||||
patchMeanVelocityForce(const patchMeanVelocityForce&) = delete;
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
// Member Operators
|
// IO
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- Read dictionary
|
||||||
void operator=(const patchMeanVelocityForce&) = delete;
|
virtual bool read(const dictionary& dict);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,88 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration | Website: https://openfoam.org
|
|
||||||
\\ / A nd | Copyright (C) 2017-2020 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 "PhaseLimitStabilization.H"
|
|
||||||
#include "fvMatrices.H"
|
|
||||||
#include "fvmSup.H"
|
|
||||||
#include "uniformDimensionedFields.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
Foam::fv::PhaseLimitStabilization<Type>::PhaseLimitStabilization
|
|
||||||
(
|
|
||||||
const word& name,
|
|
||||||
const word& modelType,
|
|
||||||
const dictionary& dict,
|
|
||||||
const fvMesh& mesh
|
|
||||||
)
|
|
||||||
:
|
|
||||||
option(name, modelType, dict, mesh),
|
|
||||||
fieldName_(coeffs_.lookup("field")),
|
|
||||||
rateName_(coeffs_.lookup("rate")),
|
|
||||||
residualAlpha_(coeffs_.lookup<scalar>("residualAlpha"))
|
|
||||||
{
|
|
||||||
fieldNames_.setSize(1, fieldName_);
|
|
||||||
applied_.setSize(1, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::fv::PhaseLimitStabilization<Type>::addSup
|
|
||||||
(
|
|
||||||
const volScalarField& alpha,
|
|
||||||
const volScalarField& rho,
|
|
||||||
fvMatrix<Type>& eqn,
|
|
||||||
const label fieldi
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
const GeometricField<Type, fvPatchField, volMesh>& psi = eqn.psi();
|
|
||||||
|
|
||||||
uniformDimensionedScalarField& rate =
|
|
||||||
mesh_.lookupObjectRef<uniformDimensionedScalarField>(rateName_);
|
|
||||||
|
|
||||||
eqn -= fvm::Sp(max(residualAlpha_ - alpha, scalar(0))*rho*rate, psi);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
bool Foam::fv::PhaseLimitStabilization<Type>::read(const dictionary& dict)
|
|
||||||
{
|
|
||||||
if (option::read(dict))
|
|
||||||
{
|
|
||||||
coeffs_.lookup("residualAlpha") >> residualAlpha_;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2017-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -23,16 +23,157 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "makeFvOption.H"
|
#include "phaseLimitStabilization.H"
|
||||||
#include "PhaseLimitStabilization.H"
|
#include "fvMatrices.H"
|
||||||
|
#include "fvmSup.H"
|
||||||
|
#include "uniformDimensionedFields.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
makeFvOption(PhaseLimitStabilization, scalar);
|
namespace Foam
|
||||||
makeFvOption(PhaseLimitStabilization, vector);
|
{
|
||||||
makeFvOption(PhaseLimitStabilization, sphericalTensor);
|
namespace fv
|
||||||
makeFvOption(PhaseLimitStabilization, symmTensor);
|
{
|
||||||
makeFvOption(PhaseLimitStabilization, tensor);
|
defineTypeNameAndDebug(phaseLimitStabilization, 0);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
option,
|
||||||
|
phaseLimitStabilization,
|
||||||
|
dictionary
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fv::phaseLimitStabilization::readCoeffs()
|
||||||
|
{
|
||||||
|
fieldName_ = coeffs_.lookup<word>("field");
|
||||||
|
rateName_ = coeffs_.lookup<word>("rate");
|
||||||
|
residualAlpha_ = coeffs_.lookup<scalar>("residualAlpha");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::fv::phaseLimitStabilization::addSupType
|
||||||
|
(
|
||||||
|
const volScalarField& alpha,
|
||||||
|
const volScalarField& rho,
|
||||||
|
fvMatrix<Type>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const GeometricField<Type, fvPatchField, volMesh>& psi = eqn.psi();
|
||||||
|
|
||||||
|
uniformDimensionedScalarField& rate =
|
||||||
|
mesh_.lookupObjectRef<uniformDimensionedScalarField>(rateName_);
|
||||||
|
|
||||||
|
eqn -= fvm::Sp(max(residualAlpha_ - alpha, scalar(0))*rho*rate, psi);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::fv::phaseLimitStabilization::phaseLimitStabilization
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const word& modelType,
|
||||||
|
const dictionary& dict,
|
||||||
|
const fvMesh& mesh
|
||||||
|
)
|
||||||
|
:
|
||||||
|
option(name, modelType, dict, mesh),
|
||||||
|
fieldName_(word::null),
|
||||||
|
rateName_(word::null),
|
||||||
|
residualAlpha_(NaN)
|
||||||
|
{
|
||||||
|
readCoeffs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::wordList Foam::fv::phaseLimitStabilization::addedToFields() const
|
||||||
|
{
|
||||||
|
return wordList(1, fieldName_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fv::phaseLimitStabilization::addSup
|
||||||
|
(
|
||||||
|
const volScalarField& alpha,
|
||||||
|
const volScalarField& rho,
|
||||||
|
fvMatrix<scalar>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
addSupType(alpha, rho, eqn, fieldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fv::phaseLimitStabilization::addSup
|
||||||
|
(
|
||||||
|
const volScalarField& alpha,
|
||||||
|
const volScalarField& rho,
|
||||||
|
fvMatrix<vector>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
addSupType(alpha, rho, eqn, fieldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fv::phaseLimitStabilization::addSup
|
||||||
|
(
|
||||||
|
const volScalarField& alpha,
|
||||||
|
const volScalarField& rho,
|
||||||
|
fvMatrix<symmTensor>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
addSupType(alpha, rho, eqn, fieldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fv::phaseLimitStabilization::addSup
|
||||||
|
(
|
||||||
|
const volScalarField& alpha,
|
||||||
|
const volScalarField& rho,
|
||||||
|
fvMatrix<sphericalTensor>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
addSupType(alpha, rho, eqn, fieldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fv::phaseLimitStabilization::addSup
|
||||||
|
(
|
||||||
|
const volScalarField& alpha,
|
||||||
|
const volScalarField& rho,
|
||||||
|
fvMatrix<tensor>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
addSupType(alpha, rho, eqn, fieldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::fv::phaseLimitStabilization::read(const dictionary& dict)
|
||||||
|
{
|
||||||
|
if (option::read(dict))
|
||||||
|
{
|
||||||
|
readCoeffs();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2017-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2017-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -22,7 +22,7 @@ License
|
|||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Class
|
Class
|
||||||
Foam::fv::PhaseLimitStabilization
|
Foam::fv::phaseLimitStabilization
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Stabilization source for phase transport equations
|
Stabilization source for phase transport equations
|
||||||
@ -41,21 +41,22 @@ Usage
|
|||||||
\verbatim
|
\verbatim
|
||||||
stabilization
|
stabilization
|
||||||
{
|
{
|
||||||
type symmTensorPhaseLimitStabilization;
|
type phaseLimitStabilization;
|
||||||
|
|
||||||
field sigma.liquid;
|
field sigma.liquid;
|
||||||
|
|
||||||
rate rLambda.liquid;
|
rate rLambda.liquid;
|
||||||
residualAlpha 1e-3;
|
residualAlpha 1e-3;
|
||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
PhaseLimitStabilization.C
|
phaseLimitStabilization.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef PhaseLimitStabilization_H
|
#ifndef phaseLimitStabilization_H
|
||||||
#define PhaseLimitStabilization_H
|
#define phaseLimitStabilization_H
|
||||||
|
|
||||||
#include "fvOption.H"
|
#include "fvOption.H"
|
||||||
|
|
||||||
@ -67,11 +68,10 @@ namespace fv
|
|||||||
{
|
{
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class PhaseLimitStabilization Declaration
|
Class phaseLimitStabilization Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
template<class Type>
|
class phaseLimitStabilization
|
||||||
class PhaseLimitStabilization
|
|
||||||
:
|
:
|
||||||
public option
|
public option
|
||||||
{
|
{
|
||||||
@ -87,16 +87,32 @@ class PhaseLimitStabilization
|
|||||||
scalar residualAlpha_;
|
scalar residualAlpha_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
|
//- Add source terms to a phase equation
|
||||||
|
template<class Type>
|
||||||
|
void addSupType
|
||||||
|
(
|
||||||
|
const volScalarField& alpha,
|
||||||
|
const volScalarField& rho,
|
||||||
|
fvMatrix<Type>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
TypeName("PhaseLimitStabilization");
|
TypeName("phaseLimitStabilization");
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
PhaseLimitStabilization
|
phaseLimitStabilization
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const word& modelType,
|
const word& modelType,
|
||||||
@ -105,24 +121,67 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Disallow default bitwise copy construction
|
//- Disallow default bitwise copy construction
|
||||||
PhaseLimitStabilization(const PhaseLimitStabilization&) = delete;
|
phaseLimitStabilization(const phaseLimitStabilization&) = delete;
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~PhaseLimitStabilization()
|
virtual ~phaseLimitStabilization()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Source term to compressible phase equation
|
// Checks
|
||||||
virtual void addSup
|
|
||||||
(
|
//- Return the list of fields for which the option adds source term
|
||||||
const volScalarField& alpha,
|
// to the transport equation
|
||||||
const volScalarField& rho,
|
virtual wordList addedToFields() const;
|
||||||
fvMatrix<Type>& eqn,
|
|
||||||
const label fieldi
|
|
||||||
) const;
|
// Evaluation
|
||||||
|
|
||||||
|
// Explicit and implicit sources for phase equations
|
||||||
|
|
||||||
|
virtual void addSup
|
||||||
|
(
|
||||||
|
const volScalarField& alpha,
|
||||||
|
const volScalarField& rho,
|
||||||
|
fvMatrix<scalar>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const;
|
||||||
|
|
||||||
|
virtual void addSup
|
||||||
|
(
|
||||||
|
const volScalarField& alpha,
|
||||||
|
const volScalarField& rho,
|
||||||
|
fvMatrix<vector>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const;
|
||||||
|
|
||||||
|
virtual void addSup
|
||||||
|
(
|
||||||
|
const volScalarField& alpha,
|
||||||
|
const volScalarField& rho,
|
||||||
|
fvMatrix<symmTensor>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const;
|
||||||
|
|
||||||
|
virtual void addSup
|
||||||
|
(
|
||||||
|
const volScalarField& alpha,
|
||||||
|
const volScalarField& rho,
|
||||||
|
fvMatrix<sphericalTensor>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const;
|
||||||
|
|
||||||
|
virtual void addSup
|
||||||
|
(
|
||||||
|
const volScalarField& alpha,
|
||||||
|
const volScalarField& rho,
|
||||||
|
fvMatrix<tensor>& eqn,
|
||||||
|
const word& fieldName
|
||||||
|
) const;
|
||||||
|
|
||||||
|
|
||||||
//- Read dictionary
|
//- Read dictionary
|
||||||
virtual bool read(const dictionary& dict);
|
virtual bool read(const dictionary& dict);
|
||||||
@ -131,7 +190,7 @@ public:
|
|||||||
// Member Operators
|
// Member Operators
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const PhaseLimitStabilization&) = delete;
|
void operator=(const phaseLimitStabilization&) = delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -142,12 +201,6 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#ifdef NoRepository
|
|
||||||
#include "PhaseLimitStabilization.C"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -43,6 +43,14 @@ namespace fv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fv::radialActuationDiskSource::readCoeffs()
|
||||||
|
{
|
||||||
|
coeffs_.lookup("coeffs") >> radialCoeffs_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::fv::radialActuationDiskSource::radialActuationDiskSource
|
Foam::fv::radialActuationDiskSource::radialActuationDiskSource
|
||||||
@ -54,9 +62,9 @@ Foam::fv::radialActuationDiskSource::radialActuationDiskSource
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
actuationDiskSource(name, modelType, dict, mesh),
|
actuationDiskSource(name, modelType, dict, mesh),
|
||||||
radialCoeffs_(coeffs_.lookup("coeffs"))
|
radialCoeffs_()
|
||||||
{
|
{
|
||||||
Info<< " - creating radial actuation disk zone: " << name_ << endl;
|
readCoeffs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -65,7 +73,7 @@ Foam::fv::radialActuationDiskSource::radialActuationDiskSource
|
|||||||
void Foam::fv::radialActuationDiskSource::addSup
|
void Foam::fv::radialActuationDiskSource::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const scalarField& cellsV = mesh_.V();
|
const scalarField& cellsV = mesh_.V();
|
||||||
@ -90,7 +98,7 @@ void Foam::fv::radialActuationDiskSource::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const scalarField& cellsV = mesh_.V();
|
const scalarField& cellsV = mesh_.V();
|
||||||
@ -115,7 +123,7 @@ bool Foam::fv::radialActuationDiskSource::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
if (actuationDiskSource::read(dict))
|
if (actuationDiskSource::read(dict))
|
||||||
{
|
{
|
||||||
coeffs_.lookup("coeffs") >> radialCoeffs_;
|
readCoeffs();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -28,13 +28,16 @@ Description
|
|||||||
Actuation disk source including radial thrust
|
Actuation disk source including radial thrust
|
||||||
|
|
||||||
Constant values for momentum source for actuation disk
|
Constant values for momentum source for actuation disk
|
||||||
\f[
|
|
||||||
T = 2 \rho A U_{o}^2 a (1-a)
|
\f[
|
||||||
\f]
|
T = 2 \rho A U_{o}^2 a (1-a)
|
||||||
|
\f]
|
||||||
|
|
||||||
and
|
and
|
||||||
\f[
|
|
||||||
U_1 = (1 - a)U_{o}
|
\f[
|
||||||
\f]
|
U_1 = (1 - a)U_{o}
|
||||||
|
\f]
|
||||||
|
|
||||||
where:
|
where:
|
||||||
\vartable
|
\vartable
|
||||||
@ -44,22 +47,31 @@ Description
|
|||||||
U_1 | velocity at the disk
|
U_1 | velocity at the disk
|
||||||
\endvartable
|
\endvartable
|
||||||
|
|
||||||
|
|
||||||
The thrust is distributed by a radial function:
|
The thrust is distributed by a radial function:
|
||||||
\f[
|
|
||||||
thrust(r) = T (C_0 + C_1 r^2 + C_2 r^4)
|
\f[
|
||||||
\f]
|
thrust(r) = T (C_0 + C_1 r^2 + C_2 r^4)
|
||||||
|
\f]
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
Example usage:
|
Example usage:
|
||||||
\verbatim
|
\verbatim
|
||||||
fieldName U; // name of field to apply source
|
radialActuationDiskSource1
|
||||||
diskDir (-1 0 0); // disk direction
|
{
|
||||||
Cp 0.1; // power coefficient
|
type radialActuationDiskSource;
|
||||||
Ct 0.5; // thrust coefficient
|
|
||||||
diskArea 5.0; // disk area
|
selectionMode cellSet;
|
||||||
coeffs (0.1 0.5 0.01); // radial distribution coefficients
|
cellSet radialActuationDisk1;
|
||||||
upstreamPoint (0 0 0); // upstream point
|
|
||||||
|
U U; // Name of the velocity field
|
||||||
|
|
||||||
|
diskDir (-1 0 0); // Disk direction
|
||||||
|
Cp 0.1; // Power coefficient
|
||||||
|
Ct 0.5; // Thrust coefficient
|
||||||
|
diskArea 5.0; // Disk area
|
||||||
|
coeffs (0.1 0.5 0.01); // Radial distribution coefficients
|
||||||
|
upstreamPoint (0 0 0); // Upstream point
|
||||||
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
|
|
||||||
@ -98,6 +110,9 @@ class radialActuationDiskSource
|
|||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
//- Add resistance to the UEqn
|
//- Add resistance to the UEqn
|
||||||
template<class RhoFieldType>
|
template<class RhoFieldType>
|
||||||
void addRadialActuationDiskAxialInertialResistance
|
void addRadialActuationDiskAxialInertialResistance
|
||||||
@ -142,7 +157,7 @@ public:
|
|||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Source term to compressible momentum equation
|
//- Source term to compressible momentum equation
|
||||||
@ -150,7 +165,7 @@ public:
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -25,7 +25,7 @@ Class
|
|||||||
Foam::profileModelList
|
Foam::profileModelList
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Base class for profile models
|
List of profile models
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
profileModelList.C
|
profileModelList.C
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -68,25 +68,65 @@ namespace Foam
|
|||||||
|
|
||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fv::rotorDiskSource::readCoeffs()
|
||||||
|
{
|
||||||
|
UName_ = coeffs_.lookupOrDefault<word>("U", "U");
|
||||||
|
|
||||||
|
// Read co-ordinate system/geometry invariant properties
|
||||||
|
scalar rpm(coeffs_.lookup<scalar>("rpm"));
|
||||||
|
omega_ = rpm/60.0*mathematical::twoPi;
|
||||||
|
|
||||||
|
coeffs_.lookup("nBlades") >> nBlades_;
|
||||||
|
|
||||||
|
inletFlow_ = inletFlowTypeNames_.read(coeffs_.lookup("inletFlowType"));
|
||||||
|
|
||||||
|
coeffs_.lookup("tipEffect") >> tipEffect_;
|
||||||
|
|
||||||
|
const dictionary& flapCoeffs(coeffs_.subDict("flapCoeffs"));
|
||||||
|
flapCoeffs.lookup("beta0") >> flap_.beta0;
|
||||||
|
flapCoeffs.lookup("beta1c") >> flap_.beta1c;
|
||||||
|
flapCoeffs.lookup("beta2s") >> flap_.beta2s;
|
||||||
|
flap_.beta0 = degToRad(flap_.beta0);
|
||||||
|
flap_.beta1c = degToRad(flap_.beta1c);
|
||||||
|
flap_.beta2s = degToRad(flap_.beta2s);
|
||||||
|
|
||||||
|
// Create co-ordinate system
|
||||||
|
createCoordinateSystem();
|
||||||
|
|
||||||
|
// Read co-odinate system dependent properties
|
||||||
|
checkData();
|
||||||
|
|
||||||
|
constructGeometry();
|
||||||
|
|
||||||
|
trim_->read(coeffs_);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
writeField("thetag", trim_->thetag()(), true);
|
||||||
|
writeField("faceArea", area_, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::rotorDiskSource::checkData()
|
void Foam::fv::rotorDiskSource::checkData()
|
||||||
{
|
{
|
||||||
// Set inflow type
|
// Set inflow type
|
||||||
switch (selectionMode())
|
switch (selectionMode())
|
||||||
{
|
{
|
||||||
case smCellSet:
|
case selectionModeType::cellSet:
|
||||||
case smCellZone:
|
case selectionModeType::cellZone:
|
||||||
case smAll:
|
case selectionModeType::all:
|
||||||
{
|
{
|
||||||
// Set the profile ID for each blade section
|
// Set the profile ID for each blade section
|
||||||
profiles_.connectBlades(blade_.profileName(), blade_.profileID());
|
profiles_.connectBlades(blade_.profileName(), blade_.profileID());
|
||||||
switch (inletFlow_)
|
switch (inletFlow_)
|
||||||
{
|
{
|
||||||
case ifFixed:
|
case inletFlowType::fixed:
|
||||||
{
|
{
|
||||||
coeffs_.lookup("inletVelocity") >> inletVelocity_;
|
coeffs_.lookup("inletVelocity") >> inletVelocity_;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ifSurfaceNormal:
|
case inletFlowType::surfaceNormal:
|
||||||
{
|
{
|
||||||
scalar UIn
|
scalar UIn
|
||||||
(
|
(
|
||||||
@ -95,7 +135,7 @@ void Foam::fv::rotorDiskSource::checkData()
|
|||||||
inletVelocity_ = -coordSys_.R().e3()*UIn;
|
inletVelocity_ = -coordSys_.R().e3()*UIn;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ifLocal:
|
case inletFlowType::local:
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -105,8 +145,6 @@ void Foam::fv::rotorDiskSource::checkData()
|
|||||||
<< "Unknown inlet velocity type" << abort(FatalError);
|
<< "Unknown inlet velocity type" << abort(FatalError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -115,9 +153,9 @@ void Foam::fv::rotorDiskSource::checkData()
|
|||||||
<< "Source cannot be used with '"
|
<< "Source cannot be used with '"
|
||||||
<< selectionModeTypeNames_[selectionMode()]
|
<< selectionModeTypeNames_[selectionMode()]
|
||||||
<< "' mode. Please use one of: " << nl
|
<< "' mode. Please use one of: " << nl
|
||||||
<< selectionModeTypeNames_[smCellSet] << nl
|
<< selectionModeTypeNames_[selectionModeType::cellSet] << nl
|
||||||
<< selectionModeTypeNames_[smCellZone] << nl
|
<< selectionModeTypeNames_[selectionModeType::cellZone] << nl
|
||||||
<< selectionModeTypeNames_[smAll]
|
<< selectionModeTypeNames_[selectionModeType::all]
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -272,7 +310,7 @@ void Foam::fv::rotorDiskSource::createCoordinateSystem()
|
|||||||
|
|
||||||
switch (gm)
|
switch (gm)
|
||||||
{
|
{
|
||||||
case gmAuto:
|
case geometryModeType::automatic:
|
||||||
{
|
{
|
||||||
// Determine rotation origin (cell volume weighted)
|
// Determine rotation origin (cell volume weighted)
|
||||||
scalar sumV = 0.0;
|
scalar sumV = 0.0;
|
||||||
@ -348,7 +386,7 @@ void Foam::fv::rotorDiskSource::createCoordinateSystem()
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case gmSpecified:
|
case geometryModeType::specified:
|
||||||
{
|
{
|
||||||
coeffs_.lookup("origin") >> origin;
|
coeffs_.lookup("origin") >> origin;
|
||||||
coeffs_.lookup("axis") >> axis;
|
coeffs_.lookup("axis") >> axis;
|
||||||
@ -368,13 +406,6 @@ void Foam::fv::rotorDiskSource::createCoordinateSystem()
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Unknown geometryMode " << geometryModeTypeNames_[gm]
|
|
||||||
<< ". Available geometry modes include "
|
|
||||||
<< geometryModeTypeNames_ << exit(FatalError);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
coordSys_ = coordinateSystems::cylindrical
|
coordSys_ = coordinateSystems::cylindrical
|
||||||
@ -441,8 +472,8 @@ Foam::tmp<Foam::vectorField> Foam::fv::rotorDiskSource::inflowVelocity
|
|||||||
{
|
{
|
||||||
switch (inletFlow_)
|
switch (inletFlow_)
|
||||||
{
|
{
|
||||||
case ifFixed:
|
case inletFlowType::fixed:
|
||||||
case ifSurfaceNormal:
|
case inletFlowType::surfaceNormal:
|
||||||
{
|
{
|
||||||
return tmp<vectorField>
|
return tmp<vectorField>
|
||||||
(
|
(
|
||||||
@ -451,7 +482,7 @@ Foam::tmp<Foam::vectorField> Foam::fv::rotorDiskSource::inflowVelocity
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ifLocal:
|
case inletFlowType::local:
|
||||||
{
|
{
|
||||||
return U.primitiveField();
|
return U.primitiveField();
|
||||||
|
|
||||||
@ -479,25 +510,26 @@ Foam::fv::rotorDiskSource::rotorDiskSource
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
cellSetOption(name, modelType, dict, mesh),
|
cellSetOption(name, modelType, dict, mesh),
|
||||||
rhoRef_(1.0),
|
UName_(word::null),
|
||||||
omega_(0.0),
|
omega_(0),
|
||||||
nBlades_(0),
|
nBlades_(0),
|
||||||
inletFlow_(ifLocal),
|
inletFlow_(inletFlowType::local),
|
||||||
inletVelocity_(Zero),
|
inletVelocity_(Zero),
|
||||||
tipEffect_(1.0),
|
tipEffect_(1),
|
||||||
flap_(),
|
flap_(),
|
||||||
x_(cells().size(), Zero),
|
x_(cells().size(), Zero),
|
||||||
R_(cells().size(), I),
|
R_(cells().size(), I),
|
||||||
invR_(cells().size(), I),
|
invR_(cells().size(), I),
|
||||||
area_(cells().size(), 0.0),
|
area_(cells().size(), Zero),
|
||||||
coordSys_("rotorCoordSys", vector::zero, axesRotation(sphericalTensor::I)),
|
coordSys_("rotorCoordSys", vector::zero, axesRotation(sphericalTensor::I)),
|
||||||
cylindrical_(),
|
cylindrical_(),
|
||||||
rMax_(0.0),
|
rMax_(0),
|
||||||
trim_(trimModel::New(*this, coeffs_)),
|
trim_(trimModel::New(*this, coeffs_)),
|
||||||
blade_(coeffs_.subDict("blade")),
|
blade_(coeffs_.subDict("blade")),
|
||||||
profiles_(coeffs_.subDict("profiles"))
|
profiles_(coeffs_.subDict("profiles")),
|
||||||
|
rhoRef_(1)
|
||||||
{
|
{
|
||||||
read(dict);
|
readCoeffs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -509,10 +541,16 @@ Foam::fv::rotorDiskSource::~rotorDiskSource()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::wordList Foam::fv::rotorDiskSource::addedToFields() const
|
||||||
|
{
|
||||||
|
return wordList(1, UName_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::rotorDiskSource::addSup
|
void Foam::fv::rotorDiskSource::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
volVectorField force
|
volVectorField force
|
||||||
@ -553,7 +591,7 @@ void Foam::fv::rotorDiskSource::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
volVectorField force
|
volVectorField force
|
||||||
@ -591,44 +629,7 @@ bool Foam::fv::rotorDiskSource::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
if (cellSetOption::read(dict))
|
if (cellSetOption::read(dict))
|
||||||
{
|
{
|
||||||
coeffs_.lookup("fields") >> fieldNames_;
|
readCoeffs();
|
||||||
applied_.setSize(fieldNames_.size(), false);
|
|
||||||
|
|
||||||
// Read co-ordinate system/geometry invariant properties
|
|
||||||
scalar rpm(coeffs_.lookup<scalar>("rpm"));
|
|
||||||
omega_ = rpm/60.0*mathematical::twoPi;
|
|
||||||
|
|
||||||
coeffs_.lookup("nBlades") >> nBlades_;
|
|
||||||
|
|
||||||
inletFlow_ = inletFlowTypeNames_.read(coeffs_.lookup("inletFlowType"));
|
|
||||||
|
|
||||||
coeffs_.lookup("tipEffect") >> tipEffect_;
|
|
||||||
|
|
||||||
const dictionary& flapCoeffs(coeffs_.subDict("flapCoeffs"));
|
|
||||||
flapCoeffs.lookup("beta0") >> flap_.beta0;
|
|
||||||
flapCoeffs.lookup("beta1c") >> flap_.beta1c;
|
|
||||||
flapCoeffs.lookup("beta2s") >> flap_.beta2s;
|
|
||||||
flap_.beta0 = degToRad(flap_.beta0);
|
|
||||||
flap_.beta1c = degToRad(flap_.beta1c);
|
|
||||||
flap_.beta2s = degToRad(flap_.beta2s);
|
|
||||||
|
|
||||||
|
|
||||||
// Create co-ordinate system
|
|
||||||
createCoordinateSystem();
|
|
||||||
|
|
||||||
// Read co-odinate system dependent properties
|
|
||||||
checkData();
|
|
||||||
|
|
||||||
constructGeometry();
|
|
||||||
|
|
||||||
trim_->read(coeffs_);
|
|
||||||
|
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
writeField("thetag", trim_->thetag()(), true);
|
|
||||||
writeField("faceArea", area_, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -25,32 +25,32 @@ Class
|
|||||||
Foam::fv::rotorDiskSource
|
Foam::fv::rotorDiskSource
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Rotor disk source
|
|
||||||
|
|
||||||
Cell based momentum source which approximates the mean effects of
|
Cell based momentum source which approximates the mean effects of
|
||||||
rotor forces on a cylindrical region within the domain.
|
rotor forces on a cylindrical region within the domain.
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
Example usage:
|
Example usage:
|
||||||
\verbatim
|
\verbatim
|
||||||
fields (U); // names of fields on which to apply source
|
rotorDiskSource1
|
||||||
nBlades 3; // number of blades
|
{
|
||||||
tipEffect 0.96; // normalised radius above which lift = 0
|
type rotorDisk;
|
||||||
|
|
||||||
inletFlowType local; // inlet flow type specification
|
U U; // Name of the velocity field
|
||||||
|
|
||||||
geometryMode auto; // geometry specification
|
nBlades 3; // Number of blades
|
||||||
|
tipEffect 0.96; // Normalised radius above which lift = 0
|
||||||
|
inletFlowType local; // Inlet flow type specification
|
||||||
|
geometryMode auto; // Geometry specification
|
||||||
|
refDirection (-1 0 0); // Reference direction for psi angle
|
||||||
|
|
||||||
refDirection (-1 0 0); // reference direction
|
trimModel fixed; // Trim model; fixed or targetCoeff
|
||||||
// - used as reference for psi angle
|
// see fixedTrim.H or targetCoeffTrim.H for documentation
|
||||||
|
|
||||||
trimModel fixed; // fixed || targetForce
|
|
||||||
|
|
||||||
flapCoeffs
|
flapCoeffs
|
||||||
{
|
{
|
||||||
beta0 0; // coning angle [deg]
|
beta0 0; // Coning angle [deg]
|
||||||
beta1c 0; // lateral flapping coeff (cos coeff)
|
beta1c 0; // Lateral flapping coeff (cos coeff)
|
||||||
beta2s 0; // longitudinal flapping coeff (sin coeff)
|
beta2s 0; // Longitudinal flapping coeff (sin coeff)
|
||||||
}
|
}
|
||||||
|
|
||||||
blade
|
blade
|
||||||
@ -62,8 +62,10 @@ Usage
|
|||||||
{
|
{
|
||||||
profile1
|
profile1
|
||||||
{
|
{
|
||||||
type lookup; // lookup || series
|
type lookup; // Profile model; lookup or series
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|
||||||
// see lookupProfile.H or seriesProfile.H for documentation
|
// see lookupProfile.H or seriesProfile.H for documentation
|
||||||
}
|
}
|
||||||
profile2
|
profile2
|
||||||
@ -71,12 +73,13 @@ Usage
|
|||||||
...
|
...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
Where:
|
Where:
|
||||||
Valid options for the \c geometryMode entry include:
|
Valid options for the \c geometryMode entry include:
|
||||||
- auto : determine rotor co-ord system from cells
|
- auto : determine rotor coordinate system from cells
|
||||||
- specified : specified co-ord system
|
- specified : specified coordinate system
|
||||||
|
|
||||||
Valid options for the \c inletFlowType entry include:
|
Valid options for the \c inletFlowType entry include:
|
||||||
- fixed : specified velocity
|
- fixed : specified velocity
|
||||||
@ -128,16 +131,16 @@ public:
|
|||||||
|
|
||||||
enum geometryModeType
|
enum geometryModeType
|
||||||
{
|
{
|
||||||
gmAuto,
|
automatic,
|
||||||
gmSpecified
|
specified
|
||||||
};
|
};
|
||||||
static const NamedEnum<geometryModeType, 2> geometryModeTypeNames_;
|
static const NamedEnum<geometryModeType, 2> geometryModeTypeNames_;
|
||||||
|
|
||||||
enum inletFlowType
|
enum inletFlowType
|
||||||
{
|
{
|
||||||
ifFixed,
|
fixed,
|
||||||
ifSurfaceNormal,
|
surfaceNormal,
|
||||||
ifLocal
|
local
|
||||||
};
|
};
|
||||||
static const NamedEnum<inletFlowType, 3> inletFlowTypeNames_;
|
static const NamedEnum<inletFlowType, 3> inletFlowTypeNames_;
|
||||||
|
|
||||||
@ -157,8 +160,8 @@ protected:
|
|||||||
|
|
||||||
// Protected data
|
// Protected data
|
||||||
|
|
||||||
//- Reference density for incompressible case
|
//- Name of the velocity field
|
||||||
mutable scalar rhoRef_;
|
word UName_;
|
||||||
|
|
||||||
//- Rotational speed [rad/s]
|
//- Rotational speed [rad/s]
|
||||||
// Positive anti-clockwise when looking along -ve lift direction
|
// Positive anti-clockwise when looking along -ve lift direction
|
||||||
@ -211,9 +214,15 @@ protected:
|
|||||||
//- Profile data
|
//- Profile data
|
||||||
profileModelList profiles_;
|
profileModelList profiles_;
|
||||||
|
|
||||||
|
//- Reference density for incompressible case
|
||||||
|
mutable scalar rhoRef_;
|
||||||
|
|
||||||
|
|
||||||
// Protected Member Functions
|
// Protected Member Functions
|
||||||
|
|
||||||
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
//- Check data
|
//- Check data
|
||||||
void checkData();
|
void checkData();
|
||||||
|
|
||||||
@ -281,6 +290,13 @@ public:
|
|||||||
inline const coordinateSystems::cylindrical& coordSys() const;
|
inline const coordinateSystems::cylindrical& coordSys() const;
|
||||||
|
|
||||||
|
|
||||||
|
// Checks
|
||||||
|
|
||||||
|
//- Return the list of fields for which the option adds source term
|
||||||
|
// to the transport equation
|
||||||
|
virtual wordList addedToFields() const;
|
||||||
|
|
||||||
|
|
||||||
// Evaluation
|
// Evaluation
|
||||||
|
|
||||||
//- Calculate forces
|
//- Calculate forces
|
||||||
@ -302,7 +318,7 @@ public:
|
|||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Source term to compressible momentum equation
|
//- Source term to compressible momentum equation
|
||||||
@ -310,7 +326,7 @@ public:
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2015-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2015-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -106,6 +106,23 @@ namespace Foam
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fv::sixDoFAccelerationSource::readCoeffs()
|
||||||
|
{
|
||||||
|
UName_ = coeffs_.lookupOrDefault<word>("U", "U");
|
||||||
|
|
||||||
|
accelerations_.reset
|
||||||
|
(
|
||||||
|
Function1<accelerationVectors>::New
|
||||||
|
(
|
||||||
|
"accelerations",
|
||||||
|
coeffs_
|
||||||
|
).ptr()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::fv::sixDoFAccelerationSource::sixDoFAccelerationSource
|
Foam::fv::sixDoFAccelerationSource::sixDoFAccelerationSource
|
||||||
@ -117,32 +134,34 @@ Foam::fv::sixDoFAccelerationSource::sixDoFAccelerationSource
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
option(name, modelType, dict, mesh),
|
option(name, modelType, dict, mesh),
|
||||||
accelerations_
|
|
||||||
(
|
|
||||||
Function1<accelerationVectors>::New("accelerations", coeffs_)
|
|
||||||
),
|
|
||||||
UName_(coeffs_.lookupOrDefault<word>("U", "U")),
|
UName_(coeffs_.lookupOrDefault<word>("U", "U")),
|
||||||
g0_("g0", dimAcceleration, Zero)
|
accelerations_(nullptr),
|
||||||
|
g_
|
||||||
|
(
|
||||||
|
mesh.foundObject<uniformDimensionedVectorField>("g")
|
||||||
|
? dimensionedVector(mesh.lookupObject<uniformDimensionedVectorField>("g"))
|
||||||
|
: dimensionedVector("g", dimAcceleration, Zero)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
fieldNames_.setSize(1, UName_);
|
readCoeffs();
|
||||||
applied_.setSize(1, false);
|
|
||||||
|
|
||||||
if (mesh.foundObject<uniformDimensionedVectorField>("g"))
|
|
||||||
{
|
|
||||||
g0_ = mesh.lookupObject<uniformDimensionedVectorField>("g");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::wordList Foam::fv::sixDoFAccelerationSource::addedToFields() const
|
||||||
|
{
|
||||||
|
return wordList(1, UName_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::sixDoFAccelerationSource::addSup
|
void Foam::fv::sixDoFAccelerationSource::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addSup<geometricOneField>(geometricOneField(), eqn, fieldi);
|
addSup<geometricOneField>(geometricOneField(), eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -150,10 +169,10 @@ void Foam::fv::sixDoFAccelerationSource::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addSup<volScalarField>(rho, eqn, fieldi);
|
addSup<volScalarField>(rho, eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -161,12 +180,7 @@ bool Foam::fv::sixDoFAccelerationSource::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
if (option::read(dict))
|
if (option::read(dict))
|
||||||
{
|
{
|
||||||
accelerations_ = Function1<accelerationVectors>::New
|
readCoeffs();
|
||||||
(
|
|
||||||
"accelerations",
|
|
||||||
dict
|
|
||||||
);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2015-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2015-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -74,9 +74,12 @@ public:
|
|||||||
typedef Vector<vector> accelerationVectors;
|
typedef Vector<vector> accelerationVectors;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
|
|
||||||
// Protected data
|
// Private data
|
||||||
|
|
||||||
|
//- Velocity field name, default = U
|
||||||
|
word UName_;
|
||||||
|
|
||||||
//- Accelerations function returning a vector containing
|
//- Accelerations function returning a vector containing
|
||||||
// linear acceleration vector
|
// linear acceleration vector
|
||||||
@ -84,24 +87,22 @@ protected:
|
|||||||
// angular acceleration vector
|
// angular acceleration vector
|
||||||
autoPtr<Function1<accelerationVectors>> accelerations_;
|
autoPtr<Function1<accelerationVectors>> accelerations_;
|
||||||
|
|
||||||
//- Velocity field name, default = U
|
|
||||||
word UName_;
|
|
||||||
|
|
||||||
//- Optional gravitational acceleration
|
//- Optional gravitational acceleration
|
||||||
dimensionedVector g0_;
|
dimensionedVector g_;
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
//- Source term to momentum equation
|
//- Source term to momentum equation
|
||||||
template<class RhoFieldType>
|
template<class RhoFieldType>
|
||||||
void addSup
|
void addSup
|
||||||
(
|
(
|
||||||
const RhoFieldType& rho,
|
const RhoFieldType& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
@ -136,11 +137,15 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- Return the list of fields for which the option adds source term
|
||||||
|
// to the transport equation
|
||||||
|
virtual wordList addedToFields() const;
|
||||||
|
|
||||||
//- Source term to momentum equation
|
//- Source term to momentum equation
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Source term to compressible momentum equation
|
//- Source term to compressible momentum equation
|
||||||
@ -148,7 +153,7 @@ public:
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Read dictionary
|
//- Read dictionary
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2015-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2015-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -35,7 +35,7 @@ void Foam::fv::sixDoFAccelerationSource::addSup
|
|||||||
(
|
(
|
||||||
const RhoFieldType& rho,
|
const RhoFieldType& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
Vector<vector> accelerations(accelerations_->value(mesh_.time().value()));
|
Vector<vector> accelerations(accelerations_->value(mesh_.time().value()));
|
||||||
@ -49,7 +49,7 @@ void Foam::fv::sixDoFAccelerationSource::addSup
|
|||||||
const uniformDimensionedScalarField& hRef =
|
const uniformDimensionedScalarField& hRef =
|
||||||
mesh_.lookupObject<uniformDimensionedScalarField>("hRef");
|
mesh_.lookupObject<uniformDimensionedScalarField>("hRef");
|
||||||
|
|
||||||
g = g0_ - dimensionedVector("a", dimAcceleration, accelerations.x());
|
g = g_ - dimensionedVector("a", dimAcceleration, accelerations.x());
|
||||||
|
|
||||||
dimensionedScalar ghRef(- mag(g)*hRef);
|
dimensionedScalar ghRef(- mag(g)*hRef);
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2019-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2019-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -47,10 +47,18 @@ namespace fv
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
const Foam::volScalarField&
|
void Foam::fv::solidEquilibriumEnergySource::readCoeffs()
|
||||||
Foam::fv::solidEquilibriumEnergySource::alpha() const
|
|
||||||
{
|
{
|
||||||
const word alphaName = IOobject::groupName("alpha", phaseName_);
|
phaseName_ = coeffs_.lookupOrDefault<word>("phase", word::null);
|
||||||
|
|
||||||
|
solidPhaseName_ = coeffs_.lookup<word>("solidPhase");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::volScalarField&
|
||||||
|
Foam::fv::solidEquilibriumEnergySource::solidAlpha() const
|
||||||
|
{
|
||||||
|
const word alphaName = IOobject::groupName("alpha", solidPhaseName_);
|
||||||
|
|
||||||
if (!mesh_.foundObject<volScalarField>(alphaName))
|
if (!mesh_.foundObject<volScalarField>(alphaName))
|
||||||
{
|
{
|
||||||
@ -75,19 +83,21 @@ Foam::fv::solidEquilibriumEnergySource::alpha() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const Foam::solidThermo& Foam::fv::solidEquilibriumEnergySource::thermo() const
|
const Foam::solidThermo&
|
||||||
|
Foam::fv::solidEquilibriumEnergySource::solidThermo() const
|
||||||
{
|
{
|
||||||
const word thermoName =
|
const word thermoName =
|
||||||
IOobject::groupName(basicThermo::dictName, phaseName_);
|
IOobject::groupName(basicThermo::dictName, solidPhaseName_);
|
||||||
|
|
||||||
if (!mesh_.foundObject<solidThermo>(thermoName))
|
if (!mesh_.foundObject<Foam::solidThermo>(thermoName))
|
||||||
{
|
{
|
||||||
solidThermo* thermoPtr = solidThermo::New(mesh_, phaseName_).ptr();
|
Foam::solidThermo* thermoPtr =
|
||||||
|
solidThermo::New(mesh_, solidPhaseName_).ptr();
|
||||||
|
|
||||||
thermoPtr->properties().store();
|
thermoPtr->properties().store();
|
||||||
}
|
}
|
||||||
|
|
||||||
return mesh_.lookupObject<solidThermo>(thermoName);
|
return mesh_.lookupObject<Foam::solidThermo>(thermoName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -102,11 +112,12 @@ Foam::fv::solidEquilibriumEnergySource::solidEquilibriumEnergySource
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
option(name, modelType, dict, mesh),
|
option(name, modelType, dict, mesh),
|
||||||
phaseName_(dict.lookup<word>("phase"))
|
phaseName_(word::null),
|
||||||
|
solidPhaseName_(word::null)
|
||||||
{
|
{
|
||||||
read(dict);
|
read(dict);
|
||||||
alpha();
|
solidAlpha();
|
||||||
thermo();
|
solidThermo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -118,20 +129,32 @@ Foam::fv::solidEquilibriumEnergySource::~solidEquilibriumEnergySource()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::wordList Foam::fv::solidEquilibriumEnergySource::addedToFields() const
|
||||||
|
{
|
||||||
|
const basicThermo& thermo =
|
||||||
|
mesh_.lookupObject<basicThermo>
|
||||||
|
(
|
||||||
|
IOobject::groupName(basicThermo::dictName, phaseName_)
|
||||||
|
);
|
||||||
|
|
||||||
|
return wordList(1, thermo.he().name());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::solidEquilibriumEnergySource::addSup
|
void Foam::fv::solidEquilibriumEnergySource::addSup
|
||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const volScalarField alphahe(thermo().alphahe());
|
const volScalarField alphahe(solidThermo().alphahe());
|
||||||
|
|
||||||
const volScalarField& A = this->alpha();
|
const volScalarField& A = solidAlpha();
|
||||||
const volScalarField B(1 - A);
|
const volScalarField B(1 - A);
|
||||||
|
|
||||||
eqn -=
|
eqn -=
|
||||||
A/B*fvm::ddt(thermo().rho(), eqn.psi());
|
A/B*fvm::ddt(solidThermo().rho(), eqn.psi());
|
||||||
- 1/B*fvm::laplacian
|
- 1/B*fvm::laplacian
|
||||||
(
|
(
|
||||||
A*alphahe,
|
A*alphahe,
|
||||||
@ -146,16 +169,16 @@ void Foam::fv::solidEquilibriumEnergySource::addSup
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const volScalarField alphahe(alpha*thermo().alphahe());
|
const volScalarField alphahe(alpha*solidThermo().alphahe());
|
||||||
|
|
||||||
const volScalarField& A = this->alpha();
|
const volScalarField& A = solidAlpha();
|
||||||
const volScalarField B(1 - A);
|
const volScalarField B(1 - A);
|
||||||
|
|
||||||
eqn -=
|
eqn -=
|
||||||
A/B*fvm::ddt(alpha, thermo().rho(), eqn.psi());
|
A/B*fvm::ddt(alpha, solidThermo().rho(), eqn.psi());
|
||||||
- 1/B*fvm::laplacian
|
- 1/B*fvm::laplacian
|
||||||
(
|
(
|
||||||
A*alphahe,
|
A*alphahe,
|
||||||
@ -169,10 +192,7 @@ bool Foam::fv::solidEquilibriumEnergySource::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
if (option::read(dict))
|
if (option::read(dict))
|
||||||
{
|
{
|
||||||
fieldNames_ = wordList(1, coeffs_.lookup<word>("field"));
|
readCoeffs();
|
||||||
|
|
||||||
applied_.setSize(fieldNames_.size(), false);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2019-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2019-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -29,16 +29,16 @@ Description
|
|||||||
equation. It assumes that the solid is in thermal equilibrium with the
|
equation. It assumes that the solid is in thermal equilibrium with the
|
||||||
surrounding fluid phase.
|
surrounding fluid phase.
|
||||||
|
|
||||||
The volume fraction of the solid phase is read from constant/alpha.<phase>,
|
The volume fraction of the solid phase is read from
|
||||||
and the associated thermophysical properties are specified in
|
constant/alpha.<solidPhase>, and the associated thermophysical properties
|
||||||
constant/thermophysicalProperties.<phase>.
|
are specified in constant/thermophysicalProperties.<solidPhase>.
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
\table
|
\table
|
||||||
Property | Description | Req'd? | Default
|
Property | Description | Req'd? | Default
|
||||||
phase | Name of the solid phase | yes |
|
phase | Name of the phase to which this option applies \\
|
||||||
field | Name of the energy field to apply the option to \\
|
| no | none
|
||||||
| yes |
|
solidPhase | Name of the solid phase | yes |
|
||||||
\endtable
|
\endtable
|
||||||
|
|
||||||
Example specification:
|
Example specification:
|
||||||
@ -46,8 +46,8 @@ Usage
|
|||||||
<fvOptionName>
|
<fvOptionName>
|
||||||
{
|
{
|
||||||
type solidEquilibriumEnergySource;
|
type solidEquilibriumEnergySource;
|
||||||
phase solid;
|
|
||||||
field e;
|
solidPhase solid;
|
||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
@ -77,14 +77,23 @@ class solidEquilibriumEnergySource
|
|||||||
{
|
{
|
||||||
// Private Member Data
|
// Private Member Data
|
||||||
|
|
||||||
//- The name of the phase
|
//- The name of the phase to which this option applies
|
||||||
const word phaseName_;
|
word phaseName_;
|
||||||
|
|
||||||
//- Get the volume fraction field
|
//- The name of the solid phase
|
||||||
const volScalarField& alpha() const;
|
word solidPhaseName_;
|
||||||
|
|
||||||
//- Get the thermo
|
|
||||||
const solidThermo& thermo() const;
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
|
//- Get the solid volume fraction field
|
||||||
|
const volScalarField& solidAlpha() const;
|
||||||
|
|
||||||
|
//- Get the solid thermo
|
||||||
|
const Foam::solidThermo& solidThermo() const;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -117,6 +126,13 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
// Checks
|
||||||
|
|
||||||
|
//- Return the list of fields for which the option adds source term
|
||||||
|
// to the transport equation
|
||||||
|
virtual wordList addedToFields() const;
|
||||||
|
|
||||||
|
|
||||||
// Evaluation
|
// Evaluation
|
||||||
|
|
||||||
//- Explicit and implicit sources for compressible equations
|
//- Explicit and implicit sources for compressible equations
|
||||||
@ -124,7 +140,7 @@ public:
|
|||||||
(
|
(
|
||||||
const volScalarField&,
|
const volScalarField&,
|
||||||
fvMatrix<scalar>&,
|
fvMatrix<scalar>&,
|
||||||
const label
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Explicit and implicit sources for phase equations
|
//- Explicit and implicit sources for phase equations
|
||||||
@ -133,7 +149,7 @@ public:
|
|||||||
const volScalarField&,
|
const volScalarField&,
|
||||||
const volScalarField&,
|
const volScalarField&,
|
||||||
fvMatrix<scalar>&,
|
fvMatrix<scalar>&,
|
||||||
const label
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2014-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2014-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -66,12 +66,36 @@ const Foam::NamedEnum<Foam::fv::solidificationMeltingSource::thermoMode, 2>
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fv::solidificationMeltingSource::readCoeffs()
|
||||||
|
{
|
||||||
|
Tsol_ = coeffs_.lookup<scalar>("Tsol");
|
||||||
|
Tliq_ = coeffs_.lookupOrDefault<scalar>("Tliq", Tsol_);
|
||||||
|
alpha1e_ = coeffs_.lookupOrDefault<scalar>("alpha1e", 0.0);
|
||||||
|
L_ = coeffs_.lookup<scalar>("L");
|
||||||
|
|
||||||
|
relax_ = coeffs_.lookupOrDefault("relax", 0.9);
|
||||||
|
|
||||||
|
mode_ = thermoModeTypeNames_.read(coeffs_.lookup("thermoMode"));
|
||||||
|
|
||||||
|
rhoRef_ = coeffs_.lookup<scalar>("rhoRef");
|
||||||
|
TName_ = coeffs_.lookupOrDefault<word>("T", "T");
|
||||||
|
CpName_ = coeffs_.lookupOrDefault<word>("Cp", "Cp");
|
||||||
|
UName_ = coeffs_.lookupOrDefault<word>("U", "U");
|
||||||
|
phiName_ = coeffs_.lookupOrDefault<word>("phi", "phi");
|
||||||
|
|
||||||
|
Cu_ = coeffs_.lookupOrDefault<scalar>("Cu", 100000);
|
||||||
|
q_ = coeffs_.lookupOrDefault("q", 0.001);
|
||||||
|
|
||||||
|
beta_ = coeffs_.lookup<scalar>("beta");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::tmp<Foam::volScalarField>
|
Foam::tmp<Foam::volScalarField>
|
||||||
Foam::fv::solidificationMeltingSource::Cp() const
|
Foam::fv::solidificationMeltingSource::Cp() const
|
||||||
{
|
{
|
||||||
switch (mode_)
|
switch (mode_)
|
||||||
{
|
{
|
||||||
case mdThermo:
|
case thermoMode::thermo:
|
||||||
{
|
{
|
||||||
const basicThermo& thermo =
|
const basicThermo& thermo =
|
||||||
mesh_.lookupObject<basicThermo>(basicThermo::dictName);
|
mesh_.lookupObject<basicThermo>(basicThermo::dictName);
|
||||||
@ -79,7 +103,7 @@ Foam::fv::solidificationMeltingSource::Cp() const
|
|||||||
return thermo.Cp();
|
return thermo.Cp();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case mdLookup:
|
case thermoMode::lookup:
|
||||||
{
|
{
|
||||||
if (CpName_ == "CpRef")
|
if (CpName_ == "CpRef")
|
||||||
{
|
{
|
||||||
@ -200,20 +224,20 @@ Foam::fv::solidificationMeltingSource::solidificationMeltingSource
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
cellSetOption(sourceName, modelType, dict, mesh),
|
cellSetOption(sourceName, modelType, dict, mesh),
|
||||||
Tsol_(coeffs_.lookup<scalar>("Tsol")),
|
Tsol_(NaN),
|
||||||
Tliq_(coeffs_.lookupOrDefault("Tliq", Tsol_)),
|
Tliq_(NaN),
|
||||||
alpha1e_(coeffs_.lookupOrDefault("alpha1e", 0.0)),
|
alpha1e_(NaN),
|
||||||
L_(coeffs_.lookup<scalar>("L")),
|
L_(NaN),
|
||||||
relax_(coeffs_.lookupOrDefault("relax", 0.9)),
|
relax_(NaN),
|
||||||
mode_(thermoModeTypeNames_.read(coeffs_.lookup("thermoMode"))),
|
mode_(thermoMode::thermo),
|
||||||
rhoRef_(coeffs_.lookup<scalar>("rhoRef")),
|
rhoRef_(NaN),
|
||||||
TName_(coeffs_.lookupOrDefault<word>("T", "T")),
|
TName_(word::null),
|
||||||
CpName_(coeffs_.lookupOrDefault<word>("Cp", "Cp")),
|
CpName_(word::null),
|
||||||
UName_(coeffs_.lookupOrDefault<word>("U", "U")),
|
UName_(word::null),
|
||||||
phiName_(coeffs_.lookupOrDefault<word>("phi", "phi")),
|
phiName_(word::null),
|
||||||
Cu_(coeffs_.lookupOrDefault<scalar>("Cu", 100000)),
|
Cu_(NaN),
|
||||||
q_(coeffs_.lookupOrDefault("q", 0.001)),
|
q_(NaN),
|
||||||
beta_(coeffs_.lookup<scalar>("beta")),
|
beta_(NaN),
|
||||||
alpha1_
|
alpha1_
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
@ -231,42 +255,37 @@ Foam::fv::solidificationMeltingSource::solidificationMeltingSource
|
|||||||
curTimeIndex_(-1),
|
curTimeIndex_(-1),
|
||||||
deltaT_(cells().size(), 0)
|
deltaT_(cells().size(), 0)
|
||||||
{
|
{
|
||||||
fieldNames_.setSize(2);
|
readCoeffs();
|
||||||
fieldNames_[0] = UName_;
|
|
||||||
|
|
||||||
switch (mode_)
|
|
||||||
{
|
|
||||||
case mdThermo:
|
|
||||||
{
|
|
||||||
const basicThermo& thermo =
|
|
||||||
mesh_.lookupObject<basicThermo>(basicThermo::dictName);
|
|
||||||
|
|
||||||
fieldNames_[1] = thermo.he().name();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case mdLookup:
|
|
||||||
{
|
|
||||||
fieldNames_[1] = TName_;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Unhandled thermo mode: " << thermoModeTypeNames_[mode_]
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
applied_.setSize(fieldNames_.size(), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::wordList Foam::fv::solidificationMeltingSource::addedToFields() const
|
||||||
|
{
|
||||||
|
switch (mode_)
|
||||||
|
{
|
||||||
|
case thermoMode::thermo:
|
||||||
|
{
|
||||||
|
const basicThermo& thermo =
|
||||||
|
mesh_.lookupObject<basicThermo>(basicThermo::dictName);
|
||||||
|
|
||||||
|
return wordList({UName_, thermo.he().name()});
|
||||||
|
}
|
||||||
|
case thermoMode::lookup:
|
||||||
|
{
|
||||||
|
return wordList({UName_, TName_});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return wordList::null();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::solidificationMeltingSource::addSup
|
void Foam::fv::solidificationMeltingSource::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
apply(geometricOneField(), eqn);
|
apply(geometricOneField(), eqn);
|
||||||
@ -277,7 +296,7 @@ void Foam::fv::solidificationMeltingSource::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
apply(rho, eqn);
|
apply(rho, eqn);
|
||||||
@ -287,7 +306,7 @@ void Foam::fv::solidificationMeltingSource::addSup
|
|||||||
void Foam::fv::solidificationMeltingSource::addSup
|
void Foam::fv::solidificationMeltingSource::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
@ -327,11 +346,27 @@ void Foam::fv::solidificationMeltingSource::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// Momentum source uses a Boussinesq approximation - redirect
|
// Momentum source uses a Boussinesq approximation - redirect
|
||||||
addSup(eqn, fieldi);
|
addSup(eqn, fieldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::fv::solidificationMeltingSource::read(const dictionary& dict)
|
||||||
|
{
|
||||||
|
if (cellSetOption::read(dict))
|
||||||
|
{
|
||||||
|
readCoeffs();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2014-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2014-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -114,7 +114,6 @@ Usage
|
|||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
solidificationMeltingSource.C
|
solidificationMeltingSource.C
|
||||||
solidificationMeltingSourceIO.C
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -143,10 +142,10 @@ class solidificationMeltingSource
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum thermoMode
|
enum class thermoMode
|
||||||
{
|
{
|
||||||
mdThermo,
|
thermo,
|
||||||
mdLookup
|
lookup
|
||||||
};
|
};
|
||||||
|
|
||||||
static const NamedEnum<thermoMode, 2> thermoModeTypeNames_;
|
static const NamedEnum<thermoMode, 2> thermoModeTypeNames_;
|
||||||
@ -213,6 +212,9 @@ private:
|
|||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
//- Return the specific heat capacity field
|
//- Return the specific heat capacity field
|
||||||
tmp<volScalarField> Cp() const;
|
tmp<volScalarField> Cp() const;
|
||||||
|
|
||||||
@ -253,20 +255,27 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
// Checks
|
||||||
|
|
||||||
|
//- Return the list of fields for which the option adds source term
|
||||||
|
// to the transport equation
|
||||||
|
virtual wordList addedToFields() const;
|
||||||
|
|
||||||
|
|
||||||
// Add explicit and implicit contributions
|
// Add explicit and implicit contributions
|
||||||
|
|
||||||
//- Add explicit contribution to enthalpy equation
|
//- Add explicit contribution to enthalpy equation
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Add implicit contribution to momentum equation
|
//- Add implicit contribution to momentum equation
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
@ -277,7 +286,7 @@ public:
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Add implicit contribution to compressible momentum equation
|
//- Add implicit contribution to compressible momentum equation
|
||||||
@ -285,7 +294,7 @@ public:
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,63 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration | Website: https://openfoam.org
|
|
||||||
\\ / A nd | Copyright (C) 2014-2018 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 "solidificationMeltingSource.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
|
||||||
|
|
||||||
bool Foam::fv::solidificationMeltingSource::read(const dictionary& dict)
|
|
||||||
{
|
|
||||||
if (cellSetOption::read(dict))
|
|
||||||
{
|
|
||||||
coeffs_.lookup("Tsol") >> Tsol_;
|
|
||||||
coeffs_.readIfPresent("Tliq", Tliq_);
|
|
||||||
coeffs_.readIfPresent("alpha1e", alpha1e_);
|
|
||||||
coeffs_.lookup("L") >> L_;
|
|
||||||
|
|
||||||
coeffs_.readIfPresent("relax", relax_);
|
|
||||||
|
|
||||||
mode_ = thermoModeTypeNames_.read(coeffs_.lookup("thermoMode"));
|
|
||||||
|
|
||||||
coeffs_.lookup("rhoRef") >> rhoRef_;
|
|
||||||
coeffs_.readIfPresent("T", TName_);
|
|
||||||
coeffs_.readIfPresent("U", UName_);
|
|
||||||
|
|
||||||
coeffs_.readIfPresent("Cu", Cu_);
|
|
||||||
coeffs_.readIfPresent("q", q_);
|
|
||||||
|
|
||||||
coeffs_.readIfPresent("beta", beta_);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2019-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2019-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -50,9 +50,19 @@ namespace fv
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
const Foam::volScalarField& Foam::fv::volumeFractionSource::alpha() const
|
void Foam::fv::volumeFractionSource::readCoeffs()
|
||||||
{
|
{
|
||||||
const word alphaName = IOobject::groupName("alpha", phaseName_);
|
phiName_ = coeffs_.lookupOrDefault<word>("phi", "phi");
|
||||||
|
rhoName_ = coeffs_.lookupOrDefault<word>("rho", "rho");
|
||||||
|
UName_ = coeffs_.lookupOrDefault<word>("U", "U");
|
||||||
|
|
||||||
|
volumePhaseName_ = coeffs_.lookup<word>("volumePhase");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::volScalarField& Foam::fv::volumeFractionSource::volumeAlpha() const
|
||||||
|
{
|
||||||
|
const word alphaName = IOobject::groupName("alpha", volumePhaseName_);
|
||||||
|
|
||||||
if (!mesh_.foundObject<volScalarField>(alphaName))
|
if (!mesh_.foundObject<volScalarField>(alphaName))
|
||||||
{
|
{
|
||||||
@ -79,11 +89,13 @@ const Foam::volScalarField& Foam::fv::volumeFractionSource::alpha() const
|
|||||||
|
|
||||||
Foam::tmp<Foam::volScalarField> Foam::fv::volumeFractionSource::D
|
Foam::tmp<Foam::volScalarField> Foam::fv::volumeFractionSource::D
|
||||||
(
|
(
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
|
const word phiName =
|
||||||
|
IOobject::groupName(phiName_, IOobject::group(fieldName));
|
||||||
const surfaceScalarField& phi =
|
const surfaceScalarField& phi =
|
||||||
mesh().lookupObject<surfaceScalarField>(phiName_);
|
mesh().lookupObject<surfaceScalarField>(phiName);
|
||||||
|
|
||||||
if (phi.dimensions() == dimVolume/dimTime)
|
if (phi.dimensions() == dimVolume/dimTime)
|
||||||
{
|
{
|
||||||
@ -104,9 +116,9 @@ Foam::tmp<Foam::volScalarField> Foam::fv::volumeFractionSource::D
|
|||||||
);
|
);
|
||||||
|
|
||||||
return
|
return
|
||||||
fieldNames_[fieldi] == ttm.thermo().T().name()
|
fieldName == ttm.thermo().T().name()
|
||||||
? ttm.kappaEff()
|
? ttm.kappaEff()
|
||||||
: fieldNames_[fieldi] == ttm.thermo().he().name()
|
: fieldName == ttm.thermo().he().name()
|
||||||
? ttm.alphaEff()
|
? ttm.alphaEff()
|
||||||
: ttm.momentumTransport().muEff();
|
: ttm.momentumTransport().muEff();
|
||||||
}
|
}
|
||||||
@ -124,30 +136,36 @@ template <class Type>
|
|||||||
void Foam::fv::volumeFractionSource::addDivSup
|
void Foam::fv::volumeFractionSource::addDivSup
|
||||||
(
|
(
|
||||||
fvMatrix<Type>& eqn,
|
fvMatrix<Type>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
|
const word phiName =
|
||||||
|
IOobject::groupName(phiName_, IOobject::group(fieldName));
|
||||||
const surfaceScalarField& phi =
|
const surfaceScalarField& phi =
|
||||||
mesh().lookupObject<surfaceScalarField>(phiName_);
|
mesh().lookupObject<surfaceScalarField>(phiName);
|
||||||
|
|
||||||
const volScalarField AByB(this->alpha()/(1 - this->alpha()));
|
const volScalarField AByB(volumeAlpha()/(1 - volumeAlpha()));
|
||||||
|
|
||||||
eqn -= AByB*fvm::div(phi, eqn.psi());
|
const word scheme("div(" + phiName + "," + eqn.psi().name() + ")");
|
||||||
|
|
||||||
|
eqn -= AByB*fvm::div(phi, eqn.psi(), scheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::volumeFractionSource::addUDivSup
|
void Foam::fv::volumeFractionSource::addUDivSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
|
const word phiName =
|
||||||
|
IOobject::groupName(phiName_, IOobject::group(fieldName));
|
||||||
const surfaceScalarField& phi =
|
const surfaceScalarField& phi =
|
||||||
mesh().lookupObject<surfaceScalarField>(phiName_);
|
mesh().lookupObject<surfaceScalarField>(phiName);
|
||||||
|
|
||||||
const volScalarField AByB(this->alpha()/(1 - this->alpha()));
|
const volScalarField AByB(volumeAlpha()/(1 - volumeAlpha()));
|
||||||
|
|
||||||
const word scheme("div(" + phiName_ + "," + eqn.psi().name() + ")");
|
const word scheme("div(" + phiName + "," + eqn.psi().name() + ")");
|
||||||
|
|
||||||
eqn -= fvm::div(fvc::interpolate(AByB)*phi, eqn.psi(), scheme);
|
eqn -= fvm::div(fvc::interpolate(AByB)*phi, eqn.psi(), scheme);
|
||||||
}
|
}
|
||||||
@ -156,13 +174,15 @@ void Foam::fv::volumeFractionSource::addUDivSup
|
|||||||
void Foam::fv::volumeFractionSource::addRhoDivSup
|
void Foam::fv::volumeFractionSource::addRhoDivSup
|
||||||
(
|
(
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
|
const word phiName =
|
||||||
|
IOobject::groupName(phiName_, IOobject::group(fieldName));
|
||||||
const surfaceScalarField& phi =
|
const surfaceScalarField& phi =
|
||||||
mesh().lookupObject<surfaceScalarField>(phiName_);
|
mesh().lookupObject<surfaceScalarField>(phiName);
|
||||||
|
|
||||||
const volScalarField AByB(this->alpha()/(1 - this->alpha()));
|
const volScalarField AByB(volumeAlpha()/(1 - volumeAlpha()));
|
||||||
|
|
||||||
eqn -= AByB*fvc::div(phi);
|
eqn -= AByB*fvc::div(phi);
|
||||||
}
|
}
|
||||||
@ -173,12 +193,12 @@ void Foam::fv::volumeFractionSource::addLaplacianSup
|
|||||||
(
|
(
|
||||||
const AlphaFieldType& alpha,
|
const AlphaFieldType& alpha,
|
||||||
fvMatrix<Type>& eqn,
|
fvMatrix<Type>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const volScalarField B(1 - this->alpha());
|
const volScalarField B(1 - volumeAlpha());
|
||||||
|
|
||||||
const volScalarField D(this->D(fieldi));
|
const volScalarField D(this->D(fieldName));
|
||||||
|
|
||||||
const word scheme("laplacian(" + D.name() + "," + eqn.psi().name() + ")");
|
const word scheme("laplacian(" + D.name() + "," + eqn.psi().name() + ")");
|
||||||
|
|
||||||
@ -199,15 +219,16 @@ Foam::fv::volumeFractionSource::volumeFractionSource
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
option(name, modelType, dict, mesh),
|
option(name, modelType, dict, mesh),
|
||||||
phaseName_(dict.lookup<word>("phase")),
|
phiName_(word::null),
|
||||||
phiName_("phi"),
|
rhoName_(word::null),
|
||||||
rhoName_("rho"),
|
UName_(word::null),
|
||||||
UName_("U")
|
volumePhaseName_(word::null)
|
||||||
{
|
{
|
||||||
read(dict);
|
readCoeffs();
|
||||||
alpha();
|
volumeAlpha();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::fv::volumeFractionSource::~volumeFractionSource()
|
Foam::fv::volumeFractionSource::~volumeFractionSource()
|
||||||
@ -216,20 +237,32 @@ Foam::fv::volumeFractionSource::~volumeFractionSource()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::fv::volumeFractionSource::addsToField(const word& fieldName) const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::wordList Foam::fv::volumeFractionSource::addedToFields() const
|
||||||
|
{
|
||||||
|
return wordList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::volumeFractionSource::addSup
|
void Foam::fv::volumeFractionSource::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (fieldNames_[fieldi] == rhoName_)
|
if (IOobject::member(fieldName) == rhoName_)
|
||||||
{
|
{
|
||||||
addRhoDivSup(eqn, fieldi);
|
addRhoDivSup(eqn, fieldName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
addDivSup(eqn, fieldi);
|
addDivSup(eqn, fieldName);
|
||||||
addLaplacianSup(geometricOneField(), eqn, fieldi);
|
addLaplacianSup(geometricOneField(), eqn, fieldName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,17 +270,17 @@ void Foam::fv::volumeFractionSource::addSup
|
|||||||
void Foam::fv::volumeFractionSource::addSup
|
void Foam::fv::volumeFractionSource::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (fieldNames_[fieldi] == UName_)
|
if (IOobject::member(fieldName) == UName_)
|
||||||
{
|
{
|
||||||
addUDivSup(eqn, fieldi);
|
addUDivSup(eqn, fieldName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
addDivSup(eqn, fieldi);
|
addDivSup(eqn, fieldName);
|
||||||
addLaplacianSup(geometricOneField(), eqn, fieldi);
|
addLaplacianSup(geometricOneField(), eqn, fieldName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,33 +288,33 @@ void Foam::fv::volumeFractionSource::addSup
|
|||||||
void Foam::fv::volumeFractionSource::addSup
|
void Foam::fv::volumeFractionSource::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<sphericalTensor>& eqn,
|
fvMatrix<sphericalTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addDivSup(eqn, fieldi);
|
addDivSup(eqn, fieldName);
|
||||||
addLaplacianSup(geometricOneField(), eqn, fieldi);
|
addLaplacianSup(geometricOneField(), eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::volumeFractionSource::addSup
|
void Foam::fv::volumeFractionSource::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<symmTensor>& eqn,
|
fvMatrix<symmTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addDivSup(eqn, fieldi);
|
addDivSup(eqn, fieldName);
|
||||||
addLaplacianSup(geometricOneField(), eqn, fieldi);
|
addLaplacianSup(geometricOneField(), eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::volumeFractionSource::addSup
|
void Foam::fv::volumeFractionSource::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<tensor>& eqn,
|
fvMatrix<tensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addDivSup(eqn, fieldi);
|
addDivSup(eqn, fieldName);
|
||||||
addLaplacianSup(geometricOneField(), eqn, fieldi);
|
addLaplacianSup(geometricOneField(), eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -289,17 +322,17 @@ void Foam::fv::volumeFractionSource::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (fieldNames_[fieldi] == rhoName_)
|
if (IOobject::member(fieldName) == rhoName_)
|
||||||
{
|
{
|
||||||
addRhoDivSup(eqn, fieldi);
|
addRhoDivSup(eqn, fieldName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
addDivSup(eqn, fieldi);
|
addDivSup(eqn, fieldName);
|
||||||
addLaplacianSup(geometricOneField(), eqn, fieldi);
|
addLaplacianSup(geometricOneField(), eqn, fieldName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,17 +341,17 @@ void Foam::fv::volumeFractionSource::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (fieldNames_[fieldi] == UName_)
|
if (IOobject::member(fieldName) == UName_)
|
||||||
{
|
{
|
||||||
addUDivSup(eqn, fieldi);
|
addUDivSup(eqn, fieldName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
addDivSup(eqn, fieldi);
|
addDivSup(eqn, fieldName);
|
||||||
addLaplacianSup(geometricOneField(), eqn, fieldi);
|
addLaplacianSup(geometricOneField(), eqn, fieldName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,11 +360,11 @@ void Foam::fv::volumeFractionSource::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<sphericalTensor>& eqn,
|
fvMatrix<sphericalTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addDivSup(eqn, fieldi);
|
addDivSup(eqn, fieldName);
|
||||||
addLaplacianSup(geometricOneField(), eqn, fieldi);
|
addLaplacianSup(geometricOneField(), eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -339,11 +372,11 @@ void Foam::fv::volumeFractionSource::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<symmTensor>& eqn,
|
fvMatrix<symmTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addDivSup(eqn, fieldi);
|
addDivSup(eqn, fieldName);
|
||||||
addLaplacianSup(geometricOneField(), eqn, fieldi);
|
addLaplacianSup(geometricOneField(), eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -351,11 +384,11 @@ void Foam::fv::volumeFractionSource::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<tensor>& eqn,
|
fvMatrix<tensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addDivSup(eqn, fieldi);
|
addDivSup(eqn, fieldName);
|
||||||
addLaplacianSup(geometricOneField(), eqn, fieldi);
|
addLaplacianSup(geometricOneField(), eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -364,17 +397,17 @@ void Foam::fv::volumeFractionSource::addSup
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (fieldNames_[fieldi] == rhoName_)
|
if (IOobject::member(fieldName) == rhoName_)
|
||||||
{
|
{
|
||||||
addRhoDivSup(eqn, fieldi);
|
addRhoDivSup(eqn, fieldName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
addDivSup(eqn, fieldi);
|
addDivSup(eqn, fieldName);
|
||||||
addLaplacianSup(alpha, eqn, fieldi);
|
addLaplacianSup(alpha, eqn, fieldName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -384,17 +417,17 @@ void Foam::fv::volumeFractionSource::addSup
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (fieldNames_[fieldi] == UName_)
|
if (IOobject::member(fieldName) == UName_)
|
||||||
{
|
{
|
||||||
addUDivSup(eqn, fieldi);
|
addUDivSup(eqn, fieldName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
addDivSup(eqn, fieldi);
|
addDivSup(eqn, fieldName);
|
||||||
addLaplacianSup(alpha, eqn, fieldi);
|
addLaplacianSup(alpha, eqn, fieldName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,11 +437,11 @@ void Foam::fv::volumeFractionSource::addSup
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<sphericalTensor>& eqn,
|
fvMatrix<sphericalTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addDivSup(eqn, fieldi);
|
addDivSup(eqn, fieldName);
|
||||||
addLaplacianSup(alpha, eqn, fieldi);
|
addLaplacianSup(alpha, eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -417,11 +450,11 @@ void Foam::fv::volumeFractionSource::addSup
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<symmTensor>& eqn,
|
fvMatrix<symmTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addDivSup(eqn, fieldi);
|
addDivSup(eqn, fieldName);
|
||||||
addLaplacianSup(alpha, eqn, fieldi);
|
addLaplacianSup(alpha, eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -430,11 +463,11 @@ void Foam::fv::volumeFractionSource::addSup
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<tensor>& eqn,
|
fvMatrix<tensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addDivSup(eqn, fieldi);
|
addDivSup(eqn, fieldName);
|
||||||
addLaplacianSup(alpha, eqn, fieldi);
|
addLaplacianSup(alpha, eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -442,19 +475,7 @@ bool Foam::fv::volumeFractionSource::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
if (option::read(dict))
|
if (option::read(dict))
|
||||||
{
|
{
|
||||||
if (coeffs_.found("fields"))
|
readCoeffs();
|
||||||
{
|
|
||||||
coeffs_.lookup("fields") >> fieldNames_;
|
|
||||||
}
|
|
||||||
|
|
||||||
applied_.setSize(fieldNames_.size(), false);
|
|
||||||
|
|
||||||
dict.readIfPresent("phi", phiName_);
|
|
||||||
|
|
||||||
dict.readIfPresent("rho", rhoName_);
|
|
||||||
|
|
||||||
dict.readIfPresent("U", UName_);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2019-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2019-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -27,9 +27,9 @@ Class
|
|||||||
Description
|
Description
|
||||||
This option adds transport terms into the equations to account for the
|
This option adds transport terms into the equations to account for the
|
||||||
presence of a constant volume fraction. The volume fraction is read from
|
presence of a constant volume fraction. The volume fraction is read from
|
||||||
constant/alpha.<phase>, where <phase> is given as a parameter to the
|
constant/alpha.<volumePhase>, where <volumePhase> is given as a parameter
|
||||||
option. Both advective and diffusive terms are added, and the resulting
|
to the option. Both advective and diffusive terms are added, and the
|
||||||
solution is time-accurate. The flux and velocity are treated as
|
resulting solution is time-accurate. The flux and velocity are treated as
|
||||||
superficial.
|
superficial.
|
||||||
|
|
||||||
This can be used to represent the effect of porous media that are caused
|
This can be used to represent the effect of porous media that are caused
|
||||||
@ -40,26 +40,25 @@ Description
|
|||||||
|
|
||||||
Usage
|
Usage
|
||||||
\table
|
\table
|
||||||
Property | Description | Req'd? | Default
|
Property | Description | Req'd? | Default
|
||||||
phase | Name of the phase associated with the volume fraction \\
|
phi | Name of the flux field | no | phi
|
||||||
| yes |
|
rho | Name of the density field | no | rho
|
||||||
phi | Name of the flux field | no | phi
|
U | Name of the velocity field | no | U
|
||||||
rho | Name of the density field | no | rho
|
volumePhase | Name of the phase associated with the volume fraction \\
|
||||||
U | Name of the velocity field | no | U
|
| yes |
|
||||||
fields | Names of the fields to apply the option to \\
|
|
||||||
| yes |
|
|
||||||
\endtable
|
\endtable
|
||||||
|
|
||||||
Example specification:
|
Example specification:
|
||||||
\verbatim
|
\verbatim
|
||||||
<fvOptionName>
|
volumeFractionSource1
|
||||||
{
|
{
|
||||||
type volumeFractionSource;
|
type volumeFractionSource;
|
||||||
phase solid;
|
|
||||||
phi phi;
|
phi phi;
|
||||||
rho rho;
|
rho rho;
|
||||||
U U;
|
U U;
|
||||||
fields (rho U e);
|
|
||||||
|
volumePhase solid;
|
||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
@ -92,9 +91,6 @@ class volumeFractionSource
|
|||||||
{
|
{
|
||||||
// Private Member Data
|
// Private Member Data
|
||||||
|
|
||||||
//- The name of the phase
|
|
||||||
const word phaseName_;
|
|
||||||
|
|
||||||
//- The name of the flux field
|
//- The name of the flux field
|
||||||
word phiName_;
|
word phiName_;
|
||||||
|
|
||||||
@ -104,18 +100,24 @@ class volumeFractionSource
|
|||||||
//- The name of the velocity field
|
//- The name of the velocity field
|
||||||
word UName_;
|
word UName_;
|
||||||
|
|
||||||
|
//- The name of the volume fraction phase
|
||||||
|
word volumePhaseName_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
//- Get the volume fraction field
|
//- Get the volume fraction field
|
||||||
const volScalarField& alpha() const;
|
const volScalarField& volumeAlpha() const;
|
||||||
|
|
||||||
//- Get the diffusivity for a given field
|
//- Get the diffusivity for a given field
|
||||||
tmp<volScalarField> D(const label) const;
|
tmp<volScalarField> D(const word& fieldName) const;
|
||||||
|
|
||||||
//- Add time-derivative terms to an equation
|
//- Add time-derivative terms to an equation
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void addDdtSup(fvMatrix<Type>&, const label) const;
|
void addDdtSup(fvMatrix<Type>&, const word& fieldName) const;
|
||||||
|
|
||||||
//- Add time-derivative terms to a compressible equation
|
//- Add time-derivative terms to a compressible equation
|
||||||
template <class Type>
|
template <class Type>
|
||||||
@ -123,7 +125,7 @@ class volumeFractionSource
|
|||||||
(
|
(
|
||||||
const volScalarField&,
|
const volScalarField&,
|
||||||
fvMatrix<Type>&,
|
fvMatrix<Type>&,
|
||||||
const label
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Add time-derivative terms to a phase-compressible equation
|
//- Add time-derivative terms to a phase-compressible equation
|
||||||
@ -133,18 +135,18 @@ class volumeFractionSource
|
|||||||
const volScalarField&,
|
const volScalarField&,
|
||||||
const volScalarField&,
|
const volScalarField&,
|
||||||
fvMatrix<Type>&,
|
fvMatrix<Type>&,
|
||||||
const label
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Add divergence terms to an equation
|
//- Add divergence terms to an equation
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void addDivSup(fvMatrix<Type>&, const label) const;
|
void addDivSup(fvMatrix<Type>&, const word& fieldName) const;
|
||||||
|
|
||||||
//- Add divergence terms to the momentum equation
|
//- Add divergence terms to the momentum equation
|
||||||
void addUDivSup(fvMatrix<vector>&, const label) const;
|
void addUDivSup(fvMatrix<vector>&, const word& fieldName) const;
|
||||||
|
|
||||||
//- Add divergence terms to the continuity equation
|
//- Add divergence terms to the continuity equation
|
||||||
void addRhoDivSup(fvMatrix<scalar>&, const label) const;
|
void addRhoDivSup(fvMatrix<scalar>&, const word& fieldName) const;
|
||||||
|
|
||||||
//- Add Laplacian terms to an equation
|
//- Add Laplacian terms to an equation
|
||||||
template <class Type, class AlphaFieldType>
|
template <class Type, class AlphaFieldType>
|
||||||
@ -152,7 +154,7 @@ class volumeFractionSource
|
|||||||
(
|
(
|
||||||
const AlphaFieldType& alpha,
|
const AlphaFieldType& alpha,
|
||||||
fvMatrix<Type>& eqn,
|
fvMatrix<Type>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
@ -183,23 +185,50 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
// Checks
|
||||||
|
|
||||||
|
//- Return true if the option adds a source term to the given
|
||||||
|
// field's transport equation
|
||||||
|
virtual bool addsToField(const word& fieldName) const;
|
||||||
|
|
||||||
|
//- Return the list of fields for which the option adds source term
|
||||||
|
// to the transport equation
|
||||||
|
virtual wordList addedToFields() const;
|
||||||
|
|
||||||
|
|
||||||
// Evaluation
|
// Evaluation
|
||||||
|
|
||||||
// Explicit and implicit sources
|
// Explicit and implicit sources
|
||||||
|
|
||||||
virtual void addSup(fvMatrix<scalar>&, const label) const;
|
virtual void addSup
|
||||||
|
(
|
||||||
|
fvMatrix<scalar>&,
|
||||||
|
const word& fieldName
|
||||||
|
) const;
|
||||||
|
|
||||||
virtual void addSup(fvMatrix<vector>&, const label) const;
|
virtual void addSup
|
||||||
|
(
|
||||||
|
fvMatrix<vector>&,
|
||||||
|
const word& fieldName
|
||||||
|
) const;
|
||||||
|
|
||||||
virtual void addSup(fvMatrix<symmTensor>&, const label) const;
|
virtual void addSup
|
||||||
|
(
|
||||||
|
fvMatrix<symmTensor>&,
|
||||||
|
const word& fieldName
|
||||||
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<sphericalTensor>&,
|
fvMatrix<sphericalTensor>&,
|
||||||
const label
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup(fvMatrix<tensor>&, const label) const;
|
virtual void addSup
|
||||||
|
(
|
||||||
|
fvMatrix<tensor>&,
|
||||||
|
const word& fieldName
|
||||||
|
) const;
|
||||||
|
|
||||||
|
|
||||||
// Explicit and implicit sources for compressible equations
|
// Explicit and implicit sources for compressible equations
|
||||||
@ -208,35 +237,35 @@ public:
|
|||||||
(
|
(
|
||||||
const volScalarField&,
|
const volScalarField&,
|
||||||
fvMatrix<scalar>&,
|
fvMatrix<scalar>&,
|
||||||
const label
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
const volScalarField&,
|
const volScalarField&,
|
||||||
fvMatrix<vector>&,
|
fvMatrix<vector>&,
|
||||||
const label
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
const volScalarField&,
|
const volScalarField&,
|
||||||
fvMatrix<symmTensor>&,
|
fvMatrix<symmTensor>&,
|
||||||
const label
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
const volScalarField&,
|
const volScalarField&,
|
||||||
fvMatrix<sphericalTensor>&,
|
fvMatrix<sphericalTensor>&,
|
||||||
const label
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
const volScalarField&,
|
const volScalarField&,
|
||||||
fvMatrix<tensor>&,
|
fvMatrix<tensor>&,
|
||||||
const label
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
@ -247,7 +276,7 @@ public:
|
|||||||
const volScalarField&,
|
const volScalarField&,
|
||||||
const volScalarField&,
|
const volScalarField&,
|
||||||
fvMatrix<scalar>&,
|
fvMatrix<scalar>&,
|
||||||
const label
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
@ -255,7 +284,7 @@ public:
|
|||||||
const volScalarField&,
|
const volScalarField&,
|
||||||
const volScalarField&,
|
const volScalarField&,
|
||||||
fvMatrix<vector>&,
|
fvMatrix<vector>&,
|
||||||
const label
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
@ -263,7 +292,7 @@ public:
|
|||||||
const volScalarField&,
|
const volScalarField&,
|
||||||
const volScalarField&,
|
const volScalarField&,
|
||||||
fvMatrix<symmTensor>&,
|
fvMatrix<symmTensor>&,
|
||||||
const label
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
@ -271,7 +300,7 @@ public:
|
|||||||
const volScalarField&,
|
const volScalarField&,
|
||||||
const volScalarField&,
|
const volScalarField&,
|
||||||
fvMatrix<sphericalTensor>&,
|
fvMatrix<sphericalTensor>&,
|
||||||
const label
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
@ -279,7 +308,7 @@ public:
|
|||||||
const volScalarField&,
|
const volScalarField&,
|
||||||
const volScalarField&,
|
const volScalarField&,
|
||||||
fvMatrix<tensor>&,
|
fvMatrix<tensor>&,
|
||||||
const label
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,251 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration | Website: https://openfoam.org
|
|
||||||
\\ / A nd | Copyright (C) 2012-2020 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 "CodedSource.H"
|
|
||||||
#include "fvMesh.H"
|
|
||||||
#include "fvMatrices.H"
|
|
||||||
#include "dynamicCode.H"
|
|
||||||
#include "dynamicCodeContext.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * Protected Static Data Members * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
const Foam::wordList Foam::fv::CodedSource<Type>::codeKeys_ =
|
|
||||||
{
|
|
||||||
"codeAddSup",
|
|
||||||
"codeAddRhoSup",
|
|
||||||
"codeAddAlphaRhoSup",
|
|
||||||
"codeCorrect",
|
|
||||||
"codeInclude",
|
|
||||||
"codeSetValue",
|
|
||||||
"localCode"
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::fv::CodedSource<Type>::prepare
|
|
||||||
(
|
|
||||||
dynamicCode& dynCode,
|
|
||||||
const dynamicCodeContext& context
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
word sourceType(pTraits<Type>::typeName);
|
|
||||||
|
|
||||||
// Set additional rewrite rules
|
|
||||||
dynCode.setFilterVariable("typeName", name_);
|
|
||||||
dynCode.setFilterVariable("TemplateType", sourceType);
|
|
||||||
dynCode.setFilterVariable("SourceType", sourceType + "Source");
|
|
||||||
|
|
||||||
// compile filtered C template
|
|
||||||
dynCode.addCompileFile("codedFvOptionTemplate.C");
|
|
||||||
|
|
||||||
// copy filtered H template
|
|
||||||
dynCode.addCopyFile("codedFvOptionTemplate.H");
|
|
||||||
|
|
||||||
// debugging: make BC verbose
|
|
||||||
// dynCode.setFilterVariable("verbose", "true");
|
|
||||||
// Info<<"compile " << name_ << " sha1: "
|
|
||||||
// << context.sha1() << endl;
|
|
||||||
|
|
||||||
// define Make/options
|
|
||||||
dynCode.setMakeOptions
|
|
||||||
(
|
|
||||||
"EXE_INC = -g \\\n"
|
|
||||||
"-I$(LIB_SRC)/finiteVolume/lnInclude \\\n"
|
|
||||||
"-I$(LIB_SRC)/meshTools/lnInclude \\\n"
|
|
||||||
"-I$(LIB_SRC)/sampling/lnInclude \\\n"
|
|
||||||
"-I$(LIB_SRC)/fvOptions/lnInclude \\\n"
|
|
||||||
+ context.options()
|
|
||||||
+ "\n\nLIB_LIBS = \\\n"
|
|
||||||
+ " -lmeshTools \\\n"
|
|
||||||
+ " -lfvOptions \\\n"
|
|
||||||
+ " -lsampling \\\n"
|
|
||||||
+ " -lfiniteVolume \\\n"
|
|
||||||
+ context.libs()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
Foam::string Foam::fv::CodedSource<Type>::description() const
|
|
||||||
{
|
|
||||||
return "fvOption:: " + name_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::fv::CodedSource<Type>::clearRedirect() const
|
|
||||||
{
|
|
||||||
redirectFvOptionPtr_.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
const Foam::dictionary& Foam::fv::CodedSource<Type>::codeDict() const
|
|
||||||
{
|
|
||||||
return coeffs_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
const Foam::wordList& Foam::fv::CodedSource<Type>::codeKeys() const
|
|
||||||
{
|
|
||||||
return codeKeys_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
Foam::fv::CodedSource<Type>::CodedSource
|
|
||||||
(
|
|
||||||
const word& name,
|
|
||||||
const word& modelType,
|
|
||||||
const dictionary& dict,
|
|
||||||
const fvMesh& mesh
|
|
||||||
)
|
|
||||||
:
|
|
||||||
cellSetOption(name, modelType, dict, mesh)
|
|
||||||
{
|
|
||||||
read(dict);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
Foam::fv::option& Foam::fv::CodedSource<Type>::redirectFvOption() const
|
|
||||||
{
|
|
||||||
if (!redirectFvOptionPtr_.valid())
|
|
||||||
{
|
|
||||||
dictionary constructDict(dict_);
|
|
||||||
constructDict.set("type", name_);
|
|
||||||
|
|
||||||
redirectFvOptionPtr_ = option::New
|
|
||||||
(
|
|
||||||
name_,
|
|
||||||
constructDict,
|
|
||||||
mesh_
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return redirectFvOptionPtr_();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::fv::CodedSource<Type>::correct
|
|
||||||
(
|
|
||||||
GeometricField<Type, fvPatchField, volMesh>& field
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
Info<< "CodedSource<"<< pTraits<Type>::typeName
|
|
||||||
<< ">::correct for source " << name_ << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateLibrary();
|
|
||||||
redirectFvOption().correct(field);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::fv::CodedSource<Type>::addSup
|
|
||||||
(
|
|
||||||
fvMatrix<Type>& eqn,
|
|
||||||
const label fieldi
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
Info<< "CodedSource<"<< pTraits<Type>::typeName
|
|
||||||
<< ">::addSup for source " << name_ << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateLibrary();
|
|
||||||
redirectFvOption().addSup(eqn, fieldi);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::fv::CodedSource<Type>::addSup
|
|
||||||
(
|
|
||||||
const volScalarField& rho,
|
|
||||||
fvMatrix<Type>& eqn,
|
|
||||||
const label fieldi
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
Info<< "CodedSource<"<< pTraits<Type>::typeName
|
|
||||||
<< ">::addSup for source " << name_ << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateLibrary();
|
|
||||||
redirectFvOption().addSup(rho, eqn, fieldi);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::fv::CodedSource<Type>::addSup
|
|
||||||
(
|
|
||||||
const volScalarField& alpha,
|
|
||||||
const volScalarField& rho,
|
|
||||||
fvMatrix<Type>& eqn,
|
|
||||||
const label fieldi
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
Info<< "CodedSource<"<< pTraits<Type>::typeName
|
|
||||||
<< ">::addSup for source " << name_ << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateLibrary();
|
|
||||||
redirectFvOption().addSup(alpha, rho, eqn, fieldi);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::fv::CodedSource<Type>::constrain
|
|
||||||
(
|
|
||||||
fvMatrix<Type>& eqn,
|
|
||||||
const label fieldi
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
Info<< "CodedSource<"<< pTraits<Type>::typeName
|
|
||||||
<< ">::constrain for source " << name_ << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateLibrary();
|
|
||||||
redirectFvOption().constrain(eqn, fieldi);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,244 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration | Website: https://openfoam.org
|
|
||||||
\\ / A nd | Copyright (C) 2012-2020 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/>.
|
|
||||||
|
|
||||||
Class
|
|
||||||
Foam::fv::CodedSource
|
|
||||||
|
|
||||||
Description
|
|
||||||
Constructs on-the-fly fvOption source from user-supplied code
|
|
||||||
|
|
||||||
Usage
|
|
||||||
Example usage in controlDict:
|
|
||||||
\verbatim
|
|
||||||
energySource
|
|
||||||
{
|
|
||||||
type scalarCodedSource;
|
|
||||||
|
|
||||||
name sourceTime;
|
|
||||||
|
|
||||||
scalarCodedSourceCoeffs
|
|
||||||
{
|
|
||||||
selectionMode all;
|
|
||||||
|
|
||||||
fields (h);
|
|
||||||
|
|
||||||
codeInclude
|
|
||||||
#{
|
|
||||||
#};
|
|
||||||
|
|
||||||
codeCorrect
|
|
||||||
#{
|
|
||||||
Pout<< "**codeCorrect**" << endl;
|
|
||||||
#};
|
|
||||||
|
|
||||||
codeAddSup
|
|
||||||
#{
|
|
||||||
const Time& time = mesh().time();
|
|
||||||
const scalarField& V = mesh_.V();
|
|
||||||
scalarField& heSource = eqn.source();
|
|
||||||
heSource -= 0.1*sqr(time.value())*V;
|
|
||||||
#};
|
|
||||||
|
|
||||||
codeAddRhoSup
|
|
||||||
#{
|
|
||||||
Pout<< "**codeAddRhoSup**" << endl;
|
|
||||||
#};
|
|
||||||
|
|
||||||
codeAddAlphaRhoSup
|
|
||||||
#{
|
|
||||||
Pout<< "**codeAddAlphaRhoSup**" << endl;
|
|
||||||
#};
|
|
||||||
|
|
||||||
codeSetValue
|
|
||||||
#{
|
|
||||||
Pout<< "**codeSetValue**" << endl;
|
|
||||||
#};
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceTimeCoeffs
|
|
||||||
{
|
|
||||||
$scalarCodedSourceCoeffs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
\endverbatim
|
|
||||||
|
|
||||||
|
|
||||||
SourceFiles
|
|
||||||
codedSource.C
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef CodedSource_H
|
|
||||||
#define CodedSource_H
|
|
||||||
|
|
||||||
#include "cellSetOption.H"
|
|
||||||
#include "codedBase.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
namespace fv
|
|
||||||
{
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
Class codedSource Declaration
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
class CodedSource
|
|
||||||
:
|
|
||||||
public cellSetOption,
|
|
||||||
public codedBase
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
|
|
||||||
// Protected static data
|
|
||||||
|
|
||||||
//- The keywords associated with source code
|
|
||||||
static const wordList codeKeys_;
|
|
||||||
|
|
||||||
|
|
||||||
// Protected data
|
|
||||||
|
|
||||||
//- The name
|
|
||||||
word name_;
|
|
||||||
|
|
||||||
//- Underlying functionObject
|
|
||||||
mutable autoPtr<option> redirectFvOptionPtr_;
|
|
||||||
|
|
||||||
|
|
||||||
// Protected Member Functions
|
|
||||||
|
|
||||||
//- Adapt the context for the current object
|
|
||||||
virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
|
|
||||||
|
|
||||||
//- Name of the dynamically generated CodedType
|
|
||||||
virtual const word& codeName() const
|
|
||||||
{
|
|
||||||
return name_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return a description (type + name) for the output
|
|
||||||
virtual string description() const;
|
|
||||||
|
|
||||||
//- Clear any redirected objects
|
|
||||||
virtual void clearRedirect() const;
|
|
||||||
|
|
||||||
//- Get the dictionary to initialize the codeContext
|
|
||||||
virtual const dictionary& codeDict() const;
|
|
||||||
|
|
||||||
//- Get the keywords associated with source code
|
|
||||||
virtual const wordList& codeKeys() const;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
//- Runtime type information
|
|
||||||
TypeName("coded");
|
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
|
||||||
|
|
||||||
//- Construct from components
|
|
||||||
CodedSource
|
|
||||||
(
|
|
||||||
const word& name,
|
|
||||||
const word& modelType,
|
|
||||||
const dictionary& dict,
|
|
||||||
const fvMesh& mesh
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
|
||||||
|
|
||||||
//- Dynamically compiled fvOption
|
|
||||||
option& redirectFvOption() const;
|
|
||||||
|
|
||||||
|
|
||||||
// Evaluation
|
|
||||||
|
|
||||||
//- Correct field
|
|
||||||
virtual void correct
|
|
||||||
(
|
|
||||||
GeometricField<Type, fvPatchField, volMesh>&
|
|
||||||
) const;
|
|
||||||
|
|
||||||
//- Explicit and implicit matrix contributions
|
|
||||||
virtual void addSup
|
|
||||||
(
|
|
||||||
fvMatrix<Type>& eqn,
|
|
||||||
const label fieldi
|
|
||||||
) const;
|
|
||||||
|
|
||||||
//- Explicit and implicit matrix contributions
|
|
||||||
// to compressible equation
|
|
||||||
virtual void addSup
|
|
||||||
(
|
|
||||||
const volScalarField& rho,
|
|
||||||
fvMatrix<Type>& eqn,
|
|
||||||
const label fieldi
|
|
||||||
) const;
|
|
||||||
|
|
||||||
//- Explicit and implicit matrix contributions
|
|
||||||
// to phase equation
|
|
||||||
virtual void addSup
|
|
||||||
(
|
|
||||||
const volScalarField& alpha,
|
|
||||||
const volScalarField& rho,
|
|
||||||
fvMatrix<Type>& eqn,
|
|
||||||
const label fieldi
|
|
||||||
) const;
|
|
||||||
|
|
||||||
//- Set value
|
|
||||||
virtual void constrain
|
|
||||||
(
|
|
||||||
fvMatrix<Type>& eqn,
|
|
||||||
const label fieldi
|
|
||||||
) const;
|
|
||||||
|
|
||||||
|
|
||||||
// IO
|
|
||||||
|
|
||||||
//- Read source dictionary
|
|
||||||
virtual bool read(const dictionary& dict);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace fv
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#ifdef NoRepository
|
|
||||||
#include "CodedSource.C"
|
|
||||||
#include "CodedSourceIO.C"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,61 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration | Website: https://openfoam.org
|
|
||||||
\\ / A nd | Copyright (C) 2012-2020 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 "CodedSource.H"
|
|
||||||
#include "stringOps.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
bool Foam::fv::CodedSource<Type>::read(const dictionary& dict)
|
|
||||||
{
|
|
||||||
if (cellSetOption::read(dict))
|
|
||||||
{
|
|
||||||
coeffs_.lookup("fields") >> fieldNames_;
|
|
||||||
applied_.setSize(fieldNames_.size(), false);
|
|
||||||
|
|
||||||
// The name keyword is "name". "redirectType" is also maintained here
|
|
||||||
// for backwards compatibility, but "name" is taken in preference and
|
|
||||||
// is printed in the error message if neither keyword is present.
|
|
||||||
name_ = word::null;
|
|
||||||
name_ = dict.lookupOrDefault("redirectType", name_);
|
|
||||||
name_ = dict.lookupOrDefault("name", name_);
|
|
||||||
if (name_ == word::null)
|
|
||||||
{
|
|
||||||
dict.lookup("name"); // <-- generate error message with "name" in it
|
|
||||||
}
|
|
||||||
|
|
||||||
updateLibrary();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -23,16 +23,257 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "makeFvOption.H"
|
#include "codedSource.H"
|
||||||
#include "CodedSource.H"
|
#include "fvMesh.H"
|
||||||
|
#include "fvMatrices.H"
|
||||||
|
#include "dynamicCode.H"
|
||||||
|
#include "dynamicCodeContext.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * Private Static Data Members * * * * * * * * * * * //
|
||||||
|
|
||||||
makeFvOption(CodedSource, scalar);
|
const Foam::wordList Foam::fv::codedSource::codeKeys_ =
|
||||||
makeFvOption(CodedSource, vector);
|
{
|
||||||
makeFvOption(CodedSource, sphericalTensor);
|
"codeAddSup",
|
||||||
makeFvOption(CodedSource, symmTensor);
|
"codeAddRhoSup",
|
||||||
makeFvOption(CodedSource, tensor);
|
"codeAddAlphaRhoSup",
|
||||||
|
"codeInclude",
|
||||||
|
"localCode"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace fv
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(codedSource, 0);
|
||||||
|
addToRunTimeSelectionTable(option, codedSource, dictionary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fv::codedSource::readCoeffs()
|
||||||
|
{
|
||||||
|
fieldName_ = coeffs_.lookup<word>("field");
|
||||||
|
|
||||||
|
name_ = coeffs_.lookup<word>("name");
|
||||||
|
|
||||||
|
if (fieldPrimitiveTypeName() != word::null)
|
||||||
|
{
|
||||||
|
updateLibrary();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::word Foam::fv::codedSource::fieldPrimitiveTypeName() const
|
||||||
|
{
|
||||||
|
#define fieldPrimitiveTypeNameTernary(Type, nullArg) \
|
||||||
|
mesh_.foundObject<VolField<Type>>(fieldName_) \
|
||||||
|
? pTraits<Type>::typeName \
|
||||||
|
:
|
||||||
|
|
||||||
|
return FOR_ALL_FIELD_TYPES(fieldPrimitiveTypeNameTernary) word::null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fv::codedSource::prepare
|
||||||
|
(
|
||||||
|
dynamicCode& dynCode,
|
||||||
|
const dynamicCodeContext& context
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const word primitiveTypeName = fieldPrimitiveTypeName();
|
||||||
|
|
||||||
|
// Set additional rewrite rules
|
||||||
|
dynCode.setFilterVariable("typeName", name_);
|
||||||
|
dynCode.setFilterVariable("TemplateType", primitiveTypeName);
|
||||||
|
dynCode.setFilterVariable("SourceType", primitiveTypeName + "Source");
|
||||||
|
|
||||||
|
// compile filtered C template
|
||||||
|
dynCode.addCompileFile("codedFvOptionTemplate.C");
|
||||||
|
|
||||||
|
// copy filtered H template
|
||||||
|
dynCode.addCopyFile("codedFvOptionTemplate.H");
|
||||||
|
|
||||||
|
// define Make/options
|
||||||
|
dynCode.setMakeOptions
|
||||||
|
(
|
||||||
|
"EXE_INC = -g \\\n"
|
||||||
|
"-I$(LIB_SRC)/finiteVolume/lnInclude \\\n"
|
||||||
|
"-I$(LIB_SRC)/meshTools/lnInclude \\\n"
|
||||||
|
"-I$(LIB_SRC)/sampling/lnInclude \\\n"
|
||||||
|
"-I$(LIB_SRC)/fvOptions/lnInclude \\\n"
|
||||||
|
+ context.options()
|
||||||
|
+ "\n\nLIB_LIBS = \\\n"
|
||||||
|
+ " -lmeshTools \\\n"
|
||||||
|
+ " -lfvOptions \\\n"
|
||||||
|
+ " -lsampling \\\n"
|
||||||
|
+ " -lfiniteVolume \\\n"
|
||||||
|
+ context.libs()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::word& Foam::fv::codedSource::codeName() const
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::string Foam::fv::codedSource::description() const
|
||||||
|
{
|
||||||
|
return "fvOption:: " + name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fv::codedSource::clearRedirect() const
|
||||||
|
{
|
||||||
|
redirectFvOptionPtr_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::dictionary& Foam::fv::codedSource::codeDict() const
|
||||||
|
{
|
||||||
|
return coeffs_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::wordList& Foam::fv::codedSource::codeKeys() const
|
||||||
|
{
|
||||||
|
return codeKeys_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::fv::option& Foam::fv::codedSource::redirectFvOption() const
|
||||||
|
{
|
||||||
|
if (!redirectFvOptionPtr_.valid())
|
||||||
|
{
|
||||||
|
dictionary constructDict(dict_);
|
||||||
|
constructDict.set("type", name_);
|
||||||
|
redirectFvOptionPtr_ = option::New
|
||||||
|
(
|
||||||
|
name_,
|
||||||
|
constructDict,
|
||||||
|
mesh_
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return redirectFvOptionPtr_();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::fv::codedSource::codedSource
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const word& modelType,
|
||||||
|
const dictionary& dict,
|
||||||
|
const fvMesh& mesh
|
||||||
|
)
|
||||||
|
:
|
||||||
|
cellSetOption(name, modelType, dict, mesh),
|
||||||
|
fieldName_(word::null)
|
||||||
|
{
|
||||||
|
readCoeffs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::wordList Foam::fv::codedSource::addedToFields() const
|
||||||
|
{
|
||||||
|
return wordList(1, fieldName_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define implementAddSup(Type, nullArg) \
|
||||||
|
\
|
||||||
|
void Foam::fv::codedSource::addSup \
|
||||||
|
( \
|
||||||
|
fvMatrix<Type>& eqn, \
|
||||||
|
const word& fieldName \
|
||||||
|
) const \
|
||||||
|
{ \
|
||||||
|
if (fieldPrimitiveTypeName() != word::null) \
|
||||||
|
{ \
|
||||||
|
if (debug) \
|
||||||
|
{ \
|
||||||
|
Info<< "codedSource::addSup for source " << name_ << endl; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
updateLibrary(); \
|
||||||
|
redirectFvOption().addSup(eqn, fieldName); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
FOR_ALL_FIELD_TYPES(implementAddSup);
|
||||||
|
|
||||||
|
|
||||||
|
#define implementAddRhoSup(Type, nullArg) \
|
||||||
|
\
|
||||||
|
void Foam::fv::codedSource::addSup \
|
||||||
|
( \
|
||||||
|
const volScalarField& rho, \
|
||||||
|
fvMatrix<Type>& eqn, \
|
||||||
|
const word& fieldName \
|
||||||
|
) const \
|
||||||
|
{ \
|
||||||
|
if (fieldPrimitiveTypeName() != word::null) \
|
||||||
|
{ \
|
||||||
|
if (debug) \
|
||||||
|
{ \
|
||||||
|
Info<< "codedSource::addSup for source " << name_ << endl; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
updateLibrary(); \
|
||||||
|
redirectFvOption().addSup(rho, eqn, fieldName); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
FOR_ALL_FIELD_TYPES(implementAddRhoSup);
|
||||||
|
|
||||||
|
|
||||||
|
#define implementAddAlphaRhoSup(Type, nullArg) \
|
||||||
|
\
|
||||||
|
void Foam::fv::codedSource::addSup \
|
||||||
|
( \
|
||||||
|
const volScalarField& alpha, \
|
||||||
|
const volScalarField& rho, \
|
||||||
|
fvMatrix<Type>& eqn, \
|
||||||
|
const word& fieldName \
|
||||||
|
) const \
|
||||||
|
{ \
|
||||||
|
if (fieldPrimitiveTypeName() != word::null) \
|
||||||
|
{ \
|
||||||
|
if (debug) \
|
||||||
|
{ \
|
||||||
|
Info<< "codedSource::addSup for source " << name_ << endl; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
updateLibrary(); \
|
||||||
|
redirectFvOption().addSup(alpha, rho, eqn, fieldName); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
FOR_ALL_FIELD_TYPES(implementAddAlphaRhoSup);
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::fv::codedSource::read(const dictionary& dict)
|
||||||
|
{
|
||||||
|
if (cellSetOption::read(dict))
|
||||||
|
{
|
||||||
|
readCoeffs();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
231
src/fvOptions/sources/general/codedSource/codedSource.H
Normal file
231
src/fvOptions/sources/general/codedSource/codedSource.H
Normal file
@ -0,0 +1,231 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration | Website: https://openfoam.org
|
||||||
|
\\ / A nd | Copyright (C) 2012-2021 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/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::fv::codedSource
|
||||||
|
|
||||||
|
Description
|
||||||
|
Constructs on-the-fly fvOption source from user-supplied code
|
||||||
|
|
||||||
|
Usage
|
||||||
|
Example usage in constant/fvOptions:
|
||||||
|
\verbatim
|
||||||
|
energySource
|
||||||
|
{
|
||||||
|
type codedSource;
|
||||||
|
name sourceTime;
|
||||||
|
|
||||||
|
selectionMode all;
|
||||||
|
|
||||||
|
field h;
|
||||||
|
|
||||||
|
codeInclude
|
||||||
|
#{
|
||||||
|
#};
|
||||||
|
|
||||||
|
codeAddSup
|
||||||
|
#{
|
||||||
|
Pout<< "**codeAddSup**" << endl;
|
||||||
|
const Time& time = mesh().time();
|
||||||
|
const scalarField& V = mesh_.V();
|
||||||
|
scalarField& heSource = eqn.source();
|
||||||
|
heSource -= 0.1*sqr(time.value())*V;
|
||||||
|
#};
|
||||||
|
|
||||||
|
codeAddRhoSup
|
||||||
|
#{
|
||||||
|
Pout<< "**codeAddRhoSup**" << endl;
|
||||||
|
#};
|
||||||
|
|
||||||
|
codeAddAlphaRhoSup
|
||||||
|
#{
|
||||||
|
Pout<< "**codeAddAlphaRhoSup**" << endl;
|
||||||
|
#};
|
||||||
|
}
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
codedSource.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef codedSource_H
|
||||||
|
#define codedSource_H
|
||||||
|
|
||||||
|
#include "cellSetOption.H"
|
||||||
|
#include "codedBase.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace fv
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class codedSource Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class codedSource
|
||||||
|
:
|
||||||
|
public cellSetOption,
|
||||||
|
public codedBase
|
||||||
|
{
|
||||||
|
// Private static data
|
||||||
|
|
||||||
|
//- The keywords associated with source code
|
||||||
|
static const wordList codeKeys_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- The name
|
||||||
|
word name_;
|
||||||
|
|
||||||
|
//- The name of the field that this option applies to
|
||||||
|
word fieldName_;
|
||||||
|
|
||||||
|
//- Underlying functionObject
|
||||||
|
mutable autoPtr<option> redirectFvOptionPtr_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
|
//- Return the name of the field's primitive type
|
||||||
|
word fieldPrimitiveTypeName() const;
|
||||||
|
|
||||||
|
//- Adapt the context for the current object
|
||||||
|
virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
|
||||||
|
|
||||||
|
//- Name of the dynamically generated CodedType
|
||||||
|
virtual const word& codeName() const;
|
||||||
|
|
||||||
|
//- Return a description (type + name) for the output
|
||||||
|
virtual string description() const;
|
||||||
|
|
||||||
|
//- Clear any redirected objects
|
||||||
|
virtual void clearRedirect() const;
|
||||||
|
|
||||||
|
//- Get the dictionary to initialize the codeContext
|
||||||
|
virtual const dictionary& codeDict() const;
|
||||||
|
|
||||||
|
//- Get the keywords associated with source code
|
||||||
|
virtual const wordList& codeKeys() const;
|
||||||
|
|
||||||
|
//- Dynamically compiled fvOption
|
||||||
|
option& redirectFvOption() const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("codedSource");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
codedSource
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const word& modelType,
|
||||||
|
const dictionary& dict,
|
||||||
|
const fvMesh& mesh
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Checks
|
||||||
|
|
||||||
|
//- Return the list of fields for which the option adds source term
|
||||||
|
// to the transport equation
|
||||||
|
virtual wordList addedToFields() const;
|
||||||
|
|
||||||
|
|
||||||
|
// Evaluation
|
||||||
|
|
||||||
|
// Explicit and implicit matrix contributions
|
||||||
|
|
||||||
|
#define defineAddSup(Type, nullArg) \
|
||||||
|
\
|
||||||
|
virtual void addSup \
|
||||||
|
( \
|
||||||
|
fvMatrix<Type>& eqn, \
|
||||||
|
const word& fieldName \
|
||||||
|
) const;
|
||||||
|
|
||||||
|
FOR_ALL_FIELD_TYPES(defineAddSup);
|
||||||
|
|
||||||
|
|
||||||
|
// Explicit and implicit matrix contributions to compressible
|
||||||
|
// equations
|
||||||
|
|
||||||
|
#define defineAddRhoSup(Type, nullArg) \
|
||||||
|
\
|
||||||
|
virtual void addSup \
|
||||||
|
( \
|
||||||
|
const volScalarField& rho, \
|
||||||
|
fvMatrix<Type>& eqn, \
|
||||||
|
const word& fieldName \
|
||||||
|
) const;
|
||||||
|
|
||||||
|
FOR_ALL_FIELD_TYPES(defineAddRhoSup);
|
||||||
|
|
||||||
|
|
||||||
|
// Explicit and implicit matrix contributions to phase equations
|
||||||
|
|
||||||
|
#define defineAddAlphaRhoSup(Type, nullArg) \
|
||||||
|
\
|
||||||
|
virtual void addSup \
|
||||||
|
( \
|
||||||
|
const volScalarField& alpha, \
|
||||||
|
const volScalarField& rho, \
|
||||||
|
fvMatrix<Type>& eqn, \
|
||||||
|
const word& fieldName \
|
||||||
|
) const;
|
||||||
|
|
||||||
|
FOR_ALL_FIELD_TYPES(defineAddAlphaRhoSup);
|
||||||
|
|
||||||
|
|
||||||
|
// IO
|
||||||
|
|
||||||
|
//- Read source dictionary
|
||||||
|
virtual bool read(const dictionary& dict);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace fv
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -57,13 +57,59 @@ const Foam::NamedEnum<Foam::fv::semiImplicitSource::volumeMode, 2>
|
|||||||
Foam::fv::semiImplicitSource::volumeModeNames_;
|
Foam::fv::semiImplicitSource::volumeModeNames_;
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * ** Private Member Functions ** * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fv::semiImplicitSource::readCoeffs()
|
||||||
|
{
|
||||||
|
// Get the volume mode
|
||||||
|
volumeMode_ = volumeModeNames_.read(coeffs_.lookup("volumeMode"));
|
||||||
|
|
||||||
|
// Set volume normalisation
|
||||||
|
switch (volumeMode_)
|
||||||
|
{
|
||||||
|
case volumeMode::absolute:
|
||||||
|
VDash_ = V();
|
||||||
|
break;
|
||||||
|
case volumeMode::specific:
|
||||||
|
VDash_ = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set field source terms
|
||||||
|
fieldSp_.clear();
|
||||||
|
fieldSu_.clear();
|
||||||
|
forAllConstIter(dictionary, coeffs_.subDict("sources"), iter)
|
||||||
|
{
|
||||||
|
fieldSu_.set
|
||||||
|
(
|
||||||
|
iter().keyword(),
|
||||||
|
objectFunction1::New<VolField>
|
||||||
|
(
|
||||||
|
"explicit",
|
||||||
|
iter().dict(),
|
||||||
|
iter().keyword(),
|
||||||
|
mesh_,
|
||||||
|
false
|
||||||
|
).ptr()
|
||||||
|
);
|
||||||
|
fieldSp_.set
|
||||||
|
(
|
||||||
|
iter().keyword(),
|
||||||
|
Function1<scalar>::New
|
||||||
|
(
|
||||||
|
"implicit",
|
||||||
|
iter().dict()
|
||||||
|
).ptr()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::fv::semiImplicitSource::addSupType
|
void Foam::fv::semiImplicitSource::addSupType
|
||||||
(
|
(
|
||||||
fvMatrix<Type>& eqn,
|
fvMatrix<Type>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
@ -80,7 +126,7 @@ void Foam::fv::semiImplicitSource::addSupType
|
|||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name_ + fieldNames_[fieldi] + "Su",
|
name_ + fieldName + "Su",
|
||||||
mesh_.time().timeName(),
|
mesh_.time().timeName(),
|
||||||
mesh_,
|
mesh_,
|
||||||
IOobject::NO_READ,
|
IOobject::NO_READ,
|
||||||
@ -97,13 +143,14 @@ void Foam::fv::semiImplicitSource::addSupType
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Explicit source function for the field
|
// Explicit source function for the field
|
||||||
UIndirectList<Type>(Su, cells()) = fieldSu_[fieldi].value<Type>(t)/VDash_;
|
UIndirectList<Type>(Su, cells()) =
|
||||||
|
fieldSu_[fieldName]->value<Type>(t)/VDash_;
|
||||||
|
|
||||||
volScalarField::Internal Sp
|
volScalarField::Internal Sp
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name_ + fieldNames_[fieldi] + "Sp",
|
name_ + fieldName + "Sp",
|
||||||
mesh_.time().timeName(),
|
mesh_.time().timeName(),
|
||||||
mesh_,
|
mesh_,
|
||||||
IOobject::NO_READ,
|
IOobject::NO_READ,
|
||||||
@ -120,7 +167,8 @@ void Foam::fv::semiImplicitSource::addSupType
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Implicit source function for the field
|
// Implicit source function for the field
|
||||||
UIndirectList<scalar>(Sp, cells()) = fieldSp_[fieldi].value(t)/VDash_;
|
UIndirectList<scalar>(Sp, cells()) =
|
||||||
|
fieldSp_[fieldName]->value(t)/VDash_;
|
||||||
|
|
||||||
eqn += Su + fvm::SuSp(Sp, psi);
|
eqn += Su + fvm::SuSp(Sp, psi);
|
||||||
}
|
}
|
||||||
@ -131,7 +179,7 @@ void Foam::fv::semiImplicitSource::addSupType
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<Type>& eqn,
|
fvMatrix<Type>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
@ -140,7 +188,7 @@ void Foam::fv::semiImplicitSource::addSupType
|
|||||||
<< ">::addSup for source " << name_ << endl;
|
<< ">::addSup for source " << name_ << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this->addSup(eqn, fieldi);
|
return this->addSup(eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -158,7 +206,7 @@ Foam::fv::semiImplicitSource::semiImplicitSource
|
|||||||
volumeMode_(volumeMode::absolute),
|
volumeMode_(volumeMode::absolute),
|
||||||
VDash_(1)
|
VDash_(1)
|
||||||
{
|
{
|
||||||
read(dict);
|
readCoeffs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -170,53 +218,59 @@ Foam::fv::semiImplicitSource::~semiImplicitSource()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::wordList Foam::fv::semiImplicitSource::addedToFields() const
|
||||||
|
{
|
||||||
|
return fieldSu_.toc();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::semiImplicitSource::addSup
|
void Foam::fv::semiImplicitSource::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addSupType(eqn, fieldi);
|
addSupType(eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::semiImplicitSource::addSup
|
void Foam::fv::semiImplicitSource::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addSupType(eqn, fieldi);
|
addSupType(eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::semiImplicitSource::addSup
|
void Foam::fv::semiImplicitSource::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<symmTensor>& eqn,
|
fvMatrix<symmTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addSupType(eqn, fieldi);
|
addSupType(eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::semiImplicitSource::addSup
|
void Foam::fv::semiImplicitSource::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<sphericalTensor>& eqn,
|
fvMatrix<sphericalTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addSupType(eqn, fieldi);
|
addSupType(eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::semiImplicitSource::addSup
|
void Foam::fv::semiImplicitSource::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<tensor>& eqn,
|
fvMatrix<tensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addSupType(eqn, fieldi);
|
addSupType(eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -224,10 +278,10 @@ void Foam::fv::semiImplicitSource::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addSupType(eqn, fieldi);
|
addSupType(eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -235,10 +289,10 @@ void Foam::fv::semiImplicitSource::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addSupType(eqn, fieldi);
|
addSupType(eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -246,10 +300,10 @@ void Foam::fv::semiImplicitSource::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<symmTensor>& eqn,
|
fvMatrix<symmTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addSupType(eqn, fieldi);
|
addSupType(eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -257,10 +311,10 @@ void Foam::fv::semiImplicitSource::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<sphericalTensor>& eqn,
|
fvMatrix<sphericalTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addSupType(eqn, fieldi);
|
addSupType(eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -268,10 +322,10 @@ void Foam::fv::semiImplicitSource::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<tensor>& eqn,
|
fvMatrix<tensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addSupType(eqn, fieldi);
|
addSupType(eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -280,10 +334,10 @@ void Foam::fv::semiImplicitSource::addSup
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addSupType(eqn, fieldi);
|
addSupType(eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -292,10 +346,10 @@ void Foam::fv::semiImplicitSource::addSup
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addSupType(eqn, fieldi);
|
addSupType(eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -304,10 +358,10 @@ void Foam::fv::semiImplicitSource::addSup
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<symmTensor>& eqn,
|
fvMatrix<symmTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addSupType(eqn, fieldi);
|
addSupType(eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -316,10 +370,10 @@ void Foam::fv::semiImplicitSource::addSup
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<sphericalTensor>& eqn,
|
fvMatrix<sphericalTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addSupType(eqn, fieldi);
|
addSupType(eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -328,10 +382,10 @@ void Foam::fv::semiImplicitSource::addSup
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<tensor>& eqn,
|
fvMatrix<tensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addSupType(eqn, fieldi);
|
addSupType(eqn, fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -339,52 +393,7 @@ bool Foam::fv::semiImplicitSource::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
if (cellSetOption::read(dict))
|
if (cellSetOption::read(dict))
|
||||||
{
|
{
|
||||||
volumeMode_ = volumeModeNames_.read(coeffs_.lookup("volumeMode"));
|
readCoeffs();
|
||||||
|
|
||||||
const dictionary& sources = coeffs_.subDict("sources");
|
|
||||||
|
|
||||||
// Number of fields with a source term
|
|
||||||
const label nFields = sources.size();
|
|
||||||
|
|
||||||
// Set field names and source terms
|
|
||||||
fieldNames_.setSize(nFields);
|
|
||||||
fieldSp_.setSize(nFields);
|
|
||||||
fieldSu_.setSize(nFields);
|
|
||||||
label i = 0;
|
|
||||||
forAllConstIter(dictionary, sources, iter)
|
|
||||||
{
|
|
||||||
fieldNames_[i] = iter().keyword();
|
|
||||||
fieldSu_.set
|
|
||||||
(
|
|
||||||
i,
|
|
||||||
objectFunction1::New<VolField>
|
|
||||||
(
|
|
||||||
"explicit",
|
|
||||||
iter().dict(),
|
|
||||||
fieldNames_[i],
|
|
||||||
mesh_
|
|
||||||
).ptr()
|
|
||||||
);
|
|
||||||
fieldSp_.set
|
|
||||||
(
|
|
||||||
i,
|
|
||||||
Function1<scalar>::New
|
|
||||||
(
|
|
||||||
"implicit",
|
|
||||||
iter().dict()
|
|
||||||
).ptr()
|
|
||||||
);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set volume normalisation
|
|
||||||
if (volumeMode_ == volumeMode::absolute)
|
|
||||||
{
|
|
||||||
VDash_ = V();
|
|
||||||
}
|
|
||||||
|
|
||||||
applied_.setSize(nFields, false);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -93,7 +93,7 @@ SourceFiles
|
|||||||
#define semiImplicitSource_H
|
#define semiImplicitSource_H
|
||||||
|
|
||||||
#include "cellSetOption.H"
|
#include "cellSetOption.H"
|
||||||
#include "Function1.H"
|
#include "HashPtrTable.H"
|
||||||
#include "objectFunction1.H"
|
#include "objectFunction1.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -137,17 +137,20 @@ private:
|
|||||||
scalar VDash_;
|
scalar VDash_;
|
||||||
|
|
||||||
//- Explicit parts of the sources
|
//- Explicit parts of the sources
|
||||||
PtrList<objectFunction1> fieldSu_;
|
HashPtrTable<objectFunction1> fieldSu_;
|
||||||
|
|
||||||
//- Implicit parts of the sources
|
//- Implicit parts of the sources
|
||||||
PtrList<Function1<scalar>> fieldSp_;
|
HashPtrTable<Function1<scalar>> fieldSp_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
//- Add divergence terms to an equation
|
//- Add divergence terms to an equation
|
||||||
template <class Type>
|
template <class Type>
|
||||||
void addSupType(fvMatrix<Type>&, const label) const;
|
void addSupType(fvMatrix<Type>&, const word&) const;
|
||||||
|
|
||||||
//- Add divergence terms to an equation
|
//- Add divergence terms to an equation
|
||||||
template <class Type>
|
template <class Type>
|
||||||
@ -155,7 +158,7 @@ private:
|
|||||||
(
|
(
|
||||||
const volScalarField&,
|
const volScalarField&,
|
||||||
fvMatrix<Type>&,
|
fvMatrix<Type>&,
|
||||||
const label
|
const word&
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
@ -182,6 +185,13 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
// Checks
|
||||||
|
|
||||||
|
//- Return the list of fields for which the option adds source term
|
||||||
|
// to the transport equation
|
||||||
|
virtual wordList addedToFields() const;
|
||||||
|
|
||||||
|
|
||||||
// Evaluation
|
// Evaluation
|
||||||
|
|
||||||
// Explicit and implicit sources
|
// Explicit and implicit sources
|
||||||
@ -189,31 +199,31 @@ public:
|
|||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<symmTensor>& eqn,
|
fvMatrix<symmTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<sphericalTensor>& eqn,
|
fvMatrix<sphericalTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<tensor>& eqn,
|
fvMatrix<tensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
@ -223,35 +233,35 @@ public:
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<symmTensor>& eqn,
|
fvMatrix<symmTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<sphericalTensor>& eqn,
|
fvMatrix<sphericalTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<tensor>& eqn,
|
fvMatrix<tensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
@ -262,7 +272,7 @@ public:
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
@ -270,7 +280,7 @@ public:
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
@ -278,7 +288,7 @@ public:
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<symmTensor>& eqn,
|
fvMatrix<symmTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
@ -286,7 +296,7 @@ public:
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<sphericalTensor>& eqn,
|
fvMatrix<sphericalTensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
@ -294,7 +304,7 @@ public:
|
|||||||
const volScalarField& alpha,
|
const volScalarField& alpha,
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<tensor>& eqn,
|
fvMatrix<tensor>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -45,63 +45,71 @@ namespace fv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::fv::interRegionExplicitPorositySource::initialise() const
|
void Foam::fv::interRegionExplicitPorositySource::readCoeffs()
|
||||||
{
|
{
|
||||||
if (!firstIter_)
|
UName_ = coeffs_.lookupOrDefault<word>("U", "U");
|
||||||
|
|
||||||
|
muName_ = coeffs_.lookupOrDefault<word>("mu", "thermo:mu");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::porosityModel&
|
||||||
|
Foam::fv::interRegionExplicitPorositySource::porosity() const
|
||||||
|
{
|
||||||
|
if (!porosityPtr_.valid())
|
||||||
{
|
{
|
||||||
return;
|
const word zoneName(name_ + ":porous");
|
||||||
}
|
|
||||||
|
|
||||||
const word zoneName(name_ + ":porous");
|
const fvMesh& nbrMesh =
|
||||||
|
mesh_.time().lookupObject<fvMesh>(nbrRegionName());
|
||||||
|
const cellZoneMesh& cellZones = nbrMesh.cellZones();
|
||||||
|
label zoneID = cellZones.findZoneID(zoneName);
|
||||||
|
|
||||||
const fvMesh& nbrMesh = mesh_.time().lookupObject<fvMesh>(nbrRegionName_);
|
if (zoneID == -1)
|
||||||
const cellZoneMesh& cellZones = nbrMesh.cellZones();
|
{
|
||||||
label zoneID = cellZones.findZoneID(zoneName);
|
cellZoneMesh& cz = const_cast<cellZoneMesh&>(cellZones);
|
||||||
|
|
||||||
if (zoneID == -1)
|
zoneID = cz.size();
|
||||||
{
|
|
||||||
cellZoneMesh& cz = const_cast<cellZoneMesh&>(cellZones);
|
|
||||||
|
|
||||||
zoneID = cz.size();
|
cz.setSize(zoneID + 1);
|
||||||
|
|
||||||
cz.setSize(zoneID + 1);
|
cz.set
|
||||||
|
|
||||||
cz.set
|
|
||||||
(
|
|
||||||
zoneID,
|
|
||||||
new cellZone
|
|
||||||
(
|
(
|
||||||
zoneName,
|
|
||||||
nbrMesh.faceNeighbour(), // Neighbour internal cells
|
|
||||||
zoneID,
|
zoneID,
|
||||||
cellZones
|
new cellZone
|
||||||
)
|
(
|
||||||
);
|
zoneName,
|
||||||
|
nbrMesh.faceNeighbour(), // Neighbour internal cells
|
||||||
|
zoneID,
|
||||||
|
cellZones
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
cz.clearAddressing();
|
cz.clearAddressing();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Unable to create porous cellZone " << zoneName
|
<< "Unable to create porous cellZone " << zoneName
|
||||||
<< ": zone already exists"
|
<< ": zone already exists"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
porosityPtr_.reset
|
porosityPtr_.reset
|
||||||
(
|
|
||||||
porosityModel::New
|
|
||||||
(
|
(
|
||||||
name_,
|
porosityModel::New
|
||||||
nbrMesh,
|
(
|
||||||
coeffs_,
|
name_,
|
||||||
zoneName
|
nbrMesh,
|
||||||
).ptr()
|
coeffs_,
|
||||||
),
|
zoneName
|
||||||
|
).ptr()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
firstIter_ = false;
|
return porosityPtr_();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -116,27 +124,31 @@ Foam::fv::interRegionExplicitPorositySource::interRegionExplicitPorositySource
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
interRegionOption(name, modelType, dict, mesh),
|
interRegionOption(name, modelType, dict, mesh),
|
||||||
porosityPtr_(nullptr),
|
UName_(word::null),
|
||||||
firstIter_(true),
|
muName_(word::null),
|
||||||
UName_(coeffs_.lookupOrDefault<word>("U", "U")),
|
porosityPtr_(nullptr)
|
||||||
muName_(coeffs_.lookupOrDefault<word>("mu", "thermo:mu"))
|
|
||||||
{
|
{
|
||||||
fieldNames_.setSize(1, UName_);
|
readCoeffs();
|
||||||
applied_.setSize(1, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::wordList
|
||||||
|
Foam::fv::interRegionExplicitPorositySource::addedToFields() const
|
||||||
|
{
|
||||||
|
return wordList(1, UName_);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::interRegionExplicitPorositySource::addSup
|
void Foam::fv::interRegionExplicitPorositySource::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
initialise();
|
const fvMesh& nbrMesh = mesh_.time().lookupObject<fvMesh>(nbrRegionName());
|
||||||
|
|
||||||
const fvMesh& nbrMesh = mesh_.time().lookupObject<fvMesh>(nbrRegionName_);
|
|
||||||
|
|
||||||
const volVectorField& U = eqn.psi();
|
const volVectorField& U = eqn.psi();
|
||||||
|
|
||||||
@ -164,7 +176,7 @@ void Foam::fv::interRegionExplicitPorositySource::addSup
|
|||||||
|
|
||||||
fvMatrix<vector> nbrEqn(UNbr, eqn.dimensions());
|
fvMatrix<vector> nbrEqn(UNbr, eqn.dimensions());
|
||||||
|
|
||||||
porosityPtr_->addResistance(nbrEqn);
|
porosity().addResistance(nbrEqn);
|
||||||
|
|
||||||
// Convert source from neighbour to local region
|
// Convert source from neighbour to local region
|
||||||
fvMatrix<vector> porosityEqn(U, eqn.dimensions());
|
fvMatrix<vector> porosityEqn(U, eqn.dimensions());
|
||||||
@ -185,12 +197,10 @@ void Foam::fv::interRegionExplicitPorositySource::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
initialise();
|
const fvMesh& nbrMesh = mesh_.time().lookupObject<fvMesh>(nbrRegionName());
|
||||||
|
|
||||||
const fvMesh& nbrMesh = mesh_.time().lookupObject<fvMesh>(nbrRegionName_);
|
|
||||||
|
|
||||||
const volVectorField& U = eqn.psi();
|
const volVectorField& U = eqn.psi();
|
||||||
|
|
||||||
@ -265,7 +275,7 @@ void Foam::fv::interRegionExplicitPorositySource::addSup
|
|||||||
muNbr.primitiveFieldRef()
|
muNbr.primitiveFieldRef()
|
||||||
);
|
);
|
||||||
|
|
||||||
porosityPtr_->addResistance(nbrEqn, rhoNbr, muNbr);
|
porosity().addResistance(nbrEqn, rhoNbr, muNbr);
|
||||||
|
|
||||||
// Convert source from neighbour to local region
|
// Convert source from neighbour to local region
|
||||||
fvMatrix<vector> porosityEqn(U, eqn.dimensions());
|
fvMatrix<vector> porosityEqn(U, eqn.dimensions());
|
||||||
@ -286,11 +296,7 @@ bool Foam::fv::interRegionExplicitPorositySource::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
if (interRegionOption::read(dict))
|
if (interRegionOption::read(dict))
|
||||||
{
|
{
|
||||||
coeffs_.readIfPresent("U", UName_);
|
readCoeffs();
|
||||||
coeffs_.readIfPresent("mu", muName_);
|
|
||||||
|
|
||||||
// Reset the porosity model?
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -27,12 +27,13 @@ Class
|
|||||||
Description
|
Description
|
||||||
Inter-region explicit porosity source.
|
Inter-region explicit porosity source.
|
||||||
|
|
||||||
Sources described by, for example using the DarcyForchheimer model:
|
Usage
|
||||||
|
Example usage, here employing the Darcy-Forchheimer model:
|
||||||
\verbatim
|
\verbatim
|
||||||
interRegionExplicitPorositySourceCoeffs
|
interRegionExplicitPorositySourceCoeffs
|
||||||
{
|
{
|
||||||
type DarcyForchheimer;
|
type DarcyForchheimer;
|
||||||
|
|
||||||
DarcyForchheimerCoeffs
|
DarcyForchheimerCoeffs
|
||||||
{
|
{
|
||||||
d d [0 -2 0 0 0 0 0] (5e7 -1000 -1000);
|
d d [0 -2 0 0 0 0 0] (5e7 -1000 -1000);
|
||||||
@ -40,16 +41,19 @@ Description
|
|||||||
|
|
||||||
coordinateSystem
|
coordinateSystem
|
||||||
{
|
{
|
||||||
e1 (0.70710678 0.70710678 0);
|
type cartesian;
|
||||||
e2 (0 0 1);
|
origin (0 0 0);
|
||||||
|
coordinateRotation
|
||||||
|
{
|
||||||
|
type axesRotation;
|
||||||
|
e1 (0.70710678 0.70710678 0);
|
||||||
|
e2 (0 0 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
Note
|
|
||||||
The porous region must be selected as a cellZone.
|
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
interRegionExplicitPorositySource.C
|
interRegionExplicitPorositySource.C
|
||||||
|
|
||||||
@ -79,16 +83,7 @@ class interRegionExplicitPorositySource
|
|||||||
:
|
:
|
||||||
public interRegionOption
|
public interRegionOption
|
||||||
{
|
{
|
||||||
|
// Private data
|
||||||
protected:
|
|
||||||
|
|
||||||
// Protected data
|
|
||||||
|
|
||||||
//- Run-time selectable porosity model
|
|
||||||
mutable autoPtr<porosityModel> porosityPtr_;
|
|
||||||
|
|
||||||
//- First iteration
|
|
||||||
mutable bool firstIter_;
|
|
||||||
|
|
||||||
//- Velocity field name, default = U
|
//- Velocity field name, default = U
|
||||||
word UName_;
|
word UName_;
|
||||||
@ -97,11 +92,17 @@ protected:
|
|||||||
// default = thermo:mu
|
// default = thermo:mu
|
||||||
word muName_;
|
word muName_;
|
||||||
|
|
||||||
|
//- Run-time selectable porosity model
|
||||||
|
mutable autoPtr<porosityModel> porosityPtr_;
|
||||||
|
|
||||||
|
|
||||||
// Protected Member Functions
|
// Protected Member Functions
|
||||||
|
|
||||||
//- Initialise
|
//- Non-virtual read
|
||||||
void initialise() const;
|
void readCoeffs();
|
||||||
|
|
||||||
|
//- Get the porosity model
|
||||||
|
porosityModel& porosity() const;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -135,24 +136,29 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
// Checks
|
||||||
|
|
||||||
|
//- Return the list of fields for which the option adds source term
|
||||||
|
// to the transport equation
|
||||||
|
virtual wordList addedToFields() const;
|
||||||
|
|
||||||
|
|
||||||
// Add explicit and implicit contributions
|
// Add explicit and implicit contributions
|
||||||
|
|
||||||
//- Vector
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
// Add explicit and implicit contributions to compressible equation
|
// Add explicit and implicit contributions to compressible equation
|
||||||
|
|
||||||
//- Vector
|
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<vector>& eqn,
|
fvMatrix<vector>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -43,6 +43,12 @@ namespace fv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::fv::constantHeatTransfer::correctHtc() const
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::fv::constantHeatTransfer::constantHeatTransfer
|
Foam::fv::constantHeatTransfer::constantHeatTransfer
|
||||||
@ -53,45 +59,37 @@ Foam::fv::constantHeatTransfer::constantHeatTransfer
|
|||||||
const fvMesh& mesh
|
const fvMesh& mesh
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
interRegionHeatTransferModel(name, modelType, dict, mesh),
|
interRegionHeatTransferModel(name, modelType, dict, mesh)
|
||||||
htcConst_(),
|
|
||||||
AoV_()
|
|
||||||
{
|
{
|
||||||
if (master_)
|
if (master())
|
||||||
{
|
{
|
||||||
htcConst_.reset
|
const volScalarField htcConst
|
||||||
(
|
(
|
||||||
new volScalarField
|
IOobject
|
||||||
(
|
(
|
||||||
IOobject
|
"htcConst",
|
||||||
(
|
mesh_.time().constant(),
|
||||||
"htcConst",
|
mesh_,
|
||||||
mesh_.time().timeName(),
|
IOobject::MUST_READ,
|
||||||
mesh_,
|
IOobject::AUTO_WRITE
|
||||||
IOobject::MUST_READ,
|
),
|
||||||
IOobject::AUTO_WRITE
|
mesh_
|
||||||
),
|
|
||||||
mesh_
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
AoV_.reset
|
const volScalarField AoV
|
||||||
(
|
(
|
||||||
new volScalarField
|
IOobject
|
||||||
(
|
(
|
||||||
IOobject
|
"AoV",
|
||||||
(
|
mesh_.time().constant(),
|
||||||
"AoV",
|
mesh_,
|
||||||
mesh_.time().timeName(),
|
IOobject::MUST_READ,
|
||||||
mesh_,
|
IOobject::AUTO_WRITE
|
||||||
IOobject::MUST_READ,
|
),
|
||||||
IOobject::AUTO_WRITE
|
mesh_
|
||||||
),
|
|
||||||
mesh_
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
htc_ = htcConst_()*AoV_();
|
htc_ = htcConst*AoV;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,10 +102,6 @@ Foam::fv::constantHeatTransfer::~constantHeatTransfer()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::fv::constantHeatTransfer::calculateHtc() const
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
bool Foam::fv::constantHeatTransfer::read(const dictionary& dict)
|
bool Foam::fv::constantHeatTransfer::read(const dictionary& dict)
|
||||||
{
|
{
|
||||||
if (interRegionHeatTransferModel::read(dict))
|
if (interRegionHeatTransferModel::read(dict))
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -25,8 +25,9 @@ Class
|
|||||||
Foam::fv::constantHeatTransfer
|
Foam::fv::constantHeatTransfer
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Constant heat transfer model. htcConst [W/m^2/K] and area/volume [1/m]
|
Constant heat transfer model. A heat transfer coefficieqt [W/m^2/K] field
|
||||||
must be provided.
|
(htcConst) and area-per-unit-volume [1/m] field (AoV) must be provided in
|
||||||
|
constant.
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -50,13 +51,10 @@ class constantHeatTransfer
|
|||||||
:
|
:
|
||||||
public interRegionHeatTransferModel
|
public interRegionHeatTransferModel
|
||||||
{
|
{
|
||||||
// Private Data
|
// Private Member Functions
|
||||||
|
|
||||||
//- Constant heat transfer coefficient [W/m^2/K]
|
//- Correct the heat transfer coefficient
|
||||||
autoPtr<volScalarField> htcConst_;
|
virtual void correctHtc() const;
|
||||||
|
|
||||||
//- Area per unit volume of heat exchanger [1/m]
|
|
||||||
autoPtr<volScalarField> AoV_;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -83,9 +81,6 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Calculate the heat transfer coefficient
|
|
||||||
virtual void calculateHtc() const;
|
|
||||||
|
|
||||||
//- Read dictionary
|
//- Read dictionary
|
||||||
virtual bool read(const dictionary& dict);
|
virtual bool read(const dictionary& dict);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -45,40 +45,27 @@ namespace fv
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
const Foam::Function2<Foam::scalar>&
|
void Foam::fv::function2HeatTransfer::readCoeffs()
|
||||||
Foam::fv::function2HeatTransfer::htcFunc() const
|
|
||||||
{
|
{
|
||||||
if (!htcFunc_.valid())
|
UName_ = coeffs_.lookupOrDefault<word>("U", "U");
|
||||||
{
|
UNbrName_ = coeffs_.lookupOrDefault<word>("UNbr", "U");
|
||||||
htcFunc_ = Function2<scalar>::New("htcFunc", coeffs_);
|
|
||||||
}
|
|
||||||
|
|
||||||
return htcFunc_();
|
htcFunc_.reset(Function2<scalar>::New("htcFunc", coeffs_).ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const Foam::volScalarField& Foam::fv::function2HeatTransfer::AoV() const
|
void Foam::fv::function2HeatTransfer::correctHtc() const
|
||||||
{
|
{
|
||||||
if (!AoV_.valid())
|
const volVectorField& U = mesh_.lookupObject<volVectorField>(UName_);
|
||||||
{
|
|
||||||
AoV_.reset
|
|
||||||
(
|
|
||||||
new volScalarField
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
"AoV",
|
|
||||||
startTimeName_,
|
|
||||||
mesh_,
|
|
||||||
IOobject::MUST_READ,
|
|
||||||
IOobject::AUTO_WRITE
|
|
||||||
),
|
|
||||||
mesh_
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return AoV_();
|
const fvMesh& nbrMesh = mesh_.time().lookupObject<fvMesh>(nbrRegionName());
|
||||||
|
|
||||||
|
const volVectorField& UNbr =
|
||||||
|
nbrMesh.lookupObject<volVectorField>(UNbrName_);
|
||||||
|
const scalarField UMagNbr(mag(UNbr));
|
||||||
|
const scalarField UMagNbrMapped(interpolate(UMagNbr));
|
||||||
|
|
||||||
|
htc_.primitiveFieldRef() = htcFunc_->value(mag(U()), UMagNbrMapped)*AoV_();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -93,12 +80,29 @@ Foam::fv::function2HeatTransfer::function2HeatTransfer
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
interRegionHeatTransferModel(name, modelType, dict, mesh),
|
interRegionHeatTransferModel(name, modelType, dict, mesh),
|
||||||
UName_(coeffs_.lookupOrDefault<word>("U", "U")),
|
UName_(word::null),
|
||||||
UNbrName_(coeffs_.lookupOrDefault<word>("UNbr", "U")),
|
UNbrName_(word::null),
|
||||||
htcFunc_(),
|
htcFunc_(),
|
||||||
AoV_(),
|
AoV_
|
||||||
startTimeName_(mesh.time().timeName())
|
(
|
||||||
{}
|
master()
|
||||||
|
? new volScalarField
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"AoV",
|
||||||
|
mesh_.time().constant(),
|
||||||
|
mesh_,
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
mesh_
|
||||||
|
)
|
||||||
|
: nullptr
|
||||||
|
)
|
||||||
|
{
|
||||||
|
readCoeffs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
@ -109,25 +113,11 @@ Foam::fv::function2HeatTransfer::~function2HeatTransfer()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::fv::function2HeatTransfer::calculateHtc() const
|
|
||||||
{
|
|
||||||
const fvMesh& nbrMesh = mesh_.time().lookupObject<fvMesh>(nbrRegionName());
|
|
||||||
|
|
||||||
const volVectorField& UNbr =
|
|
||||||
nbrMesh.lookupObject<volVectorField>(UNbrName_);
|
|
||||||
|
|
||||||
const scalarField UMagNbr(mag(UNbr));
|
|
||||||
const scalarField UMagNbrMapped(interpolate(UMagNbr));
|
|
||||||
const volVectorField& U = mesh_.lookupObject<volVectorField>(UName_);
|
|
||||||
|
|
||||||
htc_.primitiveFieldRef() = htcFunc().value(mag(U()), UMagNbrMapped)*AoV();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Foam::fv::function2HeatTransfer::read(const dictionary& dict)
|
bool Foam::fv::function2HeatTransfer::read(const dictionary& dict)
|
||||||
{
|
{
|
||||||
if (interRegionHeatTransferModel::read(dict))
|
if (interRegionHeatTransferModel::read(dict))
|
||||||
{
|
{
|
||||||
|
readCoeffs();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -25,11 +25,10 @@ Class
|
|||||||
Foam::fv::function2HeatTransfer
|
Foam::fv::function2HeatTransfer
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Function2 heat transfer model.
|
Function2 heat transfer model. The 2D function returns the heat transfer
|
||||||
|
coefficient as a function of the local and neighbouring velocity
|
||||||
The heat exchange area per unit volume must be provided. The 2D function
|
magnitudes. An area-per-unit-volume [1/m] field (AoV) must be provided in
|
||||||
returns the heat transfer coefficient by querying the local and neighbour
|
constant.
|
||||||
region velocities.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -68,16 +67,19 @@ class function2HeatTransfer
|
|||||||
//- Area per unit volume of heat exchanger
|
//- Area per unit volume of heat exchanger
|
||||||
mutable autoPtr<volScalarField> AoV_;
|
mutable autoPtr<volScalarField> AoV_;
|
||||||
|
|
||||||
//- Heat transfer coefficient function
|
|
||||||
const Function2<scalar>& htcFunc() const;
|
|
||||||
|
|
||||||
//- Field of area divided by volume
|
|
||||||
const volScalarField& AoV() const;
|
|
||||||
|
|
||||||
//- Start time name
|
//- Start time name
|
||||||
const word startTimeName_;
|
const word startTimeName_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Non-virtual read
|
||||||
|
void readCoeffs();
|
||||||
|
|
||||||
|
//- Calculate the heat transfer coefficient
|
||||||
|
virtual void correctHtc() const;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
@ -102,9 +104,6 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Calculate the heat transfer coefficient
|
|
||||||
virtual void calculateHtc() const;
|
|
||||||
|
|
||||||
//- Read dictionary
|
//- Read dictionary
|
||||||
virtual bool read(const dictionary& dict);
|
virtual bool read(const dictionary& dict);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -41,62 +41,64 @@ namespace fv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * Protected member functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::fv::interRegionHeatTransferModel::setNbrModel() const
|
void Foam::fv::interRegionHeatTransferModel::readCoeffs()
|
||||||
{
|
{
|
||||||
if (!firstIter_)
|
nbrModelName_ = coeffs_.lookup<word>("nbrModel");
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const fvMesh& nbrMesh = mesh_.time().lookupObject<fvMesh>(nbrRegionName_);
|
semiImplicit_ = coeffs_.lookup<bool>("semiImplicit");
|
||||||
|
|
||||||
|
TName_ = coeffs_.lookupOrDefault<word>("T", "T");
|
||||||
|
TNbrName_ = coeffs_.lookupOrDefault<word>("TNbr", "T");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::fv::interRegionHeatTransferModel&
|
||||||
|
Foam::fv::interRegionHeatTransferModel::nbrModel() const
|
||||||
|
{
|
||||||
|
const fvMesh& nbrMesh = mesh_.time().lookupObject<fvMesh>(nbrRegionName());
|
||||||
|
|
||||||
const optionList& fvOptions = nbrMesh.lookupObject<optionList>("fvOptions");
|
const optionList& fvOptions = nbrMesh.lookupObject<optionList>("fvOptions");
|
||||||
|
|
||||||
bool nbrModelFound = false;
|
if (fvOptions.found(nbrModelName_))
|
||||||
|
|
||||||
forAll(fvOptions, i)
|
|
||||||
{
|
{
|
||||||
if (fvOptions[i].name() == nbrModelName_)
|
return const_cast<interRegionHeatTransferModel&>
|
||||||
{
|
(
|
||||||
nbrModel_ = &const_cast<interRegionHeatTransferModel&>
|
refCast<const interRegionHeatTransferModel>
|
||||||
(
|
(
|
||||||
refCast<const interRegionHeatTransferModel>(fvOptions[i])
|
fvOptions[nbrModelName_]
|
||||||
);
|
)
|
||||||
nbrModelFound = true;
|
);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (!nbrModelFound)
|
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Neighbour model not found" << nbrModelName_
|
<< "Neighbour model not found" << nbrModelName_
|
||||||
<< " in region " << nbrMesh.name() << nl
|
<< " in region " << nbrMesh.name() << nl
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
|
|
||||||
|
return const_cast<interRegionHeatTransferModel&>
|
||||||
|
(
|
||||||
|
NullObjectRef<interRegionHeatTransferModel>()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
firstIter_ = false;
|
|
||||||
|
|
||||||
// Set nbr model's nbr model to avoid construction order problems
|
|
||||||
nbrModel_->setNbrModel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::interRegionHeatTransferModel::correct() const
|
void Foam::fv::interRegionHeatTransferModel::correct() const
|
||||||
{
|
{
|
||||||
if (master_)
|
if (master())
|
||||||
{
|
{
|
||||||
if (mesh_.time().timeIndex() != timeIndex_)
|
if (mesh_.time().timeIndex() != timeIndex_)
|
||||||
{
|
{
|
||||||
calculateHtc();
|
correctHtc();
|
||||||
timeIndex_ = mesh_.time().timeIndex();
|
timeIndex_ = mesh_.time().timeIndex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nbrModel().correct();
|
nbrModel().correctHtc();
|
||||||
interpolate(nbrModel().htc(), htc_);
|
interpolate(nbrModel().htc(), htc_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,10 +121,11 @@ Foam::fv::interRegionHeatTransferModel::interRegionHeatTransferModel
|
|||||||
dict,
|
dict,
|
||||||
mesh
|
mesh
|
||||||
),
|
),
|
||||||
nbrModelName_(coeffs_.lookup("nbrModel")),
|
nbrModelName_(word::null),
|
||||||
nbrModel_(nullptr),
|
|
||||||
firstIter_(true),
|
|
||||||
timeIndex_(-1),
|
timeIndex_(-1),
|
||||||
|
semiImplicit_(false),
|
||||||
|
TName_(word::null),
|
||||||
|
TNbrName_(word::null),
|
||||||
htc_
|
htc_
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
@ -140,15 +143,9 @@ Foam::fv::interRegionHeatTransferModel::interRegionHeatTransferModel
|
|||||||
0
|
0
|
||||||
),
|
),
|
||||||
zeroGradientFvPatchScalarField::typeName
|
zeroGradientFvPatchScalarField::typeName
|
||||||
),
|
)
|
||||||
semiImplicit_(false),
|
|
||||||
TName_(coeffs_.lookupOrDefault<word>("T", "T")),
|
|
||||||
TNbrName_(coeffs_.lookupOrDefault<word>("TNbr", "T"))
|
|
||||||
{
|
{
|
||||||
coeffs_.lookup("fields") >> fieldNames_;
|
readCoeffs();
|
||||||
applied_.setSize(fieldNames_.size(), false);
|
|
||||||
|
|
||||||
coeffs_.lookup("semiImplicit") >> semiImplicit_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -160,14 +157,21 @@ Foam::fv::interRegionHeatTransferModel::~interRegionHeatTransferModel()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::wordList Foam::fv::interRegionHeatTransferModel::addedToFields() const
|
||||||
|
{
|
||||||
|
const basicThermo& thermo =
|
||||||
|
mesh_.lookupObject<basicThermo>(basicThermo::dictName);
|
||||||
|
|
||||||
|
return wordList(1, thermo.he().name());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fv::interRegionHeatTransferModel::addSup
|
void Foam::fv::interRegionHeatTransferModel::addSup
|
||||||
(
|
(
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
setNbrModel();
|
|
||||||
|
|
||||||
correct();
|
correct();
|
||||||
|
|
||||||
const volScalarField& he = eqn.psi();
|
const volScalarField& he = eqn.psi();
|
||||||
@ -181,7 +185,7 @@ void Foam::fv::interRegionHeatTransferModel::addSup
|
|||||||
|
|
||||||
volScalarField& Tmapped = tTmapped.ref();
|
volScalarField& Tmapped = tTmapped.ref();
|
||||||
|
|
||||||
const fvMesh& nbrMesh = mesh_.time().lookupObject<fvMesh>(nbrRegionName_);
|
const fvMesh& nbrMesh = mesh_.time().lookupObject<fvMesh>(nbrRegionName());
|
||||||
|
|
||||||
const volScalarField& Tnbr =
|
const volScalarField& Tnbr =
|
||||||
nbrMesh.lookupObject<volScalarField>(TNbrName_);
|
nbrMesh.lookupObject<volScalarField>(TNbrName_);
|
||||||
@ -205,33 +209,21 @@ void Foam::fv::interRegionHeatTransferModel::addSup
|
|||||||
{
|
{
|
||||||
if (he.dimensions() == dimEnergy/dimMass)
|
if (he.dimensions() == dimEnergy/dimMass)
|
||||||
{
|
{
|
||||||
if (mesh_.foundObject<basicThermo>(basicThermo::dictName))
|
const basicThermo& thermo =
|
||||||
|
mesh_.lookupObject<basicThermo>(basicThermo::dictName);
|
||||||
|
|
||||||
|
const volScalarField htcByCpv(htc_/thermo.Cpv());
|
||||||
|
|
||||||
|
eqn += htc_*(Tmapped - T) + htcByCpv*he - fvm::Sp(htcByCpv, he);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
{
|
{
|
||||||
const basicThermo& thermo =
|
const dimensionedScalar energy =
|
||||||
mesh_.lookupObject<basicThermo>(basicThermo::dictName);
|
fvc::domainIntegrate(htc_*(Tmapped - T));
|
||||||
|
|
||||||
const volScalarField htcByCpv(htc_/thermo.Cpv());
|
Info<< "Energy exchange from region " << nbrMesh.name()
|
||||||
|
<< " To " << mesh_.name() << " : " << energy.value()
|
||||||
eqn += htc_*(Tmapped - T) + htcByCpv*he - fvm::Sp(htcByCpv, he);
|
<< endl;
|
||||||
|
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
const dimensionedScalar energy =
|
|
||||||
fvc::domainIntegrate(htc_*(Tmapped - T));
|
|
||||||
|
|
||||||
Info<< "Energy exchange from region " << nbrMesh.name()
|
|
||||||
<< " To " << mesh_.name() << " : " << energy.value()
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< " on mesh " << mesh_.name()
|
|
||||||
<< " could not find object basicThermo."
|
|
||||||
<< " The available objects are: "
|
|
||||||
<< mesh_.names()
|
|
||||||
<< exit(FatalError);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (he.dimensions() == dimTemperature)
|
else if (he.dimensions() == dimTemperature)
|
||||||
@ -250,10 +242,24 @@ void Foam::fv::interRegionHeatTransferModel::addSup
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
addSup(eqn, fieldi);
|
addSup(eqn, fieldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::fv::interRegionHeatTransferModel::read(const dictionary& dict)
|
||||||
|
{
|
||||||
|
if (interRegionOption::read(dict))
|
||||||
|
{
|
||||||
|
readCoeffs();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -27,11 +27,10 @@ Class
|
|||||||
Description
|
Description
|
||||||
Base class for inter region heat exchange. The derived classes must
|
Base class for inter region heat exchange. The derived classes must
|
||||||
provide the heat transfer coefficient (htc) which is used as follows
|
provide the heat transfer coefficient (htc) which is used as follows
|
||||||
in the energy equation.
|
in the energy equation:
|
||||||
|
\f[
|
||||||
\f[
|
-htc*T_{mapped} + Sp(htc, T)
|
||||||
-htc*Tmapped + Sp(htc, T)
|
\f]
|
||||||
\f]
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -56,25 +55,14 @@ class interRegionHeatTransferModel
|
|||||||
:
|
:
|
||||||
public interRegionOption
|
public interRegionOption
|
||||||
{
|
{
|
||||||
protected:
|
// Private data
|
||||||
|
|
||||||
// Protected data
|
|
||||||
|
|
||||||
//- Name of the model in the neighbour mesh
|
//- Name of the model in the neighbour mesh
|
||||||
word nbrModelName_;
|
word nbrModelName_;
|
||||||
|
|
||||||
//- Pointer to neighbour interRegionHeatTransferModel
|
|
||||||
mutable interRegionHeatTransferModel* nbrModel_;
|
|
||||||
|
|
||||||
//- First iteration
|
|
||||||
mutable bool firstIter_;
|
|
||||||
|
|
||||||
//- Time index - used for updating htc
|
//- Time index - used for updating htc
|
||||||
mutable label timeIndex_;
|
mutable label timeIndex_;
|
||||||
|
|
||||||
//- Heat transfer coefficient [W/m^2/k] times area/volume [1/m]
|
|
||||||
mutable volScalarField htc_;
|
|
||||||
|
|
||||||
//- Flag to activate semi-implicit coupling
|
//- Flag to activate semi-implicit coupling
|
||||||
bool semiImplicit_;
|
bool semiImplicit_;
|
||||||
|
|
||||||
@ -85,17 +73,31 @@ protected:
|
|||||||
word TNbrName_;
|
word TNbrName_;
|
||||||
|
|
||||||
|
|
||||||
// Protected member functions
|
// Private member functions
|
||||||
|
|
||||||
//- Set the neighbour interRegionHeatTransferModel
|
//- Non-virtual read
|
||||||
void setNbrModel() const;
|
void readCoeffs();
|
||||||
|
|
||||||
//- Inherit correct from interRegionOption
|
//- Get the neighbour interRegionHeatTransferModel
|
||||||
using interRegionOption::correct;
|
interRegionHeatTransferModel& nbrModel() const;
|
||||||
|
|
||||||
//- Correct to calculate the inter-region heat transfer coefficient
|
//- Correct to calculate the inter-region heat transfer coefficient
|
||||||
void correct() const;
|
void correct() const;
|
||||||
|
|
||||||
|
//- Correct heat transfer coefficient
|
||||||
|
virtual void correctHtc() const = 0;
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected data
|
||||||
|
|
||||||
|
//- Heat transfer coefficient [W/m^2/k] times area/volume [1/m]
|
||||||
|
mutable volScalarField htc_;
|
||||||
|
|
||||||
|
|
||||||
|
// Protected Member Functions
|
||||||
|
|
||||||
//- Interpolate field with nbrModel specified
|
//- Interpolate field with nbrModel specified
|
||||||
template<class Type>
|
template<class Type>
|
||||||
tmp<Field<Type>> interpolate
|
tmp<Field<Type>> interpolate
|
||||||
@ -155,26 +157,24 @@ public:
|
|||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
//- Return const access to the neighbour region name
|
|
||||||
inline const word& nbrRegionName() const;
|
|
||||||
|
|
||||||
//- Return const access to the mapToMap pointer
|
|
||||||
inline const meshToMesh& meshInterp() const;
|
|
||||||
|
|
||||||
//- Return the heat transfer coefficient
|
//- Return the heat transfer coefficient
|
||||||
inline const volScalarField& htc() const;
|
inline const volScalarField& htc() const;
|
||||||
|
|
||||||
//- Return const access to the neighbour model
|
|
||||||
inline const interRegionHeatTransferModel& nbrModel() const;
|
|
||||||
|
|
||||||
//- Return access to the neighbour model
|
// Checks
|
||||||
inline interRegionHeatTransferModel& nbrModel();
|
|
||||||
|
//- Return the list of fields for which the option adds source term
|
||||||
|
// to the transport equation
|
||||||
|
virtual wordList addedToFields() const;
|
||||||
|
|
||||||
|
|
||||||
|
// Sources
|
||||||
|
|
||||||
//- Source term to energy equation
|
//- Source term to energy equation
|
||||||
virtual void addSup
|
virtual void addSup
|
||||||
(
|
(
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Source term to compressible energy equation
|
//- Source term to compressible energy equation
|
||||||
@ -182,11 +182,14 @@ public:
|
|||||||
(
|
(
|
||||||
const volScalarField& rho,
|
const volScalarField& rho,
|
||||||
fvMatrix<scalar>& eqn,
|
fvMatrix<scalar>& eqn,
|
||||||
const label fieldi
|
const word& fieldName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Calculate heat transfer coefficient
|
|
||||||
virtual void calculateHtc() const = 0;
|
// Correction
|
||||||
|
|
||||||
|
//- Inherit base class correct method to avoid clang warning
|
||||||
|
using interRegionOption::correct;
|
||||||
|
|
||||||
|
|
||||||
// IO
|
// IO
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -25,59 +25,10 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline const Foam::word&
|
|
||||||
Foam::fv::interRegionHeatTransferModel::nbrRegionName() const
|
|
||||||
{
|
|
||||||
return nbrRegionName_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline const Foam::meshToMesh&
|
|
||||||
Foam::fv::interRegionHeatTransferModel::meshInterp() const
|
|
||||||
{
|
|
||||||
if (!meshInterpPtr_.valid())
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Interpolation object not set"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
return meshInterpPtr_();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline const Foam::volScalarField&
|
inline const Foam::volScalarField&
|
||||||
Foam::fv::interRegionHeatTransferModel::htc() const
|
Foam::fv::interRegionHeatTransferModel::htc() const
|
||||||
{
|
{
|
||||||
return htc_;
|
return htc_;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline const Foam::fv::interRegionHeatTransferModel&
|
|
||||||
Foam::fv::interRegionHeatTransferModel::nbrModel() const
|
|
||||||
{
|
|
||||||
if (nbrModel_ == nullptr)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Neighbour model not set"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
return *nbrModel_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline Foam::fv::interRegionHeatTransferModel&
|
|
||||||
Foam::fv::interRegionHeatTransferModel::nbrModel()
|
|
||||||
{
|
|
||||||
if (nbrModel_ == nullptr)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Neighbour model not set"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
return *nbrModel_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,43 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration | Website: https://openfoam.org
|
|
||||||
\\ / A nd | Copyright (C) 2011-2018 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 "interRegionHeatTransferModel.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
bool Foam::fv::interRegionHeatTransferModel::read(const dictionary& dict)
|
|
||||||
{
|
|
||||||
if (interRegionOption::read(dict))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration | Website: https://openfoam.org
|
\\ / O peration | Website: https://openfoam.org
|
||||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -31,7 +31,7 @@ Foam::fv::interRegionHeatTransferModel::interpolate
|
|||||||
const Field<Type>& field
|
const Field<Type>& field
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (master_)
|
if (master())
|
||||||
{
|
{
|
||||||
return meshInterp().mapTgtToSrc(field);
|
return meshInterp().mapTgtToSrc(field);
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ void Foam::fv::interRegionHeatTransferModel::interpolate
|
|||||||
Field<Type>& result
|
Field<Type>& result
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (master_)
|
if (master())
|
||||||
{
|
{
|
||||||
meshInterp().mapTgtToSrc(field, plusEqOp<scalar>(), result);
|
meshInterp().mapTgtToSrc(field, plusEqOp<scalar>(), result);
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user