mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: inconsistency between constructor and output (fixes #1816)
- slipped in with changes to csvTableReader (commit 59ed3ba18d) so
only affects the 2006 version.
- adjust constructor to expect "componentColumns", but also accept
"valueColumns" as 1912 and earlier-compatibility. This not only
fixes the reported bug, but also ensure proper compatibility with
older files.
ENH: use "refColumn" instead of "timeColumn" for csvTableReader
- consistent with the CSV Function1.
Support 'timeColumn' as 1912 and earlier-compatibility.
TUT: remove unused table-reader entry
This commit is contained in:
@ -46,11 +46,10 @@ Description
|
|||||||
readerType csv;
|
readerType csv;
|
||||||
file "<constant>/p0vsTime.csv";
|
file "<constant>/p0vsTime.csv";
|
||||||
hasHeaderLine true; // skip first line
|
hasHeaderLine true; // skip first line
|
||||||
timeColumn 0; // time is in column 0
|
refColumn 0; // reference (eg, time) is in column 0
|
||||||
valueColumns (1); // value starts in column 1
|
componentColumns (1); // component values starts in column 1
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
|
|
||||||
Note
|
Note
|
||||||
- Accessing an empty list results in an error.
|
- Accessing an empty list results in an error.
|
||||||
- Accessing a list with a single element always returns the same value.
|
- Accessing a list with a single element always returns the same value.
|
||||||
|
|||||||
@ -37,6 +37,7 @@ template<class Type>
|
|||||||
Foam::labelList Foam::csvTableReader<Type>::getComponentColumns
|
Foam::labelList Foam::csvTableReader<Type>::getComponentColumns
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
|
std::initializer_list<std::pair<const char*,int>> compat,
|
||||||
const dictionary& dict
|
const dictionary& dict
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -45,7 +46,7 @@ Foam::labelList Foam::csvTableReader<Type>::getComponentColumns
|
|||||||
|
|
||||||
labelList cols;
|
labelList cols;
|
||||||
|
|
||||||
ITstream& is = dict.lookup(name);
|
ITstream& is = dict.lookupCompat(name, compat);
|
||||||
is.format(IOstream::ASCII);
|
is.format(IOstream::ASCII);
|
||||||
is >> cols;
|
is >> cols;
|
||||||
dict.checkITstream(is, name);
|
dict.checkITstream(is, name);
|
||||||
@ -113,8 +114,11 @@ Foam::csvTableReader<Type>::csvTableReader(const dictionary& dict)
|
|||||||
:
|
:
|
||||||
tableReader<Type>(dict),
|
tableReader<Type>(dict),
|
||||||
headerLine_(dict.get<bool>("hasHeaderLine")),
|
headerLine_(dict.get<bool>("hasHeaderLine")),
|
||||||
refColumn_(dict.get<label>("timeColumn")),
|
refColumn_(dict.getCompat<label>("refColumn", {{"timeColumn", 1912}})),
|
||||||
componentColumns_(getComponentColumns("valueColumns", dict)),
|
componentColumns_
|
||||||
|
(
|
||||||
|
getComponentColumns("componentColumns", {{"valueColumns", 1912}}, dict)
|
||||||
|
),
|
||||||
separator_(dict.getOrDefault<string>("separator", ",")[0])
|
separator_(dict.getOrDefault<string>("separator", ",")[0])
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -218,9 +222,9 @@ void Foam::csvTableReader<Type>::write(Ostream& os) const
|
|||||||
tableReader<Type>::write(os);
|
tableReader<Type>::write(os);
|
||||||
|
|
||||||
os.writeEntry("hasHeaderLine", headerLine_);
|
os.writeEntry("hasHeaderLine", headerLine_);
|
||||||
os.writeEntry("timeColumn", refColumn_);
|
os.writeEntry("refColumn", refColumn_);
|
||||||
|
|
||||||
// Force writing labelList in ascii
|
// Force writing labelList in ASCII
|
||||||
const enum IOstream::streamFormat fmt = os.format();
|
const enum IOstream::streamFormat fmt = os.format();
|
||||||
os.format(IOstream::ASCII);
|
os.format(IOstream::ASCII);
|
||||||
os.writeEntry("componentColumns", componentColumns_);
|
os.writeEntry("componentColumns", componentColumns_);
|
||||||
|
|||||||
@ -76,6 +76,7 @@ class csvTableReader
|
|||||||
static labelList getComponentColumns
|
static labelList getComponentColumns
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
|
std::initializer_list<std::pair<const char*,int>> compat,
|
||||||
const dictionary& dict
|
const dictionary& dict
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -264,7 +264,7 @@ void Foam::Function1Types::CSV<Type>::writeData(Ostream& os) const
|
|||||||
os.writeEntry("nHeaderLine", nHeaderLine_);
|
os.writeEntry("nHeaderLine", nHeaderLine_);
|
||||||
os.writeEntry("refColumn", refColumn_);
|
os.writeEntry("refColumn", refColumn_);
|
||||||
|
|
||||||
// Force writing labelList in ascii
|
// Force writing labelList in ASCII
|
||||||
const enum IOstream::streamFormat fmt = os.format();
|
const enum IOstream::streamFormat fmt = os.format();
|
||||||
os.format(IOstream::ASCII);
|
os.format(IOstream::ASCII);
|
||||||
os.writeEntry("componentColumns", componentColumns_);
|
os.writeEntry("componentColumns", componentColumns_);
|
||||||
|
|||||||
@ -27,7 +27,6 @@ boundaryField
|
|||||||
outOfBounds clamp;
|
outOfBounds clamp;
|
||||||
direction in;
|
direction in;
|
||||||
readerType openFoam;
|
readerType openFoam;
|
||||||
hasHeaderLine true;
|
|
||||||
file "<constant>/FluxVsdP.dat";
|
file "<constant>/FluxVsdP.dat";
|
||||||
//nonDimensional true;
|
//nonDimensional true;
|
||||||
//rpm 300;
|
//rpm 300;
|
||||||
|
|||||||
Reference in New Issue
Block a user