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:
parent
dd1c2edb6b
commit
fa364eda12
@ -43,14 +43,13 @@ Description
|
||||
|
||||
Read csv format:
|
||||
\verbatim
|
||||
readerType csv;
|
||||
file "<constant>/p0vsTime.csv";
|
||||
hasHeaderLine true; // skip first line
|
||||
timeColumn 0; // time is in column 0
|
||||
valueColumns (1); // value starts in column 1
|
||||
readerType csv;
|
||||
file "<constant>/p0vsTime.csv";
|
||||
hasHeaderLine true; // skip first line
|
||||
refColumn 0; // reference (eg, time) is in column 0
|
||||
componentColumns (1); // component values 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.
|
||||
|
@ -37,6 +37,7 @@ template<class Type>
|
||||
Foam::labelList Foam::csvTableReader<Type>::getComponentColumns
|
||||
(
|
||||
const word& name,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
@ -45,7 +46,7 @@ Foam::labelList Foam::csvTableReader<Type>::getComponentColumns
|
||||
|
||||
labelList cols;
|
||||
|
||||
ITstream& is = dict.lookup(name);
|
||||
ITstream& is = dict.lookupCompat(name, compat);
|
||||
is.format(IOstream::ASCII);
|
||||
is >> cols;
|
||||
dict.checkITstream(is, name);
|
||||
@ -113,8 +114,11 @@ Foam::csvTableReader<Type>::csvTableReader(const dictionary& dict)
|
||||
:
|
||||
tableReader<Type>(dict),
|
||||
headerLine_(dict.get<bool>("hasHeaderLine")),
|
||||
refColumn_(dict.get<label>("timeColumn")),
|
||||
componentColumns_(getComponentColumns("valueColumns", dict)),
|
||||
refColumn_(dict.getCompat<label>("refColumn", {{"timeColumn", 1912}})),
|
||||
componentColumns_
|
||||
(
|
||||
getComponentColumns("componentColumns", {{"valueColumns", 1912}}, dict)
|
||||
),
|
||||
separator_(dict.getOrDefault<string>("separator", ",")[0])
|
||||
{}
|
||||
|
||||
@ -218,9 +222,9 @@ void Foam::csvTableReader<Type>::write(Ostream& os) const
|
||||
tableReader<Type>::write(os);
|
||||
|
||||
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();
|
||||
os.format(IOstream::ASCII);
|
||||
os.writeEntry("componentColumns", componentColumns_);
|
||||
|
@ -76,6 +76,7 @@ class csvTableReader
|
||||
static labelList getComponentColumns
|
||||
(
|
||||
const word& name,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
@ -264,7 +264,7 @@ void Foam::Function1Types::CSV<Type>::writeData(Ostream& os) const
|
||||
os.writeEntry("nHeaderLine", nHeaderLine_);
|
||||
os.writeEntry("refColumn", refColumn_);
|
||||
|
||||
// Force writing labelList in ascii
|
||||
// Force writing labelList in ASCII
|
||||
const enum IOstream::streamFormat fmt = os.format();
|
||||
os.format(IOstream::ASCII);
|
||||
os.writeEntry("componentColumns", componentColumns_);
|
||||
|
@ -27,7 +27,6 @@ boundaryField
|
||||
outOfBounds clamp;
|
||||
direction in;
|
||||
readerType openFoam;
|
||||
hasHeaderLine true;
|
||||
file "<constant>/FluxVsdP.dat";
|
||||
//nonDimensional true;
|
||||
//rpm 300;
|
||||
|
Loading…
Reference in New Issue
Block a user