diff --git a/src/postProcessing/functionObjects/field/streamLine/streamLineBase.C b/src/postProcessing/functionObjects/field/streamLine/streamLineBase.C index a83cbf6131745ebf9a801ad1fb11b2510f8dac6e..f5da6adc2ab9335166ef5837f19dfa68dc1c2b04 100644 --- a/src/postProcessing/functionObjects/field/streamLine/streamLineBase.C +++ b/src/postProcessing/functionObjects/field/streamLine/streamLineBase.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 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. @@ -778,6 +778,10 @@ void Foam::streamLineBase::write() } + // Note: filenames scattered below since used in global call + fileName scalarVtkFile; + fileName vectorVtkFile; + if (Pstream::master()) { if (bounds_ != boundBox::greatBox) @@ -873,7 +877,7 @@ void Foam::streamLineBase::write() } } - fileName vtkFile + scalarVtkFile = fileName ( vtkPath / scalarFormatterPtr_().getFileName @@ -884,7 +888,7 @@ void Foam::streamLineBase::write() ); if (log_) Info - << " Writing data to " << vtkFile.path() << endl; + << " Writing data to " << scalarVtkFile.path() << endl; scalarFormatterPtr_().write ( @@ -892,16 +896,8 @@ void Foam::streamLineBase::write() tracks, scalarNames_, scalarValues, - OFstream(vtkFile)() + OFstream(scalarVtkFile)() ); - - forAll(scalarNames_, nameI) - { - dictionary propsDict; - propsDict.add("file", vtkFile); - const word& fieldName = scalarNames_[nameI]; - setProperty(fieldName, propsDict); - } } // Convert vector values @@ -927,7 +923,7 @@ void Foam::streamLineBase::write() } } - fileName vtkFile + vectorVtkFile = fileName ( vtkPath / vectorFormatterPtr_().getFileName @@ -937,7 +933,8 @@ void Foam::streamLineBase::write() ) ); - //if (log_) Info<< " Writing vector data to " << vtkFile << endl; + //if (log_) Info<< " Writing vector data to " + // << vectorVtkFile << endl; vectorFormatterPtr_().write ( @@ -945,18 +942,31 @@ void Foam::streamLineBase::write() tracks, vectorNames_, vectorValues, - OFstream(vtkFile)() + OFstream(vectorVtkFile)() ); - - forAll(vectorNames_, nameI) - { - dictionary propsDict; - propsDict.add("file", vtkFile); - const word& fieldName = vectorNames_[nameI]; - setProperty(fieldName, propsDict); - } } } + + + // fileNames are generated on the master but setProperty needs to + // be across all procs + Pstream::scatter(scalarVtkFile); + forAll(scalarNames_, nameI) + { + dictionary propsDict; + propsDict.add("file", scalarVtkFile); + const word& fieldName = scalarNames_[nameI]; + setProperty(fieldName, propsDict); + } + + Pstream::scatter(vectorVtkFile); + forAll(vectorNames_, nameI) + { + dictionary propsDict; + propsDict.add("file", vectorVtkFile); + const word& fieldName = vectorNames_[nameI]; + setProperty(fieldName, propsDict); + } } } diff --git a/src/sampling/sampledSet/sampledSets/sampledSets.H b/src/sampling/sampledSet/sampledSets/sampledSets.H index 2f007a879bcef06619fb59adcf9b86928a50a016..5711afc6cf1a72e2d99ec287a256f46eb7818dac 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSets.H +++ b/src/sampling/sampledSet/sampledSets/sampledSets.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. @@ -227,8 +227,9 @@ class sampledSets PtrList<volFieldSampler<T>>& masterFields ); + //- Write set on master, return fileName template<class Type> - void writeSampleFile + fileName writeSampleFile ( const coordSet& masterSampleSet, const PtrList<volFieldSampler<Type>>& masterFields, diff --git a/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C b/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C index 3a0d5903431c6388928d28e384ebb86717ee2b08..eb213773498f47300b1549436b7342f188cb0e1f 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C +++ b/src/sampling/sampledSet/sampledSets/sampledSetsTemplates.C @@ -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. @@ -122,7 +122,7 @@ Foam::sampledSets::volFieldSampler<Type>::volFieldSampler template<class Type> -void Foam::sampledSets::writeSampleFile +Foam::fileName Foam::sampledSets::writeSampleFile ( const coordSet& masterSampleSet, const PtrList<volFieldSampler<Type>>& masterFields, @@ -155,20 +155,14 @@ void Foam::sampledSets::writeSampleFile valueSets, ofs ); - - forAll(masterFields, fieldi) - { - dictionary propsDict; - propsDict.add("file", fName); - const word& fieldName = masterFields[fieldi].name(); - setProperty(fieldName, propsDict); - } + return fName; } else { WarningInFunction << "File " << ofs.name() << " could not be opened. " << "No data will be written" << endl; + return fileName::null; } } @@ -326,11 +320,12 @@ void Foam::sampledSets::sampleAndWrite(fieldGroup<Type>& fields) PtrList<volFieldSampler<Type>> masterFields(sampledFields.size()); combineSampledValues(sampledFields, indexSets_, masterFields); - if (Pstream::master()) + forAll(masterSampledSets_, setI) { - forAll(masterSampledSets_, setI) + fileName sampleFile; + if (Pstream::master()) { - writeSampleFile + sampleFile = writeSampleFile ( masterSampledSets_[setI], masterFields, @@ -339,6 +334,18 @@ void Foam::sampledSets::sampleAndWrite(fieldGroup<Type>& fields) fields.formatter() ); } + + Pstream::scatter(sampleFile); + if (sampleFile.size()) + { + forAll(masterFields, fieldi) + { + dictionary propsDict; + propsDict.add("file", sampleFile); + const word& fieldName = masterFields[fieldi].name(); + setProperty(fieldName, propsDict); + } + } } } } diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C index b1f5a81b887562922d0439f315055d336e547add..eb6852cda6d495c72c22dabf16229f8af49d09c4 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C @@ -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. @@ -49,6 +49,9 @@ void Foam::sampledSurfaces::writeSurface gatheredValues[Pstream::myProcNo()] = values; Pstream::gatherList(gatheredValues); + + fileName sampleFile; + if (Pstream::master()) { // Combine values into single field @@ -72,7 +75,7 @@ void Foam::sampledSurfaces::writeSurface // skip surface without faces (eg, a failed cut-plane) if (mergeList_[surfI].faces.size()) { - fileName fName = formatter_->write + sampleFile = formatter_->write ( outputDir, s.name(), @@ -82,12 +85,16 @@ void Foam::sampledSurfaces::writeSurface allValues, s.interpolate() ); - - dictionary propsDict; - propsDict.add("file", fName); - setProperty(fieldName, propsDict); } } + + Pstream::scatter(sampleFile); + if (sampleFile.size()) + { + dictionary propsDict; + propsDict.add("file", sampleFile); + setProperty(fieldName, propsDict); + } } else {