diff --git a/src/postProcessing/functionObjects/field/readFields/readFields.C b/src/postProcessing/functionObjects/field/readFields/readFields.C index 07a43d6bbc..0179e27874 100644 --- a/src/postProcessing/functionObjects/field/readFields/readFields.C +++ b/src/postProcessing/functionObjects/field/readFields/readFields.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,7 +30,7 @@ License namespace Foam { -defineTypeNameAndDebug(readFields, 0); + defineTypeNameAndDebug(readFields, 0); } @@ -54,6 +54,9 @@ Foam::readFields::readFields if (isA(obr_)) { read(dict); + + // Fields should all be present from start time so read on construction + execute(); } else { @@ -87,16 +90,28 @@ void Foam::readFields::execute() { if (active_) { + if (log_) Info << type() << " " << name_ << ":" << nl; + + bool loaded = false; forAll(fieldSet_, fieldI) { const word& fieldName = fieldSet_[fieldI]; - // If necessary load field - loadField(fieldName); - loadField(fieldName); - loadField(fieldName); - loadField(fieldName); - loadField(fieldName); + // Load field if necessary + loaded = loadField(fieldName) || loaded; + loaded = loadField(fieldName) || loaded; + loaded = loadField(fieldName) || loaded; + loaded = loadField(fieldName) || loaded; + loaded = loadField(fieldName) || loaded; + } + + if (log_) + { + if (!loaded) + { + Info<< " no fields loaded" << endl; + } + Info<< endl; } } } diff --git a/src/postProcessing/functionObjects/field/readFields/readFields.H b/src/postProcessing/functionObjects/field/readFields/readFields.H index f785e4a881..dca694a7bc 100644 --- a/src/postProcessing/functionObjects/field/readFields/readFields.H +++ b/src/postProcessing/functionObjects/field/readFields/readFields.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -106,7 +106,7 @@ protected: // Protected Member Functions template - void loadField(const word&) const; + bool loadField(const word&) const; private: diff --git a/src/postProcessing/functionObjects/field/readFields/readFieldsTemplates.C b/src/postProcessing/functionObjects/field/readFields/readFieldsTemplates.C index 4b128aa388..6810bf7f09 100644 --- a/src/postProcessing/functionObjects/field/readFields/readFieldsTemplates.C +++ b/src/postProcessing/functionObjects/field/readFields/readFieldsTemplates.C @@ -31,7 +31,7 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template -void Foam::readFields::loadField(const word& fieldName) const +bool Foam::readFields::loadField(const word& fieldName) const { typedef GeometricField vfType; typedef GeometricField sfType; @@ -77,6 +77,7 @@ void Foam::readFields::loadField(const word& fieldName) const if (log_) Info<< " Reading " << fieldName << endl; vfType* vfPtr = new vfType(fieldHeader, mesh); mesh.objectRegistry::store(vfPtr); + return true; } else if ( @@ -88,8 +89,11 @@ void Foam::readFields::loadField(const word& fieldName) const if (log_) Info<< " Reading " << fieldName << endl; sfType* sfPtr = new sfType(fieldHeader, mesh); mesh.objectRegistry::store(sfPtr); + return true; } } + + return false; }