diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C index ac8734c944..1d0f6c3beb 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C @@ -189,9 +189,8 @@ int main(int argc, char *argv[]) "(tet pyr prism hex poly)." ); - // the volume field types that we handle - const label nVolFieldTypes = 10; - const word volFieldTypes[] = + // The volume field types that we handle + const wordList volFieldTypes { volScalarField::typeName, volVectorField::typeName, @@ -363,7 +362,7 @@ int main(int argc, char *argv[]) // ~~~~~~~~~~~~~~~~~~~~~~ Info<< "Write volume field ("; - for (label typei=0; typei < nVolFieldTypes; ++typei) + forAll(volFieldTypes, typei) { const word& fieldType = volFieldTypes[typei]; wordList fieldNames = objects.names(fieldType); diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C index c890d2993b..ab2e67e855 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C @@ -139,18 +139,22 @@ int main(int argc, char *argv[]) ); // The volume field types that we handle - wordHashSet volFieldTypes; - volFieldTypes.insert(volScalarField::typeName); - volFieldTypes.insert(volVectorField::typeName); - volFieldTypes.insert(volSphericalTensorField::typeName); - volFieldTypes.insert(volSymmTensorField::typeName); - volFieldTypes.insert(volTensorField::typeName); + const wordHashSet volFieldTypes + { + volScalarField::typeName, + volVectorField::typeName, + volSphericalTensorField::typeName, + volSymmTensorField::typeName, + volTensorField::typeName + }; // The lagrangian field types that we handle - wordHashSet cloudFieldTypes; - cloudFieldTypes.insert(scalarIOField::typeName); - cloudFieldTypes.insert(vectorIOField::typeName); - cloudFieldTypes.insert(tensorIOField::typeName); + const wordHashSet cloudFieldTypes + { + scalarIOField::typeName, + vectorIOField::typeName, + tensorIOField::typeName + }; #include "setRootCase.H" diff --git a/src/fileFormats/ensight/file/ensightCase.C b/src/fileFormats/ensight/file/ensightCase.C index 0ac968e799..dc803f5f99 100644 --- a/src/fileFormats/ensight/file/ensightCase.C +++ b/src/fileFormats/ensight/file/ensightCase.C @@ -58,14 +58,17 @@ void Foam::ensightCase::initialize() // eg, convert new results or a particular time interva // OR remove everything - if (options_->overwrite()) + if (isDir(ensightDir_)) { - rmDir(ensightDir_); - } - else if (isDir(ensightDir_)) - { - Info<<"Warning: re-using existing directory" << nl - << " " << ensightDir_ << endl; + if (options_->overwrite()) + { + Foam::rmDir(ensightDir_); + } + else + { + Info<<"Warning: re-using existing directory" << nl + << " " << ensightDir_ << endl; + } } // Create ensight and data directories diff --git a/src/fileFormats/ensight/part/ensightCells.C b/src/fileFormats/ensight/part/ensightCells.C index ea12323d5c..5e17013314 100644 --- a/src/fileFormats/ensight/part/ensightCells.C +++ b/src/fileFormats/ensight/part/ensightCells.C @@ -65,7 +65,7 @@ inline Foam::label Foam::ensightCells::offset } -void Foam::ensightCells::allocate() +void Foam::ensightCells::resize() { // overall required size label n = 0; @@ -97,13 +97,39 @@ Foam::ensightCells::ensightCells(const label partIndex) sizes_(0), lists_() { - // ensure sub-lists are properly initialized to nullptr + // Ensure sub-lists are properly initialized to nullptr forAll(lists_, typeI) { lists_[typeI] = nullptr; } - clear(); + resize(); // adjust allocation +} + + +Foam::ensightCells::ensightCells(const ensightCells& obj) +: + index_(obj.index_), + address_(obj.address_), + sizes_(0), + lists_() +{ + // Ensure sub-lists are properly initialized to nullptr + forAll(lists_, typeI) + { + lists_[typeI] = nullptr; + } + + // Total (reduced) sizes + FixedList totSizes = obj.sizes_; + + // Local sizes + this->sizes_ = obj.sizes(); + + resize(); // adjust allocation + + // Restore total (reduced) sizes + this->sizes_ = totSizes; } @@ -111,7 +137,12 @@ Foam::ensightCells::ensightCells(const label partIndex) Foam::ensightCells::~ensightCells() { - clear(); + sizes_ = 0; + forAll(lists_, typeI) + { + deleteDemandDrivenData(lists_[typeI]); + } + address_.clear(); } @@ -143,12 +174,7 @@ Foam::label Foam::ensightCells::total() const void Foam::ensightCells::clear() { sizes_ = 0; - - forAll(lists_, typeI) - { - deleteDemandDrivenData(lists_[typeI]); - } - address_.clear(); + resize(); } @@ -156,7 +182,7 @@ void Foam::ensightCells::reduce() { forAll(sizes_, typeI) { - sizes_[typeI] = lists_[typeI] ? lists_[typeI]->size() : 0; + sizes_[typeI] = lists_[typeI]->size(); Foam::reduce(sizes_[typeI], sumOp