Skip to content
Snippets Groups Projects
Commit 09ed4226 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

BUG: decomposePar fails with csv table in binary (fixes #1498)

parent 404f9ee6
Branches
Tags
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -25,7 +25,6 @@ License ...@@ -25,7 +25,6 @@ License
#include "CSV.H" #include "CSV.H"
#include "DynamicList.H" #include "DynamicList.H"
//#include "IFstream.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
...@@ -33,7 +32,7 @@ template<> ...@@ -33,7 +32,7 @@ template<>
Foam::label Foam::Function1Types::CSV<Foam::label>::readValue Foam::label Foam::Function1Types::CSV<Foam::label>::readValue
( (
const List<string>& splitted const List<string>& splitted
) ) const
{ {
if (componentColumns_[0] >= splitted.size()) if (componentColumns_[0] >= splitted.size())
{ {
...@@ -51,7 +50,7 @@ template<> ...@@ -51,7 +50,7 @@ template<>
Foam::scalar Foam::Function1Types::CSV<Foam::scalar>::readValue Foam::scalar Foam::Function1Types::CSV<Foam::scalar>::readValue
( (
const List<string>& splitted const List<string>& splitted
) ) const
{ {
if (componentColumns_[0] >= splitted.size()) if (componentColumns_[0] >= splitted.size())
{ {
...@@ -66,7 +65,10 @@ Foam::scalar Foam::Function1Types::CSV<Foam::scalar>::readValue ...@@ -66,7 +65,10 @@ Foam::scalar Foam::Function1Types::CSV<Foam::scalar>::readValue
template<class Type> template<class Type>
Type Foam::Function1Types::CSV<Type>::readValue(const List<string>& splitted) Type Foam::Function1Types::CSV<Type>::readValue
(
const List<string>& splitted
) const
{ {
Type result; Type result;
...@@ -91,7 +93,6 @@ template<class Type> ...@@ -91,7 +93,6 @@ template<class Type>
void Foam::Function1Types::CSV<Type>::read() void Foam::Function1Types::CSV<Type>::read()
{ {
fileName expandedFile(fName_); fileName expandedFile(fName_);
//IFstream is(expandedFile.expand());
autoPtr<ISstream> isPtr(fileHandler().NewIFstream(expandedFile.expand())); autoPtr<ISstream> isPtr(fileHandler().NewIFstream(expandedFile.expand()));
ISstream& is = isPtr(); ISstream& is = isPtr();
...@@ -211,17 +212,24 @@ Foam::Function1Types::CSV<Type>::CSV ...@@ -211,17 +212,24 @@ Foam::Function1Types::CSV<Type>::CSV
TableBase<Type>(entryName, dict), TableBase<Type>(entryName, dict),
nHeaderLine_(dict.get<label>("nHeaderLine")), nHeaderLine_(dict.get<label>("nHeaderLine")),
refColumn_(dict.get<label>("refColumn")), refColumn_(dict.get<label>("refColumn")),
componentColumns_(dict.lookup("componentColumns")), componentColumns_(),
separator_(dict.lookupOrDefault<string>("separator", ",")[0]), separator_(dict.getOrDefault<string>("separator", ",")[0]),
mergeSeparators_(dict.get<bool>("mergeSeparators")), mergeSeparators_(dict.get<bool>("mergeSeparators")),
fName_(fName.empty() ? dict.get<fileName>("file") : fName) fName_(fName.empty() ? dict.get<fileName>("file") : fName)
{ {
// Writing of "componentColumns" was forced to be ASCII,
// do the same when reading
ITstream& is = dict.lookup("componentColumns");
is.format(IOstream::ASCII);
is >> componentColumns_;
dict.checkITstream(is, "componentColumns");
if (componentColumns_.size() != pTraits<Type>::nComponents) if (componentColumns_.size() != pTraits<Type>::nComponents)
{ {
FatalErrorInFunction FatalIOErrorInFunction(dict)
<< componentColumns_ << " does not have the expected length of " << componentColumns_ << " does not have the expected length of "
<< pTraits<Type>::nComponents << endl << pTraits<Type>::nComponents << nl
<< exit(FatalError); << exit(FatalIOError);
} }
read(); read();
...@@ -243,13 +251,6 @@ Foam::Function1Types::CSV<Type>::CSV(const CSV<Type>& csv) ...@@ -243,13 +251,6 @@ Foam::Function1Types::CSV<Type>::CSV(const CSV<Type>& csv)
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::Function1Types::CSV<Type>::~CSV()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type> template<class Type>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2017-2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -102,7 +102,7 @@ class CSV ...@@ -102,7 +102,7 @@ class CSV
void read(); void read();
//- Read the next value from the splitted string //- Read the next value from the splitted string
Type readValue(const List<string>&); Type readValue(const List<string>& splitted) const;
//- No copy assignment //- No copy assignment
void operator=(const CSV<Type>&) = delete; void operator=(const CSV<Type>&) = delete;
...@@ -135,7 +135,7 @@ public: ...@@ -135,7 +135,7 @@ public:
//- Destructor //- Destructor
virtual ~CSV(); virtual ~CSV() = default;
// Member Functions // Member Functions
...@@ -148,13 +148,6 @@ public: ...@@ -148,13 +148,6 @@ public:
}; };
template<>
label CSV<label>::readValue(const List<string>& splitted);
template<>
Foam::scalar CSV<scalar>::readValue(const List<string>& splitted);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Function1Types } // End namespace Function1Types
......
...@@ -32,7 +32,7 @@ writeInterval 0.02; ...@@ -32,7 +32,7 @@ writeInterval 0.02;
purgeWrite 0; purgeWrite 0;
writeFormat ascii; writeFormat binary;
writePrecision 10; writePrecision 10;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment