From 1945632da9cbe295cab7b99843e2781bb82cd1a0 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Mon, 30 Jul 2012 15:57:15 +0100 Subject: [PATCH] ENH: dictionary: allow transfer of empty dictionary --- .../db/IOobjects/IOdictionary/IOdictionaryIO.C | 6 +++--- src/OpenFOAM/db/dictionary/dictionaryIO.C | 8 +++++++- src/Pstream/mpi/UIPread.C | 15 +++------------ 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionaryIO.C b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionaryIO.C index 8585392e27d..881250f3eb9 100644 --- a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionaryIO.C +++ b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionaryIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -102,7 +102,7 @@ void Foam::IOdictionary::readFile(const bool masterOnly) myComm.above(), 0, Pstream::msgType(), - IOstream::ASCII + IOstream::BINARY ); IOdictionary::readData(fromAbove); } @@ -121,7 +121,7 @@ void Foam::IOdictionary::readFile(const bool masterOnly) myComm.below()[belowI], 0, Pstream::msgType(), - IOstream::ASCII + IOstream::BINARY ); IOdictionary::writeData(toBelow); } diff --git a/src/OpenFOAM/db/dictionary/dictionaryIO.C b/src/OpenFOAM/db/dictionary/dictionaryIO.C index 03ce2b76a7f..aa1321d9147 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryIO.C +++ b/src/OpenFOAM/db/dictionary/dictionaryIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -80,6 +80,12 @@ Foam::autoPtr<Foam::dictionary> Foam::dictionary::New(Istream& is) bool Foam::dictionary::read(Istream& is, const bool keepHeader) { + // Check for empty dictionary + if (is.eof()) + { + return true; + } + if (!is.good()) { FatalIOErrorIn("dictionary::read(Istream&, bool)", is) diff --git a/src/Pstream/mpi/UIPread.C b/src/Pstream/mpi/UIPread.C index bcc6f4c4128..19d6b161122 100644 --- a/src/Pstream/mpi/UIPread.C +++ b/src/Pstream/mpi/UIPread.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -107,12 +107,7 @@ Foam::UIPstream::UIPstream if (!messageSize_) { - FatalErrorIn - ( - "UIPstream::UIPstream(const commsTypes, const int, " - "DynamicList<char>&, streamFormat, versionNumber)" - ) << "read failed" - << Foam::abort(FatalError); + setEof(); } } } @@ -199,11 +194,7 @@ Foam::UIPstream::UIPstream(const int fromProcNo, PstreamBuffers& buffers) if (!messageSize_) { - FatalErrorIn - ( - "UIPstream::UIPstream(const int, PstreamBuffers&)" - ) << "read failed" - << Foam::abort(FatalError); + setEof(); } } } -- GitLab