unitConversion: Unit conversions on all input parameters

The majority of input parameters now support automatic unit conversion.
Units are specified within square brackets, either before or after the
value. Primitive parameters (e.g., scalars, vectors, tensors, ...),
dimensioned types, fields, Function1-s and Function2-s all support unit
conversion in this way.

Unit conversion occurs on input only. OpenFOAM writes out all fields and
parameters in standard units. It is recommended to use '.orig' files in
the 0 directory to preserve user-readable input if those files are being
modified by pre-processing applications (e.g., setFields).

For example, to specify a volumetric flow rate inlet boundary in litres
per second [l/s], rather than metres-cubed per second [m^3/s], in 0/U:

    boundaryField
    {
        inlet
        {
            type            flowRateInletVelocity;
            volumetricFlowRate 0.1 [l/s];
            value           $internalField;
        }

        ...
    }

Or, to specify the pressure field in bar, in 0/p:

    internalField   uniform 1 [bar];

Or, to convert the parameters of an Arrhenius reaction rate from a
cm-mol-kcal unit system, in constant/chemistryProperties:

    reactions
    {
        methaneReaction
        {
            type    irreversibleArrhenius;
            reaction "CH4^0.2 + 2O2^1.3 = CO2 + 2H2O";
            A       6.7e12 [(mol/cm^3)^-0.5/s];
            beta    0;
            Ea      48.4 [kcal/mol];
        }
    }

Or, to define a time-varying outlet pressure using a CSV file in which
the pressure column is in mega-pascals [MPa], in 0/p:

    boundaryField
    {
        outlet
        {
            type            uniformFixedValue;
            value
            {
                type            table;
                format          csv;
                nHeaderLine     1;
                units           ([s] [MPa]); // <-- new units entry
                columns         (0 1);
                mergeSeparators no;
                file            "data/pressure.csv";
                outOfBounds     clamp;
                interpolationScheme linear;
            }
        }

        ...
    }

(Note also that a new 'columns' entry replaces the old 'refColumn' and
'componentColumns'. This is is considered to be more intuitive, and has
a consistent syntax with the new 'units' entry. 'columns' and
'componentColumns' have been retained for backwards compatibility and
will continue to work for the time being.)

Unit definitions can be added in the global or case controlDict files.
See UnitConversions in $WM_PROJECT_DIR/etc/controlDict for examples.
Currently available units include:

    Standard: kg m s K kmol A Cd

     Derived: Hz N Pa J W g um mm cm km l ml us ms min hr mol
              rpm bar atm kPa MPa cal kcal cSt cP % rad rot deg

A user-time unit is also provided if user-time is in operation. This
allows it to be specified locally whether a parameter relates to
real-time or to user-time. For example, to define a mass source that
ramps up from a given engine-time (in crank-angle-degrees [CAD]) over a
duration in real-time, in constant/fvModels:

    massSource1
    {
        type        massSource;
        points      ((1 2 3));
        massFlowRate
        {
            type        scale;
            scale       linearRamp;
            start       20 [CAD];
            duration    50 [ms];
            value       0.1 [g/s];
        }
    }

Specified units will be checked against the parameter's dimensions where
possible, and an error generated if they are not consistent. For the
dimensions to be available for this check, the code requires
modification, and work propagating this change across OpenFOAM is
ongoing. Unit conversions are still possible without these changes, but
the validity of such conversions will not be checked.

Units are no longer permitted in 'dimensions' entries in field files.
These 'dimensions' entries can now, instead, take the names of
dimensions. The names of the available dimensions are:

    Standard: mass length time temperature
              moles current luminousIntensity

     Derived: area volume rate velocity momentum acceleration density
              force energy power pressure kinematicPressure
              compressibility gasConstant specificHeatCapacity
              kinematicViscosity dynamicViscosity thermalConductivity
              volumetricFlux massFlux

So, for example, a 0/epsilon file might specify the dimensions as
follows:

    dimensions      [energy/mass/time];

And a 0/alphat file might have:

    dimensions      [thermalConductivity/specificHeatCapacity];

*** Development Notes ***

A unit conversion can construct trivially from a dimension set,
resulting in a "standard" unit with a conversion factor of one. This
means the functions which perform unit conversion on read can be
provided dimension sets or unit conversion objects interchangeably.

A basic `dict.lookup<vector>("Umean")` call will do unit conversion, but
it does not know the parameter's dimensions, so it cannot check the
validity of the supplied units. A corresponding lookup function has been
added in which the dimensions or units can be provided; in this case the
corresponding call would be `dict.lookup<vector>("Umean", dimVelocity)`.
This function enables additional checking and should be used wherever
possible.

Function1-s and Function2-s have had their constructors and selectors
changed so that dimensions/units must be specified by calling code. In
the case of Function1, two unit arguments must be given; one for the
x-axis and one for the value-axis. For Function2-s, three must be
provided.

In some cases, it is desirable (or at least established practice), that
a given non-standard unit be used in the absence of specific
user-defined units. Commonly this includes reading angles in degrees
(rather than radians) and reading times in user-time (rather than
real-time). The primitive lookup functions and Function1 and Function2
selectors both support specifying a non-standard default unit. For
example, `theta_ = dict.lookup<scalar>("theta", unitDegrees)` will read
an angle in degrees by default. If this is done within a model which
also supports writing then the write call must be modified accordingly
so that the data is also written out in degrees. Overloads of writeEntry
have been created for this purpose. In this case, the angle theta should
be written out with `writeEntry(os, "theta", unitDegrees, theta_)`.
Function1-s and Function2-s behave similarly, but with greater numbers
of dimensions/units arguments as before.

The non-standard user-time unit can be accessed by a `userUnits()`
method that has been added to Time. Use of this user-time unit in the
construction of Function1-s should prevent the need for explicit
user-time conversion in boundary conditions and sub-models and similar.

Some models might contain non-typed stream-based lookups of the form
`dict.lookup("p0") >> p0_` (e.g., in a re-read method), or
`Umean_(dict.lookup("Umean"))` (e.g., in an initialiser list). These
calls cannot facilitate unit conversion and are therefore discouraged.
They should be replaced with
`p0_ = dict.lookup<scalar>("p0", dimPressure)` and
`Umean_(dict.lookup<vector>("Umean", dimVelocity))` and similar whenever
they are found.
This commit is contained in:
Will Bainbridge
2024-04-19 11:44:41 +01:00
parent d21e75ac74
commit 476bb42b04
626 changed files with 8274 additions and 4300 deletions

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -53,9 +53,12 @@ activeBaffleVelocityFvPatchVectorField
p.boundaryMesh()[cyclicPatchLabel_] p.boundaryMesh()[cyclicPatchLabel_]
).neighbFvPatch().Sf() ).neighbFvPatch().Sf()
), ),
openFraction_(dict.lookup<scalar>("openFraction")), openFraction_(dict.lookup<scalar>("openFraction", unitFraction)),
openingTime_(dict.lookup<scalar>("openingTime")), openingTime_(dict.lookup<scalar>("openingTime", dimTime)),
maxOpenFractionDelta_(dict.lookup<scalar>("maxOpenFractionDelta")), maxOpenFractionDelta_
(
dict.lookup<scalar>("maxOpenFractionDelta", unitFraction)
),
curTimeIndex_(-1) curTimeIndex_(-1)
{ {
fvPatchVectorField::operator=(Zero); fvPatchVectorField::operator=(Zero);

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -47,12 +47,15 @@ activePressureForceBaffleVelocityFvPatchVectorField
initWallSf_(0), initWallSf_(0),
initCyclicSf_(0), initCyclicSf_(0),
nbrCyclicSf_(0), nbrCyclicSf_(0),
openFraction_(dict.lookup<scalar>("openFraction")), openFraction_(dict.lookup<scalar>("openFraction", unitFraction)),
openingTime_(dict.lookup<scalar>("openingTime")), openingTime_(dict.lookup<scalar>("openingTime", dimTime)),
maxOpenFractionDelta_(dict.lookup<scalar>("maxOpenFractionDelta")), maxOpenFractionDelta_
(
dict.lookup<scalar>("maxOpenFractionDelta", unitFraction)
),
curTimeIndex_(-1), curTimeIndex_(-1),
minThresholdValue_(dict.lookup<scalar>("minThresholdValue")), minThresholdValue_(dict.lookup<scalar>("minThresholdValue", dimPressure)),
fBased_(readBool(dict.lookup("forceBased"))), fBased_(dict.lookup<bool>("forceBased")),
baffleActivated_(0) baffleActivated_(0)
{ {
fvPatchVectorField::operator=(Zero); fvPatchVectorField::operator=(Zero);

View File

@ -22,7 +22,7 @@ dimensionedScalar rho
dimensionedScalar nu dimensionedScalar nu
( (
"nu", "nu",
dimViscosity, dimKinematicViscosity,
physicalProperties physicalProperties
); );

View File

@ -15,7 +15,7 @@ IOdictionary physicalProperties
dimensionedScalar nu dimensionedScalar nu
( (
"nu", "nu",
dimViscosity, dimKinematicViscosity,
physicalProperties.lookup("nu") physicalProperties.lookup("nu")
); );

View File

@ -15,7 +15,8 @@ IOdictionary gravitationalProperties
const dimensionedVector g(gravitationalProperties.lookup("g")); const dimensionedVector g(gravitationalProperties.lookup("g"));
const Switch rotating(gravitationalProperties.lookup("rotating")); const Switch rotating(gravitationalProperties.lookup("rotating"));
const dimensionedVector Omega = const dimensionedVector Omega =
rotating ? gravitationalProperties.lookup("Omega") rotating
: dimensionedVector("Omega", -dimTime, vector(0,0,0)); ? gravitationalProperties.lookup("Omega")
: dimensionedVector("Omega", dimless/dimTime, vector::zero);
const dimensionedScalar magg = mag(g); const dimensionedScalar magg = mag(g);
const dimensionedVector gHat = g/magg; const dimensionedVector gHat = g/magg;

View File

@ -59,11 +59,20 @@ namespace Foam
void Foam::fv::VoFSolidificationMelting::readCoeffs() void Foam::fv::VoFSolidificationMelting::readCoeffs()
{ {
alphaSolidT_.reset(Function1<scalar>::New("alphaSolidT", coeffs()).ptr()); alphaSolidT_.reset
(
Function1<scalar>::New
(
"alphaSolidT",
dimTemperature,
unitFraction,
coeffs()
).ptr()
);
L_ = dimensionedScalar("L", dimEnergy/dimMass, coeffs()); L_ = dimensionedScalar("L", dimEnergy/dimMass, coeffs());
relax_ = coeffs().lookupOrDefault<scalar>("relax", 0.9); relax_ = coeffs().lookupOrDefault<scalar>("relax", dimless, 0.9);
Cu_ = coeffs().lookupOrDefault<scalar>("Cu", 100000); Cu_ = coeffs().lookupOrDefault<scalar>("Cu", dimless/dimTime, 100000);
q_ = coeffs().lookupOrDefault<scalar>("q", 0.001); q_ = coeffs().lookupOrDefault<scalar>("q", dimless, 0.001);
} }

View File

@ -57,10 +57,7 @@ bool Foam::solvers::fluidSolver::read()
maxDeltaT_ = maxDeltaT_ =
runTime.controlDict().found("maxDeltaT") runTime.controlDict().found("maxDeltaT")
? runTime.userTimeToTime ? runTime.controlDict().lookup<scalar>("maxDeltaT", runTime.userUnits())
(
runTime.controlDict().lookup<scalar>("maxDeltaT")
)
: vGreat; : vGreat;
correctPhi = pimple.dict().lookupOrDefault correctPhi = pimple.dict().lookupOrDefault

View File

@ -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) 2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2023-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -72,8 +72,22 @@ bool Foam::functionObjects::fluidMaxDeltaT::read(const dictionary& dict)
{ {
fvMeshFunctionObject::read(dict); fvMeshFunctionObject::read(dict);
maxCoPtr_ = Function1<scalar>::New("maxCo", dict); maxCoPtr_ =
maxDeltaTPtr_ = Function1<scalar>::New("maxDeltaT", dict); Function1<scalar>::New
(
"maxCo",
time_.userUnits(),
dimless,
dict
);
maxDeltaTPtr_ =
Function1<scalar>::New
(
"maxDeltaT",
time_.userUnits(),
time_.userUnits(),
dict
);
return true; return true;
} }
@ -93,15 +107,14 @@ bool Foam::functionObjects::fluidMaxDeltaT::write()
Foam::scalar Foam::functionObjects::fluidMaxDeltaT::maxDeltaT() const Foam::scalar Foam::functionObjects::fluidMaxDeltaT::maxDeltaT() const
{ {
scalar deltaT = scalar deltaT = maxDeltaTPtr_().value(time_.value());
time_.userTimeToTime(maxDeltaTPtr_().value(time_.userTimeValue()));
const scalar CoNum = const scalar CoNum =
mesh_.lookupObject<solvers::fluidSolver>(solver::typeName).CoNum; mesh_.lookupObject<solvers::fluidSolver>(solver::typeName).CoNum;
if (CoNum > small) if (CoNum > small)
{ {
const scalar maxCo = maxCoPtr_().value(time_.userTimeValue()); const scalar maxCo = maxCoPtr_().value(time_.value());
deltaT = min(deltaT, maxCo/CoNum*time_.deltaTValue()); deltaT = min(deltaT, maxCo/CoNum*time_.deltaTValue());
} }

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2014-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -74,7 +74,7 @@ Foam::incompressibleDriftFluxMixture::incompressibleDriftFluxMixture
mesh mesh
), ),
mesh, mesh,
dimensionedScalar(dimViscosity, 0), dimensionedScalar(dimKinematicViscosity, 0),
calculatedFvPatchScalarField::typeName calculatedFvPatchScalarField::typeName
), ),

View File

@ -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) 2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2023-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -88,7 +88,7 @@ Foam::incompressibleMultiphaseVoFMixture::incompressibleMultiphaseVoFMixture
mesh mesh
), ),
mesh, mesh,
dimensionedScalar(dimViscosity, 0), dimensionedScalar(dimKinematicViscosity, 0),
calculatedFvPatchScalarField::typeName calculatedFvPatchScalarField::typeName
) )
{ {

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -73,7 +73,7 @@ Foam::incompressibleTwoPhaseVoFMixture::incompressibleTwoPhaseVoFMixture
mesh mesh
), ),
mesh, mesh,
dimensionedScalar(dimViscosity, 0), dimensionedScalar(dimKinematicViscosity, 0),
calculatedFvPatchScalarField::typeName calculatedFvPatchScalarField::typeName
) )
{ {

View File

@ -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) 2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2023-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -39,7 +39,7 @@ filmSurfaceVelocityFvPatchVectorField
) )
: :
mixedFvPatchField<vector>(p, iF, dict, false), mixedFvPatchField<vector>(p, iF, dict, false),
Cs_(dict.lookupOrDefault<scalar>("Cs", 0)) Cs_(dict.lookupOrDefault<scalar>("Cs", dimless, 0))
{ {
refValue() = Zero; refValue() = Zero;
refGrad() = Zero; refGrad() = Zero;
@ -49,7 +49,7 @@ filmSurfaceVelocityFvPatchVectorField
{ {
fvPatchVectorField::operator= fvPatchVectorField::operator=
( (
vectorField("value", dict, p.size()) vectorField("value", iF.dimensions(), dict, p.size())
); );
} }
else else

View File

@ -235,10 +235,7 @@ bool Foam::solvers::isothermalFilm::read()
maxDeltaT_ = maxDeltaT_ =
runTime.controlDict().found("maxDeltaT") runTime.controlDict().found("maxDeltaT")
? runTime.userTimeToTime ? runTime.controlDict().lookup<scalar>("maxDeltaT", runTime.userUnits())
(
runTime.controlDict().lookup<scalar>("maxDeltaT")
)
: vGreat; : vGreat;
return true; return true;

View File

@ -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) 2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2023-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -46,10 +46,7 @@ Foam::solvers::movingMesh::movingMesh(fvMesh& mesh)
maxDeltaT_ maxDeltaT_
( (
runTime.controlDict().found("maxDeltaT") runTime.controlDict().found("maxDeltaT")
? runTime.userTimeToTime ? runTime.controlDict().lookup<scalar>("maxDeltaT", runTime.userUnits())
(
runTime.controlDict().lookup<scalar>("maxDeltaT")
)
: vGreat : vGreat
) )
{} {}

View File

@ -284,7 +284,7 @@ void Foam::solvers::multiphaseEuler::cellPressureCorrector()
mesh mesh
), ),
mesh, mesh,
dimensionedScalar(dimFlux, 0) dimensionedScalar(dimVolumetricFlux, 0)
); );
forAll(movingPhases, movingPhasei) forAll(movingPhases, movingPhasei)

View File

@ -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) 2022-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2022-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -226,7 +226,7 @@ void Foam::solvers::multiphaseEuler::facePressureCorrector()
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
), ),
mesh, mesh,
dimensionedScalar(dimFlux, 0) dimensionedScalar(dimVolumetricFlux, 0)
); );
forAll(movingPhases, movingPhasei) forAll(movingPhases, movingPhasei)

View File

@ -52,7 +52,13 @@ void Foam::fv::homogeneousLiquidPhaseSeparation::readCoeffs()
{ {
solubilityCurve_.reset solubilityCurve_.reset
( (
Function1<scalar>::New("solubility", coeffs()).ptr() Function1<scalar>::New
(
"solubility",
dimTemperature,
unitFraction,
coeffs()
).ptr()
); );
} }

View File

@ -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) 2022-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2022-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -70,7 +70,7 @@ Foam::tmp<Foam::volScalarField> Foam::liftModels::SaffmanMei::Cl() const
*sqr(interface_.dispersed().d()) *sqr(interface_.dispersed().d())
/( /(
interface_.continuous().fluidThermo().nu() interface_.continuous().fluidThermo().nu()
+ dimensionedScalar(dimViscosity, small) + dimensionedScalar(dimKinematicViscosity, small)
) )
); );

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2014-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -52,16 +52,10 @@ JohnsonJacksonParticleSlipFvPatchVectorField
partialSlipFvPatchVectorField(p, iF), partialSlipFvPatchVectorField(p, iF),
specularityCoefficient_ specularityCoefficient_
( (
"specularityCoefficient", dict.lookup<scalar>("specularityCoefficient", unitFraction)
dimless,
dict.lookup("specularityCoefficient")
) )
{ {
if if (specularityCoefficient_ < 0 || specularityCoefficient_ > 1)
(
(specularityCoefficient_.value() < 0)
|| (specularityCoefficient_.value() > 1)
)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "The specularity coefficient has to be between 0 and 1" << "The specularity coefficient has to be between 0 and 1"
@ -70,7 +64,7 @@ JohnsonJacksonParticleSlipFvPatchVectorField
fvPatchVectorField::operator= fvPatchVectorField::operator=
( (
vectorField("value", dict, p.size()) vectorField("value", iF.dimensions(), dict, p.size())
); );
} }
@ -163,7 +157,7 @@ void Foam::JohnsonJacksonParticleSlipFvPatchVectorField::updateCoeffs()
constant::mathematical::pi constant::mathematical::pi
*alpha *alpha
*gs0 *gs0
*specularityCoefficient_.value() *specularityCoefficient_
*sqrt(3*Theta) *sqrt(3*Theta)
/max(6*nu*phase.alphaMax(), small) /max(6*nu*phase.alphaMax(), small)
); );

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2014-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -69,7 +69,7 @@ class JohnsonJacksonParticleSlipFvPatchVectorField
// Private Data // Private Data
//- Specularity coefficient //- Specularity coefficient
dimensionedScalar specularityCoefficient_; const scalar specularityCoefficient_;
public: public:

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2014-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -51,33 +51,21 @@ JohnsonJacksonParticleThetaFvPatchScalarField
mixedFvPatchScalarField(p, iF, dict, false), mixedFvPatchScalarField(p, iF, dict, false),
restitutionCoefficient_ restitutionCoefficient_
( (
"restitutionCoefficient", dict.lookup<scalar>("restitutionCoefficient", unitFraction)
dimless,
dict.lookup("restitutionCoefficient")
), ),
specularityCoefficient_ specularityCoefficient_
( (
"specularityCoefficient", dict.lookup<scalar>("specularityCoefficient", unitFraction)
dimless,
dict.lookup("specularityCoefficient")
) )
{ {
if if (restitutionCoefficient_ < 0 || restitutionCoefficient_ > 1)
(
(restitutionCoefficient_.value() < 0)
|| (restitutionCoefficient_.value() > 1)
)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "The restitution coefficient has to be between 0 and 1" << "The restitution coefficient has to be between 0 and 1"
<< abort(FatalError); << abort(FatalError);
} }
if if (specularityCoefficient_ < 0 || specularityCoefficient_ > 1)
(
(specularityCoefficient_.value() < 0)
|| (specularityCoefficient_.value() > 1)
)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "The specularity coefficient has to be between 0 and 1" << "The specularity coefficient has to be between 0 and 1"
@ -86,7 +74,7 @@ JohnsonJacksonParticleThetaFvPatchScalarField
fvPatchScalarField::operator= fvPatchScalarField::operator=
( (
scalarField("value", dict, p.size()) scalarField("value", iF.dimensions(), dict, p.size())
); );
} }
@ -182,13 +170,13 @@ void Foam::JohnsonJacksonParticleThetaFvPatchScalarField::updateCoeffs()
const scalarField Theta(patchInternalField()); const scalarField Theta(patchInternalField());
// calculate the reference value and the value fraction // calculate the reference value and the value fraction
if (restitutionCoefficient_.value() != 1.0) if (restitutionCoefficient_ != 1.0)
{ {
this->refValue() = this->refValue() =
(2.0/3.0) (2.0/3.0)
*specularityCoefficient_.value() *specularityCoefficient_
*magSqr(U) *magSqr(U)
/(scalar(1) - sqr(restitutionCoefficient_.value())); /(scalar(1) - sqr(restitutionCoefficient_));
this->refGrad() = 0.0; this->refGrad() = 0.0;
@ -197,7 +185,7 @@ void Foam::JohnsonJacksonParticleThetaFvPatchScalarField::updateCoeffs()
constant::mathematical::pi constant::mathematical::pi
*alpha *alpha
*gs0 *gs0
*(scalar(1) - sqr(restitutionCoefficient_.value())) *(scalar(1) - sqr(restitutionCoefficient_))
*sqrt(3*Theta) *sqrt(3*Theta)
/max(4*kappa*phase.alphaMax(), small) /max(4*kappa*phase.alphaMax(), small)
); );
@ -214,7 +202,7 @@ void Foam::JohnsonJacksonParticleThetaFvPatchScalarField::updateCoeffs()
this->refGrad() = this->refGrad() =
pos0(alpha - small) pos0(alpha - small)
*constant::mathematical::pi *constant::mathematical::pi
*specularityCoefficient_.value() *specularityCoefficient_
*alpha *alpha
*gs0 *gs0
*sqrt(3*Theta) *sqrt(3*Theta)

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2014-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -69,10 +69,10 @@ class JohnsonJacksonParticleThetaFvPatchScalarField
// Private Data // Private Data
//- Particle-wall restitution coefficient //- Particle-wall restitution coefficient
dimensionedScalar restitutionCoefficient_; const scalar restitutionCoefficient_;
//- Specularity coefficient //- Specularity coefficient
dimensionedScalar specularityCoefficient_; const scalar specularityCoefficient_;
public: public:

View File

@ -222,7 +222,7 @@ Foam::phaseSystem::phaseSystem
mesh mesh
), ),
mesh, mesh,
dimensionedScalar(dimFlux, 0) dimensionedScalar(dimVolumetricFlux, 0)
), ),
dpdt_ dpdt_

View File

@ -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) 2021-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2021-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -119,7 +119,7 @@ void Foam::diameterModels::LiaoBase::precompute()
const dimensionedScalar nuc const dimensionedScalar nuc
( (
"nuc", "nuc",
dimViscosity, dimKinematicViscosity,
gAverage(populationBalance_.continuousPhase().fluidThermo().nu()()) gAverage(populationBalance_.continuousPhase().fluidThermo().nu()())
); );

View File

@ -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) 2021-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2021-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -84,6 +84,7 @@ public:
( (
const speciesTable& species, const speciesTable& species,
const objectRegistry& ob, const objectRegistry& ob,
const dimensionSet& dims,
const dictionary& dict const dictionary& dict
); );

View File

@ -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) 2021-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2021-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -34,10 +34,11 @@ phaseSurfaceArrheniusReactionRate
( (
const speciesTable& species, const speciesTable& species,
const objectRegistry& ob, const objectRegistry& ob,
const dimensionSet& dims,
const dictionary& dict const dictionary& dict
) )
: :
ArrheniusReactionRate(species, dict), ArrheniusReactionRate(species, dims, dict),
phaseName_(dict.lookup("phase")), phaseName_(dict.lookup("phase")),
ob_(ob), ob_(ob),
tAv_(nullptr) tAv_(nullptr)

View File

@ -576,8 +576,8 @@ alphatWallBoilingWallFunctionFvPatchScalarField
), ),
tolerance_(dict.lookupOrDefault<scalar>("tolerance", rootSmall)), tolerance_(dict.lookupOrDefault<scalar>("tolerance", rootSmall)),
Prt_(dict.lookupOrDefault<scalar>("Prt", 0.85)), Prt_(dict.lookupOrDefault<scalar>("Prt", dimless, 0.85)),
tau_(dict.lookupOrDefault<scalar>("bubbleWaitingTimeRatio", 0.8)), tau_(dict.lookupOrDefault<scalar>("bubbleWaitingTimeRatio", dimless, 0.8)),
partitioningModel_(nullptr), partitioningModel_(nullptr),
nucleationSiteModel_(nullptr), nucleationSiteModel_(nullptr),
@ -628,6 +628,7 @@ alphatWallBoilingWallFunctionFvPatchScalarField
auto readFieldBackwardsCompatible = [&p] auto readFieldBackwardsCompatible = [&p]
( (
const dictionary& dict, const dictionary& dict,
const unitConversion& units,
const wordList& keywords, const wordList& keywords,
scalarField& field scalarField& field
) )
@ -636,7 +637,7 @@ alphatWallBoilingWallFunctionFvPatchScalarField
{ {
if (dict.found(keywords[i])) if (dict.found(keywords[i]))
{ {
field = scalarField(keywords[i], dict, p.size()); field = scalarField(keywords[i], units, dict, p.size());
return; return;
} }
} }
@ -646,17 +647,25 @@ alphatWallBoilingWallFunctionFvPatchScalarField
readFieldBackwardsCompatible readFieldBackwardsCompatible
( (
dict, dict,
unitFraction,
{"wetFraction", "wallLiquidFraction"}, {"wetFraction", "wallLiquidFraction"},
wetFraction_ wetFraction_
); );
if (phaseType_ == liquidPhase) if (phaseType_ == liquidPhase)
{ {
readFieldBackwardsCompatible(dict, {"dDeparture"}, dDeparture_); readFieldBackwardsCompatible
(
dict,
dimLength,
{"dDeparture"},
dDeparture_
);
readFieldBackwardsCompatible readFieldBackwardsCompatible
( (
dict, dict,
dimless/dimTime,
{"fDeparture", "depFrequency"}, {"fDeparture", "depFrequency"},
fDeparture_ fDeparture_
); );
@ -664,15 +673,34 @@ alphatWallBoilingWallFunctionFvPatchScalarField
readFieldBackwardsCompatible readFieldBackwardsCompatible
( (
dict, dict,
dimless/dimArea,
{"nucleationSiteDensity", "nucSiteDensity"}, {"nucleationSiteDensity", "nucSiteDensity"},
nucleationSiteDensity_ nucleationSiteDensity_
); );
readFieldBackwardsCompatible(dict, {"qQuenching"}, qQuenching_); readFieldBackwardsCompatible
(
dict,
dimPower/dimArea,
{"qQuenching"},
qQuenching_
);
readFieldBackwardsCompatible(dict, {"qEvaporative"}, qEvaporative_); readFieldBackwardsCompatible
(
dict,
dimPower/dimArea,
{"qEvaporative"},
qEvaporative_
);
readFieldBackwardsCompatible(dict, {"dmdtf"}, dmdtf_); readFieldBackwardsCompatible
(
dict,
dimDensity/dimTime,
{"dmdtf"},
dmdtf_
);
} }
} }

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -44,21 +44,15 @@ Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
rhoName_(dict.lookupOrDefault<word>("rho", "rho")), rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
psiName_(dict.lookupOrDefault<word>("psi", "psi")), psiName_(dict.lookupOrDefault<word>("psi", "psi")),
muName_(dict.lookupOrDefault<word>("mu", "mu")), muName_(dict.lookupOrDefault<word>("mu", "mu")),
accommodationCoeff_(dict.lookup<scalar>("accommodationCoeff")), accommodationCoeff_(dict.lookup<scalar>("accommodationCoeff", dimless)),
Twall_("Twall", dict, p.size()), Twall_("Twall", dimTemperature, dict, p.size()),
gamma_(dict.lookupOrDefault<scalar>("gamma", 1.4)) gamma_(dict.lookupOrDefault<scalar>("gamma", dimless, 1.4))
{ {
if if (mag(accommodationCoeff_) < small || mag(accommodationCoeff_) > 2.0)
(
mag(accommodationCoeff_) < small
|| mag(accommodationCoeff_) > 2.0
)
{ {
FatalIOErrorInFunction FatalIOErrorInFunction(dict)
( << "unphysical accommodationCoeff specified"
dict << "(0 < accommodationCoeff <= 2)" << endl
) << "unphysical accommodationCoeff specified"
<< "(0 < accommodationCoeff <= 1)" << endl
<< exit(FatalIOError); << exit(FatalIOError);
} }
@ -66,7 +60,7 @@ Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
{ {
fvPatchField<scalar>::operator= fvPatchField<scalar>::operator=
( (
scalarField("value", dict, p.size()) scalarField("value", iF.dimensions(), dict, p.size())
); );
} }
else else

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -45,21 +45,15 @@ Foam::maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField
psiName_(dict.lookupOrDefault<word>("psi", "psi")), psiName_(dict.lookupOrDefault<word>("psi", "psi")),
muName_(dict.lookupOrDefault<word>("mu", "mu")), muName_(dict.lookupOrDefault<word>("mu", "mu")),
accommodationCoeff_(dict.lookup<scalar>("accommodationCoeff")), accommodationCoeff_(dict.lookup<scalar>("accommodationCoeff")),
Uwall_("Uwall", dict, p.size()), Uwall_("Uwall", dimVelocity, dict, p.size()),
thermalCreep_(dict.lookupOrDefault("thermalCreep", true)), thermalCreep_(dict.lookupOrDefault("thermalCreep", true)),
curvature_(dict.lookupOrDefault("curvature", true)) curvature_(dict.lookupOrDefault("curvature", true))
{ {
if if (mag(accommodationCoeff_) < small || mag(accommodationCoeff_) > 2.0)
(
mag(accommodationCoeff_) < small
|| mag(accommodationCoeff_) > 2.0
)
{ {
FatalIOErrorInFunction FatalIOErrorInFunction(dict)
( << "unphysical accommodationCoeff_ specified"
dict << "(0 < accommodationCoeff_ <= 2)" << endl
) << "unphysical accommodationCoeff_ specified"
<< "(0 < accommodationCoeff_ <= 1)" << endl
<< exit(FatalIOError); << exit(FatalIOError);
} }
@ -67,14 +61,15 @@ Foam::maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField
{ {
fvPatchField<vector>::operator= fvPatchField<vector>::operator=
( (
vectorField("value", dict, p.size()) vectorField("value", iF.dimensions(), dict, p.size())
); );
if (dict.found("refValue") && dict.found("valueFraction")) if (dict.found("refValue") && dict.found("valueFraction"))
{ {
this->refValue() = vectorField("refValue", dict, p.size()); this->refValue() =
vectorField("refValue", iF.dimensions(), dict, p.size());
this->valueFraction() = this->valueFraction() =
scalarField("valueFraction", dict, p.size()); scalarField("valueFraction", unitFraction, dict, p.size());
} }
else else
{ {

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -50,8 +50,8 @@ Foam::mixedFixedValueSlipFvPatchField<Type>::mixedFixedValueSlipFvPatchField
) )
: :
transformFvPatchField<Type>(p, iF), transformFvPatchField<Type>(p, iF),
refValue_("refValue", dict, p.size()), refValue_("refValue", iF.dimensions(), dict, p.size()),
valueFraction_("valueFraction", dict, p.size()) valueFraction_("valueFraction", unitFraction, dict, p.size())
{} {}

View File

@ -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) 2022-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2022-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -91,10 +91,7 @@ bool Foam::solvers::solid::read()
maxDeltaT_ = maxDeltaT_ =
runTime.controlDict().found("maxDeltaT") runTime.controlDict().found("maxDeltaT")
? runTime.userTimeToTime ? runTime.controlDict().lookup<scalar>("maxDeltaT", runTime.userUnits())
(
runTime.controlDict().lookup<scalar>("maxDeltaT")
)
: vGreat; : vGreat;
return true; return true;

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2018-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -38,9 +38,12 @@ hydrostaticDisplacementFvPatchVectorField
) )
: :
tractionDisplacementFvPatchVectorField(p, iF), tractionDisplacementFvPatchVectorField(p, iF),
rhoLiquid_(dict.lookup<scalar>("rhoLiquid")), rhoLiquid_(dict.lookup<scalar>("rhoLiquid", dimDensity)),
liquidSurfacePressure_(dict.lookup<scalar>("liquidSurfacePressure")), liquidSurfacePressure_
liquidSurfacePoint_(dict.lookup("liquidSurfacePoint")) (
dict.lookup<scalar>("liquidSurfacePressure", dimPressure)
),
liquidSurfacePoint_(dict.lookup<vector>("liquidSurfacePoint", dimLength))
{} {}

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -53,8 +53,17 @@ tractionDisplacementFvPatchVectorField
) )
: :
fixedGradientFvPatchVectorField(p, iF), fixedGradientFvPatchVectorField(p, iF),
traction_("traction", dict, p.size()), traction_("traction", dimPressure, dict, p.size()),
pressure_(Function1<scalar>::New("pressure", dict)) pressure_
(
Function1<scalar>::New
(
"pressure",
db().time().userUnits(),
dimPressure,
dict
)
)
{ {
fvPatchVectorField::operator=(patchInternalField()); fvPatchVectorField::operator=(patchInternalField());
gradient() = Zero; gradient() = Zero;
@ -127,7 +136,7 @@ void Foam::tractionDisplacementFvPatchVectorField::updateCoeffs()
return; return;
} }
this->updateCoeffs(pressure_->value(this->db().time().userTimeValue())); this->updateCoeffs(pressure_->value(db().time().value()));
} }
@ -135,7 +144,7 @@ void Foam::tractionDisplacementFvPatchVectorField::write(Ostream& os) const
{ {
fvPatchVectorField::write(os); fvPatchVectorField::write(os);
writeEntry(os, "traction", traction_); writeEntry(os, "traction", traction_);
writeEntry(os, pressure_()); writeEntry(os, db().time().userUnits(), dimPressure, pressure_());
writeEntry(os, "value", *this); writeEntry(os, "value", *this);
} }

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -55,8 +55,10 @@ class tractionDisplacementFvPatchVectorField
// Private Data // Private Data
vectorField traction_; vectorField traction_;
autoPtr<Function1<scalar>> pressure_; autoPtr<Function1<scalar>> pressure_;
protected: protected:
//- Update the coefficients associated with the patch field //- Update the coefficients associated with the patch field

View File

@ -53,7 +53,6 @@ Description
#include "removePoints.H" #include "removePoints.H"
#include "meshCheck.H" #include "meshCheck.H"
#include "polyTopoChangeMap.H" #include "polyTopoChangeMap.H"
#include "unitConversion.H"
using namespace Foam; using namespace Foam;
@ -305,24 +304,25 @@ int main(int argc, char *argv[])
#include "createPolyMesh.H" #include "createPolyMesh.H"
const word oldInstance = mesh.pointsInstance(); const word oldInstance = mesh.pointsInstance();
const scalar featureAngle = args.argRead<scalar>(1); const scalar featureAngle = degToRad(args.argRead<scalar>(1));
const scalar minCos = Foam::cos(degToRad(featureAngle)); const scalar minCos = Foam::cos(featureAngle);
// Sin of angle between two consecutive edges on a face. // Sin of angle between two consecutive edges on a face.
// If sin(angle) larger than this the face will be considered concave. // If sin(angle) larger than this the face will be considered concave.
scalar concaveAngle = args.optionLookupOrDefault("concaveAngle", 30.0); const scalar concaveAngle =
scalar concaveSin = Foam::sin(degToRad(concaveAngle)); degToRad(args.optionLookupOrDefault("concaveAngle", 30.0));
const scalar concaveSin = Foam::sin(concaveAngle);
const bool overwrite = args.optionFound("overwrite"); const bool overwrite = args.optionFound("overwrite");
const bool meshQuality = args.optionFound("meshQuality"); const bool meshQuality = args.optionFound("meshQuality");
Info<< "Merging all faces of a cell" << nl Info<< "Merging all faces of a cell" << nl
<< " - which are on the same patch" << nl << " - which are on the same patch" << nl
<< " - which make an angle < " << featureAngle << " degrees" << " - which make an angle < " << radToDeg(featureAngle)
<< nl << " degrees" << nl
<< " (cos:" << minCos << ')' << nl << " (cos:" << minCos << ')' << nl
<< " - even when resulting face becomes concave by more than " << " - even when resulting face becomes concave by more than "
<< concaveAngle << " degrees" << nl << radToDeg(concaveAngle) << " degrees" << nl
<< " (sin:" << concaveSin << ')' << nl << " (sin:" << concaveSin << ')' << nl
<< endl; << endl;

View File

@ -50,7 +50,6 @@ Description
#include "cellSet.H" #include "cellSet.H"
#include "cellModeller.H" #include "cellModeller.H"
#include "meshCutter.H" #include "meshCutter.H"
#include "unitConversion.H"
#include "geomCellLooper.H" #include "geomCellLooper.H"
#include "plane.H" #include "plane.H"
#include "edgeVertex.H" #include "edgeVertex.H"
@ -548,9 +547,9 @@ int main(int argc, char *argv[])
#include "createPolyMesh.H" #include "createPolyMesh.H"
const word oldInstance = mesh.pointsInstance(); const word oldInstance = mesh.pointsInstance();
const scalar featureAngle = args.argRead<scalar>(1); const scalar featureAngle = degToRad(args.argRead<scalar>(1));
const scalar minCos = Foam::cos(degToRad(featureAngle)); const scalar minCos = Foam::cos(featureAngle);
const scalar minSin = Foam::sin(degToRad(featureAngle)); const scalar minSin = Foam::sin(featureAngle);
const bool readSet = args.optionFound("set"); const bool readSet = args.optionFound("set");
const bool geometry = args.optionFound("geometry"); const bool geometry = args.optionFound("geometry");
@ -559,7 +558,7 @@ int main(int argc, char *argv[])
const scalar edgeTol = args.optionLookupOrDefault("tol", 0.2); const scalar edgeTol = args.optionLookupOrDefault("tol", 0.2);
Info<< "Trying to split cells with internal angles > feature angle\n" << nl Info<< "Trying to split cells with internal angles > feature angle\n" << nl
<< "featureAngle : " << featureAngle << nl << "featureAngle : " << radToDeg(featureAngle) << nl
<< "edge snapping tol : " << edgeTol << nl; << "edge snapping tol : " << edgeTol << nl;
if (readSet) if (readSet)
{ {

View File

@ -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-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -35,7 +35,6 @@ Description
#include "IFstream.H" #include "IFstream.H"
#include "OFstream.H" #include "OFstream.H"
#include "pointField.H" #include "pointField.H"
#include "unitConversion.H"
using namespace Foam; using namespace Foam;

View File

@ -1429,7 +1429,11 @@ int main(int argc, char *argv[])
// Un-merge any merged cyclics // Un-merge any merged cyclics
if (args.optionFound("includedAngle")) if (args.optionFound("includedAngle"))
{ {
polyMeshUnMergeCyclics(mesh, args.optionRead<scalar>("includedAngle")); polyMeshUnMergeCyclics
(
mesh,
degToRad(args.optionRead<scalar>("includedAngle"))
);
} }
else else
{ {

View File

@ -43,7 +43,6 @@ Description
#include "wedgePolyPatch.H" #include "wedgePolyPatch.H"
#include "mergedCyclicPolyPatch.H" #include "mergedCyclicPolyPatch.H"
#include "polyMeshUnMergeCyclics.H" #include "polyMeshUnMergeCyclics.H"
#include "unitConversion.H"
using namespace Foam; using namespace Foam;

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -35,7 +35,6 @@ Description
#include "Time.H" #include "Time.H"
#include "repatchMesh.H" #include "repatchMesh.H"
#include "repatcher.H" #include "repatcher.H"
#include "unitConversion.H"
#include "OFstream.H" #include "OFstream.H"
#include "ListOps.H" #include "ListOps.H"
@ -84,12 +83,12 @@ int main(int argc, char *argv[])
<< " s\n" << endl << endl; << " s\n" << endl << endl;
const scalar featureAngle = args.argRead<scalar>(1); const scalar featureAngle = degToRad(args.argRead<scalar>(1));
const bool overwrite = args.optionFound("overwrite"); const bool overwrite = args.optionFound("overwrite");
const scalar minCos = Foam::cos(degToRad(featureAngle)); const scalar minCos = Foam::cos(featureAngle);
Info<< "Feature:" << featureAngle << endl Info<< "Feature:" << radToDeg(featureAngle) << endl
<< "minCos :" << minCos << endl << "minCos :" << minCos << endl
<< endl; << endl;

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -168,6 +168,7 @@ int main(int argc, char *argv[])
scalar nonOrthThreshold = 70; scalar nonOrthThreshold = 70;
args.optionReadIfPresent("nonOrthThreshold", nonOrthThreshold); args.optionReadIfPresent("nonOrthThreshold", nonOrthThreshold);
nonOrthThreshold = degToRad(nonOrthThreshold);
scalar skewThreshold = 4; scalar skewThreshold = 4;
args.optionReadIfPresent("skewThreshold", skewThreshold); args.optionReadIfPresent("skewThreshold", skewThreshold);

View File

@ -61,7 +61,6 @@ Usage
#include "argList.H" #include "argList.H"
#include "Time.H" #include "Time.H"
#include "fvMesh.H" #include "fvMesh.H"
#include "unitConversion.H"
#include "polyTopoChange.H" #include "polyTopoChange.H"
#include "polyTopoChangeMap.H" #include "polyTopoChangeMap.H"
#include "PackedBoolList.H" #include "PackedBoolList.H"
@ -90,7 +89,7 @@ void simpleMarkFeatures
labelList& multiCellFeaturePoints labelList& multiCellFeaturePoints
) )
{ {
scalar minCos = Foam::cos(degToRad(featureAngle)); const scalar minCos = Foam::cos(featureAngle);
const polyBoundaryMesh& patches = mesh.boundaryMesh(); const polyBoundaryMesh& patches = mesh.boundaryMesh();
@ -393,10 +392,10 @@ int main(int argc, char *argv[])
} }
} }
const scalar featureAngle = args.argRead<scalar>(1); const scalar featureAngle = degToRad(args.argRead<scalar>(1));
const scalar minCos = Foam::cos(degToRad(featureAngle)); const scalar minCos = Foam::cos(featureAngle);
Info<< "Feature:" << featureAngle << endl Info<< "Feature:" << radToDeg(featureAngle) << endl
<< "minCos :" << minCos << endl << "minCos :" << minCos << endl
<< endl; << endl;

View File

@ -75,7 +75,6 @@ See also
#include "pointSet.H" #include "pointSet.H"
#include "transformField.H" #include "transformField.H"
#include "transformGeometricField.H" #include "transformGeometricField.H"
#include "unitConversion.H"
using namespace Foam; using namespace Foam;

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -120,13 +120,10 @@ int main(int argc, char *argv[])
// Read field // Read field
volScalarField field(*iter(), mesh); volScalarField field(*iter(), mesh);
// lookup field from dictionary and convert field // Lookup field from dictionary and convert field
label unitNumber; const label unitNumber =
if foamDataToFluentDict.lookupOrDefault<label>(field.name(), 0);
( if (unitNumber > 0)
foamDataToFluentDict.readIfPresent(field.name(), unitNumber)
&& unitNumber > 0
)
{ {
Info<< " Converting field " << field.name() << endl; Info<< " Converting field " << field.name() << endl;
writeFluentField(field, unitNumber, fluentDataFile); writeFluentField(field, unitNumber, fluentDataFile);
@ -145,13 +142,10 @@ int main(int argc, char *argv[])
// Read field // Read field
volVectorField field(*iter(), mesh); volVectorField field(*iter(), mesh);
// lookup field from dictionary and convert field // Lookup field from dictionary and convert field
label unitNumber; const label unitNumber =
if foamDataToFluentDict.lookupOrDefault<label>(field.name(), 0);
( if (unitNumber > 0)
foamDataToFluentDict.readIfPresent(field.name(), unitNumber)
&& unitNumber > 0
)
{ {
Info<< " Converting field " << field.name() << endl; Info<< " Converting field " << field.name() << endl;
writeFluentField(field, unitNumber, fluentDataFile); writeFluentField(field, unitNumber, fluentDataFile);

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -45,8 +45,7 @@ Usage
{ {
file "pressureData"; file "pressureData";
nHeaderLine 1; // number of header lines nHeaderLine 1; // number of header lines
refColumn 0; // reference column index columns (0 1); // column indices
componentColumns (1); // component column indices
separator " "; // optional (defaults to ",") separator " "; // optional (defaults to ",")
mergeSeparators no; // merge multiple separators mergeSeparators no; // merge multiple separators
outOfBounds clamp; // optional out-of-bounds handling outOfBounds clamp; // optional out-of-bounds handling
@ -162,6 +161,7 @@ int main(int argc, char *argv[])
Function1s::Table<scalar> pData Function1s::Table<scalar> pData
( (
"pressure", "pressure",
{dimTime, dimPressure},
dict.subDict("pressureData") dict.subDict("pressureData")
); );

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -46,8 +46,6 @@ void processField
return; return;
} }
const word timeName(mesh.time().name());
IOobjectList fieldObjbjects(objects.lookupClass(VolField<Type>::typeName)); IOobjectList fieldObjbjects(objects.lookupClass(VolField<Type>::typeName));
if (fieldObjbjects.lookup(fieldName) != nullptr) if (fieldObjbjects.lookup(fieldName) != nullptr)

View File

@ -36,7 +36,6 @@ Description
#include "Time.H" #include "Time.H"
#include "volFields.H" #include "volFields.H"
#include "CompactListList.H" #include "CompactListList.H"
#include "unitConversion.H"
#include "pairPatchAgglomeration.H" #include "pairPatchAgglomeration.H"
#include "labelListIOList.H" #include "labelListIOList.H"
#include "syncTools.H" #include "syncTools.H"

View File

@ -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) 2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2023-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -27,7 +27,6 @@ License
#include "dictionary.H" #include "dictionary.H"
#include "polyPatch.H" #include "polyPatch.H"
#include "wallPolyPatch.H" #include "wallPolyPatch.H"
#include "unitConversion.H"
#include "blockMeshFunctions.H" #include "blockMeshFunctions.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

View File

@ -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-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2018-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -197,7 +197,8 @@ namespace Foam
// Either construct features from surface & featureAngle or read set. // Either construct features from surface & featureAngle or read set.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const scalar includedAngle = dict.lookup<scalar>("includedAngle"); const scalar includedAngle =
dict.lookup<scalar>("includedAngle", unitDegrees);
autoPtr<surfaceFeatures> set autoPtr<surfaceFeatures> set
( (
@ -451,7 +452,9 @@ namespace Foam
( (
closenessDict.lookupOrDefault<scalar> closenessDict.lookupOrDefault<scalar>
( (
"internalAngleTolerance", 80 "internalAngleTolerance",
unitDegrees,
80
) )
); );
@ -459,7 +462,9 @@ namespace Foam
( (
closenessDict.lookupOrDefault<scalar> closenessDict.lookupOrDefault<scalar>
( (
"externalAngleTolerance", 80 "externalAngleTolerance",
unitDegrees,
80
) )
); );

View File

@ -39,7 +39,6 @@ Usage
#include "indexedOctree.H" #include "indexedOctree.H"
#include "treeBoundBox.H" #include "treeBoundBox.H"
#include "PackedBoolList.H" #include "PackedBoolList.H"
#include "unitConversion.H"
#include "searchableSurfaces.H" #include "searchableSurfaces.H"
#include "systemDict.H" #include "systemDict.H"
@ -114,41 +113,6 @@ void greenRefine
} }
//scalar checkEdgeAngle
//(
// const triSurface& surf,
// const label edgeIndex,
// const label pointIndex,
// const scalar& angle
//)
//{
// const edge& e = surf.edges()[edgeIndex];
// vector eVec = e.vec(surf.localPoints());
// eVec /= mag(eVec) + small;
// const labelList& pEdges = surf.pointEdges()[pointIndex];
//
// forAll(pEdges, eI)
// {
// const edge& nearE = surf.edges()[pEdges[eI]];
// vector nearEVec = nearE.vec(surf.localPoints());
// nearEVec /= mag(nearEVec) + small;
// const scalar dot = eVec & nearEVec;
// const scalar minCos = degToRad(angle);
// if (mag(dot) > minCos)
// {
// return false;
// }
// }
// return true;
//}
void createBoundaryEdgeTrees void createBoundaryEdgeTrees
( (
const PtrList<triSurfaceMesh>& surfs, const PtrList<triSurfaceMesh>& surfs,
@ -429,15 +393,6 @@ int main(int argc, char *argv[])
if (nearestHit.hit()) if (nearestHit.hit())
{ {
// bool rejectEdge =
// checkEdgeAngle
// (
// surf,
// nearestHit.index(),
// pointi,
// 30
// );
if (dist2 > Foam::sqr(dist)) if (dist2 > Foam::sqr(dist))
{ {
nearestHit.setMiss(); nearestHit.setMiss();

View File

@ -60,7 +60,6 @@ See also
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "argList.H" #include "argList.H"
#include "unitConversion.H"
#include "MeshedSurfaces.H" #include "MeshedSurfaces.H"
using namespace Foam; using namespace Foam;

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -724,7 +724,6 @@ void Foam::chemkinReader::addReaction
( (
Afactor*ArrheniusCoeffs[0], Afactor*ArrheniusCoeffs[0],
ArrheniusCoeffs[1], ArrheniusCoeffs[1],
ArrheniusCoeffs[2]/RR,
FixedList<scalar, 4>(powerSeriesCoeffs) FixedList<scalar, 4>(powerSeriesCoeffs)
) )
); );

View File

@ -59,6 +59,7 @@ codeRead
const Function1s::Table<scalar> initialDistribution const Function1s::Table<scalar> initialDistribution
( (
"initialDistribution", "initialDistribution",
{dimLength, dimless},
dictionary dictionary
( (
"format", "foam", "format", "foam",

View File

@ -29,15 +29,6 @@ License
#include "volFields.H" #include "volFields.H"
#include "surfaceFields.H" #include "surfaceFields.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
Foam::scalar Foam::CLASS::t() const
{
return this->db().time().userTimeValue();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type> template<class Type>
@ -50,10 +41,19 @@ CONSTRUCT
) )
: :
PARENT(p, iF), PARENT(p, iF),
scalarData_(dict.lookup<scalar>("scalarData")), scalarData_(dict.lookup<scalar>("scalarData", unitAny)),
data_(dict.lookup<TYPE>("data")), data_(dict.lookup<TYPE>("data")),
fieldData_("fieldData", dict, p.size()), fieldData_("fieldData", iF.dimensions(), dict, p.size()),
timeVsData_(Function1<TYPE>::New("timeVsData", dict)), timeVsData_
(
Function1<TYPE>::New
(
"timeVsData",
this->db().time().userUnits(),
unitAny,
dict
)
),
wordData_(dict.lookupOrDefault<word>("wordName", "wordDefault")), wordData_(dict.lookupOrDefault<word>("wordName", "wordDefault")),
labelData_(-1), labelData_(-1),
boolData_(false) boolData_(false)
@ -61,7 +61,7 @@ CONSTRUCT
this->refGrad() = Zero; this->refGrad() = Zero;
this->valueFraction() = 0.0; this->valueFraction() = 0.0;
this->refValue() = FIELD("fieldData", dict, p.size()); this->refValue() = FIELD("fieldData", iF.dimensions(), dict, p.size());
FVPATCHF::operator=(this->refValue()); FVPATCHF::operator=(this->refValue());
PARENT::evaluate(); PARENT::evaluate();
@ -70,7 +70,7 @@ CONSTRUCT
// Initialise with the value entry if evaluation is not possible // Initialise with the value entry if evaluation is not possible
FVPATCHF::operator= FVPATCHF::operator=
( (
FIELD("value", dict, p.size()) FIELD("value", iF.dimensions(), dict, p.size())
); );
this->refValue() = *this; this->refValue() = *this;
*/ */
@ -162,7 +162,7 @@ void Foam::CLASS::updateCoeffs()
( (
data_ data_
+ fieldData_ + fieldData_
+ scalarData_*timeVsData_->value(t()) + scalarData_*timeVsData_->value(this->db().time().value())
); );
const scalarField& phip = const scalarField& phip =
@ -186,7 +186,7 @@ void Foam::CLASS::write
writeEntry(os, "scalarData", scalarData_); writeEntry(os, "scalarData", scalarData_);
writeEntry(os, "data", data_); writeEntry(os, "data", data_);
writeEntry(os, "fieldData", fieldData_); writeEntry(os, "fieldData", fieldData_);
writeEntry(os, timeVsData_()); writeEntry(os, this->db().time().userUnits(), unitAny, timeVsData_());
writeEntry(os, "wordData", wordData_); writeEntry(os, "wordData", wordData_);
writeEntry(os, "value", *this); writeEntry(os, "value", *this);
} }

View File

@ -118,12 +118,6 @@ class CONSTRUCT
bool boolData_; bool boolData_;
// Private Member Functions
//- Return current time
scalar t() const;
public: public:
//- Runtime type information //- Runtime type information

View File

@ -29,7 +29,6 @@ License
#include "volFields.H" #include "volFields.H"
#include "surfaceFields.H" #include "surfaceFields.H"
#include "read.H" #include "read.H"
#include "unitConversion.H"
//{{{ begin codeInclude //{{{ begin codeInclude
${codeInclude} ${codeInclude}

View File

@ -28,7 +28,6 @@ License
#include "fieldMapper.H" #include "fieldMapper.H"
#include "pointFields.H" #include "pointFields.H"
#include "read.H" #include "read.H"
#include "unitConversion.H"
//{{{ begin codeInclude //{{{ begin codeInclude
${codeInclude} ${codeInclude}

View File

@ -69,6 +69,7 @@ Foam::Function1s::${typeName}Function1${TemplateType}::
${typeName}Function1${TemplateType} ${typeName}Function1${TemplateType}
( (
const word& entryName, const word& entryName,
const unitConversions& units,
const dictionary& dict const dictionary& dict
) )
: :
@ -130,7 +131,8 @@ Foam::Function1s::${typeName}Function1${TemplateType}::integral
void Foam::Function1s::${typeName}Function1${TemplateType}::write void Foam::Function1s::${typeName}Function1${TemplateType}::write
( (
Ostream& os Ostream& os,
const unitConversions&
) const ) const
{ {
NotImplemented; NotImplemented;

View File

@ -69,6 +69,7 @@ public:
${typeName}Function1${TemplateType} ${typeName}Function1${TemplateType}
( (
const word& entryName, const word& entryName,
const unitConversions& units,
const dictionary& dict const dictionary& dict
); );
@ -110,7 +111,7 @@ public:
) const; ) const;
//- Write data to dictionary stream //- Write data to dictionary stream
virtual void write(Ostream& os) const; virtual void write(Ostream& os, const unitConversions&) const;
// Member Operators // Member Operators

View File

@ -69,6 +69,7 @@ Foam::Function2s::${typeName}Function2${TemplateType}::
${typeName}Function2${TemplateType} ${typeName}Function2${TemplateType}
( (
const word& entryName, const word& entryName,
const unitConversions& units,
const dictionary& dict const dictionary& dict
) )
: :
@ -118,7 +119,8 @@ Foam::Function2s::${typeName}Function2${TemplateType}::
void Foam::Function2s::${typeName}Function2${TemplateType}::write void Foam::Function2s::${typeName}Function2${TemplateType}::write
( (
Ostream& os Ostream& os,
const unitConversions&
) const ) const
{ {
NotImplemented; NotImplemented;

View File

@ -69,6 +69,7 @@ public:
${typeName}Function2${TemplateType} ${typeName}Function2${TemplateType}
( (
const word& entryName, const word& entryName,
const unitConversions& units,
const dictionary& dict const dictionary& dict
); );
@ -107,7 +108,7 @@ public:
} }
//- Write data to dictionary stream //- Write data to dictionary stream
virtual void write(Ostream& os) const; virtual void write(Ostream& os, const unitConversions&) const;
// Member Operators // Member Operators

View File

@ -26,7 +26,6 @@ License
#include "codedFunctionObjectTemplate.H" #include "codedFunctionObjectTemplate.H"
#include "volFields.H" #include "volFields.H"
#include "read.H" #include "read.H"
#include "unitConversion.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -28,7 +28,6 @@ License
#include "volFields.H" #include "volFields.H"
#include "surfaceFields.H" #include "surfaceFields.H"
#include "read.H" #include "read.H"
#include "unitConversion.H"
#include "fvMatrix.H" #include "fvMatrix.H"
//{{{ begin codeInclude //{{{ begin codeInclude

View File

@ -29,7 +29,6 @@ License
#include "volFields.H" #include "volFields.H"
#include "surfaceFields.H" #include "surfaceFields.H"
#include "read.H" #include "read.H"
#include "unitConversion.H"
//{{{ begin codeInclude //{{{ begin codeInclude
${codeInclude} ${codeInclude}

View File

@ -173,7 +173,7 @@ DimensionedConstants
} }
DimensionSets UnitConversions
{ {
unitSet SI; // USCS unitSet SI; // USCS
@ -195,16 +195,7 @@ DimensionSets
J [N m] 1; J [N m] 1;
W [J s^-1] 1; W [J s^-1] 1;
// Some non-symbolic units // Scaled units
area [m^2] 1;
volume [m^3] 1;
density [kg m^-3] 1;
acceleration [m s^-2] 1;
kinematicPressure [Pa density^-1] 1;
// Scaled units. Supported in dimensionedType and
// UniformDimensionedField. Not supported in DimensionedField or
// GeometricField.
g [kg] 1e-3; g [kg] 1e-3;
um [m] 1e-6; um [m] 1e-6;
mm [m] 1e-3; mm [m] 1e-3;
@ -212,7 +203,22 @@ DimensionSets
km [m] 1e3; km [m] 1e3;
us [s] 1e-6; us [s] 1e-6;
ms [s] 1e-3; ms [s] 1e-3;
min [s] 60;
hr [s] 3600;
mol [kmol] 1e-3; mol [kmol] 1e-3;
// Derived scaled units
l [m^3] 1e-3;
ml [m^3] 1e-6;
rpm [rot/min] 1;
bar [Pa] 1e5;
atm [Pa] 101325;
kPa [Pa] 1e3;
MPa [Pa] 1e6;
cal [J] 4.184;
kcal [J] 4184;
cSt [m^2/s] 1e-6;
cP [kg/m/s] 1e-3;
} }
USCSCoeffs USCSCoeffs

View File

@ -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-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -92,7 +92,7 @@ protected:
// - 0: no filtering // - 0: no filtering
// - 1: (1 - F1) // - 1: (1 - F1)
// - 2: (1 - F2) // - 2: (1 - F2)
direction FSST_; label FSST_;
// Protected Member Functions // Protected Member Functions

View File

@ -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) 2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2023-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -39,7 +39,7 @@ turbulentMixingLengthDissipationRateFvScalarFieldSource
) )
: :
fvScalarFieldSource(iF, dict), fvScalarFieldSource(iF, dict),
mixingLength_(dict.lookup<scalar>("mixingLength")), mixingLength_(dict.lookup<scalar>("mixingLength", dimLength)),
kName_(dict.lookupOrDefault<word>("k", "k")) kName_(dict.lookupOrDefault<word>("k", "k"))
{} {}

View File

@ -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) 2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2023-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -39,7 +39,7 @@ turbulentMixingLengthFrequencyFvScalarFieldSource
) )
: :
fvScalarFieldSource(iF, dict), fvScalarFieldSource(iF, dict),
mixingLength_(dict.lookup<scalar>("mixingLength")), mixingLength_(dict.lookup<scalar>("mixingLength", dimLength)),
kName_(dict.lookupOrDefault<word>("k", "k")) kName_(dict.lookupOrDefault<word>("k", "k"))
{} {}

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -46,12 +46,15 @@ turbulentMixingLengthDissipationRateInletFvPatchScalarField
) )
: :
inletOutletFvPatchScalarField(p, iF), inletOutletFvPatchScalarField(p, iF),
mixingLength_(dict.lookup<scalar>("mixingLength")), mixingLength_(dict.lookup<scalar>("mixingLength", dimLength)),
kName_(dict.lookupOrDefault<word>("k", "k")) kName_(dict.lookupOrDefault<word>("k", "k"))
{ {
this->phiName_ = dict.lookupOrDefault<word>("phi", "phi"); this->phiName_ = dict.lookupOrDefault<word>("phi", "phi");
fvPatchScalarField::operator=(scalarField("value", dict, p.size())); fvPatchScalarField::operator=
(
scalarField("value", iF.dimensions(), dict, p.size())
);
this->refValue() = 0.0; this->refValue() = 0.0;
this->refGrad() = 0.0; this->refGrad() = 0.0;

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -46,12 +46,15 @@ turbulentMixingLengthFrequencyInletFvPatchScalarField
) )
: :
inletOutletFvPatchScalarField(p, iF), inletOutletFvPatchScalarField(p, iF),
mixingLength_(dict.lookup<scalar>("mixingLength")), mixingLength_(dict.lookup<scalar>("mixingLength", dimLength)),
kName_(dict.lookupOrDefault<word>("k", "k")) kName_(dict.lookupOrDefault<word>("k", "k"))
{ {
this->phiName_ = dict.lookupOrDefault<word>("phi", "phi"); this->phiName_ = dict.lookupOrDefault<word>("phi", "phi");
fvPatchScalarField::operator=(scalarField("value", dict, p.size())); fvPatchScalarField::operator=
(
scalarField("value", iF.dimensions(), dict, p.size())
);
this->refValue() = 0.0; this->refValue() = 0.0;
this->refGrad() = 0.0; this->refGrad() = 0.0;

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -40,7 +40,7 @@ Foam::fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField
) )
: :
fixedValueFvPatchVectorField(p, iF, dict, false), fixedValueFvPatchVectorField(p, iF, dict, false),
tau0_(dict.lookupOrDefault<vector>("tau", Zero)) tau0_(dict.lookupOrDefault<vector>("tau", sqr(dimVelocity), Zero))
{ {
fvPatchField<vector>::operator=(patchInternalField()); fvPatchField<vector>::operator=(patchInternalField());
} }

View File

@ -50,13 +50,28 @@ Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField
? dict.lookupOrDefault<word>("rho", "rho") ? dict.lookupOrDefault<word>("rho", "rho")
: word::null : word::null
), ),
D_(cyclicPatch().owner() ? dict.lookup<scalar>("D") : NaN), D_
I_(cyclicPatch().owner() ? dict.lookup<scalar>("I") : NaN), (
length_(cyclicPatch().owner() ? dict.lookup<scalar>("length") : NaN), cyclicPatch().owner()
? dict.lookup<scalar>("D", dimless/dimArea)
: NaN
),
I_
(
cyclicPatch().owner()
? dict.lookup<scalar>("I", dimless/dimLength)
: NaN
),
length_
(
cyclicPatch().owner()
? dict.lookup<scalar>("length", dimLength)
: NaN
),
relaxation_ relaxation_
( (
cyclicPatch().owner() cyclicPatch().owner()
? dict.lookupOrDefault<scalar>("relaxation", 1) ? dict.lookupOrDefault<scalar>("relaxation", unitFraction, 1)
: NaN : NaN
), ),
jump0_(cyclicPatch().owner() ? jump()() : scalarField(p.size())) jump0_(cyclicPatch().owner() ? jump()() : scalarField(p.size()))

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -43,7 +43,7 @@ kLowReWallFunctionFvPatchScalarField::kLowReWallFunctionFvPatchScalarField
) )
: :
fixedValueFvPatchField<scalar>(p, iF, dict), fixedValueFvPatchField<scalar>(p, iF, dict),
Ceps2_(dict.lookupOrDefault<scalar>("Ceps2", 1.9)) Ceps2_(dict.lookupOrDefault<scalar>("Ceps2", dimless, 1.9))
{} {}

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -217,8 +217,8 @@ nutURoughWallFunctionFvPatchScalarField::nutURoughWallFunctionFvPatchScalarField
) )
: :
nutUWallFunctionFvPatchScalarField(p, iF, dict), nutUWallFunctionFvPatchScalarField(p, iF, dict),
Ks_("Ks", dict, p.size()), Ks_("Ks", dimLength, dict, p.size()),
Cs_("Cs", dict, p.size()) Cs_("Cs", dimless, dict, p.size())
{} {}

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -73,9 +73,9 @@ Foam::nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField
) )
: :
fixedValueFvPatchScalarField(p, iF, dict), fixedValueFvPatchScalarField(p, iF, dict),
Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)), Cmu_(dict.lookupOrDefault<scalar>("Cmu", dimless, 0.09)),
kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)), kappa_(dict.lookupOrDefault<scalar>("kappa", dimless, 0.41)),
E_(dict.lookupOrDefault<scalar>("E", 9.8)), E_(dict.lookupOrDefault<scalar>("E", dimless, 9.8)),
yPlusLam_(yPlusLam(kappa_, E_)) yPlusLam_(yPlusLam(kappa_, E_))
{ {
checkType(); checkType();

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -134,8 +134,8 @@ nutkRoughWallFunctionFvPatchScalarField::nutkRoughWallFunctionFvPatchScalarField
) )
: :
nutkWallFunctionFvPatchScalarField(p, iF, dict), nutkWallFunctionFvPatchScalarField(p, iF, dict),
Ks_("Ks", dict, p.size()), Ks_("Ks", dimLength, dict, p.size()),
Cs_("Cs", dict, p.size()) Cs_("Cs", dimless, dict, p.size())
{} {}

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -136,7 +136,7 @@ Maxwell<BasicMomentumTransportModel>::Maxwell
nModes_(modeCoefficients_.size() ? modeCoefficients_.size() : 1), nModes_(modeCoefficients_.size() ? modeCoefficients_.size() : 1),
nuM_("nuM", dimViscosity, this->coeffDict_.lookup("nuM")), nuM_("nuM", dimKinematicViscosity, this->coeffDict_.lookup("nuM")),
lambdas_(readModeCoefficients("lambda", dimTime)), lambdas_(readModeCoefficients("lambda", dimTime)),

View File

@ -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-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2018-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -57,9 +57,9 @@ BirdCarreau
) )
: :
strainRateViscosityModel(viscosityProperties, viscosity, U), strainRateViscosityModel(viscosityProperties, viscosity, U),
nuInf_("nuInf", dimViscosity, 0), nuInf_("nuInf", dimKinematicViscosity, 0),
k_("k", dimTime, 0), k_("k", dimTime, 0),
tauStar_( "tauStar", dimViscosity/dimTime, 0), tauStar_( "tauStar", dimKinematicViscosity/dimTime, 0),
n_("n", dimless, 0), n_("n", dimless, 0),
a_("a", dimless, 2) a_("a", dimless, 2)
{ {

View File

@ -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-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2018-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -56,10 +56,10 @@ Foam::laminarModels::generalisedNewtonianViscosityModels::Casson::Casson
) )
: :
strainRateViscosityModel(viscosityProperties, viscosity, U), strainRateViscosityModel(viscosityProperties, viscosity, U),
m_("m", dimViscosity, 0), m_("m", dimKinematicViscosity, 0),
tau0_("tau0", dimViscosity/dimTime, 0), tau0_("tau0", dimKinematicViscosity/dimTime, 0),
nuMin_("nuMin", dimViscosity, 0), nuMin_("nuMin", dimKinematicViscosity, 0),
nuMax_("nuMax", dimViscosity, 0) nuMax_("nuMax", dimKinematicViscosity, 0)
{ {
read(viscosityProperties); read(viscosityProperties);
correct(); correct();

View File

@ -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-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2018-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -58,9 +58,9 @@ CrossPowerLaw
) )
: :
strainRateViscosityModel(viscosityProperties, viscosity, U), strainRateViscosityModel(viscosityProperties, viscosity, U),
nuInf_("nuInf", dimViscosity, 0), nuInf_("nuInf", dimKinematicViscosity, 0),
m_("m", dimTime, 0), m_("m", dimTime, 0),
tauStar_( "tauStar", dimViscosity/dimTime, 0), tauStar_( "tauStar", dimKinematicViscosity/dimTime, 0),
n_("n", dimless, 0) n_("n", dimless, 0)
{ {
read(viscosityProperties); read(viscosityProperties);

View File

@ -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-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2018-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -58,9 +58,9 @@ HerschelBulkley
) )
: :
strainRateViscosityModel(viscosityProperties, viscosity, U), strainRateViscosityModel(viscosityProperties, viscosity, U),
k_("k", dimViscosity, 0), k_("k", dimKinematicViscosity, 0),
n_("n", dimless, 0), n_("n", dimless, 0),
tau0_("tau0", dimViscosity/dimTime, 0) tau0_("tau0", dimKinematicViscosity/dimTime, 0)
{ {
read(viscosityProperties); read(viscosityProperties);
correct(); correct();

View File

@ -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-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2018-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -57,10 +57,10 @@ Foam::laminarModels::generalisedNewtonianViscosityModels::powerLaw::powerLaw
) )
: :
strainRateViscosityModel(viscosityProperties, viscosity, U), strainRateViscosityModel(viscosityProperties, viscosity, U),
k_("k", dimViscosity, 0), k_("k", dimKinematicViscosity, 0),
n_("n", dimless, 0), n_("n", dimless, 0),
nuMin_("nuMin", dimViscosity, 0), nuMin_("nuMin", dimKinematicViscosity, 0),
nuMax_("nuMax", dimViscosity, 0) nuMax_("nuMax", dimKinematicViscosity, 0)
{ {
read(viscosityProperties); read(viscosityProperties);
correct(); correct();

View File

@ -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-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2018-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -63,6 +63,8 @@ strainRateFunction
Function1<scalar>::New Function1<scalar>::New
( (
"function", "function",
dimless/dimTime,
dimKinematicViscosity,
viscosityProperties.optionalSubDict(typeName + "Coeffs") viscosityProperties.optionalSubDict(typeName + "Coeffs")
) )
) )
@ -85,6 +87,8 @@ strainRateFunction::read
strainRateFunction_ = Function1<scalar>::New strainRateFunction_ = Function1<scalar>::New
( (
"function", "function",
dimless/dimTime,
dimKinematicViscosity,
viscosityProperties.optionalSubDict viscosityProperties.optionalSubDict
( (
typeName + "Coeffs" typeName + "Coeffs"
@ -109,7 +113,7 @@ nu
( (
IOobject::groupName(typedName("nu"), nu0.group()), IOobject::groupName(typedName("nu"), nu0.group()),
nu0.mesh(), nu0.mesh(),
dimensionedScalar(dimViscosity, 0) dimensionedScalar(dimKinematicViscosity, 0)
) )
); );

View File

@ -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-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2018-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -76,7 +76,7 @@ strainRateViscosityModel::strainRateViscosityModel
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
), ),
U.mesh(), U.mesh(),
dimensionedScalar(dimViscosity, 0) dimensionedScalar(dimKinematicViscosity, 0)
) )
{} {}

View File

@ -65,8 +65,8 @@ lambdaThixotropic<BasicMomentumTransportModel>::lambdaThixotropic
b_("b", dimless, this->coeffDict_), b_("b", dimless, this->coeffDict_),
d_("d", dimless, this->coeffDict_), d_("d", dimless, this->coeffDict_),
c_("c", pow(dimTime, d_.value() - scalar(1)), this->coeffDict_), c_("c", pow(dimTime, d_.value() - scalar(1)), this->coeffDict_),
nu0_("nu0", dimViscosity, this->coeffDict_), nu0_("nu0", dimKinematicViscosity, this->coeffDict_),
nuInf_("nuInf", dimViscosity, this->coeffDict_), nuInf_("nuInf", dimKinematicViscosity, this->coeffDict_),
K_(1 - sqrt(nuInf_/nu0_)), K_(1 - sqrt(nuInf_/nu0_)),
BinghamPlastic_(this->coeffDict_.found("sigmay")), BinghamPlastic_(this->coeffDict_.found("sigmay")),
sigmay_ sigmay_

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -185,7 +185,7 @@ Foam::laminarModel<BasicMomentumTransportModel>::nut() const
( (
this->groupName("nut"), this->groupName("nut"),
this->mesh_, this->mesh_,
dimensionedScalar(dimViscosity, 0) dimensionedScalar(dimKinematicViscosity, 0)
); );
} }

View File

@ -92,6 +92,7 @@ primitives/triad/triad.C
primitives/omega/omega.C primitives/omega/omega.C
# Run-time selectable functions # Run-time selectable functions
primitives/functions/Function1/Function1/Function1UnitConversions.C
primitives/functions/Function1/makeFunction1s.C primitives/functions/Function1/makeFunction1s.C
primitives/functions/Function1/reverseRamp/reverseRamp.C primitives/functions/Function1/reverseRamp/reverseRamp.C
primitives/functions/Function1/linearRamp/linearRamp.C primitives/functions/Function1/linearRamp/linearRamp.C
@ -106,6 +107,7 @@ primitives/functions/Function1/Table/TableReader/makeTableReaders.C
primitives/functions/Function1/unknownTypeFunction1/unknownTypeFunction1.C primitives/functions/Function1/unknownTypeFunction1/unknownTypeFunction1.C
primitives/functions/Function1/omega1/omega1.C primitives/functions/Function1/omega1/omega1.C
primitives/functions/Function2/Function2/Function2UnitConversions.C
primitives/functions/Function2/makeFunction2s.C primitives/functions/Function2/makeFunction2s.C
primitives/subModelBase/subModelBase.C primitives/subModelBase/subModelBase.C
@ -303,9 +305,15 @@ $(userTime)/userTime/userTimeNew.C
$(userTime)/realTime/realTime.C $(userTime)/realTime/realTime.C
$(userTime)/engineTime/engineTime.C $(userTime)/engineTime/engineTime.C
symbols/symbols.C
dimensionSet/dimensionSet.C dimensionSet/dimensionSet.C
dimensionSet/dimensionSetIO.C dimensionSet/dimensionSetIO.C
dimensionSet/dimensionSets.C dimensionSet/dimensionSets.C
unitConversion/unitConversion.C
unitConversion/unitConversionIO.C
unitConversion/unitConversions.C
unitConversion/namedUnitConversion.C
unitConversion/namedUnitConversionIO.C
dimensionedTypes/dimensionedScalar/dimensionedScalar.C dimensionedTypes/dimensionedScalar/dimensionedScalar.C
dimensionedTypes/dimensionedSphericalTensor/dimensionedSphericalTensor.C dimensionedTypes/dimensionedSphericalTensor/dimensionedSphericalTensor.C
dimensionedTypes/dimensionedSymmTensor/dimensionedSymmTensor.C dimensionedTypes/dimensionedSymmTensor/dimensionedSymmTensor.C

View File

@ -118,8 +118,7 @@ void Foam::Time::setControls()
if (startFrom == "startTime") if (startFrom == "startTime")
{ {
controlDict_.lookup("startTime") >> startTime_; startTime_ = controlDict_.lookup<scalar>("startTime", userUnits());
startTime_ = userTimeToTime(startTime_);
} }
else else
{ {
@ -242,11 +241,11 @@ void Foam::Time::setControls()
if (controlDict_.found("beginTime")) if (controlDict_.found("beginTime"))
{ {
beginTime_ = userTimeToTime(controlDict_.lookup<scalar>("beginTime")); beginTime_ = controlDict_.lookup<scalar>("beginTime", userUnits());
} }
else if (timeDict.found("beginTime")) else if (timeDict.found("beginTime"))
{ {
beginTime_ = userTimeToTime(timeDict.lookup<scalar>("beginTime")); beginTime_ = timeDict.lookup<scalar>("beginTime", userUnits());
} }
else else
{ {
@ -259,7 +258,7 @@ void Foam::Time::setControls()
{ {
if (timeDict.found("deltaT")) if (timeDict.found("deltaT"))
{ {
deltaT_ = userTimeToTime(timeDict.lookup<scalar>("deltaT")); deltaT_ = timeDict.lookup<scalar>("deltaT", userUnits());
deltaTSave_ = deltaT_; deltaTSave_ = deltaT_;
deltaT0_ = deltaT_; deltaT0_ = deltaT_;
} }
@ -267,7 +266,7 @@ void Foam::Time::setControls()
if (timeDict.found("deltaT0")) if (timeDict.found("deltaT0"))
{ {
deltaT0_ = userTimeToTime(timeDict.lookup<scalar>("deltaT0")); deltaT0_ = timeDict.lookup<scalar>("deltaT0", userUnits());
} }
if (timeDict.readIfPresent("index", startTimeIndex_)) if (timeDict.readIfPresent("index", startTimeIndex_))
@ -414,7 +413,8 @@ Foam::Time::Time
"OptimisationSwitches", "OptimisationSwitches",
"DebugSwitches", "DebugSwitches",
"DimensionedConstants", "DimensionedConstants",
"DimensionSets" "DimensionSets",
"UnitConversions"
} }
); );
@ -680,6 +680,7 @@ Foam::word Foam::Time::findInstance
stopInstance stopInstance
) )
); );
return io.instance(); return io.instance();
} }
@ -860,11 +861,37 @@ Foam::word Foam::Time::userTimeName() const
} }
else else
{ {
return timeName(userTimeValue()) + userTime_->unit(); return timeName(userTimeValue()) + userTime_->unitName();
} }
} }
const Foam::unitConversion& Foam::Time::userUnits() const
{
return userTime_->units();
}
const Foam::unitConversion& Foam::Time::writeIntervalUnits() const
{
static const unitConversion unitSeconds(dimTime);
switch (writeControl_)
{
case writeControl::timeStep:
return unitless;
case writeControl::runTime:
case writeControl::adjustableRunTime:
return userUnits();
case writeControl::cpuTime:
case writeControl::clockTime:
return unitSeconds;
}
return unitNone;
}
bool Foam::Time::running() const bool Foam::Time::running() const
{ {
return value() < (endTime_ - 0.5*deltaT_); return value() < (endTime_ - 0.5*deltaT_);
@ -986,12 +1013,12 @@ void Foam::Time::setTime(const instant& inst, const label newIndex)
if (timeDict.found("deltaT")) if (timeDict.found("deltaT"))
{ {
deltaT_ = userTimeToTime(timeDict.lookup<scalar>("deltaT")); deltaT_ = timeDict.lookup<scalar>("deltaT", userUnits());
} }
if (timeDict.found("deltaT0")) if (timeDict.found("deltaT0"))
{ {
deltaT0_ = userTimeToTime(timeDict.lookup<scalar>("deltaT0")); deltaT0_ = timeDict.lookup<scalar>("deltaT0", userUnits());
} }
timeDict.readIfPresent("index", timeIndex_); timeDict.readIfPresent("index", timeIndex_);

View File

@ -423,6 +423,12 @@ public:
//- Return current user time name with units //- Return current user time name with units
word userTimeName() const; word userTimeName() const;
//- Return the user-time unit conversion
const unitConversion& userUnits() const;
//- Return the write interval units
const unitConversion& writeIntervalUnits() const;
//- Return the list of function objects //- Return the list of function objects
const functionObjectList& functionObjects() const const functionObjectList& functionObjects() const
{ {

View File

@ -40,7 +40,7 @@ void Foam::Time::readDict()
if (!deltaTchanged_) if (!deltaTchanged_)
{ {
deltaT_ = userTimeToTime(controlDict_.lookup<scalar>("deltaT")); deltaT_ = controlDict_.lookup<scalar>("deltaT", userUnits());
} }
if (controlDict_.found("writeControl")) if (controlDict_.found("writeControl"))
@ -51,18 +51,12 @@ void Foam::Time::readDict()
); );
} }
scalar newWriteInterval = writeInterval_; const scalar newWriteInterval =
controlDict_.lookupBackwardsCompatible<scalar>
if (controlDict_.readIfPresent("writeInterval", newWriteInterval))
{
if
( (
writeControl_ == writeControl::runTime {"writeInterval", "writeFrequency"},
|| writeControl_ == writeControl::adjustableRunTime writeIntervalUnits()
) );
{
newWriteInterval = userTimeToTime(newWriteInterval);
}
if if
( (
@ -74,11 +68,6 @@ void Foam::Time::readDict()
<< "writeInterval < 1 for writeControl timeStep" << "writeInterval < 1 for writeControl timeStep"
<< exit(FatalIOError); << exit(FatalIOError);
} }
}
else
{
controlDict_.lookup("writeFrequency") >> newWriteInterval;
}
setWriteInterval(newWriteInterval); setWriteInterval(newWriteInterval);

View File

@ -46,7 +46,7 @@ Foam::userTimes::engine::engine(const dictionary& controlDict)
userTime(controlDict), userTime(controlDict),
omega_(dict(controlDict)) omega_(dict(controlDict))
{ {
addUnit(dimensionedScalar(unit(), dimTime, userTimeToTime(1))); addUnits(unitName(), unitConversion(dimTime, 0, 0, userTimeToTime(1)));
} }
@ -73,16 +73,22 @@ Foam::scalar Foam::userTimes::engine::timeToUserTime(const scalar t) const
} }
Foam::word Foam::userTimes::engine::unit() const Foam::word Foam::userTimes::engine::unitName() const
{ {
return "CAD"; return "CAD";
} }
const Foam::unitConversion& Foam::userTimes::engine::units() const
{
return Foam::units()[unitName()];
}
bool Foam::userTimes::engine::read(const dictionary& controlDict) bool Foam::userTimes::engine::read(const dictionary& controlDict)
{ {
omega_ = omega(dict(controlDict)); omega_ = omega(dict(controlDict));
addUnit(dimensionedScalar(unit(), dimTime, userTimeToTime(1))); addUnits(unitName(), unitConversion(dimTime, 0, 0, userTimeToTime(1)));
return true; return true;
} }

View File

@ -83,8 +83,11 @@ public:
//- Return the time t in crank-angle //- Return the time t in crank-angle
virtual scalar timeToUserTime(const scalar t) const; virtual scalar timeToUserTime(const scalar t) const;
//- Return real-time unit (s) //- Return engine-time unit name (CAD)
virtual word unit() const; virtual word unitName() const;
//- Return the engine-time unit conversion
virtual const unitConversion& units() const;
//- Read the controlDict and set all the parameters //- Read the controlDict and set all the parameters
virtual bool read(const dictionary& controlDict); virtual bool read(const dictionary& controlDict);

View File

@ -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) 2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2021-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -66,12 +66,19 @@ Foam::scalar Foam::userTimes::real::timeToUserTime(const scalar t) const
} }
Foam::word Foam::userTimes::real::unit() const Foam::word Foam::userTimes::real::unitName() const
{ {
return "s"; return "s";
} }
const Foam::unitConversion& Foam::userTimes::real::units() const
{
static const unitConversion unitSeconds(dimTime, 0, 0, 1);
return unitSeconds;
}
bool Foam::userTimes::real::read(const dictionary& controlDict) bool Foam::userTimes::real::read(const dictionary& controlDict)
{ {
return true; return true;

View File

@ -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) 2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2021-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -36,6 +36,7 @@ SourceFiles
#define realTime_H #define realTime_H
#include "userTime.H" #include "userTime.H"
#include "unitConversion.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -52,7 +53,6 @@ class real
: :
public userTime public userTime
{ {
public: public:
//- Runtime type information //- Runtime type information
@ -77,8 +77,11 @@ public:
//- Return t (s) //- Return t (s)
virtual scalar timeToUserTime(const scalar t) const; virtual scalar timeToUserTime(const scalar t) const;
//- Return real-time unit (s) //- Return real-time unit name (s)
virtual word unit() const; virtual word unitName() const;
//- Return the real-time unit conversion
virtual const unitConversion& units() const;
//- Read the controlDict and set all the parameters //- Read the controlDict and set all the parameters
virtual bool read(const dictionary& controlDict); virtual bool read(const dictionary& controlDict);

View File

@ -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) 2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2021-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -96,7 +96,10 @@ public:
virtual scalar timeToUserTime(const scalar t) const = 0; virtual scalar timeToUserTime(const scalar t) const = 0;
//- Return user-time unit //- Return user-time unit
virtual word unit() const = 0; virtual word unitName() const = 0;
//- Return the user-time unit conversion
virtual const unitConversion& units() const = 0;
//- Read the controlDict and set all the parameters //- Read the controlDict and set all the parameters
virtual bool read(const dictionary& controlDict) = 0; virtual bool read(const dictionary& controlDict) = 0;

View File

@ -27,6 +27,7 @@ License
#include "dictionaryEntry.H" #include "dictionaryEntry.H"
#include "regExp.H" #include "regExp.H"
#include "OSHA1stream.H" #include "OSHA1stream.H"
#include "unitConversion.H"
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */ /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
@ -237,6 +238,83 @@ bool Foam::dictionary::findInPatterns
} }
void Foam::dictionary::assertNoConvertUnits
(
const char* typeName,
const word& keyword,
const unitConversion& defaultUnits,
ITstream& is
) const
{
if (!defaultUnits.standard())
{
FatalIOErrorInFunction(is)
<< "Unit conversions are not supported when reading "
<< typeName << " types" << abort(FatalError);
}
}
template<class T>
T Foam::dictionary::readTypeAndConvertUnits
(
const word& keyword,
const unitConversion& defaultUnits,
ITstream& is
) const
{
// Read the units if they are before the value
unitConversion units(defaultUnits);
const bool haveUnits = units.readIfPresent(keyword, *this, is);
// Read the value
T value = pTraits<T>(is);
// Read the units if they are after the value
if (!haveUnits && !is.eof())
{
units.readIfPresent(keyword, *this, is);
}
// Modify the value by the unit conversion
units.makeStandard(value);
return value;
}
#define IMPLEMENT_SPECIALISED_READ_TYPE(T, nullArg) \
\
template<> \
Foam::T Foam::dictionary::readType \
( \
const word& keyword, \
const unitConversion& defaultUnits, \
ITstream& is \
) const \
{ \
return readTypeAndConvertUnits<T>(keyword, defaultUnits, is); \
} \
\
template<> \
Foam::T Foam::dictionary::readType \
( \
const word& keyword, \
ITstream& is \
) const \
{ \
return readTypeAndConvertUnits<T>(keyword, unitAny, is); \
}
#define IMPLEMENT_SPECIALISED_READ_LIST_TYPE(T, nullArg) \
IMPLEMENT_SPECIALISED_READ_TYPE(List<Foam::T>, nullArg)
FOR_ALL_FIELD_TYPES(IMPLEMENT_SPECIALISED_READ_TYPE)
FOR_ALL_FIELD_TYPES(IMPLEMENT_SPECIALISED_READ_LIST_TYPE)
#undef IMPLEMENT_SPECIALISED_READ_TYPE
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::dictionary::dictionary() Foam::dictionary::dictionary()

View File

@ -58,6 +58,7 @@ SourceFiles
#include "wordReList.H" #include "wordReList.H"
#include "Pair.H" #include "Pair.H"
#include "className.H" #include "className.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -65,9 +66,10 @@ namespace Foam
{ {
// Forward declaration of friend functions and operators // Forward declaration of friend functions and operators
class regExp;
class dictionary; class dictionary;
class regExp;
class SHA1Digest; class SHA1Digest;
class unitConversion;
Istream& operator>>(Istream&, dictionary&); Istream& operator>>(Istream&, dictionary&);
Ostream& operator<<(Ostream&, const dictionary&); Ostream& operator<<(Ostream&, const dictionary&);
@ -204,6 +206,37 @@ class dictionary
DLList<autoPtr<regExp>>::iterator& reLink DLList<autoPtr<regExp>>::iterator& reLink
); );
//- Check that no unit conversions are being performed
void assertNoConvertUnits
(
const char* typeName,
const word& keyword,
const unitConversion& defaultUnits,
ITstream& is
) const;
//- Read a value, check its dimensions and convert its units
template<class T>
T readTypeAndConvertUnits
(
const word& keyword,
const unitConversion& defaultUnits,
ITstream& is
) const;
//- Read a value from the token stream
template<class T>
T readType
(
const word& keyword,
const unitConversion& defaultUnits,
ITstream& is
) const;
//- Read a value from the token stream
template<class T>
T readType(const word& keyword, ITstream& is) const;
// Private Classes // Private Classes
@ -420,8 +453,7 @@ public:
bool patternMatch=true bool patternMatch=true
) const; ) const;
//- Find and return a T, //- Find and return a T, if not found throw a fatal error.
// if not found throw a fatal error.
// If recursive, search parent dictionaries. // If recursive, search parent dictionaries.
// If patternMatch, use regular expressions. // If patternMatch, use regular expressions.
template<class T> template<class T>
@ -432,8 +464,22 @@ public:
bool patternMatch=true bool patternMatch=true
) const; ) const;
//- Find and return a T, trying a list of keywords in sequence //- Find and return a T, with dimension checking and unit
// if not found throw a fatal error relating to the first keyword // conversions, and if not found throw a fatal error.
// If recursive, search parent dictionaries.
// If patternMatch, use regular expressions.
template<class T>
T lookup
(
const word&,
const unitConversion&,
bool recursive=false,
bool patternMatch=true
) const;
//- Find and return a T, trying a list of keywords in sequence,
// and if not found throw a fatal error relating to the first
// (preferred) keyword.
// If recursive, search parent dictionaries. // If recursive, search parent dictionaries.
// If patternMatch, use regular expressions. // If patternMatch, use regular expressions.
template<class T> template<class T>
@ -444,8 +490,23 @@ public:
bool patternMatch=true bool patternMatch=true
) const; ) const;
//- Find and return a T, //- Find and return a T, with dimension checking and unit
// if not found return the given default value. // conversions, trying a list of keywords in sequence, and if not
// found throw a fatal error relating to the first (preferred)
// keyword.
// If recursive, search parent dictionaries.
// If patternMatch, use regular expressions.
template<class T>
T lookupBackwardsCompatible
(
const wordList&,
const unitConversion&,
bool recursive=false,
bool patternMatch=true
) const;
//- Find and return a T, if not found return the given default
// value.
// If recursive, search parent dictionaries. // If recursive, search parent dictionaries.
// If patternMatch, use regular expressions. // If patternMatch, use regular expressions.
template<class T> template<class T>
@ -457,8 +518,23 @@ public:
bool patternMatch=true bool patternMatch=true
) const; ) const;
//- Find and return a T, trying a list of keywords in sequence //- Find and return a T with dimension checking and unit
// if not found throw a fatal error relating to the first keyword // conversions, and if not found return the given default value.
// If recursive, search parent dictionaries.
// If patternMatch, use regular expressions.
template<class T>
T lookupOrDefault
(
const word&,
const unitConversion&,
const T&,
bool recursive=false,
bool patternMatch=true
) const;
//- Find and return a T, trying a list of keywords in sequence,
// and if not found throw a fatal error relating to the first
// (preferred) keyword
// If recursive, search parent dictionaries. // If recursive, search parent dictionaries.
// If patternMatch, use regular expressions. // If patternMatch, use regular expressions.
template<class T> template<class T>
@ -470,6 +546,22 @@ public:
bool patternMatch=true bool patternMatch=true
) const; ) const;
//- Find and return a T, with dimension checking and unit
// conversions, trying a list of keywords in sequence, and if not
// found throw a fatal error relating to the first (preferred)
// keyword
// If recursive, search parent dictionaries.
// If patternMatch, use regular expressions.
template<class T>
T lookupOrDefaultBackwardsCompatible
(
const wordList&,
const unitConversion&,
const T&,
bool recursive=false,
bool patternMatch=true
) const;
//- Find and return a T, if not found return the given //- Find and return a T, if not found return the given
// default value, and add to dictionary. // default value, and add to dictionary.
// If recursive, search parent dictionaries. // If recursive, search parent dictionaries.
@ -483,7 +575,7 @@ public:
bool patternMatch=true bool patternMatch=true
); );
//- Find an entry if present, and assign to T //- Find an entry if present, and assign to T.
// Returns true if the entry was found. // Returns true if the entry was found.
// If recursive, search parent dictionaries. // If recursive, search parent dictionaries.
// If patternMatch, use regular expressions. // If patternMatch, use regular expressions.
@ -496,6 +588,21 @@ public:
bool patternMatch=true bool patternMatch=true
) const; ) const;
//- Find an entry if present, and assign to T, with dimension
// checking and unit conversions.
// Returns true if the entry was found.
// If recursive, search parent dictionaries.
// If patternMatch, use regular expressions.
template<class T>
bool readIfPresent
(
const word&,
const unitConversion&,
T&,
bool recursive=false,
bool patternMatch=true
) const;
//- Find and return an entry data stream pointer if present, //- Find and return an entry data stream pointer if present,
// otherwise return nullptr. // otherwise return nullptr.
// If recursive, search parent dictionaries. // If recursive, search parent dictionaries.
@ -768,6 +875,36 @@ public:
}; };
// Template Specialisations
//- Specialise readType for types for which unit conversions can be performed
#define DECLARE_SPECIALISED_READ_TYPE(T, nullArg) \
\
template<> \
T Foam::dictionary::readType \
( \
const word& keyword, \
const unitConversion& defaultUnits, \
ITstream& is \
) const; \
\
template<> \
T Foam::dictionary::readType \
( \
const word& keyword, \
ITstream& is \
) const;
#define DECLARE_SPECIALISED_READ_LIST_TYPE(T, nullArg) \
DECLARE_SPECIALISED_READ_TYPE(List<T>, nullArg)
FOR_ALL_FIELD_TYPES(DECLARE_SPECIALISED_READ_TYPE);
FOR_ALL_FIELD_TYPES(DECLARE_SPECIALISED_READ_LIST_TYPE);
#undef DECLARE_SPECIALISED_READ_TYPE
#undef DECLARE_SPECIALISED_READ_FIELD_TYPE
// Global Operators // Global Operators
//- Combine dictionaries. //- Combine dictionaries.
@ -888,6 +1025,16 @@ void writeEntry(Ostream& os, const dictionary& dict);
template<class EntryType> template<class EntryType>
void writeEntry(Ostream& os, const word& entryName, const EntryType& value); void writeEntry(Ostream& os, const word& entryName, const EntryType& value);
//- Helper function to write the keyword and entry
template<class EntryType>
void writeEntry
(
Ostream& os,
const word& entryName,
const unitConversion& defaultUnits,
const EntryType& value
);
//- Helper function to write the keyword and entry only if the //- Helper function to write the keyword and entry only if the
// values are not equal. The value is then output as value2 // values are not equal. The value is then output as value2
template<class EntryType> template<class EntryType>
@ -899,6 +1046,18 @@ void writeEntryIfDifferent
const EntryType& value2 const EntryType& value2
); );
//- Helper function to write the keyword and entry only if the
// values are not equal. The value is then output as value2
template<class EntryType>
void writeEntryIfDifferent
(
Ostream& os,
const word& entryName,
const unitConversion& defaultUnits,
const EntryType& value1,
const EntryType& value2
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -26,6 +26,29 @@ License
#include "dictionary.H" #include "dictionary.H"
#include "primitiveEntry.H" #include "primitiveEntry.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class T>
T Foam::dictionary::readType
(
const word& keyword,
const unitConversion& defaultUnits,
ITstream& is
) const
{
assertNoConvertUnits(pTraits<T>::typeName, keyword, defaultUnits, is);
return pTraits<T>(is);
}
template<class T>
T Foam::dictionary::readType(const word& keyword, ITstream& is) const
{
return pTraits<T>(is);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T, class ... KeysAndTs> template<class T, class ... KeysAndTs>
@ -72,15 +95,34 @@ T Foam::dictionary::lookup
if (entryPtr == nullptr) if (entryPtr == nullptr)
{ {
FatalIOErrorInFunction FatalIOErrorInFunction(*this)
( << "keyword " << keyword << " is undefined in dictionary "
*this << name() << exit(FatalIOError);
) << "keyword " << keyword << " is undefined in dictionary "
<< name()
<< exit(FatalIOError);
} }
return pTraits<T>(entryPtr->stream()); return readType<T>(keyword, entryPtr->stream());
}
template<class T>
T Foam::dictionary::lookup
(
const word& keyword,
const unitConversion& defaultUnits,
bool recursive,
bool patternMatch
) const
{
const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
if (entryPtr == nullptr)
{
FatalIOErrorInFunction(*this)
<< "keyword " << keyword << " is undefined in dictionary "
<< name() << exit(FatalIOError);
}
return readType<T>(keyword, defaultUnits, entryPtr->stream());
} }
@ -97,7 +139,32 @@ T Foam::dictionary::lookupBackwardsCompatible
if (entryPtr) if (entryPtr)
{ {
return pTraits<T>(entryPtr->stream()); return readType<T>(entryPtr->keyword(), entryPtr->stream());
}
else
{
// Generate error message using the first keyword
return lookup<T>(keywords[0], recursive, patternMatch);
}
}
template<class T>
T Foam::dictionary::lookupBackwardsCompatible
(
const wordList& keywords,
const unitConversion& defaultUnits,
bool recursive,
bool patternMatch
) const
{
const entry* entryPtr =
lookupEntryPtrBackwardsCompatible(keywords, recursive, patternMatch);
if (entryPtr)
{
return
readType<T>(entryPtr->keyword(), defaultUnits, entryPtr->stream());
} }
else else
{ {
@ -120,7 +187,38 @@ T Foam::dictionary::lookupOrDefault
if (entryPtr) if (entryPtr)
{ {
return pTraits<T>(entryPtr->stream()); return readType<T>(keyword, entryPtr->stream());
}
else
{
if (writeOptionalEntries)
{
IOInfoInFunction(*this)
<< "Optional entry '" << keyword << "' is not present,"
<< " returning the default value '" << deflt << "'"
<< endl;
}
return deflt;
}
}
template<class T>
T Foam::dictionary::lookupOrDefault
(
const word& keyword,
const unitConversion& defaultUnits,
const T& deflt,
bool recursive,
bool patternMatch
) const
{
const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
if (entryPtr)
{
return readType<T>(keyword, defaultUnits, entryPtr->stream());
} }
else else
{ {
@ -151,7 +249,33 @@ T Foam::dictionary::lookupOrDefaultBackwardsCompatible
if (entryPtr) if (entryPtr)
{ {
return pTraits<T>(entryPtr->stream()); return readType<T>(entryPtr->keyword(), entryPtr->stream());
}
else
{
// Generate debugging messages using the first keyword
return lookupOrDefault<T>(keywords[0], deflt, recursive, patternMatch);
}
}
template<class T>
T Foam::dictionary::lookupOrDefaultBackwardsCompatible
(
const wordList& keywords,
const unitConversion& defaultUnits,
const T& deflt,
bool recursive,
bool patternMatch
) const
{
const entry* entryPtr =
lookupEntryPtrBackwardsCompatible(keywords, recursive, patternMatch);
if (entryPtr)
{
return
readType<T>(entryPtr->keyword(), defaultUnits, entryPtr->stream());
} }
else else
{ {
@ -174,7 +298,7 @@ T Foam::dictionary::lookupOrAddDefault
if (entryPtr) if (entryPtr)
{ {
return pTraits<T>(entryPtr->stream()); return readType<T>(keyword, entryPtr->stream());
} }
else else
{ {
@ -205,7 +329,39 @@ bool Foam::dictionary::readIfPresent
if (entryPtr) if (entryPtr)
{ {
entryPtr->stream() >> val; val = readType<T>(keyword, entryPtr->stream());
return true;
}
else
{
if (writeOptionalEntries)
{
IOInfoInFunction(*this)
<< "Optional entry '" << keyword << "' is not present,"
<< " the default value '" << val << "' will be used."
<< endl;
}
return false;
}
}
template<class T>
bool Foam::dictionary::readIfPresent
(
const word& keyword,
const unitConversion& defaultUnits,
T& val,
bool recursive,
bool patternMatch
) const
{
const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
if (entryPtr)
{
val = readType<T>(keyword, defaultUnits, entryPtr->stream());
return true; return true;
} }
else else
@ -236,12 +392,9 @@ T Foam::dictionary::lookupScoped
if (entryPtr == nullptr) if (entryPtr == nullptr)
{ {
FatalIOErrorInFunction FatalIOErrorInFunction(*this)
( << "keyword " << keyword << " is undefined in dictionary "
*this << name() << exit(FatalIOError);
) << "keyword " << keyword << " is undefined in dictionary "
<< name()
<< exit(FatalIOError);
} }
return pTraits<T>(entryPtr->stream()); return pTraits<T>(entryPtr->stream());
@ -318,6 +471,21 @@ void Foam::writeEntry
} }
template<class EntryType>
void Foam::writeEntry
(
Ostream& os,
const word& entryName,
const unitConversion& defaultUnits,
const EntryType& value
)
{
writeKeyword(os, entryName);
writeEntry(os, defaultUnits, value);
os << token::END_STATEMENT << endl;
}
template<class EntryType> template<class EntryType>
void Foam::writeEntryIfDifferent void Foam::writeEntryIfDifferent
( (
@ -334,4 +502,21 @@ void Foam::writeEntryIfDifferent
} }
template<class EntryType>
void Foam::writeEntryIfDifferent
(
Ostream& os,
const word& entryName,
const unitConversion& defaultUnits,
const EntryType& value1,
const EntryType& value2
)
{
if (value1 != value2)
{
writeEntry(os, entryName, defaultUnits, value2);
}
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -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-2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -127,7 +127,7 @@ void Foam::timeControl::read(const dictionary& dict)
case timeControls::cpuTime: case timeControls::cpuTime:
case timeControls::adjustableRunTime: case timeControls::adjustableRunTime:
{ {
interval_ = time_.userTimeToTime(dict.lookup<scalar>(intervalName)); interval_ = dict.lookup<scalar>(intervalName, time_.userUnits());
if (timeControl_ == timeControls::adjustableRunTime) if (timeControl_ == timeControls::adjustableRunTime)
{ {
@ -150,15 +150,17 @@ void Foam::timeControl::read(const dictionary& dict)
const word frequenciesName(prefix_ + "Frequencies"); const word frequenciesName(prefix_ + "Frequencies");
const bool repeat = dict.lookupOrDefault("writeRepeat", false); const bool repeat = dict.lookupOrDefault("writeRepeat", false);
timeDelta_ = dict.lookupOrDefault timeDelta_ =
dict.lookupOrDefault
( (
"timeDelta", "timeDelta",
1e-3*time_.deltaTValue() unitNone,
1e-3*time_.userDeltaTValue()
); );
if (dict.found(timesName)) if (dict.found(timesName))
{ {
times_ = dict.lookup<scalarList>(timesName); times_ = dict.lookup<scalarList>(timesName, unitNone);
} }
else if (dict.found(frequenciesName)) else if (dict.found(frequenciesName))
{ {

View File

@ -44,17 +44,8 @@ namespace functionObjects
void Foam::functionObjects::timeControl::readControls(const dictionary& dict) void Foam::functionObjects::timeControl::readControls(const dictionary& dict)
{ {
if (!dict.readIfPresent("startTime", startTime_)) dict.readIfPresent("startTime", time().userUnits(), startTime_);
{ dict.readIfPresent("endTime", time().userUnits(), endTime_);
dict.readIfPresent("timeStart", startTime_);
}
startTime_ = time_.userTimeToTime(startTime_);
if (!dict.readIfPresent("endTime", endTime_))
{
dict.readIfPresent("timeEnd", endTime_);
}
endTime_ = time_.userTimeToTime(endTime_);
} }
@ -83,10 +74,9 @@ Foam::functionObjects::timeControl::timeControl
writeControl_(t, dict, "write"), writeControl_(t, dict, "write"),
foPtr_(functionObject::New(name, t, dict)) foPtr_(functionObject::New(name, t, dict))
{ {
readControls(dict);
writeControl_.read(dict); writeControl_.read(dict);
executeControl_.read(dict); executeControl_.read(dict);
readControls(dict);
} }

Some files were not shown because too many files have changed in this diff Show More