/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see .
\*---------------------------------------------------------------------------*/
#include "uniformInterpolationTable.H"
#include "Time.H"
#include "IOstream.H"
#include "IOdictionary.H"
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
template
void Foam::uniformInterpolationTable::checkTable() const
{
if (size() < 2)
{
FatalErrorInFunction
<< "Table " << name() << ": must have at least 2 values." << nl
<< "Table size = " << size() << nl
<< " min, interval width = " << x0_ << ", " << dx_ << nl
<< exit(FatalError);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
Foam::uniformInterpolationTable::uniformInterpolationTable
(
const IOobject& io,
bool readFields
)
:
IOobject(io),
List(2, Zero),
x0_(0.0),
dx_(1.0),
log10_(false),
bound_(false)
{
if (readFields)
{
IOdictionary dict(io);
dict.readEntry("data", *this);
dict.readEntry("x0", x0_);
dict.readEntry("dx", dx_);
dict.readIfPresent("log10", log10_);
dict.readIfPresent("bound", bound_);
}
checkTable();
}
template
Foam::uniformInterpolationTable::uniformInterpolationTable
(
const word& tableName,
const objectRegistry& db,
const dictionary& dict,
const bool initialiseOnly
)
:
IOobject
(
tableName,
db.time().constant(),
db,
IOobject::NO_READ,
IOobject::NO_WRITE,
false // if used in BCs, could be used by multiple patches
),
List(2, Zero),
x0_(dict.get("x0")),
dx_(dict.get("dx")),
log10_(dict.getOrDefault("log10", false)),
bound_(dict.getOrDefault("bound", false))
{
if (initialiseOnly)
{
const scalar xMax = dict.get("xMax");
const label nIntervals = static_cast