Function1: Preferentially construct from separate unit conversion arguments

This commit is contained in:
Will Bainbridge
2024-05-21 12:40:14 +01:00
parent 30afcdc331
commit f8b5d71e25
19 changed files with 81 additions and 25 deletions

View File

@ -161,7 +161,8 @@ int main(int argc, char *argv[])
Function1s::Table<scalar> pData Function1s::Table<scalar> pData
( (
"pressure", "pressure",
{dimTime, dimPressure}, dimTime,
dimPressure,
dict.subDict("pressureData") dict.subDict("pressureData")
); );

View File

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

View File

@ -27,6 +27,14 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::Function1s::None<Type>::None(const word& name)
:
FieldFunction1<Type, None<Type>>(name),
dictName_("unknown")
{}
template<class Type> template<class Type>
Foam::Function1s::None<Type>::None Foam::Function1s::None<Type>::None
( (

View File

@ -64,6 +64,9 @@ public:
// Constructors // Constructors
//- Construct from name
None(const word& name);
//- Construct from name and dictionary //- Construct from name and dictionary
None None
( (

View File

@ -95,8 +95,8 @@ void Foam::Function1s::Scale<Type>::write
const unitConversions& units const unitConversions& units
) const ) const
{ {
writeEntry(os, {units.x, unitless}, scale_()); writeEntry(os, units.x, unitless, scale_());
writeEntry(os, {units.x, units.x}, xScale_()); writeEntry(os, units.x, units.x, xScale_());
writeEntry(os, units, value_()); writeEntry(os, units, value_());
} }

View File

@ -180,6 +180,19 @@ Foam::Function1s::Table<Type>::Table
} }
template<class Type>
Foam::Function1s::Table<Type>::Table
(
const word& name,
const unitConversion& xUnits,
const unitConversion& valueUnits,
const dictionary& dict
)
:
Table(name, {xUnits, valueUnits}, dict)
{}
template<class Type> template<class Type>
Foam::Function1s::Table<Type>::Table Foam::Function1s::Table<Type>::Table
( (

View File

@ -188,6 +188,15 @@ public:
const dictionary& dict const dictionary& dict
); );
//- Construct from name and dictionary
Table
(
const word& name,
const unitConversion& xUnits,
const unitConversion& valueUnits,
const dictionary& dict
);
//- Construct from name and Istream //- Construct from name and Istream
Table Table
( (

View File

@ -27,6 +27,13 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::Function1s::ZeroConstant<Type>::ZeroConstant(const word& name)
:
FieldFunction1<Type, ZeroConstant<Type>>(name)
{}
template<class Type> template<class Type>
Foam::Function1s::ZeroConstant<Type>::ZeroConstant Foam::Function1s::ZeroConstant<Type>::ZeroConstant
( (

View File

@ -67,6 +67,9 @@ public:
// Constructors // Constructors
//- Construct from name
ZeroConstant(const word& name);
//- Construct from name and dictionary //- Construct from name and dictionary
ZeroConstant ZeroConstant
( (

View File

@ -27,6 +27,14 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::Function2s::None<Type>::None(const word& name)
:
FieldFunction2<Type, None<Type>>(name),
dictName_("unknown")
{}
template<class Type> template<class Type>
Foam::Function2s::None<Type>::None Foam::Function2s::None<Type>::None
( (

View File

@ -64,6 +64,9 @@ public:
// Constructors // Constructors
//- Construct from name
None(const word& name);
//- Construct from name and dictionary //- Construct from name and dictionary
None None
( (

View File

@ -86,9 +86,9 @@ void Foam::Function2s::Scale<Type>::write
const unitConversions& units const unitConversions& units
) const ) const
{ {
writeEntry(os, {units.x, units.y, unitless}, scale_()); writeEntry(os, units.x, units.y, unitless, scale_());
writeEntry(os, {units.x, units.x}, xScale_()); writeEntry(os, units.x, units.x, xScale_());
writeEntry(os, {units.y, units.y}, yScale_()); writeEntry(os, units.y, units.y, yScale_());
writeEntry(os, units, value_()); writeEntry(os, units, value_());
} }

View File

@ -27,6 +27,13 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::Function2s::ZeroConstant<Type>::ZeroConstant(const word& name)
:
FieldFunction2<Type, ZeroConstant<Type>>(name)
{}
template<class Type> template<class Type>
Foam::Function2s::ZeroConstant<Type>::ZeroConstant Foam::Function2s::ZeroConstant<Type>::ZeroConstant
( (

View File

@ -67,6 +67,9 @@ public:
// Constructors // Constructors
//- Construct from name
ZeroConstant(const word& name);
//- Construct from name and dictionary //- Construct from name and dictionary
ZeroConstant ZeroConstant
( (

View File

@ -75,15 +75,7 @@ lumpedMassTemperatureFvPatchScalarField
dimPower, dimPower,
dict dict
) )
: autoPtr<Function1<scalar>> : autoPtr<Function1<scalar>>(new Function1s::ZeroConstant<scalar>("Q"))
(
new Function1s::ZeroConstant<scalar>
(
"Q",
{db().time().userUnits(), dimPower},
dict
)
)
), ),
V_(NaN) V_(NaN)
{ {

View File

@ -237,7 +237,8 @@ Foam::displacementLayeredMotionMotionSolver::faceZoneEvaluate
Function1s::Table<vector> Function1s::Table<vector>
( (
word::null, word::null,
{mesh().time().userUnits(), dimLength}, mesh().time().userUnits(),
dimLength,
dict dict
).value(mesh().time().value()); ).value(mesh().time().value());
} }

View File

@ -53,7 +53,7 @@ Foam::saturationModels::function1Temperature::function1Temperature
saturationTemperatureModel(), saturationTemperatureModel(),
function_ function_
( (
Function1<scalar>::New("function", {dimPressure, dimTemperature}, dict) Function1<scalar>::New("function", dimPressure, dimTemperature, dict)
) )
{} {}

View File

@ -50,14 +50,11 @@ Foam::autoPtr<Foam::Function1<Foam::scalar>> Foam::liquid::New
{ {
if (dict.isDict(name)) if (dict.isDict(name))
{ {
return Function1<scalar>::New(name, {dimTemperature, dims}, dict); return Function1<scalar>::New(name, dimTemperature, dims, dict);
} }
else else
{ {
return autoPtr<Function1<scalar>> return autoPtr<Function1<scalar>>(new Function1s::None<scalar>(name));
(
new Function1s::None<scalar>(name, {dimTemperature, dims}, dict)
);
} }
} }

View File

@ -203,7 +203,7 @@ inline void Foam::liquidProperties::write
Ostream& os Ostream& os
) const ) const
{ {
writeEntry(os, {dimTemperature, dims}, f); writeEntry(os, dimTemperature, dims, f);
} }
@ -216,7 +216,7 @@ inline void Foam::liquidProperties::write
Ostream& os Ostream& os
) const ) const
{ {
writeEntry(os, {dimPressure, dimTemperature, dims}, f); writeEntry(os, dimPressure, dimTemperature, dims, f);
} }