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.
This commit is contained in:
@ -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;
|
||||
};
|
||||
|
||||
@ -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<scalar>
|
||||
new Function1s::Table<scalar>
|
||||
(
|
||||
gammaUpperReg2by11Table,
|
||||
interpolationTable<scalar>::CLAMP,
|
||||
"gamma2by11"
|
||||
"gamma2by11",
|
||||
Function1s::tableBase::boundsHandling::clamp,
|
||||
linearInterpolationWeights::typeName,
|
||||
gammaUpperReg2by11Table
|
||||
);
|
||||
|
||||
gammaUpperReg5by11_ =
|
||||
new interpolationTable<scalar>
|
||||
new Function1s::Table<scalar>
|
||||
(
|
||||
gammaUpperReg5by11Table,
|
||||
interpolationTable<scalar>::CLAMP,
|
||||
"gamma5by11"
|
||||
"gamma5by11",
|
||||
Function1s::tableBase::boundsHandling::clamp,
|
||||
linearInterpolationWeights::typeName,
|
||||
gammaUpperReg5by11Table
|
||||
);
|
||||
|
||||
gammaUpperReg8by11_ =
|
||||
new interpolationTable<scalar>
|
||||
new Function1s::Table<scalar>
|
||||
(
|
||||
gammaUpperReg8by11Table,
|
||||
interpolationTable<scalar>::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])
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -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<interpolationTable<scalar>> gammaUpperReg2by11_;
|
||||
autoPtr<Function1s::Table<scalar>> gammaUpperReg2by11_;
|
||||
|
||||
//- Interpolation table of Q(a,z) for a=5/11
|
||||
autoPtr<interpolationTable<scalar>> gammaUpperReg5by11_;
|
||||
autoPtr<Function1s::Table<scalar>> gammaUpperReg5by11_;
|
||||
|
||||
//- Interpolation table of Q(a,z) for a=8/11
|
||||
autoPtr<interpolationTable<scalar>> gammaUpperReg8by11_;
|
||||
autoPtr<Function1s::Table<scalar>> gammaUpperReg8by11_;
|
||||
|
||||
//- Empirical constant, defaults to 0.923
|
||||
dimensionedScalar C4_;
|
||||
|
||||
@ -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<Function1Types::CSV<scalar>> pData
|
||||
Function1s::TableFile<scalar> pData
|
||||
(
|
||||
"pressure",
|
||||
dict.subDict("pressureData")
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "timeVaryingUniformFixedValuePointPatchField.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::
|
||||
timeVaryingUniformFixedValuePointPatchField<Type>::
|
||||
timeVaryingUniformFixedValuePointPatchField
|
||||
(
|
||||
const pointPatch& p,
|
||||
const DimensionedField<Type, pointMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(p, iF)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::
|
||||
timeVaryingUniformFixedValuePointPatchField<Type>::
|
||||
timeVaryingUniformFixedValuePointPatchField
|
||||
(
|
||||
const timeVaryingUniformFixedValuePointPatchField<Type>& ptf,
|
||||
const pointPatch& p,
|
||||
const DimensionedField<Type, pointMesh>& iF,
|
||||
const pointPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(ptf, p, iF, mapper),
|
||||
timeSeries_(ptf.timeSeries_)
|
||||
{
|
||||
this->operator==(timeSeries_(this->db().time().timeOutputValue()));
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::
|
||||
timeVaryingUniformFixedValuePointPatchField<Type>::
|
||||
timeVaryingUniformFixedValuePointPatchField
|
||||
(
|
||||
const pointPatch& p,
|
||||
const DimensionedField<Type, pointMesh>& iF,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(p, iF),
|
||||
timeSeries_(dict)
|
||||
{
|
||||
this->operator==(timeSeries_(this->db().time().timeOutputValue()));
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::
|
||||
timeVaryingUniformFixedValuePointPatchField<Type>::
|
||||
timeVaryingUniformFixedValuePointPatchField
|
||||
(
|
||||
const timeVaryingUniformFixedValuePointPatchField<Type>& ptf
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(ptf),
|
||||
timeSeries_(ptf.timeSeries_)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::
|
||||
timeVaryingUniformFixedValuePointPatchField<Type>::
|
||||
timeVaryingUniformFixedValuePointPatchField
|
||||
(
|
||||
const timeVaryingUniformFixedValuePointPatchField<Type>& ptf,
|
||||
const DimensionedField<Type, pointMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(ptf, iF),
|
||||
timeSeries_(ptf.timeSeries_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::timeVaryingUniformFixedValuePointPatchField<Type>::updateCoeffs()
|
||||
{
|
||||
if (this->updated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this->operator==(timeSeries_(this->db().time().timeOutputValue()));
|
||||
fixedValuePointPatchField<Type>::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::timeVaryingUniformFixedValuePointPatchField<Type>::write
|
||||
(
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
fixedValuePointPatchField<Type>::write(os);
|
||||
timeSeries_.write(os);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 Type>
|
||||
class timeVaryingUniformFixedValuePointPatchField
|
||||
:
|
||||
public fixedValuePointPatchField<Type>
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- The time series being used, including the bounding treatment
|
||||
interpolationTable<Type> timeSeries_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("timeVaryingUniformFixedValue");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch and internal field
|
||||
timeVaryingUniformFixedValuePointPatchField
|
||||
(
|
||||
const pointPatch&,
|
||||
const DimensionedField<Type, pointMesh>&
|
||||
);
|
||||
|
||||
//- Construct from patch, internal field and dictionary
|
||||
timeVaryingUniformFixedValuePointPatchField
|
||||
(
|
||||
const pointPatch&,
|
||||
const DimensionedField<Type, pointMesh>&,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
//- Construct by mapping given patch field onto a new patch
|
||||
timeVaryingUniformFixedValuePointPatchField
|
||||
(
|
||||
const timeVaryingUniformFixedValuePointPatchField<Type>&,
|
||||
const pointPatch&,
|
||||
const DimensionedField<Type, pointMesh>&,
|
||||
const pointPatchFieldMapper&
|
||||
);
|
||||
|
||||
//- Copy constructor
|
||||
timeVaryingUniformFixedValuePointPatchField
|
||||
(
|
||||
const timeVaryingUniformFixedValuePointPatchField<Type>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual autoPtr<pointPatchField<Type>> clone() const
|
||||
{
|
||||
return autoPtr<pointPatchField<Type>>
|
||||
(
|
||||
new timeVaryingUniformFixedValuePointPatchField<Type>(*this)
|
||||
);
|
||||
}
|
||||
|
||||
//- Copy constructor setting internal field reference
|
||||
timeVaryingUniformFixedValuePointPatchField
|
||||
(
|
||||
const timeVaryingUniformFixedValuePointPatchField<Type>&,
|
||||
const DimensionedField<Type, pointMesh>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone setting internal field reference
|
||||
virtual autoPtr<pointPatchField<Type>> clone
|
||||
(
|
||||
const DimensionedField<Type, pointMesh>& iF
|
||||
) const
|
||||
{
|
||||
return autoPtr<pointPatchField<Type>>
|
||||
(
|
||||
new timeVaryingUniformFixedValuePointPatchField<Type>(*this, iF)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the time series used
|
||||
const interpolationTable<Type>& 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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,43 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "timeVaryingUniformFixedValuePointPatchFields.H"
|
||||
#include "pointPatchFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
makePointPatchFields(timeVaryingUniformFixedValue);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -23,31 +23,7 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//#include "IFstream.H"
|
||||
#include "openFoamTableReader.H"
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::interpolation2DTable<Type>::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<Type>::interpolation2DTable()
|
||||
:
|
||||
List<Tuple2<scalar, List<Tuple2<scalar, Type>>>>(),
|
||||
boundsHandling_(interpolation2DTable::WARN),
|
||||
fileName_("fileNameIsUndefined"),
|
||||
fileName_(fileName::null),
|
||||
reader_(nullptr)
|
||||
{}
|
||||
|
||||
@ -82,9 +58,10 @@ Foam::interpolation2DTable<Type>::interpolation2DTable(const fileName& fName)
|
||||
List<Tuple2<scalar, List<Tuple2<scalar, Type>>>>(),
|
||||
boundsHandling_(interpolation2DTable::WARN),
|
||||
fileName_(fName),
|
||||
reader_(new openFoamTableReader<Type>(dictionary()))
|
||||
reader_(new TableReaders::Foam<Type>(dictionary()))
|
||||
{
|
||||
readTable();
|
||||
reader_()(fileName_, *this);
|
||||
checkOrder();
|
||||
}
|
||||
|
||||
|
||||
@ -94,9 +71,10 @@ Foam::interpolation2DTable<Type>::interpolation2DTable(const dictionary& dict)
|
||||
List<Tuple2<scalar, List<Tuple2<scalar, Type>>>>(),
|
||||
boundsHandling_(wordToBoundsHandling(dict.lookup("outOfBounds"))),
|
||||
fileName_(dict.lookup("file")),
|
||||
reader_(tableReader<Type>::New(dict))
|
||||
reader_(new TableReaders::Foam<Type>(dictionary()))
|
||||
{
|
||||
readTable();
|
||||
reader_()(fileName_, *this);
|
||||
checkOrder();
|
||||
}
|
||||
|
||||
|
||||
@ -108,8 +86,7 @@ Foam::interpolation2DTable<Type>::interpolation2DTable
|
||||
:
|
||||
List<Tuple2<scalar, List<Tuple2<scalar, Type>>>>(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<Type>::write(Ostream& os) const
|
||||
{
|
||||
writeEntry(os, "file", fileName_);
|
||||
writeEntry(os, "outOfBounds", boundsHandlingToWord(boundsHandling_));
|
||||
reader_.write(os);
|
||||
|
||||
*this >> os;
|
||||
}
|
||||
|
||||
@ -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<tableReader<Type>> reader_;
|
||||
//- The reader
|
||||
autoPtr<TableReader<Type>> reader_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Read the table of data from file
|
||||
void readTable();
|
||||
|
||||
//- Return interpolated value in List
|
||||
Type interpolateValue
|
||||
(
|
||||
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "interpolationTable.H"
|
||||
#include "openFoamTableReader.H"
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::interpolationTable<Type>::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<class Type>
|
||||
Foam::interpolationTable<Type>::interpolationTable()
|
||||
:
|
||||
List<Tuple2<scalar, Type>>(),
|
||||
boundsHandling_(interpolationTable::WARN),
|
||||
fileName_("fileNameIsUndefined"),
|
||||
reader_(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::interpolationTable<Type>::interpolationTable
|
||||
(
|
||||
const List<Tuple2<scalar, Type>>& values,
|
||||
const boundsHandling bounds,
|
||||
const fileName& fName
|
||||
)
|
||||
:
|
||||
List<Tuple2<scalar, Type>>(values),
|
||||
boundsHandling_(bounds),
|
||||
fileName_(fName),
|
||||
reader_(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::interpolationTable<Type>::interpolationTable(const fileName& fName)
|
||||
:
|
||||
List<Tuple2<scalar, Type>>(),
|
||||
boundsHandling_(interpolationTable::WARN),
|
||||
fileName_(fName),
|
||||
reader_(new openFoamTableReader<Type>(dictionary()))
|
||||
{
|
||||
readTable();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::interpolationTable<Type>::interpolationTable(const dictionary& dict)
|
||||
:
|
||||
List<Tuple2<scalar, Type>>(),
|
||||
boundsHandling_(wordToBoundsHandling(dict.lookup("outOfBounds"))),
|
||||
fileName_(dict.lookup("file")),
|
||||
reader_(tableReader<Type>::New(dict))
|
||||
{
|
||||
readTable();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::interpolationTable<Type>::interpolationTable
|
||||
(
|
||||
const interpolationTable& interpTable
|
||||
)
|
||||
:
|
||||
List<Tuple2<scalar, Type>>(interpTable),
|
||||
boundsHandling_(interpTable.boundsHandling_),
|
||||
fileName_(interpTable.fileName_),
|
||||
reader_(interpTable.reader_) // note: steals reader. Used in write().
|
||||
{}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::word Foam::interpolationTable<Type>::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<class Type>
|
||||
typename Foam::interpolationTable<Type>::boundsHandling
|
||||
Foam::interpolationTable<Type>::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<class Type>
|
||||
typename Foam::interpolationTable<Type>::boundsHandling
|
||||
Foam::interpolationTable<Type>::outOfBounds
|
||||
(
|
||||
const boundsHandling& bound
|
||||
)
|
||||
{
|
||||
boundsHandling prev = boundsHandling_;
|
||||
boundsHandling_ = bound;
|
||||
return prev;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::interpolationTable<Type>::check() const
|
||||
{
|
||||
label n = this->size();
|
||||
scalar prevValue = List<Tuple2<scalar, Type>>::operator[](0).first();
|
||||
|
||||
for (label i=1; i<n; ++i)
|
||||
{
|
||||
const scalar currValue =
|
||||
List<Tuple2<scalar, Type>>::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<class Type>
|
||||
void Foam::interpolationTable<Type>::write(Ostream& os) const
|
||||
{
|
||||
writeEntry(os, "file", fileName_);
|
||||
writeEntry(os, "outOfBounds", boundsHandlingToWord(boundsHandling_));
|
||||
if (reader_.valid())
|
||||
{
|
||||
reader_->write(os);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::interpolationTable<Type>::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<Tuple2<scalar, Type>>::operator[](0).first();
|
||||
scalar maxLimit = List<Tuple2<scalar, Type>>::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<Tuple2<scalar, Type>>::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<Tuple2<scalar, Type>>::operator[](hi).second()
|
||||
- List<Tuple2<scalar, Type>>::operator[](lo).second()
|
||||
)
|
||||
/(
|
||||
List<Tuple2<scalar, Type>>::operator[](hi).first()
|
||||
+ minLimit
|
||||
- List<Tuple2<scalar, Type>>::operator[](lo).first()
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// normal rate of change
|
||||
return
|
||||
(
|
||||
(
|
||||
List<Tuple2<scalar, Type>>::operator[](hi).second()
|
||||
- List<Tuple2<scalar, Type>>::operator[](lo).second()
|
||||
)
|
||||
/(
|
||||
List<Tuple2<scalar, Type>>::operator[](hi).first()
|
||||
- List<Tuple2<scalar, Type>>::operator[](lo).first()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::interpolationTable<Type>::operator=
|
||||
(
|
||||
const interpolationTable& interpTable
|
||||
)
|
||||
{
|
||||
List<Tuple2<scalar, Type>>::operator=(interpTable);
|
||||
boundsHandling_ = interpTable.boundsHandling_;
|
||||
fileName_ = interpTable.fileName_;
|
||||
reader_ = interpTable.reader_; // note: steals reader. Used in write().
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
const Foam::Tuple2<Foam::scalar, Type>&
|
||||
Foam::interpolationTable<Type>::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<Tuple2<scalar, Type>>::operator[](ii);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::interpolationTable<Type>::operator()(const scalar value) const
|
||||
{
|
||||
label n = this->size();
|
||||
|
||||
if (n <= 1)
|
||||
{
|
||||
return List<Tuple2<scalar, Type>>::operator[](0).second();
|
||||
}
|
||||
|
||||
scalar minLimit = List<Tuple2<scalar, Type>>::operator[](0).first();
|
||||
scalar maxLimit = List<Tuple2<scalar, Type>>::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<Tuple2<scalar, Type>>::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<Tuple2<scalar, Type>>::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<Tuple2<scalar, Type>>::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<Tuple2<scalar, Type>>::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<Tuple2<scalar, Type>>::operator[](lo).second()
|
||||
+ (
|
||||
List<Tuple2<scalar, Type>>::operator[](hi).second()
|
||||
- List<Tuple2<scalar, Type>>::operator[](lo).second()
|
||||
)
|
||||
*(lookupValue / minLimit)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// normal interpolation
|
||||
return
|
||||
(
|
||||
List<Tuple2<scalar, Type>>::operator[](lo).second()
|
||||
+ (
|
||||
List<Tuple2<scalar, Type>>::operator[](hi).second()
|
||||
- List<Tuple2<scalar, Type>>::operator[](lo).second()
|
||||
)
|
||||
*(
|
||||
lookupValue
|
||||
- List<Tuple2<scalar, Type>>::operator[](lo).first()
|
||||
)
|
||||
/(
|
||||
List<Tuple2<scalar, Type>>::operator[](hi).first()
|
||||
- List<Tuple2<scalar, Type>>::operator[](lo).first()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::interpolationTable
|
||||
|
||||
Description
|
||||
An interpolation/look-up table of scalar vs \<Type\> 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 Type>
|
||||
class interpolationTable
|
||||
:
|
||||
public List<Tuple2<scalar, Type>>
|
||||
{
|
||||
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<tableReader<Type>> reader_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Read the table of data from file
|
||||
void readTable();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
interpolationTable();
|
||||
|
||||
//- Construct from components
|
||||
interpolationTable
|
||||
(
|
||||
const List<Tuple2<scalar, Type>>& 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<scalar, Type>
|
||||
const Tuple2<scalar, Type>& operator[](const label) const;
|
||||
|
||||
//- Return an interpolated value
|
||||
Type operator()(const scalar) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "interpolationTable.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "csvTableReader.H"
|
||||
#include "fileOperation.H"
|
||||
#include "DynamicList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::csvTableReader<Type>::csvTableReader(const dictionary& dict)
|
||||
:
|
||||
tableReader<Type>(dict),
|
||||
headerLine_(readBool(dict.lookup("hasHeaderLine"))),
|
||||
timeColumn_(readLabel(dict.lookup("timeColumn"))),
|
||||
componentColumns_(dict.lookup("valueColumns")),
|
||||
separator_(dict.lookupOrDefault<string>("separator", string(","))[0])
|
||||
{
|
||||
if (componentColumns_.size() != pTraits<Type>::nComponents)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< componentColumns_ << " does not have the expected length "
|
||||
<< pTraits<Type>::nComponents << endl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::csvTableReader<Type>::~csvTableReader()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
// doesn't recognize specialization otherwise
|
||||
template<>
|
||||
scalar csvTableReader<scalar>::readValue(const List<string>& split)
|
||||
{
|
||||
if (componentColumns_[0] >= split.size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "No column " << componentColumns_[0] << " in "
|
||||
<< split << endl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return readScalar(IStringStream(split[componentColumns_[0]])());
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type csvTableReader<Type>::readValue(const List<string>& split)
|
||||
{
|
||||
Type result;
|
||||
|
||||
for(label i = 0;i < pTraits<Type>::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<class Type>
|
||||
void Foam::csvTableReader<Type>::operator()
|
||||
(
|
||||
const fileName& fName,
|
||||
List<Tuple2<scalar, Type>>& data
|
||||
)
|
||||
{
|
||||
// IFstream in(fName);
|
||||
autoPtr<ISstream> inPtr(fileHandler().NewIFstream(fName));
|
||||
ISstream& in = inPtr();
|
||||
|
||||
DynamicList<Tuple2<scalar, Type>> values;
|
||||
|
||||
// Skip header
|
||||
if (headerLine_)
|
||||
{
|
||||
string line;
|
||||
in.getLine(line);
|
||||
}
|
||||
|
||||
while (in.good())
|
||||
{
|
||||
string line;
|
||||
in.getLine(line);
|
||||
|
||||
DynamicList<string> 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<scalar,Type>(time, value));
|
||||
}
|
||||
|
||||
data.transfer(values);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::csvTableReader<Type>::operator()
|
||||
(
|
||||
const fileName& fName,
|
||||
List<Tuple2<scalar, List<Tuple2<scalar, Type>>>>& data
|
||||
)
|
||||
{
|
||||
NotImplemented;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::csvTableReader<Type>::write(Ostream& os) const
|
||||
{
|
||||
tableReader<Type>::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_));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "openFoamTableReader.H"
|
||||
#include "tableReaders.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makeTableReaders(openFoamTableReader);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "tableReaders.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
#define defineTableReaderType(dataType) \
|
||||
defineNamedTemplateTypeNameAndDebug(tableReader<dataType >, 0); \
|
||||
defineTemplatedRunTimeSelectionTable(tableReader, dictionary, dataType);
|
||||
|
||||
defineTableReaderType(scalar);
|
||||
defineTableReaderType(vector);
|
||||
defineTableReaderType(sphericalTensor);
|
||||
defineTableReaderType(symmTensor);
|
||||
defineTableReaderType(tensor);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
SourceFiles
|
||||
tableReaders.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef tableReaders_H
|
||||
#define tableReaders_H
|
||||
|
||||
#include "tableReader.H"
|
||||
#include "fieldTypes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Only used internally
|
||||
#define makeTypeTableReadersTypeName(typeTableReader, dataType) \
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(typeTableReader<dataType>, 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<dataType>, 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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::Function1Types::CSV
|
||||
|
||||
Description
|
||||
Templated CSV function.
|
||||
|
||||
Reference column is always a scalar, e.g. time.
|
||||
|
||||
Usage:
|
||||
\verbatim
|
||||
<entryName> csvFile;
|
||||
<entryName>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 Type>
|
||||
class CSV
|
||||
:
|
||||
public TableBase<Type>
|
||||
{
|
||||
// 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<string>&);
|
||||
|
||||
|
||||
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<Type>& 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<Type>&) = delete;
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
label CSV<label>::readValue(const List<string>& split);
|
||||
|
||||
template<>
|
||||
Foam::scalar CSV<scalar>::readValue(const List<string>& split);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "CSV.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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
|
||||
@ -28,25 +28,25 @@ License
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Constant<Type>::Constant
|
||||
Foam::Function1s::Constant<Type>::Constant
|
||||
(
|
||||
const word& entryName,
|
||||
const Type& val
|
||||
)
|
||||
:
|
||||
Function1<Type>(entryName),
|
||||
FieldFunction1<Type, Constant<Type>>(entryName),
|
||||
value_(val)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Constant<Type>::Constant
|
||||
Foam::Function1s::Constant<Type>::Constant
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
Function1<Type>(entryName),
|
||||
FieldFunction1<Type, Constant<Type>>(entryName),
|
||||
value_(Zero)
|
||||
{
|
||||
Istream& is(dict.lookup(entryName));
|
||||
@ -56,21 +56,21 @@ Foam::Function1Types::Constant<Type>::Constant
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Constant<Type>::Constant
|
||||
Foam::Function1s::Constant<Type>::Constant
|
||||
(
|
||||
const word& entryName,
|
||||
Istream& is
|
||||
)
|
||||
:
|
||||
Function1<Type>(entryName),
|
||||
FieldFunction1<Type, Constant<Type>>(entryName),
|
||||
value_(pTraits<Type>(is))
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Constant<Type>::Constant(const Constant<Type>& cnst)
|
||||
Foam::Function1s::Constant<Type>::Constant(const Constant<Type>& cnst)
|
||||
:
|
||||
Function1<Type>(cnst),
|
||||
FieldFunction1<Type, Constant<Type>>(cnst),
|
||||
value_(cnst.value_)
|
||||
{}
|
||||
|
||||
@ -78,35 +78,14 @@ Foam::Function1Types::Constant<Type>::Constant(const Constant<Type>& cnst)
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Constant<Type>::~Constant()
|
||||
Foam::Function1s::Constant<Type>::~Constant()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::Function1Types::Constant<Type>::value
|
||||
(
|
||||
const scalarField& x
|
||||
) const
|
||||
{
|
||||
return tmp<Field<Type>>(new Field<Type>(x.size(), value_));
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::Function1Types::Constant<Type>::integrate
|
||||
(
|
||||
const scalarField& x1,
|
||||
const scalarField& x2
|
||||
) const
|
||||
{
|
||||
return (x2 - x1)*value_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::Constant<Type>::writeData(Ostream& os) const
|
||||
void Foam::Function1s::Constant<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
Function1<Type>::writeData(os);
|
||||
|
||||
@ -114,4 +93,4 @@ void Foam::Function1Types::Constant<Type>::writeData(Ostream& os) const
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
// ************************************************************************* i/
|
||||
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::Function1Types::Constant
|
||||
Foam::Function1s::Constant
|
||||
|
||||
Description
|
||||
Templated function that returns a constant value.
|
||||
@ -46,7 +46,7 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -56,7 +56,7 @@ namespace Function1Types
|
||||
template<class Type>
|
||||
class Constant
|
||||
:
|
||||
public Function1<Type>
|
||||
public FieldFunction1<Type, Constant<Type>>
|
||||
{
|
||||
// Private Data
|
||||
|
||||
@ -105,16 +105,6 @@ public:
|
||||
//- Integrate between two values
|
||||
virtual inline Type integrate(const scalar x1, const scalar x2) const;
|
||||
|
||||
//- Return value as a function of (scalar) independent variable
|
||||
virtual tmp<Field<Type>> value(const scalarField& x) const;
|
||||
|
||||
//- Integrate between two (scalar) values
|
||||
virtual tmp<Field<Type>> integrate
|
||||
(
|
||||
const scalarField& x1,
|
||||
const scalarField& x2
|
||||
) const;
|
||||
|
||||
//- Write in dictionary format
|
||||
virtual void writeData(Ostream& os) const;
|
||||
|
||||
@ -126,17 +116,9 @@ public:
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
tmp<Field<label>> Function1Types::Constant<label>::integrate
|
||||
(
|
||||
const scalarField& x1,
|
||||
const scalarField& x2
|
||||
) const;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Function1s
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -28,14 +28,14 @@ License
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline Type Foam::Function1Types::Constant<Type>::value(const scalar x) const
|
||||
inline Type Foam::Function1s::Constant<Type>::value(const scalar x) const
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Type Foam::Function1Types::Constant<Type>::integrate
|
||||
inline Type Foam::Function1s::Constant<Type>::integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
|
||||
@ -24,7 +24,6 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "Function1.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -43,6 +42,37 @@ Foam::Function1<Type>::Function1(const Function1<Type>& de)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type, class Function1Type>
|
||||
Foam::FieldFunction1<Type, Function1Type>::FieldFunction1
|
||||
(
|
||||
const word& entryName
|
||||
)
|
||||
:
|
||||
Function1<Type>(entryName)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type, class Function1Type>
|
||||
Foam::FieldFunction1<Type, Function1Type>::FieldFunction1
|
||||
(
|
||||
const FieldFunction1<Type, Function1Type>& ff1
|
||||
)
|
||||
:
|
||||
Function1<Type>(ff1)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type, class Function1Type>
|
||||
Foam::tmp<Foam::Function1<Type>>
|
||||
Foam::FieldFunction1<Type, Function1Type>::clone() const
|
||||
{
|
||||
return tmp<Function1<Type>>
|
||||
(
|
||||
new Function1Type(refCast<const Function1Type>(*this))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
@ -50,6 +80,11 @@ Foam::Function1<Type>::~Function1()
|
||||
{}
|
||||
|
||||
|
||||
template<class Type, class Function1Type>
|
||||
Foam::FieldFunction1<Type, Function1Type>::~FieldFunction1()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
@ -60,30 +95,14 @@ const Foam::word& Foam::Function1<Type>::name() const
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1<Type>::value(const scalar x) const
|
||||
void Foam::Function1<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Evaluation is not defined for " << type() << " functions"
|
||||
<< exit(FatalError);
|
||||
|
||||
return Zero;
|
||||
writeKeyword(os, name_) << type();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1<Type>::integrate(const scalar x1, const scalar x2) const
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Integration is not defined for " << type() << " functions"
|
||||
<< exit(FatalError);
|
||||
|
||||
return Zero;
|
||||
}
|
||||
|
||||
|
||||
template<class Function1Type>
|
||||
Foam::tmp<Foam::Field<typename Function1Type::returnType>>
|
||||
Foam::FieldFunction1<Function1Type>::value
|
||||
template<class Type, class Function1Type>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::FieldFunction1<Type, Function1Type>::value
|
||||
(
|
||||
const scalarField& x
|
||||
) const
|
||||
@ -93,37 +112,16 @@ Foam::FieldFunction1<Function1Type>::value
|
||||
|
||||
forAll(x, i)
|
||||
{
|
||||
fld[i] = Function1Type::value(x[i]);
|
||||
fld[i] = refCast<const Function1Type>(*this).value(x[i]);
|
||||
}
|
||||
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
template<class Function1Type>
|
||||
Foam::FieldFunction1<Function1Type>::FieldFunction1
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
Function1Type(entryName, dict)
|
||||
{}
|
||||
|
||||
|
||||
template<class Function1Type>
|
||||
Foam::tmp<Foam::Function1<typename Function1Type::returnType>>
|
||||
Foam::FieldFunction1<Function1Type>::clone() const
|
||||
{
|
||||
return tmp<Function1<Type>>
|
||||
(
|
||||
new FieldFunction1<Function1Type>(*this)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Function1Type>
|
||||
Foam::tmp<Foam::Field<typename Function1Type::returnType>>
|
||||
Foam::FieldFunction1<Function1Type>::integrate
|
||||
template<class Type, class Function1Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::FieldFunction1<Type, Function1Type>::integrate
|
||||
(
|
||||
const scalarField& x1,
|
||||
const scalarField& x2
|
||||
@ -134,20 +132,13 @@ Foam::FieldFunction1<Function1Type>::integrate
|
||||
|
||||
forAll(x1, i)
|
||||
{
|
||||
fld[i] = Function1Type::integrate(x1[i], x2[i]);
|
||||
fld[i] = refCast<const Function1Type>(*this).integrate(x1[i], x2[i]);
|
||||
}
|
||||
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
writeKeyword(os, name_) << type();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
|
||||
@ -40,6 +40,8 @@ SourceFiles
|
||||
#define Function1_H
|
||||
|
||||
#include "dictionary.H"
|
||||
#include "tmp.H"
|
||||
#include "typeInfo.H"
|
||||
#include "Field.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -47,9 +49,6 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
class Time;
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
template<class Type> class Function1;
|
||||
template<class Type> Ostream& operator<<(Ostream&, const Function1<Type>&);
|
||||
@ -128,13 +127,13 @@ public:
|
||||
// Evaluation
|
||||
|
||||
//- Return value as a function of (scalar) independent variable
|
||||
virtual Type value(const scalar x) const;
|
||||
virtual Type value(const scalar x) const = 0;
|
||||
|
||||
//- Return value as a function of (scalar) independent variable
|
||||
virtual tmp<Field<Type>> value(const scalarField& x) const = 0;
|
||||
|
||||
//- Integrate between two (scalar) values
|
||||
virtual Type integrate(const scalar x1, const scalar x2) const;
|
||||
virtual Type integrate(const scalar x1, const scalar x2) const = 0;
|
||||
|
||||
//- Integrate between two (scalar) values
|
||||
virtual tmp<Field<Type>> integrate
|
||||
@ -172,41 +171,43 @@ void writeEntry(Ostream& os, const Function1<Type>& f1);
|
||||
Class FieldFunction1 Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Function1Type>
|
||||
template<class Type, class Function1Type>
|
||||
class FieldFunction1
|
||||
:
|
||||
public Function1Type
|
||||
public Function1<Type>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
typedef typename Function1Type::returnType Type;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from entry name and dictionary
|
||||
FieldFunction1(const word& entryName, const dictionary& dict);
|
||||
//- Construct from entry name
|
||||
FieldFunction1(const word& entryName);
|
||||
|
||||
//- Copy constructor
|
||||
FieldFunction1(const FieldFunction1<Type, Function1Type>& ff1);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<Function1<Type>> clone() const;
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~FieldFunction1()
|
||||
{}
|
||||
virtual ~FieldFunction1();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Evaluation
|
||||
|
||||
using Function1Type::value;
|
||||
using Function1Type::integrate;
|
||||
//- Return value as a function of (scalar) independent variable
|
||||
virtual Type value(const scalar x) const = 0;
|
||||
|
||||
//- Return value as a function of (scalar) independent variable
|
||||
virtual tmp<Field<Type>> value(const scalarField& x) const;
|
||||
|
||||
//- Integrate between two (scalar) values
|
||||
virtual Type integrate(const scalar x1, const scalar x2) const = 0;
|
||||
|
||||
//- Integrate between two (scalar) values
|
||||
virtual tmp<Field<Type>> integrate
|
||||
(
|
||||
@ -226,19 +227,14 @@ public:
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(Function1<Type>, 0); \
|
||||
\
|
||||
defineTemplateRunTimeSelectionTable \
|
||||
( \
|
||||
Function1<Type>, \
|
||||
dictionary \
|
||||
);
|
||||
defineTemplateRunTimeSelectionTable(Function1<Type>, dictionary);
|
||||
|
||||
|
||||
#define makeFunction1Type(SS, Type) \
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(Function1Types::SS<Type>, 0); \
|
||||
defineNamedTemplateTypeNameAndDebug(Function1s::SS<Type>, 0); \
|
||||
\
|
||||
Function1<Type>::adddictionaryConstructorToTable \
|
||||
<FieldFunction1<Function1Types::SS<Type>>> \
|
||||
Function1<Type>::adddictionaryConstructorToTable<Function1s::SS<Type>> \
|
||||
add##SS##Type##ConstructorToTable_;
|
||||
|
||||
|
||||
@ -246,7 +242,7 @@ public:
|
||||
\
|
||||
defineTypeNameAndDebug(SS, 0); \
|
||||
\
|
||||
Function1<scalar>::adddictionaryConstructorToTable<FieldFunction1<SS>> \
|
||||
Function1<scalar>::adddictionaryConstructorToTable<SS> \
|
||||
add##SS##ConstructorToTable_;
|
||||
|
||||
|
||||
|
||||
@ -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
|
||||
@ -68,7 +68,7 @@ Foam::autoPtr<Foam::Function1<Type>> Foam::Function1<Type>::New
|
||||
is.putBack(firstToken);
|
||||
return autoPtr<Function1<Type>>
|
||||
(
|
||||
new Function1Types::Constant<Type>(entryName, is)
|
||||
new Function1s::Constant<Type>(entryName, is)
|
||||
);
|
||||
}
|
||||
else
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -28,55 +28,34 @@ License
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::OneConstant<Type>::OneConstant(const word& entryName)
|
||||
Foam::Function1s::OneConstant<Type>::OneConstant(const word& entryName)
|
||||
:
|
||||
Function1<Type>(entryName)
|
||||
FieldFunction1<Type, OneConstant<Type>>(entryName)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::OneConstant<Type>::OneConstant
|
||||
Foam::Function1s::OneConstant<Type>::OneConstant
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
Function1<Type>(entryName)
|
||||
FieldFunction1<Type, OneConstant<Type>>(entryName)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::OneConstant<Type>::~OneConstant()
|
||||
Foam::Function1s::OneConstant<Type>::~OneConstant()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::Function1Types::OneConstant<Type>::value
|
||||
(
|
||||
const scalarField& x
|
||||
) const
|
||||
{
|
||||
return tmp<Field<Type>>(new Field<Type>(x.size(), pTraits<Type>::one));
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::Function1Types::OneConstant<Type>::integrate
|
||||
(
|
||||
const scalarField& x1,
|
||||
const scalarField& x2
|
||||
) const
|
||||
{
|
||||
return (x2 - x1)*pTraits<Type>::one;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::OneConstant<Type>::writeData(Ostream& os) const
|
||||
void Foam::Function1s::OneConstant<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
Function1<Type>::writeData(os);
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::Function1Types::OneConstant
|
||||
Foam::Function1s::OneConstant
|
||||
|
||||
Description
|
||||
Templated function that returns the corresponding 1 (one).
|
||||
@ -46,7 +46,7 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -56,7 +56,7 @@ namespace Function1Types
|
||||
template<class Type>
|
||||
class OneConstant
|
||||
:
|
||||
public Function1<Type>
|
||||
public FieldFunction1<Type, OneConstant<Type>>
|
||||
{
|
||||
|
||||
public:
|
||||
@ -73,12 +73,6 @@ public:
|
||||
//- Construct from entry name and dictionary
|
||||
OneConstant(const word& entryName, const dictionary& dict);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<Function1<Type>> clone() const
|
||||
{
|
||||
return tmp<Function1<Type>>(new OneConstant<Type>(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~OneConstant();
|
||||
@ -92,16 +86,6 @@ public:
|
||||
//- Integrate between two values
|
||||
virtual inline Type integrate(const scalar x1, const scalar x2) const;
|
||||
|
||||
//- Return value as a function of (scalar) independent variable
|
||||
virtual tmp<Field<Type>> value(const scalarField& x) const;
|
||||
|
||||
//- Integrate between two (scalar) values
|
||||
virtual tmp<Field<Type>> integrate
|
||||
(
|
||||
const scalarField& x1,
|
||||
const scalarField& x2
|
||||
) const;
|
||||
|
||||
//- Write in dictionary format
|
||||
virtual void writeData(Ostream& os) const;
|
||||
|
||||
@ -115,7 +99,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Function1s
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -28,14 +28,14 @@ License
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline Type Foam::Function1Types::OneConstant<Type>::value(const scalar x) const
|
||||
inline Type Foam::Function1s::OneConstant<Type>::value(const scalar x) const
|
||||
{
|
||||
return pTraits<Type>::one;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Type Foam::Function1Types::OneConstant<Type>::integrate
|
||||
inline Type Foam::Function1s::OneConstant<Type>::integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
|
||||
@ -28,13 +28,13 @@ License
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Polynomial<Type>::Polynomial
|
||||
Foam::Function1s::Polynomial<Type>::Polynomial
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
Function1<Type>(entryName),
|
||||
FieldFunction1<Type, Polynomial<Type>>(entryName),
|
||||
coeffs_(),
|
||||
canIntegrate_(true)
|
||||
{
|
||||
@ -72,13 +72,13 @@ Foam::Function1Types::Polynomial<Type>::Polynomial
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Polynomial<Type>::Polynomial
|
||||
Foam::Function1s::Polynomial<Type>::Polynomial
|
||||
(
|
||||
const word& entryName,
|
||||
const List<Tuple2<Type, Type>>& coeffs
|
||||
)
|
||||
:
|
||||
Function1<Type>(entryName),
|
||||
FieldFunction1<Type, Polynomial<Type>>(entryName),
|
||||
coeffs_(coeffs),
|
||||
canIntegrate_(true)
|
||||
{
|
||||
@ -111,9 +111,9 @@ Foam::Function1Types::Polynomial<Type>::Polynomial
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Polynomial<Type>::Polynomial(const Polynomial& poly)
|
||||
Foam::Function1s::Polynomial<Type>::Polynomial(const Polynomial& poly)
|
||||
:
|
||||
Function1<Type>(poly),
|
||||
FieldFunction1<Type, Polynomial<Type>>(poly),
|
||||
coeffs_(poly.coeffs_),
|
||||
canIntegrate_(poly.canIntegrate_)
|
||||
{}
|
||||
@ -122,14 +122,14 @@ Foam::Function1Types::Polynomial<Type>::Polynomial(const Polynomial& poly)
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Polynomial<Type>::~Polynomial()
|
||||
Foam::Function1s::Polynomial<Type>::~Polynomial()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1Types::Polynomial<Type>::value(const scalar x) const
|
||||
Type Foam::Function1s::Polynomial<Type>::value(const scalar x) const
|
||||
{
|
||||
Type y(Zero);
|
||||
forAll(coeffs_, i)
|
||||
@ -146,7 +146,7 @@ Type Foam::Function1Types::Polynomial<Type>::value(const scalar x) const
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1Types::Polynomial<Type>::integrate
|
||||
Type Foam::Function1s::Polynomial<Type>::integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
@ -184,7 +184,7 @@ Type Foam::Function1Types::Polynomial<Type>::integrate
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::Polynomial<Type>::writeData(Ostream& os) const
|
||||
void Foam::Function1s::Polynomial<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
Function1<Type>::writeData(os);
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::Function1Types::Polynomial
|
||||
Foam::Function1s::Polynomial
|
||||
|
||||
Description
|
||||
PolynomialEntry container data entry for scalars. Items are stored in a
|
||||
@ -53,7 +53,7 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -63,7 +63,7 @@ namespace Function1Types
|
||||
template<class Type>
|
||||
class Polynomial
|
||||
:
|
||||
public Function1<Type>
|
||||
public FieldFunction1<Type, Polynomial<Type>>
|
||||
{
|
||||
// Private Data
|
||||
|
||||
@ -123,7 +123,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Function1s
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -23,24 +23,26 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ramp.H"
|
||||
#include "Ramp.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::Function1Types::ramp::read(const dictionary& coeffs)
|
||||
template <class Function1Type>
|
||||
void Foam::Function1s::Ramp<Function1Type>::read(const dictionary& coeffs)
|
||||
{
|
||||
start_ = coeffs.lookupOrDefault<scalar>("start", 0);
|
||||
duration_ = coeffs.lookupType<scalar>("duration");
|
||||
}
|
||||
|
||||
|
||||
Foam::Function1Types::ramp::ramp
|
||||
template <class Function1Type>
|
||||
Foam::Function1s::Ramp<Function1Type>::Ramp
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
Function1<scalar>(entryName)
|
||||
FieldFunction1<scalar, Function1Type>(entryName)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
@ -48,13 +50,15 @@ Foam::Function1Types::ramp::ramp
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Function1Types::ramp::~ramp()
|
||||
template <class Function1Type>
|
||||
Foam::Function1s::Ramp<Function1Type>::~Ramp()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::Function1Types::ramp::writeData(Ostream& os) const
|
||||
template <class Function1Type>
|
||||
void Foam::Function1s::Ramp<Function1Type>::writeData(Ostream& os) const
|
||||
{
|
||||
Function1<scalar>::writeData(os);
|
||||
os << token::END_STATEMENT << nl;
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::Function1Types::ramp
|
||||
Foam::Function1s::Ramp
|
||||
|
||||
Description
|
||||
Ramp function base class for the set of scalar functions starting from 0 and
|
||||
@ -59,12 +59,12 @@ See also
|
||||
Foam::Function1
|
||||
|
||||
SourceFiles
|
||||
ramp.C
|
||||
Ramp.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ramp_H
|
||||
#define ramp_H
|
||||
#ifndef Ramp_H
|
||||
#define Ramp_H
|
||||
|
||||
#include "Function1.H"
|
||||
|
||||
@ -72,16 +72,17 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ramp Declaration
|
||||
Class Ramp Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class ramp
|
||||
template <class Function1Type>
|
||||
class Ramp
|
||||
:
|
||||
public Function1<scalar>
|
||||
public FieldFunction1<scalar, Function1Type>
|
||||
{
|
||||
protected:
|
||||
|
||||
@ -127,7 +128,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from entry name and dictionary
|
||||
ramp
|
||||
Ramp
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
@ -135,7 +136,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~ramp();
|
||||
virtual ~Ramp();
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -150,17 +151,23 @@ public:
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const ramp&) = delete;
|
||||
void operator=(const Ramp<Function1Type>&) = delete;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Function1s
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "Ramp.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -28,7 +28,7 @@ License
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::Scale<Type>::read(const dictionary& coeffs)
|
||||
void Foam::Function1s::Scale<Type>::read(const dictionary& coeffs)
|
||||
{
|
||||
scale_ = Function1<scalar>::New("scale", coeffs);
|
||||
xScale_ =
|
||||
@ -50,22 +50,22 @@ void Foam::Function1Types::Scale<Type>::read(const dictionary& coeffs)
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Scale<Type>::Scale
|
||||
Foam::Function1s::Scale<Type>::Scale
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
Function1<Type>(entryName)
|
||||
FieldFunction1<Type, Scale<Type>>(entryName)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Scale<Type>::Scale(const Scale<Type>& se)
|
||||
Foam::Function1s::Scale<Type>::Scale(const Scale<Type>& se)
|
||||
:
|
||||
Function1<Type>(se),
|
||||
FieldFunction1<Type, Scale<Type>>(se),
|
||||
scale_(se.scale_, false),
|
||||
xScale_(se.xScale_, false),
|
||||
value_(se.value_, false),
|
||||
@ -77,14 +77,14 @@ Foam::Function1Types::Scale<Type>::Scale(const Scale<Type>& se)
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Scale<Type>::~Scale()
|
||||
Foam::Function1s::Scale<Type>::~Scale()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::Scale<Type>::writeData(Ostream& os) const
|
||||
void Foam::Function1s::Scale<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
Function1<Type>::writeData(os);
|
||||
os << token::END_STATEMENT << nl;
|
||||
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::Function1Types::Scale
|
||||
Foam::Function1s::Scale
|
||||
|
||||
Description
|
||||
Function1 which scales a given 'value' function by a 'scale' scalar function
|
||||
@ -108,8 +108,8 @@ Description
|
||||
\endtable
|
||||
|
||||
See also
|
||||
Foam::Function1Types::ramp
|
||||
Foam::Function1Types::reverseRamp
|
||||
Foam::Function1s::ramp
|
||||
Foam::Function1s::reverseRamp
|
||||
|
||||
SourceFiles
|
||||
Scale.C
|
||||
@ -125,7 +125,7 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -135,7 +135,7 @@ namespace Function1Types
|
||||
template<class Type>
|
||||
class Scale
|
||||
:
|
||||
public Function1<Type>
|
||||
public FieldFunction1<Type, Scale<Type>>
|
||||
{
|
||||
// Private Data
|
||||
|
||||
@ -205,7 +205,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Function1s
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -28,7 +28,7 @@ License
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline Type Foam::Function1Types::Scale<Type>::value(const scalar x) const
|
||||
inline Type Foam::Function1s::Scale<Type>::value(const scalar x) const
|
||||
{
|
||||
const scalar sx = xScale_->value(x)*x;
|
||||
return scale_->value(sx)*value_->value(sx);
|
||||
@ -36,7 +36,7 @@ inline Type Foam::Function1Types::Scale<Type>::value(const scalar x) const
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Type Foam::Function1Types::Scale<Type>::integrate
|
||||
inline Type Foam::Function1s::Scale<Type>::integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
|
||||
@ -28,7 +28,7 @@ License
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::Sine<Type>::read(const dictionary& coeffs)
|
||||
void Foam::Function1s::Sine<Type>::read(const dictionary& coeffs)
|
||||
{
|
||||
amplitude_ = Function1<Type>::New("amplitude", coeffs);
|
||||
frequency_ = readScalar(coeffs.lookup("frequency"));
|
||||
@ -44,22 +44,22 @@ void Foam::Function1Types::Sine<Type>::read(const dictionary& coeffs)
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Sine<Type>::Sine
|
||||
Foam::Function1s::Sine<Type>::Sine
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
Function1<Type>(entryName)
|
||||
FieldFunction1<Type, Sine<Type>>(entryName)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Sine<Type>::Sine(const Sine<Type>& se)
|
||||
Foam::Function1s::Sine<Type>::Sine(const Sine<Type>& se)
|
||||
:
|
||||
Function1<Type>(se),
|
||||
FieldFunction1<Type, Sine<Type>>(se),
|
||||
amplitude_(se.amplitude_, false),
|
||||
frequency_(se.frequency_),
|
||||
start_(se.start_),
|
||||
@ -71,14 +71,14 @@ Foam::Function1Types::Sine<Type>::Sine(const Sine<Type>& se)
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Sine<Type>::~Sine()
|
||||
Foam::Function1s::Sine<Type>::~Sine()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::Sine<Type>::writeData(Ostream& os) const
|
||||
void Foam::Function1s::Sine<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
Function1<Type>::writeData(os);
|
||||
os << token::END_STATEMENT << nl;
|
||||
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::Function1Types::Sine
|
||||
Foam::Function1s::Sine
|
||||
|
||||
Description
|
||||
Templated sine function with support for an offset level.
|
||||
@ -79,7 +79,7 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -89,7 +89,7 @@ namespace Function1Types
|
||||
template<class Type>
|
||||
class Sine
|
||||
:
|
||||
public Function1<Type>
|
||||
public FieldFunction1<Type, Sine<Type>>
|
||||
{
|
||||
// Private Data
|
||||
|
||||
@ -159,7 +159,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Function1s
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -29,7 +29,7 @@ License
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline Type Foam::Function1Types::Sine<Type>::value(const scalar x) const
|
||||
inline Type Foam::Function1s::Sine<Type>::value(const scalar x) const
|
||||
{
|
||||
const scalar phi = constant::mathematical::twoPi*frequency_*(x - start_);
|
||||
|
||||
@ -38,7 +38,7 @@ inline Type Foam::Function1Types::Sine<Type>::value(const scalar x) const
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Type Foam::Function1Types::Sine<Type>::integrate
|
||||
inline Type Foam::Function1s::Sine<Type>::integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
|
||||
@ -28,7 +28,7 @@ License
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::Square<Type>::read(const dictionary& coeffs)
|
||||
void Foam::Function1s::Square<Type>::read(const dictionary& coeffs)
|
||||
{
|
||||
amplitude_ = Function1<Type>::New("amplitude", coeffs);
|
||||
frequency_ = readScalar(coeffs.lookup("frequency"));
|
||||
@ -45,22 +45,22 @@ void Foam::Function1Types::Square<Type>::read(const dictionary& coeffs)
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Square<Type>::Square
|
||||
Foam::Function1s::Square<Type>::Square
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
Function1<Type>(entryName)
|
||||
FieldFunction1<Type, Square<Type>>(entryName)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Square<Type>::Square(const Square<Type>& se)
|
||||
Foam::Function1s::Square<Type>::Square(const Square<Type>& se)
|
||||
:
|
||||
Function1<Type>(se),
|
||||
FieldFunction1<Type, Square<Type>>(se),
|
||||
amplitude_(se.amplitude_, false),
|
||||
frequency_(se.frequency_),
|
||||
start_(se.start_),
|
||||
@ -73,14 +73,14 @@ Foam::Function1Types::Square<Type>::Square(const Square<Type>& se)
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Square<Type>::~Square()
|
||||
Foam::Function1s::Square<Type>::~Square()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::Square<Type>::writeData(Ostream& os) const
|
||||
void Foam::Function1s::Square<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
Function1<Type>::writeData(os);
|
||||
os << token::END_STATEMENT << nl;
|
||||
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::Function1Types::Square
|
||||
Foam::Function1s::Square
|
||||
|
||||
Description
|
||||
Templated square-wave function with support for an offset level.
|
||||
@ -85,7 +85,7 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -95,7 +95,7 @@ namespace Function1Types
|
||||
template<class Type>
|
||||
class Square
|
||||
:
|
||||
public Function1<Type>
|
||||
public FieldFunction1<Type, Square<Type>>
|
||||
{
|
||||
// Private Data
|
||||
|
||||
@ -170,7 +170,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Function1s
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -29,7 +29,7 @@ License
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline Type Foam::Function1Types::Square<Type>::value(const scalar x) const
|
||||
inline Type Foam::Function1s::Square<Type>::value(const scalar x) const
|
||||
{
|
||||
const scalar markFraction = markSpace_/(1 + markSpace_);
|
||||
|
||||
@ -43,7 +43,7 @@ inline Type Foam::Function1Types::Square<Type>::value(const scalar x) const
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Type Foam::Function1Types::Square<Type>::integrate
|
||||
inline Type Foam::Function1s::Square<Type>::integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
|
||||
@ -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
|
||||
@ -28,33 +28,63 @@ License
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Table<Type>::Table
|
||||
Foam::Function1s::Table<Type>::Table
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
TableBase<Type>(entryName, dict)
|
||||
TableBase<Type, Table<Type>>(entryName, dict)
|
||||
{
|
||||
Istream& is(dict.lookup(entryName));
|
||||
word entryType(is);
|
||||
is >> this->table_;
|
||||
TableBase<Type>::check();
|
||||
TableBase<Type, Table<Type>>::check();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Table<Type>::Table(const Table<Type>& tbl)
|
||||
Foam::Function1s::Table<Type>::Table
|
||||
(
|
||||
const word& name,
|
||||
const tableBase::boundsHandling boundsHandling,
|
||||
const word& interpolationScheme,
|
||||
const List<Tuple2<scalar, Type>>& table
|
||||
)
|
||||
:
|
||||
TableBase<Type>(tbl)
|
||||
TableBase<Type, Table<Type>>
|
||||
(
|
||||
name,
|
||||
boundsHandling,
|
||||
interpolationScheme,
|
||||
table
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1s::Table<Type>::Table(const Table<Type>& tbl)
|
||||
:
|
||||
TableBase<Type, Table<Type>>(tbl)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Table<Type>::~Table()
|
||||
Foam::Function1s::Table<Type>::~Table()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1s::Table<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
Function1<Type>::writeData(os);
|
||||
os << nl << indent << this->table_ << token::END_STATEMENT << nl;
|
||||
TableBase<Type, Table<Type>>::writeCoeffDict(os);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::Function1Types::Table
|
||||
Foam::Function1s::Table
|
||||
|
||||
Description
|
||||
Templated table container function.
|
||||
@ -47,14 +47,13 @@ SourceFiles
|
||||
#ifndef Table_H
|
||||
#define Table_H
|
||||
|
||||
#include "Function1.H"
|
||||
#include "Tuple2.H"
|
||||
#include "TableBase.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -64,7 +63,7 @@ namespace Function1Types
|
||||
template<class Type>
|
||||
class Table
|
||||
:
|
||||
public TableBase<Type>
|
||||
public TableBase<Type, Table<Type>>
|
||||
{
|
||||
|
||||
public:
|
||||
@ -78,6 +77,15 @@ public:
|
||||
//- Construct from entry name and Istream
|
||||
Table(const word& entryName, const dictionary& dict);
|
||||
|
||||
//- Construct from components
|
||||
Table
|
||||
(
|
||||
const word& name,
|
||||
const tableBase::boundsHandling boundsHandling,
|
||||
const word& interpolationScheme,
|
||||
const List<Tuple2<scalar, Type>>& table
|
||||
);
|
||||
|
||||
//- Copy constructor
|
||||
Table(const Table<Type>& tbl);
|
||||
|
||||
@ -86,6 +94,12 @@ public:
|
||||
virtual ~Table();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Write all table data in dictionary format
|
||||
virtual void writeData(Ostream& os) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
@ -95,7 +109,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Function1s
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -25,13 +25,13 @@ License
|
||||
|
||||
#include "TableBase.H"
|
||||
#include "Time.H"
|
||||
#include "interpolationWeights.H"
|
||||
#include "linearInterpolationWeights.H"
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
template<class Type, class Function1Type>
|
||||
const Foam::interpolationWeights&
|
||||
Foam::Function1Types::TableBase<Type>::interpolator() const
|
||||
Foam::Function1s::TableBase<Type, Function1Type>::interpolator() const
|
||||
{
|
||||
if (interpolatorPtr_.empty())
|
||||
{
|
||||
@ -53,8 +53,8 @@ Foam::Function1Types::TableBase<Type>::interpolator() const
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::TableBase<Type>::check() const
|
||||
template<class Type, class Function1Type>
|
||||
void Foam::Function1s::TableBase<Type, Function1Type>::check() const
|
||||
{
|
||||
if (!table_.size())
|
||||
{
|
||||
@ -82,8 +82,11 @@ void Foam::Function1Types::TableBase<Type>::check() const
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::scalar Foam::Function1Types::TableBase<Type>::bound(const scalar x) const
|
||||
template<class Type, class Function1Type>
|
||||
Foam::scalar Foam::Function1s::TableBase<Type, Function1Type>::bound
|
||||
(
|
||||
const scalar x
|
||||
) const
|
||||
{
|
||||
const bool under = x < table_.first().first();
|
||||
const bool over = x > table_.last().first();
|
||||
@ -130,15 +133,15 @@ Foam::scalar Foam::Function1Types::TableBase<Type>::bound(const scalar x) const
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::TableBase<Type>::TableBase
|
||||
template<class Type, class Function1Type>
|
||||
Foam::Function1s::TableBase<Type, Function1Type>::TableBase
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
tableBase(),
|
||||
Function1<Type>(name),
|
||||
FieldFunction1<Type, Function1Type>(name),
|
||||
name_(name),
|
||||
boundsHandling_
|
||||
(
|
||||
@ -148,17 +151,42 @@ Foam::Function1Types::TableBase<Type>::TableBase
|
||||
),
|
||||
interpolationScheme_
|
||||
(
|
||||
dict.lookupOrDefault<word>("interpolationScheme", "linear")
|
||||
dict.lookupOrDefault<word>
|
||||
(
|
||||
"interpolationScheme",
|
||||
linearInterpolationWeights::typeName
|
||||
)
|
||||
),
|
||||
table_()
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::TableBase<Type>::TableBase(const TableBase<Type>& tbl)
|
||||
template<class Type, class Function1Type>
|
||||
Foam::Function1s::TableBase<Type, Function1Type>::TableBase
|
||||
(
|
||||
const word& name,
|
||||
const tableBase::boundsHandling boundsHandling,
|
||||
const word& interpolationScheme,
|
||||
const List<Tuple2<scalar, Type>>& table
|
||||
)
|
||||
:
|
||||
tableBase(),
|
||||
Function1<Type>(tbl),
|
||||
FieldFunction1<Type, Function1Type>(name),
|
||||
name_(name),
|
||||
boundsHandling_(boundsHandling),
|
||||
interpolationScheme_(interpolationScheme),
|
||||
table_(table)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type, class Function1Type>
|
||||
Foam::Function1s::TableBase<Type, Function1Type>::TableBase
|
||||
(
|
||||
const TableBase<Type, Function1Type>& tbl
|
||||
)
|
||||
:
|
||||
tableBase(),
|
||||
FieldFunction1<Type, Function1Type>(tbl),
|
||||
name_(tbl.name_),
|
||||
boundsHandling_(tbl.boundsHandling_),
|
||||
interpolationScheme_(tbl.interpolationScheme_),
|
||||
@ -170,15 +198,18 @@ Foam::Function1Types::TableBase<Type>::TableBase(const TableBase<Type>& tbl)
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::TableBase<Type>::~TableBase()
|
||||
template<class Type, class Function1Type>
|
||||
Foam::Function1s::TableBase<Type, Function1Type>::~TableBase()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1Types::TableBase<Type>::value(const scalar x) const
|
||||
template<class Type, class Function1Type>
|
||||
Type Foam::Function1s::TableBase<Type, Function1Type>::value
|
||||
(
|
||||
const scalar x
|
||||
) const
|
||||
{
|
||||
const scalar bx = bound(x);
|
||||
|
||||
@ -194,8 +225,8 @@ Type Foam::Function1Types::TableBase<Type>::value(const scalar x) const
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1Types::TableBase<Type>::integrate
|
||||
template<class Type, class Function1Type>
|
||||
Type Foam::Function1s::TableBase<Type, Function1Type>::integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
@ -236,8 +267,9 @@ Type Foam::Function1Types::TableBase<Type>::integrate
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::scalarField> Foam::Function1Types::TableBase<Type>::x() const
|
||||
template<class Type, class Function1Type>
|
||||
Foam::tmp<Foam::scalarField>
|
||||
Foam::Function1s::TableBase<Type, Function1Type>::x() const
|
||||
{
|
||||
tmp<scalarField> tfld(new scalarField(table_.size(), 0.0));
|
||||
scalarField& fld = tfld.ref();
|
||||
@ -251,8 +283,9 @@ Foam::tmp<Foam::scalarField> Foam::Function1Types::TableBase<Type>::x() const
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>> Foam::Function1Types::TableBase<Type>::y() const
|
||||
template<class Type, class Function1Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::Function1s::TableBase<Type, Function1Type>::y() const
|
||||
{
|
||||
tmp<Field<Type>> tfld(new Field<Type>(table_.size(), Zero));
|
||||
Field<Type>& fld = tfld.ref();
|
||||
@ -266,31 +299,58 @@ Foam::tmp<Foam::Field<Type>> Foam::Function1Types::TableBase<Type>::y() const
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::TableBase<Type>::writeEntries(Ostream& os) const
|
||||
template<class Type, class Function1Type>
|
||||
void Foam::Function1s::TableBase<Type, Function1Type>::writeEntries
|
||||
(
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
if (boundsHandling_ != tableBase::boundsHandling::clamp)
|
||||
writeEntryIfDifferent
|
||||
(
|
||||
os,
|
||||
"outOfBounds",
|
||||
tableBase::boundsHandlingNames_[tableBase::boundsHandling::clamp],
|
||||
tableBase::boundsHandlingNames_[boundsHandling_]
|
||||
);
|
||||
|
||||
writeEntryIfDifferent
|
||||
(
|
||||
os,
|
||||
"interpolationScheme",
|
||||
linearInterpolationWeights::typeName,
|
||||
interpolationScheme_
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Type, class Function1Type>
|
||||
void Foam::Function1s::TableBase<Type, Function1Type>::writeCoeffDict
|
||||
(
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
OStringStream oss;
|
||||
writeEntries(oss);
|
||||
|
||||
if (oss.str().size())
|
||||
{
|
||||
writeEntry
|
||||
(
|
||||
os,
|
||||
"outOfBounds",
|
||||
tableBase::boundsHandlingNames_[boundsHandling_]
|
||||
);
|
||||
}
|
||||
if (interpolationScheme_ != "linear")
|
||||
{
|
||||
writeEntry(os, "interpolationScheme", interpolationScheme_);
|
||||
os << indent << word(this->name() + "Coeffs") << nl;
|
||||
os << indent << token::BEGIN_BLOCK << incrIndent << nl;
|
||||
writeEntries(os);
|
||||
os << decrIndent << indent << token::END_BLOCK << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::TableBase<Type>::writeData(Ostream& os) const
|
||||
template<class Type, class Function1Type>
|
||||
void Foam::Function1s::TableBase<Type, Function1Type>::writeData
|
||||
(
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
Function1<Type>::writeData(os);
|
||||
os << nl << indent << table_ << token::END_STATEMENT << nl;
|
||||
writeEntries(os);
|
||||
os << token::END_STATEMENT << nl;
|
||||
writeCoeffDict(os);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::Function1Types::TableBase
|
||||
Foam::Function1s::TableBase
|
||||
|
||||
Description
|
||||
Base class for table with bounds handling, interpolation and integration
|
||||
@ -46,18 +46,18 @@ namespace Foam
|
||||
|
||||
class interpolationWeights;
|
||||
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class TableBase Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
template<class Type, class Function1Type>
|
||||
class TableBase
|
||||
:
|
||||
public tableBase,
|
||||
public Function1<Type>
|
||||
public FieldFunction1<Type, Function1Type>
|
||||
{
|
||||
protected:
|
||||
|
||||
@ -102,21 +102,24 @@ protected:
|
||||
scalar bound(const scalar x) const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const TableBase<Type>&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary - note table is not populated
|
||||
//- Construct from dictionary. Table is not populated.
|
||||
TableBase(const word& name, const dictionary& dict);
|
||||
|
||||
//- Copy constructor. Note: steals interpolator, tableSamples
|
||||
TableBase(const TableBase<Type>& tbl);
|
||||
//- Construct from components
|
||||
TableBase
|
||||
(
|
||||
const word& name,
|
||||
const tableBase::boundsHandling boundsHandling,
|
||||
const word& interpolationScheme,
|
||||
const List<Tuple2<scalar, Type>>& table
|
||||
);
|
||||
|
||||
//- Copy constructor. Note: Steals interpolator and tableSamples.
|
||||
TableBase(const TableBase<Type, Function1Type>& tbl);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -137,18 +140,26 @@ public:
|
||||
//- Return the dependent values
|
||||
virtual tmp<Field<Type>> y() const;
|
||||
|
||||
//- Write entries only in dictionary format
|
||||
virtual void writeEntries(Ostream& os) const;
|
||||
|
||||
//- Write the coeff dict in dictionary format
|
||||
virtual void writeCoeffDict(Ostream& os) const;
|
||||
|
||||
//- Write all table data in dictionary format
|
||||
virtual void writeData(Ostream& os) const;
|
||||
|
||||
//- Write keywords only in dictionary format. Used for non-inline
|
||||
// table types
|
||||
virtual void writeEntries(Ostream& os) const;
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const TableBase<Type, Function1Type>&) = delete;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Function1s
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -31,23 +31,23 @@ namespace Foam
|
||||
{
|
||||
template<>
|
||||
const char*
|
||||
NamedEnum<Function1Types::tableBase::boundsHandling, 4>::names[] =
|
||||
NamedEnum<Function1s::tableBase::boundsHandling, 4>::names[] =
|
||||
{"error", "warn", "clamp", "repeat"};
|
||||
}
|
||||
|
||||
const Foam::NamedEnum<Foam::Function1Types::tableBase::boundsHandling, 4>
|
||||
Foam::Function1Types::tableBase::boundsHandlingNames_;
|
||||
const Foam::NamedEnum<Foam::Function1s::tableBase::boundsHandling, 4>
|
||||
Foam::Function1s::tableBase::boundsHandlingNames_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Function1Types::tableBase::tableBase()
|
||||
Foam::Function1s::tableBase::tableBase()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Function1Types::tableBase::~tableBase()
|
||||
Foam::Function1s::tableBase::~tableBase()
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -77,7 +77,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // namespace Function1Types
|
||||
} // namespace Function1s
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -28,68 +28,58 @@ License
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::TableFile<Type>::TableFile
|
||||
Foam::Function1s::TableFile<Type>::TableFile
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
TableBase<Type>(entryName, dict),
|
||||
fName_("none")
|
||||
{
|
||||
dict.lookup("file") >> fName_;
|
||||
|
||||
fileName expandedFile(fName_);
|
||||
// IFstream is(expandedFile.expand());
|
||||
autoPtr<ISstream> isPtr(fileHandler().NewIFstream(expandedFile.expand()));
|
||||
ISstream& is = isPtr();
|
||||
|
||||
if (!is.good())
|
||||
{
|
||||
FatalIOErrorInFunction
|
||||
TableBase<Type, TableFile<Type>>(entryName, dict),
|
||||
fName_(dict.lookup("file")),
|
||||
reader_
|
||||
(
|
||||
TableReader<Type>::New
|
||||
(
|
||||
is
|
||||
) << "Cannot open file." << exit(FatalIOError);
|
||||
}
|
||||
dict.lookupOrDefault<word>
|
||||
(
|
||||
"format",
|
||||
TableReaders::Foam<Type>::typeName
|
||||
),
|
||||
dict
|
||||
)
|
||||
)
|
||||
{
|
||||
reader_()(fName_, this->table_);
|
||||
|
||||
is >> this->table_;
|
||||
|
||||
TableBase<Type>::check();
|
||||
TableBase<Type, TableFile<Type>>::check();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::TableFile<Type>::TableFile(const TableFile<Type>& tbl)
|
||||
Foam::Function1s::TableFile<Type>::TableFile(const TableFile<Type>& tbl)
|
||||
:
|
||||
TableBase<Type>(tbl),
|
||||
fName_(tbl.fName_)
|
||||
TableBase<Type, TableFile<Type>>(tbl),
|
||||
fName_(tbl.fName_),
|
||||
reader_(tbl.reader_, false)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::TableFile<Type>::~TableFile()
|
||||
Foam::Function1s::TableFile<Type>::~TableFile()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::TableFile<Type>::writeData(Ostream& os) const
|
||||
void Foam::Function1s::TableFile<Type>::writeEntries(Ostream& os) const
|
||||
{
|
||||
Function1<Type>::writeData(os);
|
||||
|
||||
os << token::END_STATEMENT << nl
|
||||
<< indent << word(this->name() + "Coeffs") << nl
|
||||
<< indent << token::BEGIN_BLOCK << nl << incrIndent;
|
||||
|
||||
// Note: for TableBase write the dictionary entries it needs but not
|
||||
// the values themselves
|
||||
TableBase<Type>::writeEntries(os);
|
||||
|
||||
TableBase<Type, TableFile<Type>>::writeEntries(os);
|
||||
writeEntry(os, "file", fName_);
|
||||
os << decrIndent << indent << token::END_BLOCK << endl;
|
||||
writeEntry(os, "format", reader_->type());
|
||||
reader_->write(os);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -22,10 +22,13 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::Function1Types::TableFile
|
||||
Foam::Function1s::TableFile
|
||||
|
||||
Description
|
||||
Templated table container function where data is read from file.
|
||||
Templated table container function where data is read from file. Data is
|
||||
stored as a list of Tuple2's. The first column is scalar. Data is read in
|
||||
the form specified by the format entry, which defaults to the native
|
||||
OpenFOAM format.
|
||||
|
||||
Usage:
|
||||
\verbatim
|
||||
@ -33,37 +36,32 @@ Description
|
||||
<entryName>Coeffs
|
||||
{
|
||||
file dataFile; // name of data file
|
||||
format foam; // data format (optional)
|
||||
outOfBounds clamp; // optional out-of-bounds handling
|
||||
interpolationScheme linear; // optional interpolation method
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Data is stored as a list of Tuple2's. First column is always stored as
|
||||
scalar entries. Data is read in the form, e.g. for an entry \<entryName\>
|
||||
that is (scalar, vector):
|
||||
\verbatim
|
||||
(
|
||||
(0.0 (1 2 3))
|
||||
(1.0 (4 5 6))
|
||||
);
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
TableFile.C
|
||||
|
||||
See also
|
||||
FoamTableReader.C
|
||||
CsvTableReader.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef TableFile_H
|
||||
#define TableFile_H
|
||||
|
||||
#include "Function1.H"
|
||||
#include "Tuple2.H"
|
||||
#include "TableBase.H"
|
||||
#include "TableReader.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -73,12 +71,15 @@ namespace Function1Types
|
||||
template<class Type>
|
||||
class TableFile
|
||||
:
|
||||
public TableBase<Type>
|
||||
public TableBase<Type, TableFile<Type>>
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- File name for csv table (optional)
|
||||
fileName fName_;
|
||||
//- File name for table
|
||||
const fileName fName_;
|
||||
|
||||
//- Table reader
|
||||
const autoPtr<TableReader<Type>> reader_;
|
||||
|
||||
|
||||
public:
|
||||
@ -89,7 +90,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from entry name and Istream
|
||||
//- Construct from entry name and dictionary
|
||||
TableFile(const word& entryName, const dictionary& dict);
|
||||
|
||||
//- Copy constructor
|
||||
@ -100,10 +101,19 @@ public:
|
||||
virtual ~TableFile();
|
||||
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the file name
|
||||
inline const fileName& fName() const
|
||||
{
|
||||
return fName_;
|
||||
}
|
||||
|
||||
|
||||
// I/O
|
||||
|
||||
//- Write in dictionary format
|
||||
virtual void writeData(Ostream& os) const;
|
||||
//- Write entries only in dictionary format
|
||||
virtual void writeEntries(Ostream& os) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
@ -115,7 +125,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Function1s
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -23,16 +23,19 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "CSV.H"
|
||||
#include "CsvTableReader.H"
|
||||
#include "DynamicList.H"
|
||||
#include "Field.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<>
|
||||
Foam::label Foam::Function1Types::CSV<Foam::label>::readValue
|
||||
(
|
||||
const List<string>& split
|
||||
)
|
||||
label TableReaders::Csv<label>::readValue(const List<string>& split) const
|
||||
{
|
||||
if (componentColumns_[0] >= split.size())
|
||||
{
|
||||
@ -47,10 +50,7 @@ Foam::label Foam::Function1Types::CSV<Foam::label>::readValue
|
||||
|
||||
|
||||
template<>
|
||||
Foam::scalar Foam::Function1Types::CSV<Foam::scalar>::readValue
|
||||
(
|
||||
const List<string>& split
|
||||
)
|
||||
scalar TableReaders::Csv<scalar>::readValue(const List<string>& split) const
|
||||
{
|
||||
if (componentColumns_[0] >= split.size())
|
||||
{
|
||||
@ -65,11 +65,11 @@ Foam::scalar Foam::Function1Types::CSV<Foam::scalar>::readValue
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::Function1Types::CSV<Type>::readValue(const List<string>& split)
|
||||
Type TableReaders::Csv<Type>::readValue(const List<string>& split) const
|
||||
{
|
||||
Type result;
|
||||
|
||||
for (label i = 0; i < pTraits<Type>::nComponents; i++)
|
||||
for(label i = 0;i < pTraits<Type>::nComponents; i++)
|
||||
{
|
||||
if (componentColumns_[i] >= split.size())
|
||||
{
|
||||
@ -79,28 +79,28 @@ Type Foam::Function1Types::CSV<Type>::readValue(const List<string>& split)
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
result[i] =
|
||||
readScalar(IStringStream(split[componentColumns_[i]])());
|
||||
result[i] = readScalar
|
||||
(
|
||||
IStringStream(split[componentColumns_[i]])()
|
||||
);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::CSV<Type>::read()
|
||||
void Foam::TableReaders::Csv<Type>::read
|
||||
(
|
||||
ISstream& is,
|
||||
List<Tuple2<scalar, Type>>& data
|
||||
) const
|
||||
{
|
||||
fileName expandedFile(fName_);
|
||||
autoPtr<ISstream> isPtr(fileHandler().NewIFstream(expandedFile.expand()));
|
||||
ISstream& is = isPtr();
|
||||
|
||||
if (!is.good())
|
||||
{
|
||||
FatalIOErrorInFunction(is)
|
||||
<< "Cannot open CSV file for reading."
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
DynamicList<Tuple2<scalar, Type>> values;
|
||||
|
||||
// Skip header
|
||||
@ -118,7 +118,6 @@ void Foam::Function1Types::CSV<Type>::read()
|
||||
string line;
|
||||
is.getLine(line);
|
||||
|
||||
|
||||
label n = 0;
|
||||
std::size_t pos = 0;
|
||||
DynamicList<string> split;
|
||||
@ -181,7 +180,6 @@ void Foam::Function1Types::CSV<Type>::read()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (split.size() <= 1)
|
||||
{
|
||||
break;
|
||||
@ -193,90 +191,69 @@ void Foam::Function1Types::CSV<Type>::read()
|
||||
values.append(Tuple2<scalar,Type>(x, value));
|
||||
}
|
||||
|
||||
this->table_.transfer(values);
|
||||
data.transfer(values);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::TableReaders::Csv<Type>::read
|
||||
(
|
||||
ISstream&,
|
||||
List<Tuple2<scalar, List<Tuple2<scalar, Type>>>>& data
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::CSV<Type>::CSV
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
Foam::TableReaders::Csv<Type>::Csv(const dictionary& dict)
|
||||
:
|
||||
TableBase<Type>(entryName, dict),
|
||||
TableReader<Type>(dict),
|
||||
nHeaderLine_(readLabel(dict.lookup("nHeaderLine"))),
|
||||
refColumn_(readLabel(dict.lookup("refColumn"))),
|
||||
componentColumns_(dict.lookup("componentColumns")),
|
||||
separator_(dict.lookupOrDefault<string>("separator", string(","))[0]),
|
||||
mergeSeparators_(readBool(dict.lookup("mergeSeparators"))),
|
||||
fName_(dict.lookup("file"))
|
||||
mergeSeparators_(readBool(dict.lookup("mergeSeparators")))
|
||||
{
|
||||
if (componentColumns_.size() != pTraits<Type>::nComponents)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< componentColumns_ << " does not have the expected length of "
|
||||
<< componentColumns_ << " does not have the expected length "
|
||||
<< pTraits<Type>::nComponents << endl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
read();
|
||||
|
||||
TableBase<Type>::check();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::CSV<Type>::CSV(const CSV<Type>& tbl)
|
||||
:
|
||||
TableBase<Type>(tbl),
|
||||
nHeaderLine_(tbl.nHeaderLine_),
|
||||
refColumn_(tbl.refColumn_),
|
||||
componentColumns_(tbl.componentColumns_),
|
||||
separator_(tbl.separator_),
|
||||
mergeSeparators_(tbl.mergeSeparators_),
|
||||
fName_(tbl.fName_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::CSV<Type>::~CSV()
|
||||
Foam::TableReaders::Csv<Type>::~Csv()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
const Foam::fileName& Foam::Function1Types::CSV<Type>::fName() const
|
||||
void Foam::TableReaders::Csv<Type>::write(Ostream& os) const
|
||||
{
|
||||
return fName_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::CSV<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
Function1<Type>::writeData(os);
|
||||
os << token::END_STATEMENT << nl;
|
||||
os << indent << word(this->name() + "Coeffs") << nl;
|
||||
os << indent << token::BEGIN_BLOCK << incrIndent << nl;
|
||||
|
||||
// Note: for TableBase write the dictionary entries it needs but not
|
||||
// the values themselves
|
||||
TableBase<Type>::writeEntries(os);
|
||||
TableReader<Type>::write(os);
|
||||
|
||||
writeEntry(os, "nHeaderLine", nHeaderLine_);
|
||||
writeEntry(os, "refColumn", refColumn_);
|
||||
writeEntry(os, "componentColumns", componentColumns_);
|
||||
if (os.format() == IOstream::BINARY)
|
||||
{
|
||||
os.format(IOstream::ASCII);
|
||||
writeEntry(os, "componentColumns", componentColumns_);
|
||||
os.format(IOstream::BINARY);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeEntry(os, "componentColumns", componentColumns_);
|
||||
}
|
||||
writeEntry(os, "separator", string(separator_));
|
||||
writeEntry(os, "mergeSeparators", mergeSeparators_);
|
||||
writeEntry(os, "file", fName_);
|
||||
|
||||
os << decrIndent << indent << token::END_BLOCK << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -22,53 +22,84 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::csvTableReader
|
||||
Foam::TableReaders::Csv
|
||||
|
||||
Description
|
||||
Reads an interpolation table from a file - CSV-format
|
||||
Reads an interpolation table from a file in CSV-format. Entries govern the
|
||||
layout of the CSV file. The index of the first (x) column of the table is
|
||||
given by the refColumn entry, and is always scalar. The indices of the
|
||||
components of the second (y) column are given by the componentColumns
|
||||
entry.
|
||||
|
||||
Usage:
|
||||
\verbatim
|
||||
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
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
tableReader.C
|
||||
CsvTableReader.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef csvTableReader_H
|
||||
#define csvTableReader_H
|
||||
#ifndef CsvTableReader_H
|
||||
#define CsvTableReader_H
|
||||
|
||||
#include "tableReader.H"
|
||||
#include "TableReader.H"
|
||||
#include "labelList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace TableReaders
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class csvTableReader Declaration
|
||||
Class Csv Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class csvTableReader
|
||||
class Csv
|
||||
:
|
||||
public tableReader<Type>
|
||||
public TableReader<Type>
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Does the file have a header line?
|
||||
const bool headerLine_;
|
||||
//- Number of header lines
|
||||
const label nHeaderLine_;
|
||||
|
||||
//- Column of the time
|
||||
const label timeColumn_;
|
||||
//- Reference column
|
||||
const label refColumn_;
|
||||
|
||||
//- Labels of the components
|
||||
const labelList componentColumns_;
|
||||
|
||||
//- Read the next value from the split string
|
||||
Type readValue(const List<string>&);
|
||||
|
||||
//- Separator character
|
||||
const char separator_;
|
||||
|
||||
//- Merge separators flag; e.g. ',,,' becomes ','
|
||||
bool mergeSeparators_;
|
||||
|
||||
|
||||
// Private Member functions
|
||||
|
||||
//- Read the next value from the split string
|
||||
Type readValue(const List<string>&) const;
|
||||
|
||||
//- Read a 1D table
|
||||
virtual void read(ISstream&, List<Tuple2<scalar, Type>>&) const;
|
||||
|
||||
//- Read a 2D table
|
||||
virtual void read
|
||||
(
|
||||
ISstream&,
|
||||
List<Tuple2<scalar, List<Tuple2<scalar, Type>>>>&
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -79,37 +110,21 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
csvTableReader(const dictionary& dict);
|
||||
Csv(const dictionary& dict);
|
||||
|
||||
//- Construct and return a copy
|
||||
virtual autoPtr<tableReader<Type>> clone() const
|
||||
virtual autoPtr<TableReader<Type>> clone() const
|
||||
{
|
||||
return autoPtr<tableReader<Type>>
|
||||
(
|
||||
new csvTableReader<Type>
|
||||
(
|
||||
*this
|
||||
)
|
||||
);
|
||||
return autoPtr<TableReader<Type>>(new Csv<Type>(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~csvTableReader();
|
||||
virtual ~Csv();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the table
|
||||
virtual void operator()(const fileName&, List<Tuple2<scalar, Type>>&);
|
||||
|
||||
//- Read 2D table
|
||||
virtual void operator()
|
||||
(
|
||||
const fileName&,
|
||||
List<Tuple2<scalar, List<Tuple2<scalar, Type>>>>&
|
||||
);
|
||||
|
||||
//- Write the remaining parameters
|
||||
virtual void write(Ostream& os) const;
|
||||
};
|
||||
@ -117,12 +132,13 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace TableReaders
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "csvTableReader.C"
|
||||
#include "CsvTableReader.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -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
|
||||
@ -23,49 +23,46 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "openFoamTableReader.H"
|
||||
#include "fileOperation.H"
|
||||
#include "FoamTableReader.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::TableReaders::Foam<Type>::read
|
||||
(
|
||||
ISstream& is,
|
||||
List<Tuple2<scalar, Type>>& data
|
||||
) const
|
||||
{
|
||||
is >> data;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::TableReaders::Foam<Type>::read
|
||||
(
|
||||
ISstream& is,
|
||||
List<Tuple2<scalar, List<Tuple2<scalar, Type>>>>& data
|
||||
) const
|
||||
{
|
||||
is >> data;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::openFoamTableReader<Type>::openFoamTableReader(const dictionary& dict)
|
||||
Foam::TableReaders::Foam<Type>::Foam(const dictionary& dict)
|
||||
:
|
||||
tableReader<Type>(dict)
|
||||
TableReader<Type>(dict)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::openFoamTableReader<Type>::~openFoamTableReader()
|
||||
Foam::TableReaders::Foam<Type>::~Foam()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::openFoamTableReader<Type>::operator()
|
||||
(
|
||||
const fileName& fName,
|
||||
List<Tuple2<scalar, Type>>& data
|
||||
)
|
||||
{
|
||||
// Read data from file
|
||||
fileHandler().NewIFstream(fName)()() >> data;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::openFoamTableReader<Type>::operator()
|
||||
(
|
||||
const fileName& fName,
|
||||
List<Tuple2<scalar, List<Tuple2<scalar, Type>>>>& data
|
||||
)
|
||||
{
|
||||
// Read data from file
|
||||
fileHandler().NewIFstream(fName)()() >> data;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -22,89 +22,93 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::openFoamTableReader
|
||||
Foam::TableReaders::Foam
|
||||
|
||||
Description
|
||||
Reads an interpolation table from a file - OpenFOAM-format
|
||||
Reads an interpolation table from a file in OpenFOAM-format. This is a list
|
||||
of Tuple2's where the first (x) column is scalar, and the second (y) column
|
||||
is the type to be interpolated.
|
||||
|
||||
Usage:
|
||||
\verbatim
|
||||
(
|
||||
(0.0 (1 2 3))
|
||||
(1.0 (4 5 6))
|
||||
);
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
openFoamTableReader.C
|
||||
FoamTableReader.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef openFoamTableReader_H
|
||||
#define openFoamTableReader_H
|
||||
#ifndef FoamTableReader_H
|
||||
#define FoamTableReader_H
|
||||
|
||||
#include "tableReader.H"
|
||||
#include "TableReader.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace TableReaders
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class openFoamTableReader Declaration
|
||||
Class Foam Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class openFoamTableReader
|
||||
class Foam
|
||||
:
|
||||
public tableReader<Type>
|
||||
public TableReader<Type>
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Read a 1D table
|
||||
virtual void read(ISstream&, List<Tuple2<scalar, Type>> &) const;
|
||||
|
||||
//- Read a 2D table
|
||||
virtual void read
|
||||
(
|
||||
ISstream&,
|
||||
List<Tuple2<scalar, List<Tuple2<scalar, Type>>>>&
|
||||
) const;
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("openFoam");
|
||||
TypeName("foam");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
openFoamTableReader(const dictionary &dict);
|
||||
Foam(const dictionary &dict);
|
||||
|
||||
//- Construct and return a copy
|
||||
virtual autoPtr<tableReader<Type>> clone() const
|
||||
virtual autoPtr<TableReader<Type>> clone() const
|
||||
{
|
||||
return autoPtr<tableReader<Type>>
|
||||
(
|
||||
new openFoamTableReader<Type>
|
||||
(
|
||||
*this
|
||||
)
|
||||
);
|
||||
return autoPtr<TableReader<Type>>(new Foam<Type>(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~openFoamTableReader();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the table
|
||||
virtual void operator()(const fileName&, List<Tuple2<scalar, Type>> &);
|
||||
|
||||
//- Read 2D table
|
||||
virtual void operator()
|
||||
(
|
||||
const fileName&,
|
||||
List<Tuple2<scalar, List<Tuple2<scalar, Type>>>>&
|
||||
);
|
||||
virtual ~Foam();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace TableReaders
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "openFoamTableReader.C"
|
||||
#include "FoamTableReader.C"
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
@ -23,25 +23,20 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "tableReader.H"
|
||||
#include "TableReader.H"
|
||||
#include "fileOperation.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::autoPtr<Foam::tableReader<Type>> Foam::tableReader<Type>::New
|
||||
Foam::autoPtr<Foam::TableReader<Type>> Foam::TableReader<Type>::New
|
||||
(
|
||||
const dictionary& spec
|
||||
const word& readerType,
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
const word readerType = spec.lookupOrDefault<word>
|
||||
(
|
||||
"readerType",
|
||||
"openFoam"
|
||||
);
|
||||
|
||||
typename dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_
|
||||
->find(readerType);
|
||||
dictionaryConstructorTablePtr_->find(readerType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
{
|
||||
@ -53,32 +48,64 @@ Foam::autoPtr<Foam::tableReader<Type>> Foam::tableReader<Type>::New
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<tableReader<Type>>(cstrIter()(spec));
|
||||
return autoPtr<TableReader<Type>>(cstrIter()(dict));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::tableReader<Type>::tableReader(const dictionary&)
|
||||
Foam::TableReader<Type>::TableReader(const dictionary&)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::tableReader<Type>::~tableReader()
|
||||
Foam::TableReader<Type>::~TableReader()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::tableReader<Type>::write(Ostream& os) const
|
||||
void Foam::TableReader<Type>::write(Ostream& os) const
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
template<class TableType>
|
||||
void Foam::TableReader<Type>::operator()
|
||||
(
|
||||
const fileName& fName,
|
||||
TableType& data
|
||||
) const
|
||||
{
|
||||
if (this->type() != "openFoam")
|
||||
// Expand the file
|
||||
fileName fNameExpanded(fName);
|
||||
fNameExpanded.expand();
|
||||
|
||||
// Open a stream and check it
|
||||
autoPtr<ISstream> isPtr(fileHandler().NewIFstream(fNameExpanded));
|
||||
ISstream& is = isPtr();
|
||||
if (!is.good())
|
||||
{
|
||||
writeEntry(os, "readerType", this->type());
|
||||
FatalIOErrorInFunction(is)
|
||||
<< "Cannot open file" << fName << nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
// Read data from the stream
|
||||
read(is, data);
|
||||
|
||||
// Check something was read
|
||||
if (data.empty())
|
||||
{
|
||||
FatalIOErrorInFunction(is)
|
||||
<< "Table read from " << fName << " is empty" << nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,27 +22,22 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::tableReader
|
||||
Foam::TableReader
|
||||
|
||||
Description
|
||||
Base class to read table data for the interpolationTable
|
||||
Base class to read table data for tables
|
||||
|
||||
SourceFiles
|
||||
tableReader.C
|
||||
TableReader.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef tableReader_H
|
||||
#define tableReader_H
|
||||
#ifndef TableReader_H
|
||||
#define TableReader_H
|
||||
|
||||
#include "fileName.H"
|
||||
#include "wordList.H"
|
||||
#include "vector.H"
|
||||
#include "tensor.H"
|
||||
#include "typeInfo.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
#include "autoPtr.H"
|
||||
#include "dictionary.H"
|
||||
#include "fieldTypes.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
#include "Tuple2.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -51,24 +46,42 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class tableReader Declaration
|
||||
Class TableReader Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class tableReader
|
||||
class TableReader
|
||||
{
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Read a 1D table
|
||||
virtual void read
|
||||
(
|
||||
ISstream&,
|
||||
List<Tuple2<scalar, Type>>&
|
||||
) const = 0;
|
||||
|
||||
//- Read a 2D table
|
||||
virtual void read
|
||||
(
|
||||
ISstream&,
|
||||
List<Tuple2<scalar, List<Tuple2<scalar, Type>>>>&
|
||||
) const = 0;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("tableReader");
|
||||
TypeName("TableReader");
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
tableReader,
|
||||
TableReader,
|
||||
dictionary,
|
||||
(const dictionary& dict),
|
||||
(dict)
|
||||
@ -78,37 +91,29 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
tableReader(const dictionary& dict);
|
||||
TableReader(const dictionary& dict);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual autoPtr<tableReader<Type>> clone() const = 0;
|
||||
virtual autoPtr<TableReader<Type>> clone() const = 0;
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Return a reference to the selected tableReader
|
||||
static autoPtr<tableReader> New(const dictionary& spec);
|
||||
// Selector
|
||||
static autoPtr<TableReader<Type>> New
|
||||
(
|
||||
const word& readerType,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~tableReader();
|
||||
virtual ~TableReader();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the table
|
||||
virtual void operator()
|
||||
(
|
||||
const fileName&,
|
||||
List<Tuple2<scalar, Type>>&
|
||||
) = 0;
|
||||
|
||||
//- Read the 2D table
|
||||
virtual void operator()
|
||||
(
|
||||
const fileName&,
|
||||
List<Tuple2<scalar, List<Tuple2<scalar, Type>>>>&
|
||||
) = 0;
|
||||
//- Read a table
|
||||
template<class TableType>
|
||||
void operator()(const fileName&, TableType&) const;
|
||||
|
||||
//- Write additional information
|
||||
virtual void write(Ostream& os) const;
|
||||
@ -121,11 +126,27 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "tableReader.C"
|
||||
#endif
|
||||
#define defineTableReader(Type) \
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(TableReader<Type>, 0); \
|
||||
\
|
||||
defineTemplateRunTimeSelectionTable(TableReader<Type>, dictionary);
|
||||
|
||||
|
||||
#define makeTableReader(SS, Type) \
|
||||
\
|
||||
defineNamedTemplateTypeNameAndDebug(TableReaders::SS<Type>, 0); \
|
||||
\
|
||||
TableReader<Type>::adddictionaryConstructorToTable<TableReaders::SS<Type>> \
|
||||
add##SS##Type##ConstructorToTable_;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "TableReader.C"
|
||||
#include "FoamTableReader.H"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
@ -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
|
||||
@ -23,15 +23,25 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "csvTableReader.H"
|
||||
#include "tableReaders.H"
|
||||
#include "FoamTableReader.H"
|
||||
#include "CsvTableReader.H"
|
||||
#include "fieldTypes.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define makeTableReaders(Type) \
|
||||
defineTableReader(Type); \
|
||||
makeTableReader(Foam, Type); \
|
||||
makeTableReader(Csv, Type)
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makeTableReaders(csvTableReader);
|
||||
makeTableReaders(scalar);
|
||||
makeTableReaders(vector);
|
||||
makeTableReaders(sphericalTensor);
|
||||
makeTableReaders(symmTensor);
|
||||
makeTableReaders(tensor);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -28,7 +28,7 @@ License
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::Uniform<Type>::Uniform
|
||||
Foam::Function1s::Uniform<Type>::Uniform
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::Function1Types::Uniform
|
||||
Foam::Function1s::Uniform
|
||||
|
||||
Description
|
||||
Templated function that returns a constant value.
|
||||
@ -49,7 +49,7 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -83,7 +83,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Function1s
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -28,27 +28,27 @@ License
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::ZeroConstant<Type>::ZeroConstant
|
||||
Foam::Function1s::ZeroConstant<Type>::ZeroConstant
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
Function1<Type>(entryName)
|
||||
FieldFunction1<Type, ZeroConstant<Type>>(entryName)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Function1Types::ZeroConstant<Type>::~ZeroConstant()
|
||||
Foam::Function1s::ZeroConstant<Type>::~ZeroConstant()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::Function1Types::ZeroConstant<Type>::writeData(Ostream& os) const
|
||||
void Foam::Function1s::ZeroConstant<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
Function1<Type>::writeData(os);
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::Function1Types::ZeroConstant
|
||||
Foam::Function1s::ZeroConstant
|
||||
|
||||
Description
|
||||
Templated function that returns the corresponding 0 (zero).
|
||||
@ -46,7 +46,7 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -56,7 +56,7 @@ namespace Function1Types
|
||||
template<class Type>
|
||||
class ZeroConstant
|
||||
:
|
||||
public Function1<Type>
|
||||
public FieldFunction1<Type, ZeroConstant<Type>>
|
||||
{
|
||||
|
||||
public:
|
||||
@ -96,7 +96,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Function1s
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -28,7 +28,7 @@ License
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline Type Foam::Function1Types::ZeroConstant<Type>::value
|
||||
inline Type Foam::Function1s::ZeroConstant<Type>::value
|
||||
(
|
||||
const scalar x
|
||||
) const
|
||||
@ -38,7 +38,7 @@ inline Type Foam::Function1Types::ZeroConstant<Type>::value
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Type Foam::Function1Types::ZeroConstant<Type>::integrate
|
||||
inline Type Foam::Function1s::ZeroConstant<Type>::integrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -29,7 +29,7 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
makeScalarFunction1(halfCosineRamp);
|
||||
}
|
||||
@ -38,19 +38,19 @@ namespace Function1Types
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Function1Types::halfCosineRamp::halfCosineRamp
|
||||
Foam::Function1s::halfCosineRamp::halfCosineRamp
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
ramp(entryName, dict)
|
||||
Ramp<halfCosineRamp>(entryName, dict)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Function1Types::halfCosineRamp::~halfCosineRamp()
|
||||
Foam::Function1s::halfCosineRamp::~halfCosineRamp()
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -22,14 +22,14 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::Function1Types::halfCosineRamp
|
||||
Foam::Function1s::halfCosineRamp
|
||||
|
||||
Description
|
||||
Half-cosine ramp function starting from 0 and increasing to 1 from \c start
|
||||
over the \c duration and remaining at 1 thereafter.
|
||||
|
||||
See also
|
||||
Foam::Function1Types::ramp
|
||||
Foam::Function1s::Ramp
|
||||
|
||||
SourceFiles
|
||||
halfCosineRamp.C
|
||||
@ -39,13 +39,13 @@ SourceFiles
|
||||
#ifndef halfCosineRamp_H
|
||||
#define halfCosineRamp_H
|
||||
|
||||
#include "ramp.H"
|
||||
#include "Ramp.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -54,7 +54,7 @@ namespace Function1Types
|
||||
|
||||
class halfCosineRamp
|
||||
:
|
||||
public ramp
|
||||
public Ramp<halfCosineRamp>
|
||||
{
|
||||
|
||||
public:
|
||||
@ -99,7 +99,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Function1s
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -28,7 +28,7 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::scalar Foam::Function1Types::halfCosineRamp::value
|
||||
inline Foam::scalar Foam::Function1s::halfCosineRamp::value
|
||||
(
|
||||
const scalar t
|
||||
) const
|
||||
@ -37,7 +37,7 @@ inline Foam::scalar Foam::Function1Types::halfCosineRamp::value
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::Function1Types::halfCosineRamp::integrate
|
||||
inline Foam::scalar Foam::Function1s::halfCosineRamp::integrate
|
||||
(
|
||||
const scalar t1,
|
||||
const scalar t2
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -29,7 +29,7 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
makeScalarFunction1(linearRamp);
|
||||
}
|
||||
@ -38,19 +38,19 @@ namespace Function1Types
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Function1Types::linearRamp::linearRamp
|
||||
Foam::Function1s::linearRamp::linearRamp
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
ramp(entryName, dict)
|
||||
Ramp<linearRamp>(entryName, dict)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Function1Types::linearRamp::~linearRamp()
|
||||
Foam::Function1s::linearRamp::~linearRamp()
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -22,14 +22,14 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::Function1Types::linearRamp
|
||||
Foam::Function1s::linearRamp
|
||||
|
||||
Description
|
||||
Linear ramp function starting from 0 and increasing linearRamply to 1 from
|
||||
\c start over the \c duration and remaining at 1 thereafter.
|
||||
|
||||
See also
|
||||
Foam::Function1Types::ramp
|
||||
Foam::Function1s::Ramp
|
||||
|
||||
SourceFiles
|
||||
linearRamp.C
|
||||
@ -39,13 +39,13 @@ SourceFiles
|
||||
#ifndef linearRamp_H
|
||||
#define linearRamp_H
|
||||
|
||||
#include "ramp.H"
|
||||
#include "Ramp.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -54,7 +54,7 @@ namespace Function1Types
|
||||
|
||||
class linearRamp
|
||||
:
|
||||
public ramp
|
||||
public Ramp<linearRamp>
|
||||
{
|
||||
|
||||
public:
|
||||
@ -99,7 +99,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Function1s
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -27,22 +27,23 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::scalar Foam::Function1Types::linearRamp::value
|
||||
inline Foam::scalar Foam::Function1s::linearRamp::value
|
||||
(
|
||||
const scalar t
|
||||
) const
|
||||
{
|
||||
return ramp::linearRamp(t);
|
||||
return Ramp<linearRamp>::linearRamp(t);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::Function1Types::linearRamp::integrate
|
||||
inline Foam::scalar Foam::Function1s::linearRamp::integrate
|
||||
(
|
||||
const scalar t1,
|
||||
const scalar t2
|
||||
) const
|
||||
{
|
||||
const scalar l1 = ramp::linearRamp(t1), l2 = ramp::linearRamp(t2);
|
||||
const scalar l1 = Ramp<linearRamp>::linearRamp(t1);
|
||||
const scalar l2 = Ramp<linearRamp>::linearRamp(t2);
|
||||
|
||||
return
|
||||
(sqr(l2) - sqr(l1))/2/dLinearRampDt()
|
||||
|
||||
@ -30,7 +30,6 @@ License
|
||||
#include "PolynomialEntry.H"
|
||||
#include "Sine.H"
|
||||
#include "Square.H"
|
||||
#include "CSV.H"
|
||||
#include "Table.H"
|
||||
#include "TableFile.H"
|
||||
#include "Scale.H"
|
||||
@ -48,7 +47,6 @@ License
|
||||
makeFunction1Type(Polynomial, Type); \
|
||||
makeFunction1Type(Sine, Type); \
|
||||
makeFunction1Type(Square, Type); \
|
||||
makeFunction1Type(CSV, Type); \
|
||||
makeFunction1Type(Table, Type); \
|
||||
makeFunction1Type(TableFile, Type); \
|
||||
makeFunction1Type(Scale, Type);
|
||||
@ -66,20 +64,4 @@ namespace Foam
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::tmp<Foam::Field<Foam::label>>
|
||||
Foam::Function1Types::Constant<Foam::label>::integrate
|
||||
(
|
||||
const scalarField& x1,
|
||||
const scalarField& x2
|
||||
) const
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Evaluation is not defined for " << type() << " functions"
|
||||
<< exit(FatalError);
|
||||
|
||||
return tmp<Field<label>>(new Field<label>(x1.size()));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -29,7 +29,7 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
makeScalarFunction1(quadraticRamp);
|
||||
}
|
||||
@ -38,19 +38,19 @@ namespace Function1Types
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Function1Types::quadraticRamp::quadraticRamp
|
||||
Foam::Function1s::quadraticRamp::quadraticRamp
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
ramp(entryName, dict)
|
||||
Ramp<quadraticRamp>(entryName, dict)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Function1Types::quadraticRamp::~quadraticRamp()
|
||||
Foam::Function1s::quadraticRamp::~quadraticRamp()
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -22,14 +22,14 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::Function1Types::quadraticRamp
|
||||
Foam::Function1s::quadraticRamp
|
||||
|
||||
Description
|
||||
Quadratic ramp function starting from 0 and increasing quadraticRampally
|
||||
to 1 from \c t_0 over the \c duration and remaining at 1 thereafter.
|
||||
|
||||
See also
|
||||
Foam::Function1Types::ramp
|
||||
Foam::Function1s::Ramp
|
||||
|
||||
SourceFiles
|
||||
quadraticRamp.C
|
||||
@ -39,13 +39,13 @@ SourceFiles
|
||||
#ifndef quadraticRamp_H
|
||||
#define quadraticRamp_H
|
||||
|
||||
#include "ramp.H"
|
||||
#include "Ramp.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -54,7 +54,7 @@ namespace Function1Types
|
||||
|
||||
class quadraticRamp
|
||||
:
|
||||
public ramp
|
||||
public Ramp<quadraticRamp>
|
||||
{
|
||||
|
||||
public:
|
||||
@ -99,7 +99,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Function1s
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -27,7 +27,7 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::scalar Foam::Function1Types::quadraticRamp::value
|
||||
inline Foam::scalar Foam::Function1s::quadraticRamp::value
|
||||
(
|
||||
const scalar t
|
||||
) const
|
||||
@ -36,7 +36,7 @@ inline Foam::scalar Foam::Function1Types::quadraticRamp::value
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::Function1Types::quadraticRamp::integrate
|
||||
inline Foam::scalar Foam::Function1s::quadraticRamp::integrate
|
||||
(
|
||||
const scalar t1,
|
||||
const scalar t2
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -29,7 +29,7 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
makeScalarFunction1(quarterCosineRamp);
|
||||
}
|
||||
@ -38,19 +38,19 @@ namespace Function1Types
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Function1Types::quarterCosineRamp::quarterCosineRamp
|
||||
Foam::Function1s::quarterCosineRamp::quarterCosineRamp
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
ramp(entryName, dict)
|
||||
Ramp<quarterCosineRamp>(entryName, dict)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Function1Types::quarterCosineRamp::~quarterCosineRamp()
|
||||
Foam::Function1s::quarterCosineRamp::~quarterCosineRamp()
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -22,14 +22,14 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::Function1Types::quarterCosineRamp
|
||||
Foam::Function1s::quarterCosineRamp
|
||||
|
||||
Description
|
||||
Quarter-cosine ramp function starting from 0 and increasing to 1 from \c
|
||||
start over the \c duration and remaining at 1 thereafter.
|
||||
|
||||
See also
|
||||
Foam::Function1Types::ramp
|
||||
Foam::Function1s::Ramp
|
||||
|
||||
SourceFiles
|
||||
quarterCosineRamp.C
|
||||
@ -39,13 +39,13 @@ SourceFiles
|
||||
#ifndef quarterCosineRamp_H
|
||||
#define quarterCosineRamp_H
|
||||
|
||||
#include "ramp.H"
|
||||
#include "Ramp.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -54,7 +54,7 @@ namespace Function1Types
|
||||
|
||||
class quarterCosineRamp
|
||||
:
|
||||
public ramp
|
||||
public Ramp<quarterCosineRamp>
|
||||
{
|
||||
|
||||
public:
|
||||
@ -99,7 +99,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Function1s
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -28,7 +28,7 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::scalar Foam::Function1Types::quarterCosineRamp::value
|
||||
inline Foam::scalar Foam::Function1s::quarterCosineRamp::value
|
||||
(
|
||||
const scalar t
|
||||
) const
|
||||
@ -37,7 +37,7 @@ inline Foam::scalar Foam::Function1Types::quarterCosineRamp::value
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::Function1Types::quarterCosineRamp::integrate
|
||||
inline Foam::scalar Foam::Function1s::quarterCosineRamp::integrate
|
||||
(
|
||||
const scalar t1,
|
||||
const scalar t2
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -29,7 +29,7 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
makeScalarFunction1(quarterSineRamp);
|
||||
}
|
||||
@ -38,19 +38,19 @@ namespace Function1Types
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Function1Types::quarterSineRamp::quarterSineRamp
|
||||
Foam::Function1s::quarterSineRamp::quarterSineRamp
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
ramp(entryName, dict)
|
||||
Ramp<quarterSineRamp>(entryName, dict)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Function1Types::quarterSineRamp::~quarterSineRamp()
|
||||
Foam::Function1s::quarterSineRamp::~quarterSineRamp()
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -22,14 +22,14 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::Function1Types::quarterSineRamp
|
||||
Foam::Function1s::quarterSineRamp
|
||||
|
||||
Description
|
||||
Quarter-sine ramp function starting from 0 and increasing to 1 from \c start
|
||||
over the \c duration and remaining at 1 thereafter.
|
||||
|
||||
See also
|
||||
Foam::Function1Types::ramp
|
||||
Foam::Function1s::Ramp
|
||||
|
||||
SourceFiles
|
||||
quarterSineRamp.C
|
||||
@ -39,13 +39,13 @@ SourceFiles
|
||||
#ifndef quarterSineRamp_H
|
||||
#define quarterSineRamp_H
|
||||
|
||||
#include "ramp.H"
|
||||
#include "Ramp.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -54,7 +54,7 @@ namespace Function1Types
|
||||
|
||||
class quarterSineRamp
|
||||
:
|
||||
public ramp
|
||||
public Ramp<quarterSineRamp>
|
||||
{
|
||||
|
||||
public:
|
||||
@ -99,7 +99,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Function1s
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -28,7 +28,7 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::scalar Foam::Function1Types::quarterSineRamp::value
|
||||
inline Foam::scalar Foam::Function1s::quarterSineRamp::value
|
||||
(
|
||||
const scalar t
|
||||
) const
|
||||
@ -37,7 +37,7 @@ inline Foam::scalar Foam::Function1Types::quarterSineRamp::value
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::Function1Types::quarterSineRamp::integrate
|
||||
inline Foam::scalar Foam::Function1s::quarterSineRamp::integrate
|
||||
(
|
||||
const scalar t1,
|
||||
const scalar t2
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "hmm.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -29,7 +29,7 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
makeScalarFunction1(reverseRamp);
|
||||
}
|
||||
@ -38,38 +38,38 @@ namespace Function1Types
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Function1Types::reverseRamp::reverseRamp
|
||||
Foam::Function1s::reverseRamp::reverseRamp
|
||||
(
|
||||
const word& entryName,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
ramp(entryName, dict),
|
||||
Ramp<reverseRamp>(entryName, dict),
|
||||
ramp_(Function1<scalar>::New("ramp", dict))
|
||||
{}
|
||||
|
||||
|
||||
Foam::Function1Types::reverseRamp::reverseRamp
|
||||
Foam::Function1s::reverseRamp::reverseRamp
|
||||
(
|
||||
const reverseRamp& rr
|
||||
)
|
||||
:
|
||||
ramp(rr),
|
||||
Ramp<reverseRamp>(rr),
|
||||
ramp_(rr.ramp_, false)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Function1Types::reverseRamp::~reverseRamp()
|
||||
Foam::Function1s::reverseRamp::~reverseRamp()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::Function1Types::reverseRamp::writeData(Ostream& os) const
|
||||
void Foam::Function1s::reverseRamp::writeData(Ostream& os) const
|
||||
{
|
||||
ramp::writeData(os);
|
||||
Ramp<reverseRamp>::writeData(os);
|
||||
os << token::END_STATEMENT << nl;
|
||||
os << indent << word(this->name() + "Coeffs") << nl;
|
||||
os << indent << token::BEGIN_BLOCK << incrIndent << nl;
|
||||
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::Function1Types::reverseRamp
|
||||
Foam::Function1s::reverseRamp
|
||||
|
||||
Description
|
||||
A wrapper class to reverse any ramp function such that the result starts
|
||||
@ -56,7 +56,7 @@ Description
|
||||
\endverbatim
|
||||
|
||||
See also
|
||||
Foam::Function1Types::ramp
|
||||
Foam::Function1s::Ramp
|
||||
|
||||
SourceFiles
|
||||
reverseRamp.C
|
||||
@ -66,13 +66,13 @@ SourceFiles
|
||||
#ifndef reverseRamp_H
|
||||
#define reverseRamp_H
|
||||
|
||||
#include "ramp.H"
|
||||
#include "Ramp.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1Types
|
||||
namespace Function1s
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -81,7 +81,7 @@ namespace Function1Types
|
||||
|
||||
class reverseRamp
|
||||
:
|
||||
public ramp
|
||||
public Ramp<reverseRamp>
|
||||
{
|
||||
//- Standard ramp function to reverse
|
||||
autoPtr<Function1<scalar>> ramp_;
|
||||
@ -135,7 +135,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1Types
|
||||
} // End namespace Function1s
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -27,7 +27,7 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::scalar Foam::Function1Types::reverseRamp::value
|
||||
inline Foam::scalar Foam::Function1s::reverseRamp::value
|
||||
(
|
||||
const scalar t
|
||||
) const
|
||||
@ -36,7 +36,7 @@ inline Foam::scalar Foam::Function1Types::reverseRamp::value
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::Function1Types::reverseRamp::integrate
|
||||
inline Foam::scalar Foam::Function1s::reverseRamp::integrate
|
||||
(
|
||||
const scalar t1,
|
||||
const scalar t2
|
||||
|
||||
@ -29,7 +29,7 @@ License
|
||||
#include "pointFields.H"
|
||||
#include "PointEdgeWave.H"
|
||||
#include "syncTools.H"
|
||||
#include "interpolationTable.H"
|
||||
#include "TableFile.H"
|
||||
#include "pointConstraints.H"
|
||||
#include "mapPolyMesh.H"
|
||||
|
||||
@ -233,9 +233,9 @@ Foam::displacementLayeredMotionMotionSolver::faceZoneEvaluate
|
||||
}
|
||||
else if (type == "timeVaryingUniformFixedValue")
|
||||
{
|
||||
interpolationTable<vector> timeSeries(dict);
|
||||
Function1s::TableFile<vector> timeSeries(word::null, dict);
|
||||
|
||||
fld = timeSeries(mesh().time().timeOutputValue());
|
||||
fld = timeSeries.value(mesh().time().timeOutputValue());
|
||||
}
|
||||
else if (type == "slip")
|
||||
{
|
||||
|
||||
@ -59,7 +59,7 @@ Note
|
||||
|
||||
See also
|
||||
Foam::fixedValueFvPatchField
|
||||
Foam::Function1Types
|
||||
Foam::Function1s
|
||||
|
||||
SourceFiles
|
||||
cylindricalInletVelocityFvPatchVectorField.C
|
||||
|
||||
@ -74,7 +74,7 @@ Foam::fanPressureFvPatchScalarField::fanPressureFvPatchScalarField
|
||||
)
|
||||
:
|
||||
totalPressureFvPatchScalarField(ptf, p, iF, mapper),
|
||||
fanCurve_(ptf.fanCurve_),
|
||||
fanCurve_(ptf.fanCurve_, false),
|
||||
direction_(ptf.direction_)
|
||||
{}
|
||||
|
||||
@ -87,7 +87,7 @@ Foam::fanPressureFvPatchScalarField::fanPressureFvPatchScalarField
|
||||
)
|
||||
:
|
||||
totalPressureFvPatchScalarField(p, iF, dict),
|
||||
fanCurve_(dict),
|
||||
fanCurve_(Function1<scalar>::New("fanCurve", dict)),
|
||||
direction_(fanFlowDirectionNames_.read(dict.lookup("direction")))
|
||||
{}
|
||||
|
||||
@ -98,7 +98,7 @@ Foam::fanPressureFvPatchScalarField::fanPressureFvPatchScalarField
|
||||
)
|
||||
:
|
||||
totalPressureFvPatchScalarField(pfopsf),
|
||||
fanCurve_(pfopsf.fanCurve_),
|
||||
fanCurve_(pfopsf.fanCurve_, false),
|
||||
direction_(pfopsf.direction_)
|
||||
{}
|
||||
|
||||
@ -110,7 +110,7 @@ Foam::fanPressureFvPatchScalarField::fanPressureFvPatchScalarField
|
||||
)
|
||||
:
|
||||
totalPressureFvPatchScalarField(pfopsf, iF),
|
||||
fanCurve_(pfopsf.fanCurve_),
|
||||
fanCurve_(pfopsf.fanCurve_, false),
|
||||
direction_(pfopsf.direction_)
|
||||
{}
|
||||
|
||||
@ -157,7 +157,7 @@ void Foam::fanPressureFvPatchScalarField::updateCoeffs()
|
||||
}
|
||||
|
||||
// Pressure drop for this flow rate
|
||||
const scalar pdFan = fanCurve_(max(volFlowRate, 0.0));
|
||||
const scalar pdFan = fanCurve_->value(max(volFlowRate, 0.0));
|
||||
|
||||
totalPressureFvPatchScalarField::updateCoeffs
|
||||
(
|
||||
@ -170,7 +170,7 @@ void Foam::fanPressureFvPatchScalarField::updateCoeffs()
|
||||
void Foam::fanPressureFvPatchScalarField::write(Ostream& os) const
|
||||
{
|
||||
totalPressureFvPatchScalarField::write(os);
|
||||
fanCurve_.write(os);
|
||||
writeEntry(os, fanCurve_());
|
||||
writeEntry(os, "direction", fanFlowDirectionNames_[direction_]);
|
||||
}
|
||||
|
||||
|
||||
@ -31,9 +31,7 @@ Description
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
file | fan curve file name | yes |
|
||||
outOfBounds | out of bounds handling | yes |
|
||||
direction | direction of flow through fan [in/out] | yes |
|
||||
fanCurve | fan curve file name | yes |
|
||||
p0 | environmental total pressure | yes |
|
||||
\endtable
|
||||
|
||||
@ -42,8 +40,19 @@ Usage
|
||||
inlet
|
||||
{
|
||||
type fanPressure;
|
||||
file "fanCurve";
|
||||
outOfBounds clamp;
|
||||
fanCurve tableFile;
|
||||
tableFileCoeffs
|
||||
{
|
||||
file "$FOAM_CASE/constant/pressureVsQ";
|
||||
format csv;
|
||||
nHeaderLine 1;
|
||||
refColumn 0;
|
||||
componentColumns 1(1);
|
||||
separator ",";
|
||||
mergeSeparators no;
|
||||
outOfBounds clamp;
|
||||
interpolationScheme linear;
|
||||
}
|
||||
direction in;
|
||||
p0 uniform 0;
|
||||
value uniform 0;
|
||||
@ -52,18 +61,31 @@ Usage
|
||||
outlet
|
||||
{
|
||||
type fanPressure;
|
||||
file "fanCurve";
|
||||
outOfBounds clamp;
|
||||
fanCurve tableFile;
|
||||
tableFileCoeffs
|
||||
{
|
||||
file "$FOAM_CASE/constant/pressureVsQ";
|
||||
format csv;
|
||||
nHeaderLine 1;
|
||||
refColumn 0;
|
||||
componentColumns 1(1);
|
||||
separator ",";
|
||||
mergeSeparators no;
|
||||
outOfBounds clamp;
|
||||
interpolationScheme linear;
|
||||
}
|
||||
direction out;
|
||||
p0 uniform 0;
|
||||
value uniform 0;
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
The above example shows the use of a comma separated (CSV) file to specify
|
||||
the condition.
|
||||
|
||||
See also
|
||||
Foam::fanFvPatchField
|
||||
Foam::totalPressureFvPatchScalarField
|
||||
Foam::interpolationTable
|
||||
Foam::Function1s
|
||||
|
||||
SourceFiles
|
||||
fanPressureFvPatchScalarField.C
|
||||
@ -74,7 +96,7 @@ SourceFiles
|
||||
#define fanPressureFvPatchScalarField_H
|
||||
|
||||
#include "totalPressureFvPatchScalarField.H"
|
||||
#include "interpolationTable.H"
|
||||
#include "TableFile.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -89,9 +111,10 @@ class fanPressureFvPatchScalarField
|
||||
:
|
||||
public totalPressureFvPatchScalarField
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// Public Enumerations
|
||||
|
||||
//- Fan flow direction
|
||||
enum fanFlowDirection
|
||||
{
|
||||
@ -107,8 +130,8 @@ private:
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Tabulated fan curve
|
||||
interpolationTable<scalar> fanCurve_;
|
||||
//- Fan curve
|
||||
autoPtr<Function1<scalar>> fanCurve_;
|
||||
|
||||
//- Direction of flow through the fan relative to patch
|
||||
fanFlowDirection direction_;
|
||||
@ -137,8 +160,7 @@ public:
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
//- Construct by mapping given
|
||||
// fanPressureFvPatchScalarField
|
||||
//- Construct by mapping given fanPressureFvPatchScalarField
|
||||
// onto a new patch
|
||||
fanPressureFvPatchScalarField
|
||||
(
|
||||
|
||||
@ -39,10 +39,10 @@ Description
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
patchType | underlying patch type should be \c cyclic| yes |
|
||||
fanCurve | fan curve, e.g. \c csvFile | yes |
|
||||
jumpTable | jump data (backward compatibility mode) | no |
|
||||
reverse | reverse jump direction | no | false
|
||||
patchType | underlying patch type (should be \c cyclic) | yes |
|
||||
fanCurve | fan curve function | yes |
|
||||
jumpTable | jump table function (backward compatibility mode) | no |
|
||||
reverse | reverse jump direction | no | false
|
||||
phi | flux field name | no | phi
|
||||
rho | density field name | no | rho
|
||||
\endtable
|
||||
@ -51,16 +51,20 @@ Usage
|
||||
\verbatim
|
||||
<patchName>
|
||||
{
|
||||
type fan;
|
||||
type fanPressureJump;
|
||||
patchType cyclic;
|
||||
fanCurve csvFile;
|
||||
csvFileCoeffs
|
||||
fanCurve tableFile;
|
||||
tableFileCoeffs
|
||||
{
|
||||
hasHeaderLine 1;
|
||||
file "$FOAM_CASE/constant/pressureVsQ";
|
||||
format csv;
|
||||
nHeaderLine 1;
|
||||
refColumn 0;
|
||||
componentColumns 1(1);
|
||||
separator ",";
|
||||
file "$FOAM_CASE/constant/pressureVsQ";
|
||||
mergeSeparators no;
|
||||
outOfBounds clamp;
|
||||
interpolationScheme linear;
|
||||
}
|
||||
value uniform 0;
|
||||
}
|
||||
@ -73,7 +77,7 @@ Note
|
||||
The underlying \c patchType should be set to \c cyclic
|
||||
|
||||
See also
|
||||
Foam::Function1Types
|
||||
Foam::Function1s
|
||||
|
||||
SourceFiles
|
||||
fanPressureJumpFvPatchScalarField.C
|
||||
|
||||
@ -46,7 +46,7 @@ Usage
|
||||
|
||||
See also
|
||||
Foam::fixedValueFvPatchField
|
||||
Foam::Function1Types
|
||||
Foam::Function1s
|
||||
|
||||
SourceFiles
|
||||
fixedMeanFvPatchField.C
|
||||
|
||||
@ -54,7 +54,7 @@ Usage
|
||||
See also
|
||||
Foam::fixedMeanFvPatchField
|
||||
Foam::outletInletFvPatchField
|
||||
Foam::Function1Types
|
||||
Foam::Function1s
|
||||
|
||||
SourceFiles
|
||||
fixedMeanOutletInletFvPatchField.C
|
||||
|
||||
@ -36,8 +36,8 @@ Foam::fixedProfileFvPatchField<Type>::fixedProfileFvPatchField
|
||||
:
|
||||
fixedValueFvPatchField<Type>(p, iF),
|
||||
profile_(),
|
||||
dir_(Zero),
|
||||
origin_(0)
|
||||
origin_(0),
|
||||
direction_(Zero)
|
||||
{}
|
||||
|
||||
|
||||
@ -51,8 +51,8 @@ Foam::fixedProfileFvPatchField<Type>::fixedProfileFvPatchField
|
||||
:
|
||||
fixedValueFvPatchField<Type>(p, iF, fld),
|
||||
profile_(),
|
||||
dir_(Zero),
|
||||
origin_(0)
|
||||
origin_(0),
|
||||
direction_(Zero)
|
||||
{}
|
||||
|
||||
|
||||
@ -66,18 +66,18 @@ Foam::fixedProfileFvPatchField<Type>::fixedProfileFvPatchField
|
||||
:
|
||||
fixedValueFvPatchField<Type>(p, iF, dict, false),
|
||||
profile_(Function1<Type>::New("profile", dict)),
|
||||
dir_(dict.lookup("direction")),
|
||||
origin_(readScalar(dict.lookup("origin")))
|
||||
origin_(readScalar(dict.lookup("origin"))),
|
||||
direction_(dict.lookup("direction"))
|
||||
{
|
||||
if (mag(dir_) < small)
|
||||
if (mag(direction_) == 0)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "magnitude Direction must be greater than zero"
|
||||
<< "The direction must be non-zero"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
// Ensure direction vector is normalized
|
||||
dir_ /= mag(dir_);
|
||||
// Normalise the direction
|
||||
direction_ /= mag(direction_);
|
||||
|
||||
// Evaluate profile
|
||||
this->evaluate();
|
||||
@ -93,10 +93,10 @@ Foam::fixedProfileFvPatchField<Type>::fixedProfileFvPatchField
|
||||
const fvPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<Type>(p, iF), // Don't map
|
||||
fixedValueFvPatchField<Type>(p, iF), // Don't map
|
||||
profile_(ptf.profile_, false),
|
||||
dir_(ptf.dir_),
|
||||
origin_(ptf.origin_)
|
||||
origin_(ptf.origin_),
|
||||
direction_(ptf.direction_)
|
||||
{
|
||||
// Evaluate profile since value not mapped
|
||||
this->evaluate();
|
||||
@ -111,8 +111,8 @@ Foam::fixedProfileFvPatchField<Type>::fixedProfileFvPatchField
|
||||
:
|
||||
fixedValueFvPatchField<Type>(ptf),
|
||||
profile_(ptf.profile_, false),
|
||||
dir_(ptf.dir_),
|
||||
origin_(ptf.origin_)
|
||||
origin_(ptf.origin_),
|
||||
direction_(ptf.direction_)
|
||||
{}
|
||||
|
||||
|
||||
@ -125,8 +125,8 @@ Foam::fixedProfileFvPatchField<Type>::fixedProfileFvPatchField
|
||||
:
|
||||
fixedValueFvPatchField<Type>(ptf, iF),
|
||||
profile_(ptf.profile_, false),
|
||||
dir_(ptf.dir_),
|
||||
origin_(ptf.origin_)
|
||||
origin_(ptf.origin_),
|
||||
direction_(ptf.direction_)
|
||||
{
|
||||
// Evaluate the profile if defined
|
||||
if (ptf.profile_.valid())
|
||||
@ -146,7 +146,8 @@ void Foam::fixedProfileFvPatchField<Type>::updateCoeffs()
|
||||
return;
|
||||
}
|
||||
|
||||
const scalarField dirCmpt((dir_ & this->patch().Cf()) - origin_);
|
||||
const scalarField dirCmpt((direction_ & this->patch().Cf()) - origin_);
|
||||
|
||||
fvPatchField<Type>::operator==(profile_->value(dirCmpt));
|
||||
|
||||
fixedValueFvPatchField<Type>::updateCoeffs();
|
||||
@ -158,7 +159,7 @@ void Foam::fixedProfileFvPatchField<Type>::write(Ostream& os) const
|
||||
{
|
||||
fvPatchField<Type>::write(os);
|
||||
writeEntry(os, profile_());
|
||||
writeEntry(os, "direction", dir_);
|
||||
writeEntry(os, "direction", direction_);
|
||||
writeEntry(os, "origin", origin_);
|
||||
writeEntry(os, "value", *this);
|
||||
}
|
||||
|
||||
@ -29,10 +29,12 @@ Description
|
||||
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
profile | Profile Function1 | yes |
|
||||
direction | Profile direction | yes |
|
||||
origin | Profile origin | yes |
|
||||
Property | Description | Required | Default value
|
||||
profile | Profile function | yes |
|
||||
direction | Direction of the line along which the profile is \\
|
||||
evaluated | yes |
|
||||
origin | Origin of the line along which the profile is \\
|
||||
evaluated | yes |
|
||||
\endtable
|
||||
|
||||
Example of the boundary condition specification:
|
||||
@ -40,30 +42,29 @@ Usage
|
||||
<patchName>
|
||||
{
|
||||
type fixedProfile;
|
||||
profile csvFile;
|
||||
|
||||
profile tableFile;
|
||||
profileCoeffs
|
||||
{
|
||||
nHeaderLine 0; // 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 "Uprofile.csv"; // name of csv data file
|
||||
outOfBounds clamp; // Optional out-of-bounds handling
|
||||
interpolationScheme linear; // Optional interpolation scheme
|
||||
file "UProfile";
|
||||
format csv;
|
||||
nHeaderLine 0;
|
||||
refColumn 0;
|
||||
componentColumns (1 2 3);
|
||||
separator ",";
|
||||
mergeSeparators no;
|
||||
outOfBounds clamp;
|
||||
interpolationScheme linear;
|
||||
}
|
||||
direction (0 1 0);
|
||||
origin 0;
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Example setting a parabolic inlet profile for the PitzDaily case:
|
||||
Example setting a parabolic inlet profile for the pitzDaily case:
|
||||
\verbatim
|
||||
inlet
|
||||
{
|
||||
type fixedProfile;
|
||||
|
||||
profile polynomial
|
||||
(
|
||||
((1 0 0) (0 0 0))
|
||||
@ -74,14 +75,8 @@ Usage
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Note
|
||||
The profile entry is a Function1 type. The example above gives the
|
||||
usage for supplying csv file.
|
||||
|
||||
See also
|
||||
Foam::fixedValueFvPatchField
|
||||
Foam::Function1Types
|
||||
Foam::timeVaryingMappedFixedValueFvPatchField
|
||||
Foam::Function1s
|
||||
|
||||
SourceFiles
|
||||
fixedProfileFvPatchField.C
|
||||
@ -110,15 +105,15 @@ class fixedProfileFvPatchField
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Profile data
|
||||
//- Profile function
|
||||
autoPtr<Function1<Type>> profile_;
|
||||
|
||||
//- Profile direction
|
||||
vector dir_;
|
||||
|
||||
//- Profile origin
|
||||
//- Origin of the line along which the profile is evaluated
|
||||
scalar origin_;
|
||||
|
||||
//- Direction of the line along which the profile is evaluated
|
||||
vector direction_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
@ -73,7 +73,7 @@ Usage
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
The \c flowRate entry is a \c Function1 of time, see Foam::Function1Types.
|
||||
The \c flowRate entry is a \c Function1 of time, see Foam::Function1s.
|
||||
|
||||
Note
|
||||
- \c rhoInlet is required for the case of a mass flow rate, where the
|
||||
@ -84,7 +84,7 @@ Note
|
||||
|
||||
See also
|
||||
Foam::fixedValueFvPatchField
|
||||
Foam::Function1Types
|
||||
Foam::Function1s
|
||||
Foam::flowRateOutletVelocityFvPatchVectorField
|
||||
|
||||
SourceFiles
|
||||
|
||||
@ -68,7 +68,7 @@ Usage
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
The \c flowRate entry is a \c Function1 of time, see Foam::Function1Types.
|
||||
The \c flowRate entry is a \c Function1 of time, see Foam::Function1s.
|
||||
|
||||
Note
|
||||
- \c rhoOutlet is required for the case of a mass flow rate, where the
|
||||
@ -79,7 +79,7 @@ Note
|
||||
|
||||
See also
|
||||
Foam::fixedValueFvPatchField
|
||||
Foam::Function1Types
|
||||
Foam::Function1s
|
||||
Foam::flowRateInletVelocityFvPatchVectorField
|
||||
|
||||
SourceFiles
|
||||
|
||||
@ -51,7 +51,7 @@ Usage
|
||||
\endverbatim
|
||||
|
||||
The \c tangentialVelocity entry is a Function1 of time, see
|
||||
Foam::Function1Types.
|
||||
Foam::Function1s.
|
||||
|
||||
Note
|
||||
Sign conventions:
|
||||
|
||||
@ -60,7 +60,7 @@ Note
|
||||
|
||||
See also
|
||||
Foam::pressureInletOutletVelocityFvPatchVectorField
|
||||
Foam::Function1Types
|
||||
Foam::Function1s
|
||||
|
||||
SourceFiles
|
||||
rotatingPressureInletOutletVelocityFvPatchVectorField.C
|
||||
|
||||
@ -60,7 +60,7 @@ Usage
|
||||
|
||||
See also
|
||||
Foam::totalPressureFvPatchScalarField
|
||||
Foam::Function1Types
|
||||
Foam::Function1s
|
||||
|
||||
SourceFiles
|
||||
rotatingTotalPressureFvPatchScalarField.C
|
||||
|
||||
@ -46,11 +46,11 @@ Usage
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
The \c omega entry is a Function1 of time, see Foam::Function1Types.
|
||||
The \c omega entry is a Function1 of time, see Foam::Function1s.
|
||||
|
||||
See also
|
||||
Foam::fixedValueFvPatchField
|
||||
Foam::Function1Types
|
||||
Foam::Function1s
|
||||
|
||||
SourceFiles
|
||||
rotatingWallVelocityFvPatchVectorField.C
|
||||
|
||||
@ -63,7 +63,7 @@ Note
|
||||
|
||||
See also
|
||||
Foam::fixedValueFvPatchField
|
||||
Foam::Function1Types
|
||||
Foam::Function1s
|
||||
|
||||
SourceFiles
|
||||
swirlFlowRateInletVelocityFvPatchVectorField.C
|
||||
|
||||
@ -59,7 +59,7 @@ Note
|
||||
|
||||
See also
|
||||
Foam::fixedValueFvPatchField
|
||||
Foam::Function1Types
|
||||
Foam::Function1s
|
||||
|
||||
SourceFiles
|
||||
swirlInletVelocityFvPatchVectorField.C
|
||||
|
||||
@ -90,7 +90,7 @@ Usage
|
||||
See also
|
||||
Foam::fixedValueFvPatchField
|
||||
Foam::timeVaryingMappedFvPatchField
|
||||
Foam::Function1Types
|
||||
Foam::Function1s
|
||||
|
||||
SourceFiles
|
||||
timeVaryingMappedFixedValueFvPatchField.C
|
||||
|
||||
@ -72,7 +72,7 @@ Usage
|
||||
|
||||
See also
|
||||
Foam::timeVaryingMappedFixedValueFvPatchField
|
||||
Foam::Function1Types
|
||||
Foam::Function1s
|
||||
|
||||
SourceFiles
|
||||
timeVaryingMappedFvPatchField.C
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user