diff --git a/src/surfMesh/writers/ensight/ensightSurfaceWriter.C b/src/surfMesh/writers/ensight/ensightSurfaceWriter.C index 00318e13f0..c565f5252c 100644 --- a/src/surfMesh/writers/ensight/ensightSurfaceWriter.C +++ b/src/surfMesh/writers/ensight/ensightSurfaceWriter.C @@ -234,6 +234,7 @@ void Foam::surfaceWriters::ensightWriter::close() { times_.clear(); meshes_.clear(); + cache_.clear(); surfaceWriter::close(); } diff --git a/src/surfMesh/writers/ensight/ensightSurfaceWriter.H b/src/surfMesh/writers/ensight/ensightSurfaceWriter.H index f02f8d920c..1c6b2f431d 100644 --- a/src/surfMesh/writers/ensight/ensightSurfaceWriter.H +++ b/src/surfMesh/writers/ensight/ensightSurfaceWriter.H @@ -89,11 +89,11 @@ class ensightWriter //- The collated output times DynamicList times_; - //- Indices in times_ when a geometry (mesh) has been written + //- Indices in times_ when geometry (mesh) has been written (collated) bitSet meshes_; - // NOTE: Could also maintain fieldsDict here, - // or as a HashTable of info. + //- Cached information for times, geometry, fields (collated) + dictionary cache_; // Private Member Functions diff --git a/src/surfMesh/writers/ensight/ensightSurfaceWriterCollated.C b/src/surfMesh/writers/ensight/ensightSurfaceWriterCollated.C index 22cfe74ada..e4f774bac7 100644 --- a/src/surfMesh/writers/ensight/ensightSurfaceWriterCollated.C +++ b/src/surfMesh/writers/ensight/ensightSurfaceWriterCollated.C @@ -85,7 +85,7 @@ Foam::label Foam::surfaceWriters::ensightWriter::readPreviousTimes labelList geomIndices; scalarList meshTimes; - dictionary dict; + cache_.clear(); const fileName dictFile(baseDir/dictName); @@ -93,19 +93,19 @@ Foam::label Foam::surfaceWriters::ensightWriter::readPreviousTimes { IFstream is(dictFile); - if (is.good() && dict.read(is)) + if (is.good() && cache_.read(is)) { meshes_.clear(); - dict.readIfPresent("times", times_); + cache_.readIfPresent("times", times_); timeIndex = findTimeIndex(times_, timeValue); - if (dict.readIfPresent("geometry", geomIndices)) + if (cache_.readIfPresent("geometry", geomIndices)) { // Convert indices to bitSet entries meshes_.set(geomIndices); } - else if (dict.readIfPresent("meshes", meshTimes)) + else if (cache_.readIfPresent("meshes", meshTimes)) { WarningInFunction << nl @@ -273,47 +273,29 @@ Foam::fileName Foam::surfaceWriters::ensightWriter::writeCollated // Do case file { - dictionary dict; - // Add time information to dictionary - dict.set("geometry", meshes_.sortedToc()); - dict.set("times", times_); + cache_.set("geometry", meshes_.sortedToc()); + cache_.set("times", times_); // Debugging, or if needed for older versions: - //// dict.set + //// cache_.set //// ( //// "meshes", //// IndirectList(times_, meshes_.sortedToc()) //// ); + // Add field information to dictionary + dictionary& fieldsDict = cache_.subDictOrAdd("fields"); + dictionary& fieldDict = fieldsDict.subDictOrAdd(fieldName); - // Add field information to dictionary? - bool hasField = false; - - dictionary* fieldsDictPtr = dict.findDict("fields"); - if (fieldsDictPtr) + if (fieldDict.empty()) { - hasField = fieldsDictPtr->found(fieldName); - } - else - { - // No "fields" dictionary - create first - fieldsDictPtr = dict.set("fields", dictionary())->dictPtr(); - } - - if (!hasField) - { - dictionary fieldDict; fieldDict.set("type", ensightPTraits::typeName); fieldDict.set("name", varName); // ensight variable name - - fieldsDictPtr->set(fieldName, fieldDict); stateChanged = true; } - const dictionary& fieldsDict = *fieldsDictPtr; - if (stateChanged) { if (verbose_) @@ -323,7 +305,7 @@ Foam::fileName Foam::surfaceWriters::ensightWriter::writeCollated { OFstream os(baseDir/"fieldsDict"); os << "// Summary of Ensight fields, times" << nl << nl; - dict.write(os, false); + cache_.write(os, false); } OFstream osCase(outputFile, IOstream::ASCII); @@ -489,7 +471,7 @@ Foam::fileName Foam::surfaceWriters::ensightWriter::writeCollated OFstream timeStamp(dataDir/"time"); timeStamp << "# timestep time" << nl - << dataDir.name() << " " << timeValue << nl; + << dataDir.name() << ' ' << timeValue << nl; } }