From 405210a4f228692159827df499e30961985af68d Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 27 Sep 2016 09:02:35 +0200 Subject: [PATCH 01/10] STYLE: relocate commonly used ensight components to fileFormats - use explicit names within ensightPTraits --- src/conversion/Make/files | 4 -- src/fileFormats/Make/files | 6 ++- .../ensight/file/ensightFile.C | 0 .../ensight/file/ensightFile.H | 0 .../ensight/file/ensightGeoFile.C | 0 .../ensight/file/ensightGeoFile.H | 0 .../ensight/name/ensightFileName.H | 0 .../ensight/name/ensightFileNameI.H | 0 .../ensight/name/ensightVarName.H | 0 .../ensight/name/ensightVarNameI.H | 0 .../ensight/read}/ensightReadFile.C | 0 .../ensight/read}/ensightReadFile.H | 0 .../ensight => ensight/type}/ensightPTraits.C | 37 ++++++++----------- .../ensight => ensight/type}/ensightPTraits.H | 0 14 files changed, 21 insertions(+), 26 deletions(-) rename src/{conversion => fileFormats}/ensight/file/ensightFile.C (100%) rename src/{conversion => fileFormats}/ensight/file/ensightFile.H (100%) rename src/{conversion => fileFormats}/ensight/file/ensightGeoFile.C (100%) rename src/{conversion => fileFormats}/ensight/file/ensightGeoFile.H (100%) rename src/{conversion => fileFormats}/ensight/name/ensightFileName.H (100%) rename src/{conversion => fileFormats}/ensight/name/ensightFileNameI.H (100%) rename src/{conversion => fileFormats}/ensight/name/ensightVarName.H (100%) rename src/{conversion => fileFormats}/ensight/name/ensightVarNameI.H (100%) rename src/{conversion/ensight/readFile => fileFormats/ensight/read}/ensightReadFile.C (100%) rename src/{conversion/ensight/readFile => fileFormats/ensight/read}/ensightReadFile.H (100%) rename src/fileFormats/{sampledSetWriters/ensight => ensight/type}/ensightPTraits.C (77%) rename src/fileFormats/{sampledSetWriters/ensight => ensight/type}/ensightPTraits.H (100%) diff --git a/src/conversion/Make/files b/src/conversion/Make/files index bbf86cf859..7451df76f8 100644 --- a/src/conversion/Make/files +++ b/src/conversion/Make/files @@ -7,16 +7,12 @@ common/writer/meshWriter.C common/tables/boundaryRegion.C common/tables/cellTable.C -ensight/file/ensightFile.C -ensight/file/ensightGeoFile.C -ensight/readFile/ensightReadFile.C ensight/part/ensightPart.C ensight/part/ensightPartIO.C ensight/part/ensightPartCells.C ensight/part/ensightPartFaces.C ensight/part/ensightParts.C - starcd/STARCDMeshReader.C starcd/STARCDMeshWriter.C diff --git a/src/fileFormats/Make/files b/src/fileFormats/Make/files index 642d53dbad..6ddcb081e9 100644 --- a/src/fileFormats/Make/files +++ b/src/fileFormats/Make/files @@ -1,3 +1,8 @@ +ensight/file/ensightFile.C +ensight/file/ensightGeoFile.C +ensight/read/ensightReadFile.C +ensight/type/ensightPTraits.C + vtk/vtkUnstructuredReader.C nas/NASCore.C starcd/STARCDCore.C @@ -8,7 +13,6 @@ setWriters = sampledSetWriters $(setWriters)/writers.C $(setWriters)/ensight/ensightSetWriterRunTime.C -$(setWriters)/ensight/ensightPTraits.C $(setWriters)/gnuplot/gnuplotSetWriterRunTime.C $(setWriters)/jplot/jplotSetWriterRunTime.C $(setWriters)/raw/rawSetWriterRunTime.C diff --git a/src/conversion/ensight/file/ensightFile.C b/src/fileFormats/ensight/file/ensightFile.C similarity index 100% rename from src/conversion/ensight/file/ensightFile.C rename to src/fileFormats/ensight/file/ensightFile.C diff --git a/src/conversion/ensight/file/ensightFile.H b/src/fileFormats/ensight/file/ensightFile.H similarity index 100% rename from src/conversion/ensight/file/ensightFile.H rename to src/fileFormats/ensight/file/ensightFile.H diff --git a/src/conversion/ensight/file/ensightGeoFile.C b/src/fileFormats/ensight/file/ensightGeoFile.C similarity index 100% rename from src/conversion/ensight/file/ensightGeoFile.C rename to src/fileFormats/ensight/file/ensightGeoFile.C diff --git a/src/conversion/ensight/file/ensightGeoFile.H b/src/fileFormats/ensight/file/ensightGeoFile.H similarity index 100% rename from src/conversion/ensight/file/ensightGeoFile.H rename to src/fileFormats/ensight/file/ensightGeoFile.H diff --git a/src/conversion/ensight/name/ensightFileName.H b/src/fileFormats/ensight/name/ensightFileName.H similarity index 100% rename from src/conversion/ensight/name/ensightFileName.H rename to src/fileFormats/ensight/name/ensightFileName.H diff --git a/src/conversion/ensight/name/ensightFileNameI.H b/src/fileFormats/ensight/name/ensightFileNameI.H similarity index 100% rename from src/conversion/ensight/name/ensightFileNameI.H rename to src/fileFormats/ensight/name/ensightFileNameI.H diff --git a/src/conversion/ensight/name/ensightVarName.H b/src/fileFormats/ensight/name/ensightVarName.H similarity index 100% rename from src/conversion/ensight/name/ensightVarName.H rename to src/fileFormats/ensight/name/ensightVarName.H diff --git a/src/conversion/ensight/name/ensightVarNameI.H b/src/fileFormats/ensight/name/ensightVarNameI.H similarity index 100% rename from src/conversion/ensight/name/ensightVarNameI.H rename to src/fileFormats/ensight/name/ensightVarNameI.H diff --git a/src/conversion/ensight/readFile/ensightReadFile.C b/src/fileFormats/ensight/read/ensightReadFile.C similarity index 100% rename from src/conversion/ensight/readFile/ensightReadFile.C rename to src/fileFormats/ensight/read/ensightReadFile.C diff --git a/src/conversion/ensight/readFile/ensightReadFile.H b/src/fileFormats/ensight/read/ensightReadFile.H similarity index 100% rename from src/conversion/ensight/readFile/ensightReadFile.H rename to src/fileFormats/ensight/read/ensightReadFile.H diff --git a/src/fileFormats/sampledSetWriters/ensight/ensightPTraits.C b/src/fileFormats/ensight/type/ensightPTraits.C similarity index 77% rename from src/fileFormats/sampledSetWriters/ensight/ensightPTraits.C rename to src/fileFormats/ensight/type/ensightPTraits.C index bf29a96820..a6b70129af 100644 --- a/src/fileFormats/sampledSetWriters/ensight/ensightPTraits.C +++ b/src/fileFormats/ensight/type/ensightPTraits.C @@ -28,56 +28,51 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // template<> -const char* const Foam::ensightPTraits::typeName = - Foam::pTraits::typeName; +const char* const +Foam::ensightPTraits::typeName = "scalar"; template<> const Foam::direction Foam::ensightPTraits::componentOrder[] = {0}; + template<> -const char* const Foam::ensightPTraits::typeName = - Foam::pTraits::typeName; +const char* const +Foam::ensightPTraits::typeName = "vector"; template<> const Foam::direction Foam::ensightPTraits::componentOrder[] = {0, 1, 2}; + +// use mag(sphericalTensor) instead template<> -const char* const Foam::ensightPTraits::typeName = - Foam::pTraits::typeName; +const char* const +Foam::ensightPTraits::typeName = "scalar"; + template<> const Foam::direction Foam::ensightPTraits::componentOrder[] = {0}; template<> -const char* const Foam::ensightPTraits::typeName = - "tensor symm"; +const char* const +Foam::ensightPTraits::typeName = "tensor symm"; template<> const Foam::direction Foam::ensightPTraits::componentOrder[] = {0, 3, 5, 1, 2, 4}; + template<> -const char* const Foam::ensightPTraits::typeName = - "tensor asym"; +const char* const +Foam::ensightPTraits::typeName = "tensor asym"; template<> const Foam::direction Foam::ensightPTraits::componentOrder[] = -{ - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8 -}; + { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; // ************************************************************************* // diff --git a/src/fileFormats/sampledSetWriters/ensight/ensightPTraits.H b/src/fileFormats/ensight/type/ensightPTraits.H similarity index 100% rename from src/fileFormats/sampledSetWriters/ensight/ensightPTraits.H rename to src/fileFormats/ensight/type/ensightPTraits.H From c9cf232a02411dcb43ee1ed126e782c8760b4e0f Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 27 Sep 2016 10:08:07 +0200 Subject: [PATCH 02/10] ENH: add some convenience methods in ensightFile, ensightGeoFile - Some commonly used write methods that are independent of the calling context (ie, 2D/3D data, geometry, fields) - Provide singleton null() for ensightFile, ensightGeoFile. Can be used for MPI slaves that need a file reference for their methods, but will never write to it, but it is also reasonable to use an autoPtr with rawRef() for that as well. --- src/conversion/ensight/part/ensightPart.H | 14 +--- src/conversion/ensight/part/ensightPartIO.C | 76 +------------------ .../ensight/part/ensightPartTemplates.C | 8 +- src/fileFormats/ensight/file/ensightFile.C | 73 ++++++++++++++++++ src/fileFormats/ensight/file/ensightFile.H | 33 +++++++- src/fileFormats/ensight/file/ensightGeoFile.C | 50 ++++++++++-- src/fileFormats/ensight/file/ensightGeoFile.H | 21 +++++ .../ensight/name/ensightFileName.H | 15 ++-- src/fileFormats/ensight/name/ensightVarName.H | 13 ++-- 9 files changed, 188 insertions(+), 115 deletions(-) diff --git a/src/conversion/ensight/part/ensightPart.H b/src/conversion/ensight/part/ensightPart.H index 170b0e763d..80e31935ef 100644 --- a/src/conversion/ensight/part/ensightPart.H +++ b/src/conversion/ensight/part/ensightPart.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 | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -138,18 +138,6 @@ protected: //- Check for fully defined fields bool isFieldDefined(const List&) const; - //- Write the part header - void writeHeader(ensightFile&, bool withDescription=false) const; - - //- Write a scalar field for idList - // A null reference for idList writes the perNode values - void writeFieldList - ( - ensightFile& os, - const List& field, - const labelUList& idList - ) const; - //- Track points used virtual localPoints calcLocalPoints() const { diff --git a/src/conversion/ensight/part/ensightPartIO.C b/src/conversion/ensight/part/ensightPartIO.C index 4e21d6dd62..68cc8d4196 100644 --- a/src/conversion/ensight/part/ensightPartIO.C +++ b/src/conversion/ensight/part/ensightPartIO.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 | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,72 +30,6 @@ Description #include "dictionary.H" #include "IOstreams.H" -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -void Foam::ensightPart::writeHeader -( - ensightFile& os, - bool withDescription -) const -{ - os.write("part"); - os.newline(); - - os.write(number() + 1); // Ensight starts with 1 - os.newline(); - - if (withDescription) - { - os.write(name()); - os.newline(); - } -} - - -void Foam::ensightPart::writeFieldList -( - ensightFile& os, - const List& field, - const labelUList& idList -) const -{ - if (notNull(idList)) - { - forAll(idList, i) - { - if (idList[i] >= field.size() || std::isnan(field[idList[i]])) - { - os.writeUndef(); - } - else - { - os.write(field[idList[i]]); - } - - os.newline(); - } - } - else - { - // no idList => perNode - forAll(field, i) - { - if (std::isnan(field[i])) - { - os.writeUndef(); - } - else - { - os.write(field[i]); - } - - os.newline(); - } - } -} - - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::ensightPart::reconstruct(Istream& is) @@ -176,12 +110,8 @@ void Foam::ensightPart::writeGeometry const localPoints ptList = calcLocalPoints(); const labelUList& pointMap = ptList.list; - writeHeader(os, true); - - // write points - os.writeKeyword("coordinates"); - os.write(ptList.nPoints); - os.newline(); + os.beginPart(number(), name()); + os.beginCoordinates(ptList.nPoints); for (direction cmpt=0; cmpt < point::nComponents; ++cmpt) { diff --git a/src/conversion/ensight/part/ensightPartTemplates.C b/src/conversion/ensight/part/ensightPartTemplates.C index 1318646040..168251435c 100644 --- a/src/conversion/ensight/part/ensightPartTemplates.C +++ b/src/conversion/ensight/part/ensightPartTemplates.C @@ -41,7 +41,7 @@ void Foam::ensightPart::writeField { if (this->size() && field.size()) { - writeHeader(os); + os.beginPart(number()); if (perNode) { @@ -49,7 +49,8 @@ void Foam::ensightPart::writeField for (direction d=0; d < pTraits::nComponents; ++d) { label cmpt = ensightPTraits::componentOrder[d]; - writeFieldList(os, field.component(cmpt), labelUList::null()); + + os.writeList(field.component(cmpt)); } } else @@ -65,7 +66,8 @@ void Foam::ensightPart::writeField for (direction d=0; d < pTraits::nComponents; ++d) { label cmpt = ensightPTraits::componentOrder[d]; - writeFieldList(os, field.component(cmpt), idList); + + os.writeList(field.component(cmpt), idList); } } } diff --git a/src/fileFormats/ensight/file/ensightFile.C b/src/fileFormats/ensight/file/ensightFile.C index 05003b2a00..b106c6ecf4 100644 --- a/src/fileFormats/ensight/file/ensightFile.C +++ b/src/fileFormats/ensight/file/ensightFile.C @@ -25,6 +25,7 @@ License #include "ensightFile.H" #include "error.H" +#include "UList.H" #include #include @@ -307,4 +308,76 @@ Foam::Ostream& Foam::ensightFile::writeBinaryHeader() } +// +// Convenience Output Methods +// + +void Foam::ensightFile::beginPart(const label index) +{ + write("part"); + newline(); + write(index+1); // Ensight starts with 1 + newline(); +} + + +void Foam::ensightFile::beginParticleCoordinates(const label nparticles) +{ + write("particle coordinates"); + newline(); + write(nparticles, 8); // unusual width + newline(); +} + + +void Foam::ensightFile::writeList +( + const UList& field +) +{ + forAll(field, i) + { + if (std::isnan(field[i])) + { + writeUndef(); + } + else + { + write(field[i]); + } + + newline(); + } +} + + +void Foam::ensightFile::writeList +( + const UList& field, + const labelUList& idList +) +{ + if (notNull(idList)) + { + forAll(idList, i) + { + if (idList[i] >= field.size() || std::isnan(field[idList[i]])) + { + writeUndef(); + } + else + { + write(field[idList[i]]); + } + + newline(); + } + } + else + { + // no idList => perNode + writeList(field); + } +} + // ************************************************************************* // diff --git a/src/fileFormats/ensight/file/ensightFile.H b/src/fileFormats/ensight/file/ensightFile.H index 03cbdcd703..78b09904e1 100644 --- a/src/fileFormats/ensight/file/ensightFile.H +++ b/src/fileFormats/ensight/file/ensightFile.H @@ -38,6 +38,7 @@ Description #include "ensightFileName.H" #include "ensightVarName.H" +#include "UList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -80,9 +81,13 @@ class ensightFile public: - // Forward declarations - class FileName; - class VarName; + // Static Member Functions + + //- Return a null ensightFile + inline static const ensightFile& null() + { + return NullObjectRef(); + } // Constructors @@ -172,6 +177,28 @@ public: //- Add carriage return to ascii stream void newline(); + + + // Convenience Output Methods + + //- Begin a part (0-based index). + void beginPart(const label index); + + //- Begin a "particle coordinates" block (measured data) + void beginParticleCoordinates(const label nparticles); + + //- Write a list of floats as "%12.5e" or as binary + // With carriage return after each value (ascii stream) + void writeList(const UList& field); + + //- Write an indirect list of scalars as "%12.5e" or as binary + // With carriage return after each value (ascii stream) + void writeList + ( + const UList& field, + const labelUList& idList + ); + }; diff --git a/src/fileFormats/ensight/file/ensightGeoFile.C b/src/fileFormats/ensight/file/ensightGeoFile.C index 0119087e70..27ce98282f 100644 --- a/src/fileFormats/ensight/file/ensightGeoFile.C +++ b/src/fileFormats/ensight/file/ensightGeoFile.C @@ -35,17 +35,25 @@ License void Foam::ensightGeoFile::initialize() { + writeBinaryHeader(); + + // Description line 1 + write("Ensight Geometry File"); + newline(); + + // Description line 2 #ifdef OPENFOAM_PLUS - string desc2("Written by OpenFOAM+ " STRING_QUOTE(OPENFOAM_PLUS)); + write(string("Written by OpenFOAM+ " STRING_QUOTE(OPENFOAM_PLUS))); #else - string desc2("Written by OpenFOAM-" + string(Foam::FOAMversion)); + write(string("Written by OpenFOAM-" + string(Foam::FOAMversion))); #endif - writeBinaryHeader(); - write("Ensight Geometry File"); newline(); // description line 1 - write(desc2); newline(); // description line 2 - write("node id assign"); newline(); - write("element id assign"); newline(); + newline(); + write("node id assign"); + newline(); + + write("element id assign"); + newline(); } @@ -87,10 +95,36 @@ Foam::ensightGeoFile::~ensightGeoFile() Foam::Ostream& Foam::ensightGeoFile::writeKeyword(const keyType& key) { // ensure we get ensightFile::write(const string&) - write(static_cast(key)); newline(); + write(static_cast(key)); + newline(); return *this; } +// +// Convenience Output Methods +// + +void Foam::ensightGeoFile::beginPart +( + const label index, + const string& description +) +{ + beginPart(index); + write(description); + newline(); +} + + +void Foam::ensightGeoFile::beginCoordinates(const label npoints) +{ + write("coordinates"); + newline(); + write(npoints); + newline(); +} + + // ************************************************************************* // diff --git a/src/fileFormats/ensight/file/ensightGeoFile.H b/src/fileFormats/ensight/file/ensightGeoFile.H index 75cef26cd9..6b60c6e419 100644 --- a/src/fileFormats/ensight/file/ensightGeoFile.H +++ b/src/fileFormats/ensight/file/ensightGeoFile.H @@ -61,6 +61,15 @@ class ensightGeoFile public: + // Static Member Functions + + //- Return a null ensightGeoFile + inline static const ensightGeoFile& null() + { + return NullObjectRef(); + } + + // Constructors //- Construct from pathname. @@ -89,6 +98,18 @@ public: //- Write keyword with trailing newline virtual Ostream& writeKeyword(const keyType& key); + + + // Convenience Output Methods + + using ensightFile::beginPart; + + //- Begin a "part" (0-based index), with a description. + void beginPart(const label index, const string& description); + + //- Begin a "coordinates" block + void beginCoordinates(const label npoints); + }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/fileFormats/ensight/name/ensightFileName.H b/src/fileFormats/ensight/name/ensightFileName.H index 550a86f68c..1452730107 100644 --- a/src/fileFormats/ensight/name/ensightFileName.H +++ b/src/fileFormats/ensight/name/ensightFileName.H @@ -28,7 +28,7 @@ Description Specification of a valid Ensight file-name. Spaces must be quoted, - no '*' wildcards, not '%' (structured block continuation). + no '*' wildcards, no '%' (structured block continuation). Overall line length within case file is limited to 1024, but this is not yet addresssed. @@ -80,15 +80,16 @@ public: //- Is this character valid for an ensight file-name inline static bool valid(char); + // Member operators - // Assignment + // Assignment (disabled) - void operator=(const fileName&) = delete; - void operator=(const word&) = delete; - void operator=(const string&) = delete; - void operator=(const std::string&) = delete; - void operator=(const char*) = delete; + void operator=(const fileName&) = delete; + void operator=(const word&) = delete; + void operator=(const string&) = delete; + void operator=(const std::string&) = delete; + void operator=(const char*) = delete; }; diff --git a/src/fileFormats/ensight/name/ensightVarName.H b/src/fileFormats/ensight/name/ensightVarName.H index fe2c57aefb..2ffff6ae19 100644 --- a/src/fileFormats/ensight/name/ensightVarName.H +++ b/src/fileFormats/ensight/name/ensightVarName.H @@ -63,10 +63,8 @@ class VarName //- Strip invalid characters inline void stripInvalid(); - public: - // Constructors //- Construct as copy @@ -87,12 +85,11 @@ public: // Member operators - // Assignment - - void operator=(const word&) = delete; - void operator=(const string&) = delete; - void operator=(const std::string&) = delete; - void operator=(const char*) = delete; + // Assignment (disabled) + void operator=(const word&) = delete; + void operator=(const string&) = delete; + void operator=(const std::string&) = delete; + void operator=(const char*) = delete; }; From df9d4068169ae9555a3ad4d367c8b076cb539db8 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 27 Sep 2016 13:38:43 +0200 Subject: [PATCH 03/10] ENH: add in code for ensightCells, ensightFaces - intended as a base for various ensight-related handling --- src/fileFormats/Make/files | 2 + src/fileFormats/ensight/part/ensightCells.C | 263 +++++++++++++++ src/fileFormats/ensight/part/ensightCells.H | 202 +++++++++++ src/fileFormats/ensight/part/ensightCellsI.H | 85 +++++ src/fileFormats/ensight/part/ensightFaces.C | 337 +++++++++++++++++++ src/fileFormats/ensight/part/ensightFaces.H | 220 ++++++++++++ src/fileFormats/ensight/part/ensightFacesI.H | 91 +++++ 7 files changed, 1200 insertions(+) create mode 100644 src/fileFormats/ensight/part/ensightCells.C create mode 100644 src/fileFormats/ensight/part/ensightCells.H create mode 100644 src/fileFormats/ensight/part/ensightCellsI.H create mode 100644 src/fileFormats/ensight/part/ensightFaces.C create mode 100644 src/fileFormats/ensight/part/ensightFaces.H create mode 100644 src/fileFormats/ensight/part/ensightFacesI.H diff --git a/src/fileFormats/Make/files b/src/fileFormats/Make/files index 6ddcb081e9..91c6affaf2 100644 --- a/src/fileFormats/Make/files +++ b/src/fileFormats/Make/files @@ -1,5 +1,7 @@ ensight/file/ensightFile.C ensight/file/ensightGeoFile.C +ensight/part/ensightCells.C +ensight/part/ensightFaces.C ensight/read/ensightReadFile.C ensight/type/ensightPTraits.C diff --git a/src/fileFormats/ensight/part/ensightCells.C b/src/fileFormats/ensight/part/ensightCells.C new file mode 100644 index 0000000000..ea12323d5c --- /dev/null +++ b/src/fileFormats/ensight/part/ensightCells.C @@ -0,0 +1,263 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "ensightCells.H" +#include "error.H" +#include "polyMesh.H" +#include "cellModeller.H" +#include "demandDrivenData.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +const Foam::label Foam::ensightCells::nTypes = 5; + +namespace Foam +{ + template<> + const char* Foam::NamedEnum + < + Foam::ensightCells::elemType, + 5 + >::names[] = { "tetra4", "pyramid5", "penta6", "hexa8", "nfaced" }; +} + +const Foam::NamedEnum + Foam::ensightCells::elemEnum; + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +inline Foam::label Foam::ensightCells::offset +( + const enum elemType what, + const label i +) const +{ + label n = i; + for (label typeI = 0; typeI < label(what); ++typeI) + { + n += sizes_[typeI]; + } + + return n; +} + + +void Foam::ensightCells::allocate() +{ + // overall required size + label n = 0; + forAll(sizes_, typeI) + { + n += sizes_[typeI]; + } + address_.setSize(n, 0); + + // assign corresponding sub-lists + n = 0; + forAll(sizes_, typeI) + { + deleteDemandDrivenData(lists_[typeI]); + + lists_[typeI] = new SubList