From 7ab73932cf5b791f09001fb07ad8ce385e70234f Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Thu, 17 Oct 2019 19:11:05 +0100 Subject: [PATCH] Function1: Generalisation and removal of unused code Function1 has been generalised in order to provide functionality previously provided by some near-duplicate pieces of code. The interpolationTable and tableReader classes have been removed and their usage cases replaced by Function1. The interfaces to Function1, Table and TableFile has been improved for the purpose of using it internally; i.e., without user input. Some boundary conditions, fvOptions and function objects which previously used interpolationTable or other low-level interpolation classes directly have been changed to use Function1 instead. These changes may not be backwards compatible. See header documentation for details. In addition, the timeVaryingUniformFixedValue boundary condition has been removed as its functionality is duplicated entirely by uniformFixedValuePointPatchField. --- .../saturationModels/function1/function1.H | 6 +- .../LuoSvendsen/LuoSvendsen.C | 32 +- .../LuoSvendsen/LuoSvendsen.H | 8 +- .../utilities/postProcessing/noise/noise.C | 10 +- etc/controlDict | 3 - src/OpenFOAM/Make/files | 7 +- ...eVaryingUniformFixedValuePointPatchField.C | 132 ---- ...eVaryingUniformFixedValuePointPatchField.H | 167 ----- ...VaryingUniformFixedValuePointPatchFields.C | 43 -- ...VaryingUniformFixedValuePointPatchFields.H | 57 -- .../interpolation2DTable.C | 42 +- .../interpolation2DTable.H | 9 +- .../interpolationTable/interpolationTable.C | 634 ------------------ .../interpolationTable/interpolationTable.H | 194 ------ .../tableReaders/csv/csvTableReader.C | 196 ------ .../openFoam/openFoamTableReaders.C | 37 - .../tableReaders/tableReaders.C | 50 -- .../tableReaders/tableReaders.H | 75 --- .../primitives/functions/Function1/CSV/CSV.H | 169 ----- .../functions/Function1/Constant/Constant.C | 45 +- .../functions/Function1/Constant/Constant.H | 26 +- .../functions/Function1/Constant/ConstantI.H | 6 +- .../functions/Function1/Function1/Function1.C | 101 ++- .../functions/Function1/Function1/Function1.H | 46 +- .../Function1/Function1/Function1New.C | 4 +- .../functions/Function1/One/OneConstant.C | 35 +- .../functions/Function1/One/OneConstant.H | 24 +- .../functions/Function1/One/OneConstantI.H | 6 +- .../PolynomialEntry/PolynomialEntry.C | 20 +- .../PolynomialEntry/PolynomialEntry.H | 8 +- .../Function1/{ramp/ramp.C => Ramp/Ramp.C} | 16 +- .../Function1/{ramp/ramp.H => Ramp/Ramp.H} | 31 +- .../functions/Function1/Scale/Scale.C | 14 +- .../functions/Function1/Scale/Scale.H | 12 +- .../functions/Function1/Scale/ScaleI.H | 4 +- .../functions/Function1/Sine/Sine.C | 14 +- .../functions/Function1/Sine/Sine.H | 8 +- .../functions/Function1/Sine/SineI.H | 4 +- .../functions/Function1/Square/Square.C | 14 +- .../functions/Function1/Square/Square.H | 8 +- .../functions/Function1/Square/SquareI.H | 4 +- .../functions/Function1/Table/Table.C | 44 +- .../functions/Function1/Table/Table.H | 26 +- .../functions/Function1/Table/TableBase.C | 142 ++-- .../functions/Function1/Table/TableBase.H | 45 +- .../functions/Function1/Table/tableBase.C | 10 +- .../functions/Function1/Table/tableBase.H | 4 +- .../functions/Function1/TableFile/TableFile.C | 62 +- .../functions/Function1/TableFile/TableFile.H | 54 +- .../TableReader/Csv/CsvTableReader.C} | 131 ++-- .../TableReader/Csv/CsvTableReader.H} | 90 ++- .../TableReader/Foam/FoamTableReader.C} | 61 +- .../TableReader/Foam/FoamTableReader.H} | 74 +- .../TableReader/TableReader/TableReader.C} | 63 +- .../TableReader/TableReader/TableReader.H} | 99 +-- .../TableFile/TableReader/makeTableReaders.C} | 18 +- .../functions/Function1/Uniform/Uniform.C | 4 +- .../functions/Function1/Uniform/Uniform.H | 6 +- .../functions/Function1/Zero/ZeroConstant.C | 10 +- .../functions/Function1/Zero/ZeroConstant.H | 8 +- .../functions/Function1/Zero/ZeroConstantI.H | 6 +- .../Function1/halfCosineRamp/halfCosineRamp.C | 10 +- .../Function1/halfCosineRamp/halfCosineRamp.H | 12 +- .../halfCosineRamp/halfCosineRampI.H | 4 +- .../Function1/linearRamp/linearRamp.C | 10 +- .../Function1/linearRamp/linearRamp.H | 12 +- .../Function1/linearRamp/linearRampI.H | 9 +- .../functions/Function1/makeFunction1s.C | 18 - .../Function1/quadraticRamp/quadraticRamp.C | 10 +- .../Function1/quadraticRamp/quadraticRamp.H | 12 +- .../Function1/quadraticRamp/quadraticRampI.H | 4 +- .../quarterCosineRamp/quarterCosineRamp.C | 10 +- .../quarterCosineRamp/quarterCosineRamp.H | 12 +- .../quarterCosineRamp/quarterCosineRampI.H | 4 +- .../quarterSineRamp/quarterSineRamp.C | 10 +- .../quarterSineRamp/quarterSineRamp.H | 12 +- .../quarterSineRamp/quarterSineRampI.H | 4 +- .../functions/Function1/ramp/rampI.H | 30 - .../Function1/reverseRamp/reverseRamp.C | 16 +- .../Function1/reverseRamp/reverseRamp.H | 12 +- .../Function1/reverseRamp/reverseRampI.H | 4 +- .../displacementLayeredMotionMotionSolver.C | 6 +- ...lindricalInletVelocityFvPatchVectorField.H | 2 +- .../fanPressureFvPatchScalarField.C | 12 +- .../fanPressureFvPatchScalarField.H | 52 +- .../fanPressureJumpFvPatchScalarField.H | 24 +- .../derived/fixedMean/fixedMeanFvPatchField.H | 2 +- .../fixedMeanOutletInletFvPatchField.H | 2 +- .../fixedProfile/fixedProfileFvPatchField.C | 39 +- .../fixedProfile/fixedProfileFvPatchField.H | 51 +- .../flowRateInletVelocityFvPatchVectorField.H | 4 +- ...flowRateOutletVelocityFvPatchVectorField.H | 4 +- ...ureInletOutletVelocityFvPatchVectorField.H | 2 +- ...ureInletOutletVelocityFvPatchVectorField.H | 2 +- .../rotatingTotalPressureFvPatchScalarField.H | 2 +- .../rotatingWallVelocityFvPatchVectorField.H | 4 +- ...lFlowRateInletVelocityFvPatchVectorField.H | 2 +- .../swirlInletVelocityFvPatchVectorField.H | 2 +- .../timeVaryingMappedFixedValueFvPatchField.H | 2 +- .../timeVaryingMappedFvPatchField.H | 2 +- ...ranslatingWallVelocityFvPatchVectorField.H | 4 +- .../uniformFixedGradientFvPatchField.H | 2 +- .../uniformFixedValueFvPatchField.H | 2 +- .../uniformInletOutletFvPatchField.H | 2 +- .../uniformJump/uniformJumpFvPatchField.H | 2 +- .../uniformJumpAMIFvPatchField.H | 2 +- .../uniformTotalPressureFvPatchScalarField.H | 2 +- ...tFlowRateInletVelocityFvPatchVectorField.H | 4 +- .../CrankNicolsonDdtScheme.C | 4 +- .../setTimeStep/setTimeStepFunctionObject.H | 1 + .../waveDisplacementPointPatchVectorField.C | 12 +- .../ConeInjection/ConeInjection.C | 4 +- .../blackBodyEmission/blackBodyEmission.C | 211 +++--- .../blackBodyEmission/blackBodyEmission.H | 4 +- ...bedTemperatureDependentContactAngleForce.H | 2 +- .../temperatureDependentContactAngleForce.H | 2 +- .../rigidBodyMeshMotion/rigidBodyMeshMotion.C | 2 +- .../rigidBodyMeshMotion/rigidBodyMeshMotion.H | 2 +- .../tabulatedAxialAngularSpring.C | 11 +- .../tabulatedAxialAngularSpring.H | 9 +- .../waveSuperposition/newWaveSuperposition.C | 1 + .../waveSuperposition/waveSuperposition.C | 1 + .../constant/phaseProperties | 3 +- .../RAS/wallBoiling/constant/phaseProperties | 3 +- .../wallBoilingIATE/constant/phaseProperties | 3 +- .../constant/phaseProperties | 3 +- .../laminar/titaniaSynthesis/0/T.particles | 3 +- .../laminar/titaniaSynthesis/0/T.vapor | 3 +- .../titaniaSynthesisSurface/0/T.particles | 3 +- .../laminar/titaniaSynthesisSurface/0/T.vapor | 3 +- 130 files changed, 1156 insertions(+), 2863 deletions(-) delete mode 100644 src/OpenFOAM/fields/pointPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValuePointPatchField.C delete mode 100644 src/OpenFOAM/fields/pointPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValuePointPatchField.H delete mode 100644 src/OpenFOAM/fields/pointPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValuePointPatchFields.C delete mode 100644 src/OpenFOAM/fields/pointPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValuePointPatchFields.H delete mode 100644 src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C delete mode 100644 src/OpenFOAM/interpolations/interpolationTable/interpolationTable.H delete mode 100644 src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.C delete mode 100644 src/OpenFOAM/interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReaders.C delete mode 100644 src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReaders.C delete mode 100644 src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReaders.H delete mode 100644 src/OpenFOAM/primitives/functions/Function1/CSV/CSV.H rename src/OpenFOAM/primitives/functions/Function1/{ramp/ramp.C => Ramp/Ramp.C} (82%) rename src/OpenFOAM/primitives/functions/Function1/{ramp/ramp.H => Ramp/Ramp.H} (88%) rename src/OpenFOAM/primitives/functions/Function1/{CSV/CSV.C => TableFile/TableReader/Csv/CsvTableReader.C} (72%) rename src/OpenFOAM/{interpolations/interpolationTable/tableReaders/csv/csvTableReader.H => primitives/functions/Function1/TableFile/TableReader/Csv/CsvTableReader.H} (60%) rename src/OpenFOAM/{interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReader.C => primitives/functions/Function1/TableFile/TableReader/Foam/FoamTableReader.C} (70%) rename src/OpenFOAM/{interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReader.H => primitives/functions/Function1/TableFile/TableReader/Foam/FoamTableReader.H} (67%) rename src/OpenFOAM/{interpolations/interpolationTable/tableReaders/tableReader.C => primitives/functions/Function1/TableFile/TableReader/TableReader/TableReader.C} (60%) rename src/OpenFOAM/{interpolations/interpolationTable/tableReaders/tableReader.H => primitives/functions/Function1/TableFile/TableReader/TableReader/TableReader.H} (57%) rename src/OpenFOAM/{interpolations/interpolationTable/tableReaders/csv/csvTableReaders.C => primitives/functions/Function1/TableFile/TableReader/makeTableReaders.C} (69%) delete mode 100644 src/OpenFOAM/primitives/functions/Function1/ramp/rampI.H diff --git a/applications/solvers/multiphase/reactingEulerFoam/interfacialCompositionModels/saturationModels/function1/function1.H b/applications/solvers/multiphase/reactingEulerFoam/interfacialCompositionModels/saturationModels/function1/function1.H index 91e4a57cac..1e602e6729 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/interfacialCompositionModels/saturationModels/function1/function1.H +++ b/applications/solvers/multiphase/reactingEulerFoam/interfacialCompositionModels/saturationModels/function1/function1.H @@ -52,16 +52,16 @@ Description \verbatim type function1; - - function csvFile; + function tableFile; functionCoeffs { + file "filename.csv"; + format csv; nHeaderLine 1; refColumn 0; componentColumns (1); separator ","; mergeSeparators no; - file "filename.csv"; outOfBounds clamp; interpolationScheme linear; }; diff --git a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/populationBalanceModel/binaryBreakupModels/LuoSvendsen/LuoSvendsen.C b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/populationBalanceModel/binaryBreakupModels/LuoSvendsen/LuoSvendsen.C index 0b15ae2877..3aaa762cac 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/populationBalanceModel/binaryBreakupModels/LuoSvendsen/LuoSvendsen.C +++ b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/populationBalanceModel/binaryBreakupModels/LuoSvendsen/LuoSvendsen.C @@ -26,6 +26,7 @@ License #include "LuoSvendsen.H" #include "addToRunTimeSelectionTable.H" #include "phaseCompressibleTurbulenceModel.H" +#include "linearInterpolationWeights.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -116,27 +117,30 @@ Foam::diameterModels::binaryBreakupModels::LuoSvendsen::LuoSvendsen } gammaUpperReg2by11_ = - new interpolationTable + new Function1s::Table ( - gammaUpperReg2by11Table, - interpolationTable::CLAMP, - "gamma2by11" + "gamma2by11", + Function1s::tableBase::boundsHandling::clamp, + linearInterpolationWeights::typeName, + gammaUpperReg2by11Table ); gammaUpperReg5by11_ = - new interpolationTable + new Function1s::Table ( - gammaUpperReg5by11Table, - interpolationTable::CLAMP, - "gamma5by11" + "gamma5by11", + Function1s::tableBase::boundsHandling::clamp, + linearInterpolationWeights::typeName, + gammaUpperReg5by11Table ); gammaUpperReg8by11_ = - new interpolationTable + new Function1s::Table ( - gammaUpperReg8by11Table, - interpolationTable::CLAMP, - "gamma8by11" + "gamma8by11", + Function1s::tableBase::boundsHandling::clamp, + linearInterpolationWeights::typeName, + gammaUpperReg8by11Table ); } @@ -194,8 +198,8 @@ Foam::diameterModels::binaryBreakupModels::LuoSvendsen::addToBinaryBreakupRate integral[celli] *= 2.0*pow(b[celli], 3.0/11.0)*tgamma(5.0/11.0) *( - gammaUpperReg5by11_()(b[celli]) - - gammaUpperReg5by11_()(tMin[celli]) + gammaUpperReg5by11_->value(b[celli]) + - gammaUpperReg5by11_->value(tMin[celli]) ); } diff --git a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/populationBalanceModel/binaryBreakupModels/LuoSvendsen/LuoSvendsen.H b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/populationBalanceModel/binaryBreakupModels/LuoSvendsen/LuoSvendsen.H index 930c3a48ad..69fcba977b 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/populationBalanceModel/binaryBreakupModels/LuoSvendsen/LuoSvendsen.H +++ b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/populationBalanceModel/binaryBreakupModels/LuoSvendsen/LuoSvendsen.H @@ -135,7 +135,7 @@ SourceFiles #define LuoSvendsen_H #include "binaryBreakupModel.H" -#include "interpolationTable.H" +#include "Table.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -159,13 +159,13 @@ private: // Private Data //- Interpolation table of Q(a,z) for a=2/11 - autoPtr> gammaUpperReg2by11_; + autoPtr> gammaUpperReg2by11_; //- Interpolation table of Q(a,z) for a=5/11 - autoPtr> gammaUpperReg5by11_; + autoPtr> gammaUpperReg5by11_; //- Interpolation table of Q(a,z) for a=8/11 - autoPtr> gammaUpperReg8by11_; + autoPtr> gammaUpperReg8by11_; //- Empirical constant, defaults to 0.923 dimensionedScalar C4_; diff --git a/applications/utilities/postProcessing/noise/noise.C b/applications/utilities/postProcessing/noise/noise.C index f75561dd6c..1d0f51a336 100644 --- a/applications/utilities/postProcessing/noise/noise.C +++ b/applications/utilities/postProcessing/noise/noise.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -30,7 +30,7 @@ Description Control settings are read from the $FOAM_CASE/system/noiseDict dictionary, or user-specified dictionary using the -dict option. Pressure data is - read using a CSV reader: + read using a TableFile Function1: Usage \verbatim @@ -72,7 +72,7 @@ Usage - one-third-octave-band pressure spectrum See also - CSV.H + TableFile.H noiseFFT.H \*---------------------------------------------------------------------------*/ @@ -81,7 +81,7 @@ See also #include "noiseFFT.H" #include "argList.H" #include "Time.H" -#include "CSV.H" +#include "TableFile.H" #include "IOdictionary.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -134,7 +134,7 @@ int main(int argc, char *argv[]) #include "createFields.H" Info<< "Reading data file" << endl; - FieldFunction1> pData + Function1s::TableFile pData ( "pressure", dict.subDict("pressureData") diff --git a/etc/controlDict b/etc/controlDict index aff6dfd36e..3b61f95477 100644 --- a/etc/controlDict +++ b/etc/controlDict @@ -839,10 +839,7 @@ DebugSwitches thermophysicalFunction 0; time 0; timeVaryingAlphaContactAngle 0; - timeVaryingFlowRateInletVelocity 0; timeVaryingMappedFixedValue 0; - timeVaryingTotalPressure 0; - timeVaryingUniformFixedValue 0; timer 0; topoAction 0; topoCellLooper 0; diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 3653504ddc..38ba302a12 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -90,7 +90,6 @@ primitives/triad/triad.C /* Run-time selectable functions */ primitives/functions/Function1/makeFunction1s.C -primitives/functions/Function1/ramp/ramp.C primitives/functions/Function1/reverseRamp/reverseRamp.C primitives/functions/Function1/linearRamp/linearRamp.C primitives/functions/Function1/quadraticRamp/quadraticRamp.C @@ -98,6 +97,7 @@ primitives/functions/Function1/quarterSineRamp/quarterSineRamp.C primitives/functions/Function1/quarterCosineRamp/quarterCosineRamp.C primitives/functions/Function1/halfCosineRamp/halfCosineRamp.C primitives/functions/Function1/Table/tableBase.C +primitives/functions/Function1/TableFile/TableReader/makeTableReaders.C primitives/subModelBase/subModelBase.C @@ -681,7 +681,6 @@ derivedPointPatchFields = $(pointPatchFields)/derived $(derivedPointPatchFields)/slip/slipPointPatchFields.C $(derivedPointPatchFields)/fixedNormalSlip/fixedNormalSlipPointPatchFields.C $(derivedPointPatchFields)/uniformFixedValue/uniformFixedValuePointPatchFields.C -$(derivedPointPatchFields)/timeVaryingUniformFixedValue/timeVaryingUniformFixedValuePointPatchFields.C $(derivedPointPatchFields)/codedFixedValue/codedFixedValuePointPatchFields.C fields/GeometricFields/pointFields/pointFields.C @@ -693,10 +692,6 @@ interpolations = interpolations interpolation = $(interpolations)/interpolation $(interpolations)/patchToPatchInterpolation/PatchToPatchInterpolationName.C -$(interpolations)/interpolationTable/tableReaders/tableReaders.C -$(interpolations)/interpolationTable/tableReaders/openFoam/openFoamTableReaders.C -$(interpolations)/interpolationTable/tableReaders/csv/csvTableReaders.C - interpolationWeights = $(interpolations)/interpolationWeights $(interpolationWeights)/interpolationWeights/interpolationWeights.C $(interpolationWeights)/linearInterpolationWeights/linearInterpolationWeights.C diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValuePointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValuePointPatchField.C deleted file mode 100644 index 6d330bda8c..0000000000 --- a/src/OpenFOAM/fields/pointPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValuePointPatchField.C +++ /dev/null @@ -1,132 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "timeVaryingUniformFixedValuePointPatchField.H" -#include "Time.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template -Foam:: -timeVaryingUniformFixedValuePointPatchField:: -timeVaryingUniformFixedValuePointPatchField -( - const pointPatch& p, - const DimensionedField& iF -) -: - fixedValuePointPatchField(p, iF) -{} - - -template -Foam:: -timeVaryingUniformFixedValuePointPatchField:: -timeVaryingUniformFixedValuePointPatchField -( - const timeVaryingUniformFixedValuePointPatchField& ptf, - const pointPatch& p, - const DimensionedField& iF, - const pointPatchFieldMapper& mapper -) -: - fixedValuePointPatchField(ptf, p, iF, mapper), - timeSeries_(ptf.timeSeries_) -{ - this->operator==(timeSeries_(this->db().time().timeOutputValue())); -} - - -template -Foam:: -timeVaryingUniformFixedValuePointPatchField:: -timeVaryingUniformFixedValuePointPatchField -( - const pointPatch& p, - const DimensionedField& iF, - const dictionary& dict -) -: - fixedValuePointPatchField(p, iF), - timeSeries_(dict) -{ - this->operator==(timeSeries_(this->db().time().timeOutputValue())); -} - - -template -Foam:: -timeVaryingUniformFixedValuePointPatchField:: -timeVaryingUniformFixedValuePointPatchField -( - const timeVaryingUniformFixedValuePointPatchField& ptf -) -: - fixedValuePointPatchField(ptf), - timeSeries_(ptf.timeSeries_) -{} - - -template -Foam:: -timeVaryingUniformFixedValuePointPatchField:: -timeVaryingUniformFixedValuePointPatchField -( - const timeVaryingUniformFixedValuePointPatchField& ptf, - const DimensionedField& iF -) -: - fixedValuePointPatchField(ptf, iF), - timeSeries_(ptf.timeSeries_) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -void Foam::timeVaryingUniformFixedValuePointPatchField::updateCoeffs() -{ - if (this->updated()) - { - return; - } - - this->operator==(timeSeries_(this->db().time().timeOutputValue())); - fixedValuePointPatchField::updateCoeffs(); -} - - -template -void Foam::timeVaryingUniformFixedValuePointPatchField::write -( - Ostream& os -) const -{ - fixedValuePointPatchField::write(os); - timeSeries_.write(os); -} - - -// ************************************************************************* // diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValuePointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValuePointPatchField.H deleted file mode 100644 index 896d7becfa..0000000000 --- a/src/OpenFOAM/fields/pointPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValuePointPatchField.H +++ /dev/null @@ -1,167 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::timeVaryingUniformFixedValuePointPatchField - -Description - A time-varying form of a uniform fixed value boundary condition. - -See also - Foam::timeVaryingUniformFixedValueFvField - -SourceFiles - timeVaryingUniformFixedValuePointPatchField.C - -\*---------------------------------------------------------------------------*/ - -#ifndef timeVaryingUniformFixedValuePointPatchField_H -#define timeVaryingUniformFixedValuePointPatchField_H - -#include "fixedValuePointPatchField.H" -#include "interpolationTable.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class timeVaryingUniformFixedValuePointPatchField Declaration -\*---------------------------------------------------------------------------*/ - -template -class timeVaryingUniformFixedValuePointPatchField -: - public fixedValuePointPatchField -{ - // Private Data - - //- The time series being used, including the bounding treatment - interpolationTable timeSeries_; - - -public: - - //- Runtime type information - TypeName("timeVaryingUniformFixedValue"); - - - // Constructors - - //- Construct from patch and internal field - timeVaryingUniformFixedValuePointPatchField - ( - const pointPatch&, - const DimensionedField& - ); - - //- Construct from patch, internal field and dictionary - timeVaryingUniformFixedValuePointPatchField - ( - const pointPatch&, - const DimensionedField&, - const dictionary& - ); - - //- Construct by mapping given patch field onto a new patch - timeVaryingUniformFixedValuePointPatchField - ( - const timeVaryingUniformFixedValuePointPatchField&, - const pointPatch&, - const DimensionedField&, - const pointPatchFieldMapper& - ); - - //- Copy constructor - timeVaryingUniformFixedValuePointPatchField - ( - const timeVaryingUniformFixedValuePointPatchField& - ); - - //- Construct and return a clone - virtual autoPtr> clone() const - { - return autoPtr> - ( - new timeVaryingUniformFixedValuePointPatchField(*this) - ); - } - - //- Copy constructor setting internal field reference - timeVaryingUniformFixedValuePointPatchField - ( - const timeVaryingUniformFixedValuePointPatchField&, - const DimensionedField& - ); - - //- Construct and return a clone setting internal field reference - virtual autoPtr> clone - ( - const DimensionedField& iF - ) const - { - return autoPtr> - ( - new timeVaryingUniformFixedValuePointPatchField(*this, iF) - ); - } - - - // Member Functions - - // Access - - //- Return the time series used - const interpolationTable& timeSeries() const - { - return timeSeries_; - } - - - // Evaluation functions - - //- Update the coefficients associated with the patch field - virtual void updateCoeffs(); - - - //- Write - virtual void write(Ostream&) const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository - #include "timeVaryingUniformFixedValuePointPatchField.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValuePointPatchFields.C b/src/OpenFOAM/fields/pointPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValuePointPatchFields.C deleted file mode 100644 index 690a413662..0000000000 --- a/src/OpenFOAM/fields/pointPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValuePointPatchFields.C +++ /dev/null @@ -1,43 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "timeVaryingUniformFixedValuePointPatchFields.H" -#include "pointPatchFields.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -makePointPatchFields(timeVaryingUniformFixedValue); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValuePointPatchFields.H b/src/OpenFOAM/fields/pointPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValuePointPatchFields.H deleted file mode 100644 index a8e2920d65..0000000000 --- a/src/OpenFOAM/fields/pointPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValuePointPatchFields.H +++ /dev/null @@ -1,57 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -InClass - Foam::timeVaryingUniformFixedValuePointPatchFields - -Description - -SourceFiles - timeVaryingUniformFixedValuePointPatchFields.C - -\*---------------------------------------------------------------------------*/ - -#ifndef timeVaryingUniformFixedValuePointPatchFields_H -#define timeVaryingUniformFixedValuePointPatchFields_H - -#include "timeVaryingUniformFixedValuePointPatchField.H" -#include "fieldTypes.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -makePointPatchFieldTypedefs(timeVaryingUniformFixedValue); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/interpolations/interpolation2DTable/interpolation2DTable.C b/src/OpenFOAM/interpolations/interpolation2DTable/interpolation2DTable.C index 2781e32f4a..76c09514f4 100644 --- a/src/OpenFOAM/interpolations/interpolation2DTable/interpolation2DTable.C +++ b/src/OpenFOAM/interpolations/interpolation2DTable/interpolation2DTable.C @@ -23,31 +23,7 @@ License \*---------------------------------------------------------------------------*/ -//#include "IFstream.H" -#include "openFoamTableReader.H" - -// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // - -template -void Foam::interpolation2DTable::readTable() -{ - fileName fName(fileName_); - fName.expand(); - - // Read data from file - reader_()(fName, *this); - - if (this->empty()) - { - FatalErrorInFunction - << "table read from " << fName << " is empty" << nl - << exit(FatalError); - } - - // Check that the data are in ascending order - checkOrder(); -} - +#include "FoamTableReader.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -56,7 +32,7 @@ Foam::interpolation2DTable::interpolation2DTable() : List>>>(), boundsHandling_(interpolation2DTable::WARN), - fileName_("fileNameIsUndefined"), + fileName_(fileName::null), reader_(nullptr) {} @@ -82,9 +58,10 @@ Foam::interpolation2DTable::interpolation2DTable(const fileName& fName) List>>>(), boundsHandling_(interpolation2DTable::WARN), fileName_(fName), - reader_(new openFoamTableReader(dictionary())) + reader_(new TableReaders::Foam(dictionary())) { - readTable(); + reader_()(fileName_, *this); + checkOrder(); } @@ -94,9 +71,10 @@ Foam::interpolation2DTable::interpolation2DTable(const dictionary& dict) List>>>(), boundsHandling_(wordToBoundsHandling(dict.lookup("outOfBounds"))), fileName_(dict.lookup("file")), - reader_(tableReader::New(dict)) + reader_(new TableReaders::Foam(dictionary())) { - readTable(); + reader_()(fileName_, *this); + checkOrder(); } @@ -108,8 +86,7 @@ Foam::interpolation2DTable::interpolation2DTable : List>>>(interpTable), boundsHandling_(interpTable.boundsHandling_), - fileName_(interpTable.fileName_), - reader_(interpTable.reader_) // note: steals reader. Used in write(). + fileName_(interpTable.fileName_) {} @@ -450,6 +427,7 @@ void Foam::interpolation2DTable::write(Ostream& os) const { writeEntry(os, "file", fileName_); writeEntry(os, "outOfBounds", boundsHandlingToWord(boundsHandling_)); + reader_.write(os); *this >> os; } diff --git a/src/OpenFOAM/interpolations/interpolation2DTable/interpolation2DTable.H b/src/OpenFOAM/interpolations/interpolation2DTable/interpolation2DTable.H index d703015d11..ba08dd8fb2 100644 --- a/src/OpenFOAM/interpolations/interpolation2DTable/interpolation2DTable.H +++ b/src/OpenFOAM/interpolations/interpolation2DTable/interpolation2DTable.H @@ -38,7 +38,7 @@ SourceFiles #include "List.H" #include "Tuple2.H" -#include "tableReader.H" +#include "TableReader.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -80,15 +80,12 @@ private: //- File name fileName fileName_; - //- The actual reader - autoPtr> reader_; + //- The reader + autoPtr> reader_; // Private Member Functions - //- Read the table of data from file - void readTable(); - //- Return interpolated value in List Type interpolateValue ( diff --git a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C b/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C deleted file mode 100644 index 18ab928db9..0000000000 --- a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C +++ /dev/null @@ -1,634 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "interpolationTable.H" -#include "openFoamTableReader.H" - -// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // - -template -void Foam::interpolationTable::readTable() -{ - // preserve the original (unexpanded) fileName to avoid absolute paths - // appearing subsequently in the write() method - fileName fName(fileName_); - - fName.expand(); - - // Read data from file - reader_()(fName, *this); - - if (this->empty()) - { - FatalErrorInFunction - << "table read from " << fName << " is empty" << nl - << exit(FatalError); - } - - // Check that the data are okay - check(); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template -Foam::interpolationTable::interpolationTable() -: - List>(), - boundsHandling_(interpolationTable::WARN), - fileName_("fileNameIsUndefined"), - reader_(nullptr) -{} - - -template -Foam::interpolationTable::interpolationTable -( - const List>& values, - const boundsHandling bounds, - const fileName& fName -) -: - List>(values), - boundsHandling_(bounds), - fileName_(fName), - reader_(nullptr) -{} - - -template -Foam::interpolationTable::interpolationTable(const fileName& fName) -: - List>(), - boundsHandling_(interpolationTable::WARN), - fileName_(fName), - reader_(new openFoamTableReader(dictionary())) -{ - readTable(); -} - - -template -Foam::interpolationTable::interpolationTable(const dictionary& dict) -: - List>(), - boundsHandling_(wordToBoundsHandling(dict.lookup("outOfBounds"))), - fileName_(dict.lookup("file")), - reader_(tableReader::New(dict)) -{ - readTable(); -} - - -template -Foam::interpolationTable::interpolationTable -( - const interpolationTable& interpTable -) -: - List>(interpTable), - boundsHandling_(interpTable.boundsHandling_), - fileName_(interpTable.fileName_), - reader_(interpTable.reader_) // note: steals reader. Used in write(). -{} - - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -Foam::word Foam::interpolationTable::boundsHandlingToWord -( - const boundsHandling& bound -) const -{ - word enumName("warn"); - - switch (bound) - { - case interpolationTable::ERROR: - { - enumName = "error"; - break; - } - case interpolationTable::WARN: - { - enumName = "warn"; - break; - } - case interpolationTable::CLAMP: - { - enumName = "clamp"; - break; - } - case interpolationTable::REPEAT: - { - enumName = "repeat"; - break; - } - } - - return enumName; -} - - -template -typename Foam::interpolationTable::boundsHandling -Foam::interpolationTable::wordToBoundsHandling -( - const word& bound -) const -{ - if (bound == "error") - { - return interpolationTable::ERROR; - } - else if (bound == "warn") - { - return interpolationTable::WARN; - } - else if (bound == "clamp") - { - return interpolationTable::CLAMP; - } - else if (bound == "repeat") - { - return interpolationTable::REPEAT; - } - else - { - WarningInFunction - << "bad outOfBounds specifier " << bound << " using 'warn'" << endl; - - return interpolationTable::WARN; - } -} - - -template -typename Foam::interpolationTable::boundsHandling -Foam::interpolationTable::outOfBounds -( - const boundsHandling& bound -) -{ - boundsHandling prev = boundsHandling_; - boundsHandling_ = bound; - return prev; -} - - -template -void Foam::interpolationTable::check() const -{ - label n = this->size(); - scalar prevValue = List>::operator[](0).first(); - - for (label i=1; i>::operator[](i).first(); - - // avoid duplicate values (divide-by-zero error) - if (currValue <= prevValue) - { - FatalErrorInFunction - << "out-of-order value: " - << currValue << " at index " << i << nl - << exit(FatalError); - } - prevValue = currValue; - } -} - - -template -void Foam::interpolationTable::write(Ostream& os) const -{ - writeEntry(os, "file", fileName_); - writeEntry(os, "outOfBounds", boundsHandlingToWord(boundsHandling_)); - if (reader_.valid()) - { - reader_->write(os); - } -} - - -template -Type Foam::interpolationTable::rateOfChange(const scalar value) const -{ - label n = this->size(); - - if (n <= 1) - { - // There are not enough entries to provide a rate of change - return 0; - } - - scalar minLimit = List>::operator[](0).first(); - scalar maxLimit = List>::operator[](n-1).first(); - scalar lookupValue = value; - - if (lookupValue < minLimit) - { - switch (boundsHandling_) - { - case interpolationTable::ERROR: - { - FatalErrorInFunction - << "value (" << lookupValue << ") underflow" << nl - << exit(FatalError); - break; - } - case interpolationTable::WARN: - { - WarningInFunction - << "value (" << lookupValue << ") underflow" << nl - << " Zero rate of change." - << endl; - // fall-through to 'CLAMP' - [[fallthrough]]; - } - case interpolationTable::CLAMP: - { - return 0; - break; - } - case interpolationTable::REPEAT: - { - // adjust lookupValue to >= minLimit - scalar span = maxLimit-minLimit; - lookupValue = fmod(lookupValue-minLimit, span) + minLimit; - break; - } - } - } - else if (lookupValue >= maxLimit) - { - switch (boundsHandling_) - { - case interpolationTable::ERROR: - { - FatalErrorInFunction - << "value (" << lookupValue << ") overflow" << nl - << exit(FatalError); - break; - } - case interpolationTable::WARN: - { - WarningInFunction - << "value (" << lookupValue << ") overflow" << nl - << " Zero rate of change." - << endl; - // fall-through to 'CLAMP' - [[fallthrough]]; - } - case interpolationTable::CLAMP: - { - return 0; - break; - } - case interpolationTable::REPEAT: - { - // adjust lookupValue <= maxLimit - scalar span = maxLimit-minLimit; - lookupValue = fmod(lookupValue-minLimit, span) + minLimit; - break; - } - } - } - - label lo = 0; - label hi = 0; - - // look for the correct range - for (label i = 0; i < n; ++i) - { - if (lookupValue >= List>::operator[](i).first()) - { - lo = hi = i; - } - else - { - hi = i; - break; - } - } - - if (lo == hi) - { - // we are at the end of the table - or there is only a single entry - return 0; - } - else if (hi == 0) - { - // this treatment should should only occur under these conditions: - // -> the 'REPEAT' treatment - // -> (0 <= value <= minLimit) - // -> minLimit > 0 - // Use the value at maxLimit as the value for value=0 - lo = n - 1; - - return - ( - ( - List>::operator[](hi).second() - - List>::operator[](lo).second() - ) - /( - List>::operator[](hi).first() - + minLimit - - List>::operator[](lo).first() - ) - ); - } - else - { - // normal rate of change - return - ( - ( - List>::operator[](hi).second() - - List>::operator[](lo).second() - ) - /( - List>::operator[](hi).first() - - List>::operator[](lo).first() - ) - ); - } -} - - -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // - -template -void Foam::interpolationTable::operator= -( - const interpolationTable& interpTable -) -{ - List>::operator=(interpTable); - boundsHandling_ = interpTable.boundsHandling_; - fileName_ = interpTable.fileName_; - reader_ = interpTable.reader_; // note: steals reader. Used in write(). -} - - -template -const Foam::Tuple2& -Foam::interpolationTable::operator[](const label i) const -{ - label ii = i; - label n = this->size(); - - if (n <= 1) - { - ii = 0; - } - else if (ii < 0) - { - switch (boundsHandling_) - { - case interpolationTable::ERROR: - { - FatalErrorInFunction - << "index (" << ii << ") underflow" << nl - << exit(FatalError); - break; - } - case interpolationTable::WARN: - { - WarningInFunction - << "index (" << ii << ") underflow" << nl - << " Continuing with the first entry" - << endl; - // fall-through to 'CLAMP' - [[fallthrough]]; - } - case interpolationTable::CLAMP: - { - ii = 0; - break; - } - case interpolationTable::REPEAT: - { - while (ii < 0) - { - ii += n; - } - break; - } - } - } - else if (ii >= n) - { - switch (boundsHandling_) - { - case interpolationTable::ERROR: - { - FatalErrorInFunction - << "index (" << ii << ") overflow" << nl - << exit(FatalError); - break; - } - case interpolationTable::WARN: - { - WarningInFunction - << "index (" << ii << ") overflow" << nl - << " Continuing with the last entry" - << endl; - // fall-through to 'CLAMP' - [[fallthrough]]; - } - case interpolationTable::CLAMP: - { - ii = n - 1; - break; - } - case interpolationTable::REPEAT: - { - while (ii >= n) - { - ii -= n; - } - break; - } - } - } - - return List>::operator[](ii); -} - - -template -Type Foam::interpolationTable::operator()(const scalar value) const -{ - label n = this->size(); - - if (n <= 1) - { - return List>::operator[](0).second(); - } - - scalar minLimit = List>::operator[](0).first(); - scalar maxLimit = List>::operator[](n-1).first(); - scalar lookupValue = value; - - if (lookupValue < minLimit) - { - switch (boundsHandling_) - { - case interpolationTable::ERROR: - { - FatalErrorInFunction - << "value (" << lookupValue << ") underflow" << nl - << exit(FatalError); - break; - } - case interpolationTable::WARN: - { - WarningInFunction - << "value (" << lookupValue << ") underflow" << nl - << " Continuing with the first entry" - << endl; - // fall-through to 'CLAMP' - [[fallthrough]]; - } - case interpolationTable::CLAMP: - { - return List>::operator[](0).second(); - break; - } - case interpolationTable::REPEAT: - { - // adjust lookupValue to >= minLimit - scalar span = maxLimit-minLimit; - lookupValue = fmod(lookupValue-minLimit, span) + minLimit; - break; - } - } - } - else if (lookupValue >= maxLimit) - { - switch (boundsHandling_) - { - case interpolationTable::ERROR: - { - FatalErrorInFunction - << "value (" << lookupValue << ") overflow" << nl - << exit(FatalError); - break; - } - case interpolationTable::WARN: - { - WarningInFunction - << "value (" << lookupValue << ") overflow" << nl - << " Continuing with the last entry" - << endl; - // fall-through to 'CLAMP' - [[fallthrough]]; - } - case interpolationTable::CLAMP: - { - return List>::operator[](n-1).second(); - break; - } - case interpolationTable::REPEAT: - { - // adjust lookupValue <= maxLimit - scalar span = maxLimit-minLimit; - lookupValue = fmod(lookupValue-minLimit, span) + minLimit; - break; - } - } - } - - label lo = 0; - label hi = 0; - - // look for the correct range - for (label i = 0; i < n; ++i) - { - if (lookupValue >= List>::operator[](i).first()) - { - lo = hi = i; - } - else - { - hi = i; - break; - } - } - - if (lo == hi) - { - // we are at the end of the table - or there is only a single entry - return List>::operator[](hi).second(); - } - else if (hi == 0) - { - // this treatment should should only occur under these conditions: - // -> the 'REPEAT' treatment - // -> (0 <= value <= minLimit) - // -> minLimit > 0 - // Use the value at maxLimit as the value for value=0 - lo = n - 1; - - return - ( - List>::operator[](lo).second() - + ( - List>::operator[](hi).second() - - List>::operator[](lo).second() - ) - *(lookupValue / minLimit) - ); - } - else - { - // normal interpolation - return - ( - List>::operator[](lo).second() - + ( - List>::operator[](hi).second() - - List>::operator[](lo).second() - ) - *( - lookupValue - - List>::operator[](lo).first() - ) - /( - List>::operator[](hi).first() - - List>::operator[](lo).first() - ) - ); - } -} - - -// ************************************************************************* // diff --git a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.H b/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.H deleted file mode 100644 index 3c9e7cde0e..0000000000 --- a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.H +++ /dev/null @@ -1,194 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::interpolationTable - -Description - An interpolation/look-up table of scalar vs \ values. - The reference scalar values must be monotonically increasing. - - The handling of out-of-bounds values depends on the current setting - of \c outOfBounds. - - If \c repeat is chosen for the out-of-bounds handling, the final time - value is treated as being equivalent to time=0 for the following periods. - - - The construct from dictionary reads a filename from a dictionary and - has an optional readerType. Default is to read OpenFOAM format. The only - other format is csv (comma separated values): - - Read csv format: - \verbatim - readerType csv; - file "$FOAM_CASE/constant/p0vsTime.csv"; - hasHeaderLine true; // skip first line - timeColumn 0; // time is in column 0 - valueColumns (1); // value starts in column 1 - \endverbatim - - -Note - - Accessing an empty list results in an error. - - Accessing a list with a single element always returns the same value. - -SourceFiles - interpolationTable.C - -\*---------------------------------------------------------------------------*/ - -#ifndef interpolationTable_H -#define interpolationTable_H - -#include "List.H" -#include "Tuple2.H" - -#include "tableReader.H" -#include "autoPtr.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class interpolationTable Declaration -\*---------------------------------------------------------------------------*/ - -template -class interpolationTable -: - public List> -{ -public: - - // Public data types - - //- Enumeration for handling out-of-bound values - enum boundsHandling - { - ERROR, //!< Exit with a FatalError - WARN, //!< Issue warning and clamp value (default) - CLAMP, //!< Clamp value to the start/end value - REPEAT //!< Treat as a repeating list - }; - - -private: - - // Private Data - - //- Enumeration for handling out-of-bound values - boundsHandling boundsHandling_; - - //- File name - fileName fileName_; - - //- The actual reader - autoPtr> reader_; - - // Private Member Functions - - //- Read the table of data from file - void readTable(); - - -public: - - // Constructors - - //- Construct null - interpolationTable(); - - //- Construct from components - interpolationTable - ( - const List>& values, - const boundsHandling bounds, - const fileName& fName - ); - - //- Construct given the name of the file containing the table of data - interpolationTable(const fileName& fName); - - //- Construct by reading the fileName and boundsHandling from dictionary - // and read the table from that file. - // This is a specialised constructor used by patchFields - interpolationTable(const dictionary& dict); - - //- Construct copy - interpolationTable(const interpolationTable& interpTable); - - - // Member Functions - - //- Return the out-of-bounds handling as a word - word boundsHandlingToWord(const boundsHandling& bound) const; - - //- Return the out-of-bounds handling as an enumeration - boundsHandling wordToBoundsHandling(const word& bound) const; - - //- Set the out-of-bounds handling from enum, return previous setting - boundsHandling outOfBounds(const boundsHandling& bound); - - //- Check that list is monotonically increasing - // Exit with a FatalError if there is a problem - void check() const; - - //- Write - void write(Ostream& os) const; - - //- Return the rate of change at the interpolation location - // for the give value - Type rateOfChange(const scalar) const; - - - // Member Operators - - //- Disallow default bitwise assignment - void operator=(const interpolationTable&); - - //- Return an element of constant Tuple2 - const Tuple2& operator[](const label) const; - - //- Return an interpolated value - Type operator()(const scalar) const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository - #include "interpolationTable.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.C b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.C deleted file mode 100644 index 54d2f05f49..0000000000 --- a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/csv/csvTableReader.C +++ /dev/null @@ -1,196 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "csvTableReader.H" -#include "fileOperation.H" -#include "DynamicList.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template -Foam::csvTableReader::csvTableReader(const dictionary& dict) -: - tableReader(dict), - headerLine_(readBool(dict.lookup("hasHeaderLine"))), - timeColumn_(readLabel(dict.lookup("timeColumn"))), - componentColumns_(dict.lookup("valueColumns")), - separator_(dict.lookupOrDefault("separator", string(","))[0]) -{ - if (componentColumns_.size() != pTraits::nComponents) - { - FatalErrorInFunction - << componentColumns_ << " does not have the expected length " - << pTraits::nComponents << endl - << exit(FatalError); - } -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template -Foam::csvTableReader::~csvTableReader() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -namespace Foam -{ - // doesn't recognize specialization otherwise - template<> - scalar csvTableReader::readValue(const List& split) - { - if (componentColumns_[0] >= split.size()) - { - FatalErrorInFunction - << "No column " << componentColumns_[0] << " in " - << split << endl - << exit(FatalError); - } - - return readScalar(IStringStream(split[componentColumns_[0]])()); - } - - - template - Type csvTableReader::readValue(const List& split) - { - Type result; - - for(label i = 0;i < pTraits::nComponents; i++) - { - if (componentColumns_[i] >= split.size()) - { - FatalErrorInFunction - << "No column " << componentColumns_[i] << " in " - << split << endl - << exit(FatalError); - } - - result[i] = readScalar - ( - IStringStream(split[componentColumns_[i]])() - ); - } - - return result; - } -} - - -template -void Foam::csvTableReader::operator() -( - const fileName& fName, - List>& data -) -{ - // IFstream in(fName); - autoPtr inPtr(fileHandler().NewIFstream(fName)); - ISstream& in = inPtr(); - - DynamicList> values; - - // Skip header - if (headerLine_) - { - string line; - in.getLine(line); - } - - while (in.good()) - { - string line; - in.getLine(line); - - DynamicList split; - - std::size_t pos = 0; - while (pos != std::string::npos) - { - std::size_t nPos = line.find(separator_, pos); - - if (nPos == std::string::npos) - { - split.append(line.substr(pos)); - pos=nPos; - } - else - { - split.append(line.substr(pos, nPos-pos)); - pos=nPos+1; - } - } - - if (split.size() <= 1) - { - break; - } - - scalar time = readScalar(IStringStream(split[timeColumn_])()); - Type value = readValue(split); - - values.append(Tuple2(time, value)); - } - - data.transfer(values); -} - - -template -void Foam::csvTableReader::operator() -( - const fileName& fName, - List>>>& data -) -{ - NotImplemented; -} - - -template -void Foam::csvTableReader::write(Ostream& os) const -{ - tableReader::write(os); - - writeEntry(os, "hasHeaderLine", headerLine_); - writeEntry(os, "timeColumn", timeColumn_); - - // Force writing labelList in ascii - writeKeyword(os, "valueColumns"); - if (os.format() == IOstream::BINARY) - { - os.format(IOstream::ASCII); - os << componentColumns_; - os.format(IOstream::BINARY); - } - os << token::END_STATEMENT << nl; - - writeEntry(os, "separator", string(separator_)); -} - - -// ************************************************************************* // diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReaders.C b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReaders.C deleted file mode 100644 index e0c3ef807a..0000000000 --- a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/openFoam/openFoamTableReaders.C +++ /dev/null @@ -1,37 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "openFoamTableReader.H" -#include "tableReaders.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - makeTableReaders(openFoamTableReader); -} - -// ************************************************************************* // diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReaders.C b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReaders.C deleted file mode 100644 index 1b06396a6c..0000000000 --- a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReaders.C +++ /dev/null @@ -1,50 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "tableReaders.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -#define defineTableReaderType(dataType) \ - defineNamedTemplateTypeNameAndDebug(tableReader, 0); \ - defineTemplatedRunTimeSelectionTable(tableReader, dictionary, dataType); - -defineTableReaderType(scalar); -defineTableReaderType(vector); -defineTableReaderType(sphericalTensor); -defineTableReaderType(symmTensor); -defineTableReaderType(tensor); - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReaders.H b/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReaders.H deleted file mode 100644 index 1b1fa624fa..0000000000 --- a/src/OpenFOAM/interpolations/interpolationTable/tableReaders/tableReaders.H +++ /dev/null @@ -1,75 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -SourceFiles - tableReaders.C - -\*---------------------------------------------------------------------------*/ - -#ifndef tableReaders_H -#define tableReaders_H - -#include "tableReader.H" -#include "fieldTypes.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -// Only used internally -#define makeTypeTableReadersTypeName(typeTableReader, dataType) \ - \ - defineNamedTemplateTypeNameAndDebug(typeTableReader, 0) - -// Sometimes used externally -#define makeTableReadersTypeName(typeTableReader) \ - \ - makeTypeTableReadersTypeName(typeTableReader, scalar); \ - makeTypeTableReadersTypeName(typeTableReader, vector); \ - makeTypeTableReadersTypeName(typeTableReader, sphericalTensor); \ - makeTypeTableReadersTypeName(typeTableReader, symmTensor); \ - makeTypeTableReadersTypeName(typeTableReader, tensor) - -// Define type info for single dataType template instantiation (eg, vector) -#define makeTableReaderType(typeTableReader, dataType) \ - \ - defineNamedTemplateTypeNameAndDebug(typeTableReader, 0); \ - addTemplatedToRunTimeSelectionTable \ - ( \ - tableReader, typeTableReader, dataType, dictionary \ - ) - - -// Define type info for scalar, vector etc. instantiations -#define makeTableReaders(typeTableReader) \ - \ - makeTableReaderType(typeTableReader, scalar); \ - makeTableReaderType(typeTableReader, vector); \ - makeTableReaderType(typeTableReader, sphericalTensor); \ - makeTableReaderType(typeTableReader, symmTensor); \ - makeTableReaderType(typeTableReader, tensor) - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.H b/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.H deleted file mode 100644 index 4d111d99d1..0000000000 --- a/src/OpenFOAM/primitives/functions/Function1/CSV/CSV.H +++ /dev/null @@ -1,169 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::Function1Types::CSV - -Description - Templated CSV function. - - Reference column is always a scalar, e.g. time. - - Usage: - \verbatim - csvFile; - Coeffs - { - nHeaderLine 4; // number of header lines - refColumn 0; // reference column index - componentColumns (1 2 3); // component column indices - separator ","; // optional (defaults to ",") - mergeSeparators no; // merge multiple separators - file "fileXYZ"; // name of csv data file - outOfBounds clamp; // optional out-of-bounds handling - interpolationScheme linear; // optional interpolation scheme - } - \endverbatim - -SourceFiles - CSV.C - -\*---------------------------------------------------------------------------*/ - -#ifndef CSV_H -#define CSV_H - -#include "Function1.H" -#include "TableBase.H" -#include "Tuple2.H" -#include "labelList.H" -#include "ISstream.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -namespace Function1Types -{ - -/*---------------------------------------------------------------------------*\ - Class CSV Declaration -\*---------------------------------------------------------------------------*/ - -template -class CSV -: - public TableBase -{ - // Private Data - - //- Number header lines - label nHeaderLine_; - - //- Column of the time - label refColumn_; - - //- Labels of the components - labelList componentColumns_; - - //- Separator character - char separator_; - - //- Merge separators flag, e.g. ',,,' becomes ',' - bool mergeSeparators_; - - //- File name for csv table - fileName fName_; - - - // Private Member Functions - - //- Read csv data table - void read(); - - //- Read the next value from the split string - Type readValue(const List&); - - -public: - - //- Runtime type information - TypeName("csvFile"); - - - // Constructors - - //- Construct from entry name and dictionary - CSV - ( - const word& entryName, - const dictionary& dict - ); - - //- Copy constructor - CSV(const CSV& tbl); - - - //- Destructor - virtual ~CSV(); - - - // Member Functions - - //- Return const access to the file name - virtual const fileName& fName() const; - - //- Write in dictionary format - virtual void writeData(Ostream& os) const; - - - // Member Operators - - //- Disallow default bitwise assignment - void operator=(const CSV&) = delete; -}; - - -template<> -label CSV