From 0c79b63f2e0c55fee3cec88e12c481f607d2d9be Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Fri, 4 Dec 2020 18:46:05 +0000 Subject: [PATCH] thermophysicalFunctions: Merged into Function1 and Function2 All thermophysicalFunctions, NSRDS, API and the fast uniform and non-uniform tables have now been converted into the corresponding Function1 and Function2 so that they can be used in other contexts, e.g. diffusion coefficients for multi-component diffusion and in conjunction with other Function1 and Function2s. This also enables 'coded' Function1 and Function2 to be used for thermo-physical properties. Now all run-time selectable functions are within a single general framework improving usability and simplifying maintenance. --- src/OpenFOAM/Make/files | 2 + .../Function1/Coded/CodedFunction1.H | 2 +- .../functions/Function1/Constant/Constant.H | 6 +- .../functions/Function1/Function1/Function1.C | 24 ++-- .../functions/Function1/Function1/Function1.H | 11 +- .../functions/Function1/One/OneConstant.H | 4 +- .../PolynomialEntry/PolynomialEntry.H | 1 + .../functions/Function1/Ramp/Ramp.C | 6 +- .../functions/Function1/Ramp/Ramp.H | 4 +- .../functions/Function1/Scale/Scale.C | 10 +- .../functions/Function1/Scale/Scale.H | 4 +- .../functions/Function1/Sine/Sine.C | 10 +- .../functions/Function1/Sine/Sine.H | 4 +- .../functions/Function1/Square/Square.C | 12 +- .../functions/Function1/Square/Square.H | 4 +- .../functions/Function1/Table/Table.H | 2 +- .../functions/Function1/Uniform/Uniform.H | 2 +- .../functions/Function1/Zero/ZeroConstant.H | 2 +- .../Function1/halfCosineRamp/halfCosineRamp.H | 2 +- .../Function1/linearRamp/linearRamp.H | 2 +- .../nonUniformTable1/nonUniformTable1.C} | 75 +++++------ .../nonUniformTable1/nonUniformTable1.H} | 61 ++++----- .../nonUniformTable1/nonUniformTable1I.H} | 18 ++- .../Function1/quadraticRamp/quadraticRamp.H | 2 +- .../quarterCosineRamp/quarterCosineRamp.H | 2 +- .../quarterSineRamp/quarterSineRamp.H | 2 +- .../Function1/reverseRamp/reverseRamp.H | 2 +- .../Function1/uniformTable1/uniformTable1.C} | 52 +++++--- .../Function1/uniformTable1/uniformTable1.H} | 55 ++++---- .../Function2/Coded/CodedFunction2.H | 2 +- .../functions/Function2/Constant/Constant2.H | 6 +- .../functions/Function2/Function2/Function2.C | 24 ++-- .../functions/Function2/Function2/Function2.H | 11 +- .../functions/Function2/One/OneConstant2.H | 4 +- .../functions/Function2/Scale/Scale2.C | 14 +- .../functions/Function2/Scale/Scale2.H | 4 +- .../functions/Function2/Zero/ZeroConstant2.H | 2 +- .../functions/TimeFunction1/TimeFunction1.H | 4 +- .../basic/mixtures/pureMixture/pureMixture.C | 2 +- .../multiComponentMixture.C | 3 +- src/thermophysicalModels/specie/Make/files | 28 ++-- .../icoTabulated/icoTabulated.C | 2 +- .../icoTabulated/icoTabulated.H | 10 +- .../icoTabulated/icoTabulatedI.H | 2 +- .../rhoTabulated/rhoTabulated.C | 2 +- .../rhoTabulated/rhoTabulated.H | 2 +- .../eIcoTabulated/eIcoTabulatedThermo.C | 2 +- .../eIcoTabulated/eIcoTabulatedThermo.H | 9 +- .../thermo/eTabulated/eTabulatedThermo.C | 4 +- .../hIcoTabulated/hIcoTabulatedThermo.C | 2 +- .../hIcoTabulated/hIcoTabulatedThermo.H | 9 +- .../thermo/hTabulated/hTabulatedThermo.C | 4 +- .../APIdiffCoef.C} | 2 +- .../APIdiffCoef.H} | 6 +- ...SRDS0ThermophysicalFunction.C => NSRDS0.C} | 31 ++++- ...SRDS0ThermophysicalFunction.H => NSRDS0.H} | 34 +++-- .../NSRDS1.C} | 32 +++-- ...SRDS1ThermophysicalFunction.H => NSRDS1.H} | 34 +++-- ...DS14ThermophysicalFunction.C => NSRDS14.C} | 36 +++-- ...DS14ThermophysicalFunction.H => NSRDS14.H} | 34 +++-- .../NSRDS2.C} | 32 +++-- ...SRDS2ThermophysicalFunction.H => NSRDS2.H} | 34 +++-- .../NSRDS3.C} | 31 ++++- ...SRDS3ThermophysicalFunction.H => NSRDS3.H} | 34 +++-- ...SRDS4ThermophysicalFunction.C => NSRDS4.C} | 31 ++++- ...SRDS4ThermophysicalFunction.H => NSRDS4.H} | 32 +++-- .../NSRDS5.C} | 32 ++++- ...SRDS5ThermophysicalFunction.H => NSRDS5.H} | 34 +++-- ...SRDS6ThermophysicalFunction.C => NSRDS6.C} | 31 ++++- ...SRDS6ThermophysicalFunction.H => NSRDS6.H} | 34 +++-- .../NSRDS7.C} | 32 ++++- ...SRDS7ThermophysicalFunction.H => NSRDS7.H} | 34 +++-- .../constant/constantThermophysicalFunction.C | 63 --------- .../constant/constantThermophysicalFunction.H | 104 --------------- .../integratedNonUniformTable1.C} | 37 ++---- .../integratedNonUniformTable1.H} | 33 +++-- .../none/noneThermophysicalFunction.C | 66 --------- .../none/noneThermophysicalFunction.H | 89 ------------- .../thermophysicalFunction.C | 108 --------------- .../thermophysicalFunction.H | 125 ------------------ .../uniformTable2/uniformTable2.C | 108 ++++++++------- .../uniformTable2/uniformTable2.H | 39 +++--- .../icoTabulated/icoTabulatedTransport.C | 4 +- .../icoTabulated/icoTabulatedTransport.H | 14 +- .../icoTabulated/icoTabulatedTransportI.H | 4 +- .../transport/tabulated/tabulatedTransport.C | 4 +- .../liquidProperties/Ar/Ar.C | 55 +++++--- .../liquidProperties/Ar/Ar.H | 68 +++++----- .../liquidProperties/C10H22/C10H22.C | 53 +++++--- .../liquidProperties/C10H22/C10H22.H | 68 +++++----- .../liquidProperties/C12H26/C12H26.C | 63 ++++++--- .../liquidProperties/C12H26/C12H26.H | 68 +++++----- .../liquidProperties/C13H28/C13H28.C | 53 +++++--- .../liquidProperties/C13H28/C13H28.H | 68 +++++----- .../liquidProperties/C14H30/C14H30.C | 53 +++++--- .../liquidProperties/C14H30/C14H30.H | 68 +++++----- .../liquidProperties/C16H34/C16H34.C | 53 +++++--- .../liquidProperties/C16H34/C16H34.H | 68 +++++----- .../liquidProperties/C2H5OH/C2H5OH.C | 53 +++++--- .../liquidProperties/C2H5OH/C2H5OH.H | 68 +++++----- .../liquidProperties/C2H6/C2H6.C | 54 +++++--- .../liquidProperties/C2H6/C2H6.H | 68 +++++----- .../liquidProperties/C2H6O/C2H6O.C | 45 ++++--- .../liquidProperties/C2H6O/C2H6O.H | 68 +++++----- .../liquidProperties/C3H6O/C3H6O.C | 53 +++++--- .../liquidProperties/C3H6O/C3H6O.H | 68 +++++----- .../liquidProperties/C3H8/C3H8.C | 54 +++++--- .../liquidProperties/C3H8/C3H8.H | 68 +++++----- .../liquidProperties/C4H10O/C4H10O.C | 53 +++++--- .../liquidProperties/C4H10O/C4H10O.H | 68 +++++----- .../liquidProperties/C6H14/C6H14.C | 53 +++++--- .../liquidProperties/C6H14/C6H14.H | 68 +++++----- .../liquidProperties/C6H6/C6H6.C | 53 +++++--- .../liquidProperties/C6H6/C6H6.H | 68 +++++----- .../liquidProperties/C7H16/C7H16.C | 53 +++++--- .../liquidProperties/C7H16/C7H16.H | 68 +++++----- .../liquidProperties/C7H8/C7H8.C | 53 +++++--- .../liquidProperties/C7H8/C7H8.H | 68 +++++----- .../liquidProperties/C8H10/C8H10.C | 53 +++++--- .../liquidProperties/C8H10/C8H10.H | 66 ++++----- .../liquidProperties/C8H18/C8H18.C | 53 +++++--- .../liquidProperties/C8H18/C8H18.H | 68 +++++----- .../liquidProperties/C9H20/C9H20.C | 53 +++++--- .../liquidProperties/C9H20/C9H20.H | 68 +++++----- .../liquidProperties/CH3OH/CH3OH.C | 53 +++++--- .../liquidProperties/CH3OH/CH3OH.H | 68 +++++----- .../liquidProperties/CH4N2O/CH4N2O.C | 63 +++++---- .../liquidProperties/CH4N2O/CH4N2O.H | 68 +++++----- .../liquidProperties/H2O/H2O.C | 44 +++--- .../liquidProperties/H2O/H2O.H | 66 ++++----- .../liquidProperties/IC8H18/IC8H18.C | 53 +++++--- .../liquidProperties/IC8H18/IC8H18.H | 68 +++++----- .../liquidProperties/IDEA/IDEA.C | 42 +++--- .../liquidProperties/IDEA/IDEA.H | 66 ++++----- .../liquidProperties/MB/MB.C | 64 +++++---- .../liquidProperties/MB/MB.H | 68 +++++----- .../liquidProperties/N2/N2.C | 53 +++++--- .../liquidProperties/N2/N2.H | 68 +++++----- .../liquidProperties/aC10H7CH3/aC10H7CH3.C | 54 +++++--- .../liquidProperties/aC10H7CH3/aC10H7CH3.H | 68 +++++----- .../liquidProperties/bC10H7CH3/bC10H7CH3.C | 63 ++++++--- .../liquidProperties/bC10H7CH3/bC10H7CH3.H | 68 +++++----- .../liquidProperties/iC3H8O/iC3H8O.C | 59 +++++---- .../liquidProperties/iC3H8O/iC3H8O.H | 72 +++++----- .../liquidProperties/liquid/liquid.C | 26 ++-- .../liquidProperties/liquid/liquid.H | 30 ++--- .../liquidProperties/liquidProperties.C | 4 +- .../liquidProperties/liquidPropertiesI.H | 4 +- .../liquidProperties/nC3H8O/nC3H8O.C | 59 +++++---- .../liquidProperties/nC3H8O/nC3H8O.H | 72 +++++----- 150 files changed, 2832 insertions(+), 2827 deletions(-) rename src/{thermophysicalModels/specie/thermophysicalFunctions/nonUniformTable1D/nonUniformTable1DThermophysicalFunction.C => OpenFOAM/primitives/functions/Function1/nonUniformTable1/nonUniformTable1.C} (65%) rename src/{thermophysicalModels/specie/thermophysicalFunctions/nonUniformTable1D/nonUniformTable1DThermophysicalFunction.H => OpenFOAM/primitives/functions/Function1/nonUniformTable1/nonUniformTable1.H} (70%) rename src/{thermophysicalModels/specie/thermophysicalFunctions/nonUniformTable1D/nonUniformTable1DThermophysicalFunctionI.H => OpenFOAM/primitives/functions/Function1/nonUniformTable1/nonUniformTable1I.H} (77%) rename src/{thermophysicalModels/specie/thermophysicalFunctions/table1D/table1DThermophysicalFunction.C => OpenFOAM/primitives/functions/Function1/uniformTable1/uniformTable1.C} (70%) rename src/{thermophysicalModels/specie/thermophysicalFunctions/table1D/table1DThermophysicalFunction.H => OpenFOAM/primitives/functions/Function1/uniformTable1/uniformTable1.H} (70%) rename src/thermophysicalModels/specie/thermophysicalFunctions/{APIfunctions/APIdiffCoef/APIdiffCoefThermophysicalFunction.C => APIdiffCoef/APIdiffCoef.C} (98%) rename src/thermophysicalModels/specie/thermophysicalFunctions/{APIfunctions/APIdiffCoef/APIdiffCoefThermophysicalFunction.H => APIdiffCoef/APIdiffCoef.H} (96%) rename src/thermophysicalModels/specie/thermophysicalFunctions/NSRDS/NSRDS0/{NSRDS0ThermophysicalFunction.C => NSRDS0.C} (81%) rename src/thermophysicalModels/specie/thermophysicalFunctions/NSRDS/NSRDS0/{NSRDS0ThermophysicalFunction.H => NSRDS0.H} (82%) rename src/thermophysicalModels/specie/thermophysicalFunctions/NSRDS/{NSRDS7/NSRDS7ThermophysicalFunction.C => NSRDS1/NSRDS1.C} (80%) rename src/thermophysicalModels/specie/thermophysicalFunctions/NSRDS/NSRDS1/{NSRDS1ThermophysicalFunction.H => NSRDS1.H} (81%) rename src/thermophysicalModels/specie/thermophysicalFunctions/NSRDS/NSRDS14/{NSRDS14ThermophysicalFunction.C => NSRDS14.C} (80%) rename src/thermophysicalModels/specie/thermophysicalFunctions/NSRDS/NSRDS14/{NSRDS14ThermophysicalFunction.H => NSRDS14.H} (82%) rename src/thermophysicalModels/specie/thermophysicalFunctions/NSRDS/{NSRDS5/NSRDS5ThermophysicalFunction.C => NSRDS2/NSRDS2.C} (80%) rename src/thermophysicalModels/specie/thermophysicalFunctions/NSRDS/NSRDS2/{NSRDS2ThermophysicalFunction.H => NSRDS2.H} (81%) rename src/thermophysicalModels/specie/thermophysicalFunctions/NSRDS/{NSRDS2/NSRDS2ThermophysicalFunction.C => NSRDS3/NSRDS3.C} (80%) rename src/thermophysicalModels/specie/thermophysicalFunctions/NSRDS/NSRDS3/{NSRDS3ThermophysicalFunction.H => NSRDS3.H} (81%) rename src/thermophysicalModels/specie/thermophysicalFunctions/NSRDS/NSRDS4/{NSRDS4ThermophysicalFunction.C => NSRDS4.C} (80%) rename src/thermophysicalModels/specie/thermophysicalFunctions/NSRDS/NSRDS4/{NSRDS4ThermophysicalFunction.H => NSRDS4.H} (83%) rename src/thermophysicalModels/specie/thermophysicalFunctions/NSRDS/{NSRDS3/NSRDS3ThermophysicalFunction.C => NSRDS5/NSRDS5.C} (79%) rename src/thermophysicalModels/specie/thermophysicalFunctions/NSRDS/NSRDS5/{NSRDS5ThermophysicalFunction.H => NSRDS5.H} (81%) rename src/thermophysicalModels/specie/thermophysicalFunctions/NSRDS/NSRDS6/{NSRDS6ThermophysicalFunction.C => NSRDS6.C} (81%) rename src/thermophysicalModels/specie/thermophysicalFunctions/NSRDS/NSRDS6/{NSRDS6ThermophysicalFunction.H => NSRDS6.H} (82%) rename src/thermophysicalModels/specie/thermophysicalFunctions/NSRDS/{NSRDS1/NSRDS1ThermophysicalFunction.C => NSRDS7/NSRDS7.C} (80%) rename src/thermophysicalModels/specie/thermophysicalFunctions/NSRDS/NSRDS7/{NSRDS7ThermophysicalFunction.H => NSRDS7.H} (82%) delete mode 100644 src/thermophysicalModels/specie/thermophysicalFunctions/constant/constantThermophysicalFunction.C delete mode 100644 src/thermophysicalModels/specie/thermophysicalFunctions/constant/constantThermophysicalFunction.H rename src/thermophysicalModels/specie/thermophysicalFunctions/{integratedNonUniformTable1D/integratedNonUniformTable1DThermophysicalFunction.C => integratedNonUniformTable1/integratedNonUniformTable1.C} (76%) rename src/thermophysicalModels/specie/thermophysicalFunctions/{integratedNonUniformTable1D/integratedNonUniformTable1DThermophysicalFunction.H => integratedNonUniformTable1/integratedNonUniformTable1.H} (76%) delete mode 100644 src/thermophysicalModels/specie/thermophysicalFunctions/none/noneThermophysicalFunction.C delete mode 100644 src/thermophysicalModels/specie/thermophysicalFunctions/none/noneThermophysicalFunction.H delete mode 100644 src/thermophysicalModels/specie/thermophysicalFunctions/thermophysicalFunction/thermophysicalFunction.C delete mode 100644 src/thermophysicalModels/specie/thermophysicalFunctions/thermophysicalFunction/thermophysicalFunction.H diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index d4cb1afaa7..131f63e618 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -98,6 +98,8 @@ primitives/functions/Function1/quarterCosineRamp/quarterCosineRamp.C primitives/functions/Function1/halfCosineRamp/halfCosineRamp.C primitives/functions/Function1/Table/tableBase.C primitives/functions/Function1/Table/TableReader/makeTableReaders.C +primitives/functions/Function1/uniformTable1/uniformTable1.C +primitives/functions/Function1/nonUniformTable1/nonUniformTable1.C primitives/functions/Function2/makeFunction2s.C diff --git a/src/OpenFOAM/primitives/functions/Function1/Coded/CodedFunction1.H b/src/OpenFOAM/primitives/functions/Function1/Coded/CodedFunction1.H index 469489ec79..26c811bc56 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Coded/CodedFunction1.H +++ b/src/OpenFOAM/primitives/functions/Function1/Coded/CodedFunction1.H @@ -125,7 +125,7 @@ public: // Constructors - //- Construct from entry name and dictionary + //- Construct from name and dictionary Coded ( const word& name, diff --git a/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.H b/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.H index ee69b26cab..99674591c8 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.H +++ b/src/OpenFOAM/primitives/functions/Function1/Constant/Constant.H @@ -72,13 +72,13 @@ public: // Constructors - //- Construct from entry name and value + //- Construct from name and value Constant(const word& name, const Type& val); - //- Construct from entry name and dictionary + //- Construct from name and dictionary Constant(const word& name, const dictionary& dict); - //- Construct from entry name and Istream + //- Construct from name and Istream // Reads the constant value without the Function1 type // for backward compatibility Constant(const word& name, Istream& is); diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C index 9276400f63..f280635354 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C +++ b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.C @@ -53,16 +53,6 @@ Foam::FieldFunction1::FieldFunction1 {} -template -Foam::FieldFunction1::FieldFunction1 -( - const FieldFunction1& ff1 -) -: - Function1(ff1) -{} - - template Foam::tmp> Foam::FieldFunction1::clone() const @@ -133,6 +123,20 @@ Foam::FieldFunction1::integral } +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +template +void Foam::Function1::operator=(const Function1& f) +{ + if (this == &f) + { + FatalErrorInFunction + << "attempted assignment to self" + << abort(FatalError); + } +} + + // * * * * * * * * * * * * * * * IOstream Functions * * * * * * * * * * * * // template diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H index d94862458d..b299e2f599 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H +++ b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H @@ -94,7 +94,7 @@ public: // Constructors - //- Construct from entry name + //- Construct from name Function1(const word& name); //- Copy constructor @@ -143,8 +143,8 @@ public: // Member Operators - //- Disallow default bitwise assignment - void operator=(const Function1&) = delete; + //- Assignment + void operator=(const Function1&); // IOstream Operators @@ -176,12 +176,9 @@ public: // Constructors - //- Construct from entry name + //- Construct from name FieldFunction1(const word& name); - //- Copy constructor - FieldFunction1(const FieldFunction1& ff1); - //- Construct and return a clone virtual tmp> clone() const; diff --git a/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.H b/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.H index fa1f7167e7..d1c45d9626 100644 --- a/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.H +++ b/src/OpenFOAM/primitives/functions/Function1/One/OneConstant.H @@ -67,10 +67,10 @@ public: // Constructors - //- Construct from entry name + //- Construct from name OneConstant(const word& name); - //- Construct from entry name and dictionary + //- Construct from name and dictionary OneConstant(const word& name, const dictionary& dict); diff --git a/src/OpenFOAM/primitives/functions/Function1/PolynomialEntry/PolynomialEntry.H b/src/OpenFOAM/primitives/functions/Function1/PolynomialEntry/PolynomialEntry.H index 4122fe8ed2..82bda37e65 100644 --- a/src/OpenFOAM/primitives/functions/Function1/PolynomialEntry/PolynomialEntry.H +++ b/src/OpenFOAM/primitives/functions/Function1/PolynomialEntry/PolynomialEntry.H @@ -82,6 +82,7 @@ public: // Constructors + //- Construct from name and dictionary Polynomial(const word& name, const dictionary& dict); //- Construct from components diff --git a/src/OpenFOAM/primitives/functions/Function1/Ramp/Ramp.C b/src/OpenFOAM/primitives/functions/Function1/Ramp/Ramp.C index b363b912de..33925c8bf7 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Ramp/Ramp.C +++ b/src/OpenFOAM/primitives/functions/Function1/Ramp/Ramp.C @@ -28,10 +28,10 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -void Foam::Function1s::Ramp::read(const dictionary& coeffs) +void Foam::Function1s::Ramp::read(const dictionary& dict) { - start_ = coeffs.lookupOrDefault("start", 0); - duration_ = coeffs.lookup("duration"); + start_ = dict.lookupOrDefault("start", 0); + duration_ = dict.lookup("duration"); } diff --git a/src/OpenFOAM/primitives/functions/Function1/Ramp/Ramp.H b/src/OpenFOAM/primitives/functions/Function1/Ramp/Ramp.H index f24a1577fe..096635454b 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Ramp/Ramp.H +++ b/src/OpenFOAM/primitives/functions/Function1/Ramp/Ramp.H @@ -120,14 +120,14 @@ private: // Private Member Functions //- Read the coefficients from the given dictionary - void read(const dictionary& coeffs); + void read(const dictionary& dict); public: // Constructors - //- Construct from entry name and dictionary + //- Construct from name and dictionary Ramp ( const word& name, diff --git a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C index a25b78ff8b..990e6cb1b0 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C +++ b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.C @@ -28,14 +28,14 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // template -void Foam::Function1s::Scale::read(const dictionary& coeffs) +void Foam::Function1s::Scale::read(const dictionary& dict) { - scale_ = Function1::New("scale", coeffs); + scale_ = Function1::New("scale", dict); xScale_ = - coeffs.found("xScale") - ? Function1::New("xScale", coeffs) + dict.found("xScale") + ? Function1::New("xScale", dict) : autoPtr>(new Constant("xScale", 1)); - value_ = Function1::New("value", coeffs); + value_ = Function1::New("value", dict); integrableScale_ = isA>(xScale_()) diff --git a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.H b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.H index da3f7b92f7..5f83dd940a 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.H +++ b/src/OpenFOAM/primitives/functions/Function1/Scale/Scale.H @@ -158,7 +158,7 @@ class Scale // Private Member Functions //- Read the coefficients from the given dictionary - void read(const dictionary& coeffs); + void read(const dictionary& dict); public: @@ -169,7 +169,7 @@ public: // Constructors - //- Construct from entry name and dictionary + //- Construct from name and dictionary Scale ( const word& name, diff --git a/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.C b/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.C index 62ab6471aa..fadb559813 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.C +++ b/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.C @@ -28,12 +28,12 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // template -void Foam::Function1s::Sine::read(const dictionary& coeffs) +void Foam::Function1s::Sine::read(const dictionary& dict) { - amplitude_ = Function1::New("amplitude", coeffs); - frequency_ = coeffs.lookup("frequency"); - start_ = coeffs.lookupOrDefault("start", 0); - level_ = Function1::New("level", coeffs); + amplitude_ = Function1::New("amplitude", dict); + frequency_ = dict.lookup("frequency"); + start_ = dict.lookupOrDefault("start", 0); + level_ = Function1::New("level", dict); integrable_ = isA>(amplitude_()) diff --git a/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.H b/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.H index 96d9a50a08..aab9008ce0 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.H +++ b/src/OpenFOAM/primitives/functions/Function1/Sine/Sine.H @@ -112,7 +112,7 @@ class Sine // Private Member Functions //- Read the coefficients from the given dictionary - void read(const dictionary& coeffs); + void read(const dictionary& dict); public: @@ -123,7 +123,7 @@ public: // Constructors - //- Construct from entry name and dictionary + //- Construct from name and dictionary Sine ( const word& name, diff --git a/src/OpenFOAM/primitives/functions/Function1/Square/Square.C b/src/OpenFOAM/primitives/functions/Function1/Square/Square.C index 08f376bfab..a7ee7f00d9 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Square/Square.C +++ b/src/OpenFOAM/primitives/functions/Function1/Square/Square.C @@ -28,13 +28,13 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // template -void Foam::Function1s::Square::read(const dictionary& coeffs) +void Foam::Function1s::Square::read(const dictionary& dict) { - amplitude_ = Function1::New("amplitude", coeffs); - frequency_ = coeffs.lookup("frequency"); - start_ = coeffs.lookupOrDefault("start", 0); - level_ = Function1::New("level", coeffs); - markSpace_ = coeffs.lookupOrDefault("markSpace", 1); + amplitude_ = Function1::New("amplitude", dict); + frequency_ = dict.lookup("frequency"); + start_ = dict.lookupOrDefault("start", 0); + level_ = Function1::New("level", dict); + markSpace_ = dict.lookupOrDefault("markSpace", 1); integrable_ = isA>(amplitude_()) diff --git a/src/OpenFOAM/primitives/functions/Function1/Square/Square.H b/src/OpenFOAM/primitives/functions/Function1/Square/Square.H index cd5dbe1d0c..71cb5bf2bd 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Square/Square.H +++ b/src/OpenFOAM/primitives/functions/Function1/Square/Square.H @@ -123,7 +123,7 @@ class Square // Private Member Functions //- Read the coefficients from the given dictionary - void read(const dictionary& coeffs); + void read(const dictionary& dict); public: @@ -134,7 +134,7 @@ public: // Constructors - //- Construct from entry name and dictionary + //- Construct from name and dictionary Square ( const word& name, diff --git a/src/OpenFOAM/primitives/functions/Function1/Table/Table.H b/src/OpenFOAM/primitives/functions/Function1/Table/Table.H index 7db117e55b..c985600c9c 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Table/Table.H +++ b/src/OpenFOAM/primitives/functions/Function1/Table/Table.H @@ -180,7 +180,7 @@ public: const List>& table ); - //- Construct from entry name and dictionary + //- Construct from name and dictionary Table(const word& name, const dictionary& dict); //- Copy constructor diff --git a/src/OpenFOAM/primitives/functions/Function1/Uniform/Uniform.H b/src/OpenFOAM/primitives/functions/Function1/Uniform/Uniform.H index ad7900c85f..5a0ee8c9f2 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Uniform/Uniform.H +++ b/src/OpenFOAM/primitives/functions/Function1/Uniform/Uniform.H @@ -70,7 +70,7 @@ public: // Constructors - //- Construct from entry name and dictionary + //- Construct from name and dictionary Uniform(const word& name, const dictionary& dict); diff --git a/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.H b/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.H index a679cf335c..c8516b1e0c 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.H +++ b/src/OpenFOAM/primitives/functions/Function1/Zero/ZeroConstant.H @@ -67,7 +67,7 @@ public: // Constructors - //- Construct from entry name and dictionary + //- Construct from name and dictionary ZeroConstant(const word& name, const dictionary& dict); diff --git a/src/OpenFOAM/primitives/functions/Function1/halfCosineRamp/halfCosineRamp.H b/src/OpenFOAM/primitives/functions/Function1/halfCosineRamp/halfCosineRamp.H index 1b1befcab8..10ee898652 100644 --- a/src/OpenFOAM/primitives/functions/Function1/halfCosineRamp/halfCosineRamp.H +++ b/src/OpenFOAM/primitives/functions/Function1/halfCosineRamp/halfCosineRamp.H @@ -65,7 +65,7 @@ public: // Constructors - //- Construct from entry name and dictionary + //- Construct from name and dictionary halfCosineRamp ( const word& name, diff --git a/src/OpenFOAM/primitives/functions/Function1/linearRamp/linearRamp.H b/src/OpenFOAM/primitives/functions/Function1/linearRamp/linearRamp.H index 5d66d40107..2658f77ffa 100644 --- a/src/OpenFOAM/primitives/functions/Function1/linearRamp/linearRamp.H +++ b/src/OpenFOAM/primitives/functions/Function1/linearRamp/linearRamp.H @@ -65,7 +65,7 @@ public: // Constructors - //- Construct from entry name and dictionary + //- Construct from name and dictionary linearRamp ( const word& name, diff --git a/src/thermophysicalModels/specie/thermophysicalFunctions/nonUniformTable1D/nonUniformTable1DThermophysicalFunction.C b/src/OpenFOAM/primitives/functions/Function1/nonUniformTable1/nonUniformTable1.C similarity index 65% rename from src/thermophysicalModels/specie/thermophysicalFunctions/nonUniformTable1D/nonUniformTable1DThermophysicalFunction.C rename to src/OpenFOAM/primitives/functions/Function1/nonUniformTable1/nonUniformTable1.C index debf6a2826..10855d60fc 100644 --- a/src/thermophysicalModels/specie/thermophysicalFunctions/nonUniformTable1D/nonUniformTable1DThermophysicalFunction.C +++ b/src/OpenFOAM/primitives/functions/Function1/nonUniformTable1/nonUniformTable1.C @@ -23,23 +23,16 @@ License \*---------------------------------------------------------------------------*/ -#include "nonUniformTable1DThermophysicalFunction.H" +#include "nonUniformTable1.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -namespace thermophysicalFunctions +namespace Function1s { - defineTypeNameAndDebug(nonUniformTable1D, 0); - - addToRunTimeSelectionTable - ( - thermophysicalFunction, - nonUniformTable1D, - dictionary - ); + makeScalarFunction1(nonUniformTable) } } @@ -52,46 +45,46 @@ const char* const Foam::Tuple2::typeName // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::thermophysicalFunctions::nonUniformTable1D::nonUniformTable1D +Foam::Function1s::nonUniformTable::nonUniformTable ( const word& name, const dictionary& dict ) : - name_(name), - Tlow_(great), - Thigh_(-great), - values_(dict.lookup(name)), - deltaT_(great) + FieldFunction1(name), + low_(great), + high_(-great), + values_(dict.lookup("values")), + delta_(great) { if (values_.size() < 2) { FatalIOErrorInFunction(dict) << "Table " << nl - << " " << name_ << nl + << " " << name << nl << " has less than 2 entries." << exit(FatalIOError); } else { - Tlow_ = values_.first().first(); - Thigh_ = values_.last().first(); + low_ = values_.first().first(); + high_ = values_.last().first(); for(label i = 1; i values_[i + 1].first()) + if (x > values_[i + 1].first()) { i++; } @@ -102,25 +95,16 @@ Foam::thermophysicalFunctions::nonUniformTable1D::nonUniformTable1D } -Foam::thermophysicalFunctions::nonUniformTable1D::nonUniformTable1D -( - const dictionary& dict -) -: - nonUniformTable1D("values", dict) -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::scalar Foam::thermophysicalFunctions::nonUniformTable1D::value +Foam::scalar Foam::Function1s::nonUniformTable::value ( - scalar T + scalar x ) const { - const label i = index(T); - const scalar Ti = values_[i].first(); - const scalar lambda = (T - Ti)/(values_[i + 1].first() - Ti); + const label i = index(x); + const scalar xi = values_[i].first(); + const scalar lambda = (x - xi)/(values_[i + 1].first() - xi); return values_[i].second() @@ -128,7 +112,18 @@ Foam::scalar Foam::thermophysicalFunctions::nonUniformTable1D::value } -Foam::scalar Foam::thermophysicalFunctions::nonUniformTable1D::dfdT +Foam::scalar Foam::Function1s::nonUniformTable::integral +( + const scalar x1, + const scalar x2 +) const +{ + NotImplemented; + return 0; +} + + +Foam::scalar Foam::Function1s::nonUniformTable::dfdT ( scalar T ) const @@ -141,7 +136,7 @@ Foam::scalar Foam::thermophysicalFunctions::nonUniformTable1D::dfdT } -void Foam::thermophysicalFunctions::nonUniformTable1D::write(Ostream& os) const +void Foam::Function1s::nonUniformTable::write(Ostream& os) const { writeEntry(os, "values", values_); } diff --git a/src/thermophysicalModels/specie/thermophysicalFunctions/nonUniformTable1D/nonUniformTable1DThermophysicalFunction.H b/src/OpenFOAM/primitives/functions/Function1/nonUniformTable1/nonUniformTable1.H similarity index 70% rename from src/thermophysicalModels/specie/thermophysicalFunctions/nonUniformTable1D/nonUniformTable1DThermophysicalFunction.H rename to src/OpenFOAM/primitives/functions/Function1/nonUniformTable1/nonUniformTable1.H index 6e081bf956..3c1e5a33a0 100644 --- a/src/thermophysicalModels/specie/thermophysicalFunctions/nonUniformTable1D/nonUniformTable1DThermophysicalFunction.H +++ b/src/OpenFOAM/primitives/functions/Function1/nonUniformTable1/nonUniformTable1.H @@ -22,7 +22,7 @@ License along with OpenFOAM. If not, see . Class - Foam::thermophysicalFunctions::nonUniformTable1D + Foam::Function1s::nonUniformTable Description Non-uniform tabulated property function that linearly interpolates between @@ -33,16 +33,16 @@ Description the table. Usage - \nonUniformTable1D + \nonUniformTable Property | Description - values | List of (temperature property) value pairs - \endnonUniformTable1D + values | List of value pairs + \endnonUniformTable Example for the density of water between 280 and 350K \verbatim rho { - type nonUniformTable1D; + type nonUniformTable; values ( @@ -55,43 +55,40 @@ Usage \*---------------------------------------------------------------------------*/ -#ifndef nonUniformTable1DThermophysicalFunction_H -#define nonUniformTable1DThermophysicalFunction_H +#ifndef nonUniformTable1_H +#define nonUniformTable1_H -#include "thermophysicalFunction.H" +#include "Function1.H" #include "Tuple2.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -namespace thermophysicalFunctions +namespace Function1s { /*---------------------------------------------------------------------------*\ - Class nonUniformTable1D Declaration + Class nonUniformTable Declaration \*---------------------------------------------------------------------------*/ -class nonUniformTable1D +class nonUniformTable : - public thermophysicalFunction + public FieldFunction1 { // Private member data - //- Name of dictionary from which this function is instantiated - word name_; + //- Lowest value in the nonUniformTable + scalar low_; - //- Lowest temperature in the nonUniformTable1D - scalar Tlow_; - - //- Highest temperature in the nonUniformTable1D - scalar Thigh_; + //- Highest value in the nonUniformTable + scalar high_; //- Table values List> values_; - //- Temperature increment derived from Tlow_, Thigh_ and values_.size() - scalar deltaT_; + //- Increment derived from low_, high_ and values_.size() + scalar delta_; List