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(address_, sizes_[typeI], n);
+
+ n += sizes_[typeI];
+ }
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+Foam::ensightCells::ensightCells(const label partIndex)
+:
+ index_(partIndex),
+ address_(),
+ sizes_(0),
+ lists_()
+{
+ // ensure sub-lists are properly initialized to nullptr
+ forAll(lists_, typeI)
+ {
+ lists_[typeI] = nullptr;
+ }
+
+ clear();
+}
+
+
+// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
+
+Foam::ensightCells::~ensightCells()
+{
+ clear();
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
+
+Foam::FixedList Foam::ensightCells::sizes() const
+{
+ FixedList count;
+ forAll(lists_, typeI)
+ {
+ count[typeI] = lists_[typeI] ? lists_[typeI]->size() : 0;
+ }
+
+ return count;
+}
+
+
+Foam::label Foam::ensightCells::total() const
+{
+ label n = 0;
+ forAll(sizes_, typeI)
+ {
+ n += sizes_[typeI];
+ }
+ return n;
+}
+
+
+void Foam::ensightCells::clear()
+{
+ sizes_ = 0;
+
+ forAll(lists_, typeI)
+ {
+ deleteDemandDrivenData(lists_[typeI]);
+ }
+ address_.clear();
+}
+
+
+void Foam::ensightCells::reduce()
+{
+ forAll(sizes_, typeI)
+ {
+ sizes_[typeI] = lists_[typeI] ? lists_[typeI]->size() : 0;
+ Foam::reduce(sizes_[typeI], sumOp());
+ }
+}
+
+
+void Foam::ensightCells::sort()
+{
+ forAll(lists_, typeI)
+ {
+ if (lists_[typeI])
+ {
+ Foam::sort(*(lists_[typeI]));
+ }
+ }
+}
+
+
+void Foam::ensightCells::classify
+(
+ const polyMesh& mesh,
+ const labelUList& addressing
+)
+{
+ // References to cell shape models
+ const cellModel& tet = *(cellModeller::lookup("tet"));
+ const cellModel& pyr = *(cellModeller::lookup("pyr"));
+ const cellModel& prism = *(cellModeller::lookup("prism"));
+ const cellModel& hex = *(cellModeller::lookup("hex"));
+
+ const cellShapeList& shapes = mesh.cellShapes();
+
+ const bool indirect = notNull(addressing);
+ const label sz = indirect ? addressing.size() : mesh.nCells();
+
+ // Count the shapes
+ // Can avoid double looping, but only at the expense of allocation
+
+ sizes_ = 0; // reset sizes
+ for (label listI = 0; listI < sz; ++listI)
+ {
+ const label id = indirect ? addressing[listI] : listI;
+ const cellModel& model = shapes[id].model();
+
+ enum elemType what = NFACED;
+ if (model == tet)
+ {
+ what = TETRA4;
+ }
+ else if (model == pyr)
+ {
+ what = PYRAMID5;
+ }
+ else if (model == prism)
+ {
+ what = PENTA6;
+ }
+ else if (model == hex)
+ {
+ what = HEXA8;
+ }
+
+ sizes_[what]++;
+ }
+
+ allocate();
+ sizes_ = 0; // reset sizes
+
+ // Assign cell-id per shape type
+ for (label listI = 0; listI < sz; ++listI)
+ {
+ const label id = indirect ? addressing[listI] : listI;
+ const cellModel& model = shapes[id].model();
+
+ enum elemType what = NFACED;
+ if (model == tet)
+ {
+ what = TETRA4;
+ }
+ else if (model == pyr)
+ {
+ what = PYRAMID5;
+ }
+ else if (model == prism)
+ {
+ what = PENTA6;
+ }
+ else if (model == hex)
+ {
+ what = HEXA8;
+ }
+
+ // eg, the processor local cellId
+ lists_[what]->operator[](sizes_[what]++) = id;
+ }
+}
+
+
+Foam::label Foam::ensightCells::offset(const enum elemType what) const
+{
+ return offset(what, 0);
+}
+
+
+// ************************************************************************* //
diff --git a/src/fileFormats/ensight/part/ensightCells.H b/src/fileFormats/ensight/part/ensightCells.H
new file mode 100644
index 0000000000..4c9d034b0d
--- /dev/null
+++ b/src/fileFormats/ensight/part/ensightCells.H
@@ -0,0 +1,202 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / 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 .
+
+Class
+ Foam::ensightCells
+
+Description
+ Sorting/classification of cells (3D) into corresponding ensight element
+ types.
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef ensightCells_H
+#define ensightCells_H
+
+#include "labelList.H"
+#include "FixedList.H"
+#include "SubList.H"
+#include "NamedEnum.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+class polyMesh;
+
+/*---------------------------------------------------------------------------*\
+ Class ensightCells Declaration
+\*---------------------------------------------------------------------------*/
+
+class ensightCells
+{
+public:
+
+ // Public data
+
+ //- Addressable ensight element types
+ enum elemType
+ {
+ TETRA4,
+ PYRAMID5,
+ PENTA6,
+ HEXA8,
+ NFACED
+ };
+
+ //- Number of element types (5)
+ static const label nTypes;
+
+ //- The Ensight names for each element type
+ static const NamedEnum elemEnum;
+
+
+ // Static Member Functions
+
+ //- Return the ensight element name for the specified type
+ inline static const char* key(const enum elemType);
+
+
+private:
+
+ // Private data
+
+ //- Location within a list
+ label index_;
+
+ //- Linear list of ids, sub-sectioned per element type via SubLists
+ labelList address_;
+
+ //- List of sizes for each element type
+ FixedList sizes_;
+
+ //- List of ids for each element type
+ FixedList*, 5> lists_;
+
+
+ // Private Member Functions
+
+ //- Low-level offset routine
+ inline label offset(const enum elemType what, const label i) const;
+
+ //- Use current sizes to redimension the element lists
+ void allocate();
+
+ //- Disallow default bitwise assignment
+ void operator=(const ensightCells&) = delete;
+
+ // Retain default copy constructor (needed for lists etc).
+
+public:
+
+ // Constructors
+
+ //- Construct null, optionally with index
+ ensightCells(label partIndex = 0);
+
+
+ //- Destructor
+ ~ensightCells();
+
+
+ // Member Functions
+
+ // Access
+
+ //- The index in a list.
+ inline label index() const;
+
+ //- The index in a list, non-const access.
+ inline label& index();
+
+ //- The processor local size of all elements.
+ inline label size() const;
+
+ //- The global number of the specified element type.
+ // This value is only meaningful after a reduce operation.
+ inline label total(const enum elemType) const;
+
+ //- The global number of all element types.
+ // This value is only meaningful after a reduce operation.
+ label total() const;
+
+ //- The processor local sizes per element type.
+ FixedList sizes() const;
+
+ //- The global numbers per element type.
+ // This value is only meaningful after a reduce operation.
+ inline const FixedList& totals() const;
+
+
+ //- Return the (local) cell ids of the specified element type
+ inline const labelUList& cellIds(const enum elemType) const;
+
+ //- Return the cell ids of all elements
+ inline const labelUList& cellIds() const;
+
+ //- Starting offset of element type.
+ label offset(const enum elemType what) const;
+
+
+ // Edit
+
+ //- Classify cell types and set the element lists.
+ // The optional indirect addressing can be used when classifying
+ // groups of cells (eg, from a cellZone etc).
+ void classify
+ (
+ const polyMesh&,
+ const labelUList& addressing = labelUList::null()
+ );
+
+
+ //- Set sizes to zero, free up memory
+ void clear();
+
+ //- Sum element counts across all processes.
+ void reduce();
+
+ //- Sort element lists numerically.
+ void sort();
+
+
+ // Member operators
+
+ //- Return id from linear list of addressing.
+ inline label operator[](const label i) const;
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#include "ensightCellsI.H"
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/fileFormats/ensight/part/ensightCellsI.H b/src/fileFormats/ensight/part/ensightCellsI.H
new file mode 100644
index 0000000000..35879f3a40
--- /dev/null
+++ b/src/fileFormats/ensight/part/ensightCellsI.H
@@ -0,0 +1,85 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / 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 .
+
+\*---------------------------------------------------------------------------*/
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+inline const char* Foam::ensightCells::key(const enum elemType what)
+{
+ return elemEnum[what];
+}
+
+
+inline Foam::label Foam::ensightCells::index() const
+{
+ return index_;
+}
+
+
+inline Foam::label& Foam::ensightCells::index()
+{
+ return index_;
+}
+
+
+inline Foam::label Foam::ensightCells::size() const
+{
+ return address_.size();
+}
+
+
+inline const Foam::FixedList& Foam::ensightCells::totals() const
+{
+ return sizes_;
+}
+
+
+inline Foam::label Foam::ensightCells::total(const enum elemType what) const
+{
+ return sizes_[what];
+}
+
+
+inline const Foam::labelUList& Foam::ensightCells::cellIds
+(
+ const enum elemType what
+) const
+{
+ return *(lists_[what]);
+}
+
+
+inline const Foam::labelUList& Foam::ensightCells::cellIds() const
+{
+ return address_;
+}
+
+
+inline Foam::label Foam::ensightCells::operator[](const label i) const
+{
+ return address_[i];
+}
+
+
+// ************************************************************************* //
diff --git a/src/fileFormats/ensight/part/ensightFaces.C b/src/fileFormats/ensight/part/ensightFaces.C
new file mode 100644
index 0000000000..ffcc7dcfc4
--- /dev/null
+++ b/src/fileFormats/ensight/part/ensightFaces.C
@@ -0,0 +1,337 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / 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 "ensightFaces.H"
+#include "error.H"
+#include "polyMesh.H"
+#include "ListOps.H"
+#include "demandDrivenData.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+const Foam::label Foam::ensightFaces::nTypes = 3;
+
+namespace Foam
+{
+ template<>
+ const char* Foam::NamedEnum
+ <
+ Foam::ensightFaces::elemType,
+ 3
+ >::names[] = { "tria3", "quad4", "nsided" };
+}
+
+const Foam::NamedEnum
+ Foam::ensightFaces::elemEnum;
+
+
+// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
+
+// only used in this file-scope
+inline Foam::ensightFaces::elemType
+Foam::ensightFaces::whatType(const face& f)
+{
+ return
+ (
+ f.size() == 3
+ ? Foam::ensightFaces::elemType::TRIA3
+ : f.size() == 4
+ ? Foam::ensightFaces::elemType::QUAD4
+ : Foam::ensightFaces::elemType::NSIDED
+ );
+}
+
+
+// only used in this file-scope
+inline void Foam::ensightFaces::add
+(
+ const face& f,
+ const label id,
+ const bool flip
+)
+{
+ const enum elemType what = whatType(f);
+
+ label n = sizes_[what]++;
+ lists_[what]->operator[](n) = id;
+
+ if (flipMap_.size())
+ {
+ flipMap_[offset(what, n)] = flip;
+ }
+}
+
+
+// only used in this file-scope
+inline Foam::label Foam::ensightFaces::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::ensightFaces::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(address_, sizes_[typeI], n);
+
+ n += sizes_[typeI];
+ }
+
+ // normally assume no flipMap
+ flipMap_.clear();
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+Foam::ensightFaces::ensightFaces(label partIndex)
+:
+ index_(partIndex),
+ address_(),
+ flipMap_(),
+ sizes_(0),
+ lists_()
+{
+ // ensure sub-lists are properly initialized to nullptr
+ forAll(lists_, typeI)
+ {
+ lists_[typeI] = nullptr;
+ }
+
+ clear();
+}
+
+
+// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
+
+Foam::ensightFaces::~ensightFaces()
+{
+ clear();
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
+
+Foam::FixedList Foam::ensightFaces::sizes() const
+{
+ FixedList count;
+ forAll(lists_, typeI)
+ {
+ count[typeI] = lists_[typeI] ? lists_[typeI]->size() : 0;
+ }
+
+ return count;
+}
+
+
+Foam::label Foam::ensightFaces::total() const
+{
+ label n = 0;
+ forAll(sizes_, typeI)
+ {
+ n += sizes_[typeI];
+ }
+ return n;
+}
+
+
+void Foam::ensightFaces::clear()
+{
+ sizes_ = 0;
+
+ forAll(lists_, typeI)
+ {
+ deleteDemandDrivenData(lists_[typeI]);
+ }
+ address_.clear();
+ flipMap_.clear();
+}
+
+
+void Foam::ensightFaces::reduce()
+{
+ forAll(sizes_, typeI)
+ {
+ sizes_[typeI] = lists_[typeI] ? lists_[typeI]->size() : 0;
+ Foam::reduce(sizes_[typeI], sumOp());
+ }
+}
+
+
+void Foam::ensightFaces::sort()
+{
+ if (flipMap_.size() == address_.size())
+ {
+ // sort flip too
+
+ labelList order;
+ label start = 0;
+
+ forAll(lists_, typeI)
+ {
+ if (lists_[typeI])
+ {
+ SubList& idLst = *(lists_[typeI]);
+ const label sz = idLst.size();
+
+ if (sz)
+ {
+ SubList flip(flipMap_, sz, start);
+ start += sz; // for next sub-list
+
+ sortedOrder(idLst, order);
+
+ idLst = reorder(order, idLst);
+ flip = reorder(order, flip);
+ }
+ }
+ }
+ }
+ else
+ {
+ // no flip-maps, simpler to sort
+ forAll(lists_, typeI)
+ {
+ if (lists_[typeI])
+ {
+ SubList& idLst = *(lists_[typeI]);
+ const label sz = idLst.size();
+ if (sz)
+ {
+ Foam::sort(idLst);
+ }
+ }
+ }
+ }
+}
+
+
+void Foam::ensightFaces::classify(const faceList& faces)
+{
+ const label sz = faces.size();
+
+ // Count the shapes
+ // Can avoid double looping, but only at the expense of allocation
+
+ sizes_ = 0; // reset sizes
+ for (label listI = 0; listI < sz; ++listI)
+ {
+ const enum elemType what = whatType(faces[listI]);
+ sizes_[what]++;
+ }
+
+ allocate(); // adjust allocation
+ sizes_ = 0; // reset sizes
+
+ // Assign face-id per shape type
+ for (label listI = 0; listI < sz; ++listI)
+ {
+ add(faces[listI], listI);
+ }
+}
+
+
+void Foam::ensightFaces::classify
+(
+ const faceList& faces,
+ const labelUList& addressing,
+ const boolList& flipMap,
+ const PackedBoolList& exclude
+)
+{
+ // Note: Since PackedList::operator[] returns zero (false) for out-of-range
+ // indices, can skip our own bounds checking here.
+
+ const label sz = addressing.size();
+ const bool useFlip = (addressing.size() == flipMap.size());
+
+ // Count the shapes
+ // Can avoid double looping, but only at the expense of allocation
+
+ sizes_ = 0; // reset sizes
+ for (label listI = 0; listI < sz; ++listI)
+ {
+ const label faceId = addressing[listI];
+
+ if (!exclude[faceId])
+ {
+ const enum elemType what = whatType(faces[faceId]);
+ sizes_[what]++;
+ }
+ }
+
+ allocate(); // adjust allocation
+ sizes_ = 0; // reset sizes
+
+ if (useFlip)
+ {
+ flipMap_.setSize(address_.size(), false);
+ flipMap_ = false;
+ }
+
+ // Assign face-id per shape type
+ for (label listI = 0; listI < sz; ++listI)
+ {
+ const label faceId = addressing[listI];
+ const bool flip = useFlip && flipMap[listI];
+
+ if (!exclude[faceId])
+ {
+ add(faces[faceId], faceId, flip);
+ }
+ }
+}
+
+
+Foam::label Foam::ensightFaces::offset(const enum elemType what) const
+{
+ return offset(what, 0);
+}
+
+
+// ************************************************************************* //
diff --git a/src/fileFormats/ensight/part/ensightFaces.H b/src/fileFormats/ensight/part/ensightFaces.H
new file mode 100644
index 0000000000..693ff029eb
--- /dev/null
+++ b/src/fileFormats/ensight/part/ensightFaces.H
@@ -0,0 +1,220 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / 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 .
+
+Class
+ Foam::ensightFaces
+
+Description
+ Sorting/classification of faces (2D) into corresponding ensight types
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef ensightFaces_H
+#define ensightFaces_H
+
+#include "boolList.H"
+#include "labelList.H"
+#include "faceList.H"
+#include "FixedList.H"
+#include "PackedBoolList.H"
+#include "NamedEnum.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+ Class ensightFaces Declaration
+\*---------------------------------------------------------------------------*/
+
+class ensightFaces
+{
+public:
+
+ // Public data
+
+ //- Addressable ensight element types
+ enum elemType
+ {
+ TRIA3,
+ QUAD4,
+ NSIDED
+ };
+
+ //- Number of element types (3)
+ static const label nTypes;
+
+ //- The Ensight names for each element type
+ static const NamedEnum elemEnum;
+
+
+ // Static Member Functions
+
+ //- Return the ensight element name for the specified type
+ static inline const char* key(const enum elemType);
+
+private:
+
+ // Private data
+
+ //- Location in list
+ label index_;
+
+ //- Linear list of ids, sub-sectioned per element type via SubLists
+ labelList address_;
+
+ //- Linear list of face-flips
+ boolList flipMap_;
+
+ //- List of global sizes for each element type
+ FixedList sizes_;
+
+ //- SubLists of ids for each element type
+ FixedList*, 3> lists_;
+
+
+ // Private Member Functions
+
+ //- Simple classifier
+ inline static elemType whatType(const face&);
+
+ //- Low-level addition routine
+ inline void add(const face&, const label id, const bool flip = false);
+
+ //- Low-level offset routine
+ inline label offset(const enum elemType what, const label i) const;
+
+ //- Use current sizes to redimension the element lists
+ void allocate();
+
+ //- Disallow default bitwise assignment
+ void operator=(const ensightFaces&) = delete;
+
+ // Retain default copy constructor. Needed for lists etc.
+
+public:
+
+ // Constructors
+
+ //- Construct null, optionally with index
+ ensightFaces(label partIndex = 0);
+
+
+ //- Destructor
+ ~ensightFaces();
+
+
+ // Member Functions
+
+ // Access
+
+ //- The index in a list.
+ inline label index() const;
+
+ //- The index in a list, non-const access.
+ inline label& index();
+
+ //- The processor local size of all elements.
+ inline label size() const;
+
+ //- The global number of the specified element type.
+ // This value is only meaningful after a reduce operation.
+ inline label total(const enum elemType) const;
+
+ //- The global number of all element types.
+ // This value is only meaningful after a reduce operation.
+ label total() const;
+
+
+ //- The processor local sizes per element type.
+ FixedList sizes() const;
+
+ //- The global numbers per element type.
+ // This value is only meaningful after a reduce operation.
+ const FixedList& totals() const;
+
+
+ //- Return the (local) face ids of the specified element type
+ inline const labelUList& faceIds(const enum elemType) const;
+
+ //- Return the face ids of all elements
+ inline const labelUList& faceIds() const;
+
+ //- Return the flip-map of all elements
+ inline const boolList& flipMap() const;
+
+
+ //- Starting offset of element type.
+ label offset(const enum elemType what) const;
+
+
+ // Edit
+
+ //- Classify the face types, set element list.
+ void classify(const faceList& faces);
+
+
+ //- Classify the face types, set element list.
+ // The indirect addressing can be used when classifying groups of
+ // face (eg, from a faceZone etc) with an optional flipMap.
+ // The optional exclude marker can be used to skip faces on particular
+ // boundary types or regions.
+ void classify
+ (
+ const faceList& faces,
+ const labelUList& addressing,
+ const boolList& flipMap = boolList(),
+ const PackedBoolList& exclude = PackedBoolList()
+ );
+
+
+ //- Set sizes to zero, free up memory
+ void clear();
+
+ //- Sum element counts across all processes.
+ void reduce();
+
+ //- Sort element lists numerically.
+ void sort();
+
+
+ // Member operators
+
+ //- Return element from linear-list.
+ inline label operator[](const label i) const;
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#include "ensightFacesI.H"
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/fileFormats/ensight/part/ensightFacesI.H b/src/fileFormats/ensight/part/ensightFacesI.H
new file mode 100644
index 0000000000..bfc2bcd650
--- /dev/null
+++ b/src/fileFormats/ensight/part/ensightFacesI.H
@@ -0,0 +1,91 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / 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 .
+
+\*---------------------------------------------------------------------------*/
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+inline const char* Foam::ensightFaces::key(const enum elemType what)
+{
+ return elemEnum[what];
+}
+
+
+inline Foam::label Foam::ensightFaces::index() const
+{
+ return index_;
+}
+
+
+inline Foam::label& Foam::ensightFaces::index()
+{
+ return index_;
+}
+
+
+inline Foam::label Foam::ensightFaces::size() const
+{
+ return address_.size();
+}
+
+
+inline const Foam::FixedList& Foam::ensightFaces::totals() const
+{
+ return sizes_;
+}
+
+
+inline Foam::label Foam::ensightFaces::total(const enum elemType what) const
+{
+ return sizes_[what];
+}
+
+
+inline const Foam::labelUList& Foam::ensightFaces::faceIds
+(
+ const enum elemType what
+) const
+{
+ return *(lists_[what]);
+}
+
+
+inline const Foam::labelUList& Foam::ensightFaces::faceIds() const
+{
+ return address_;
+}
+
+
+inline const Foam::boolList& Foam::ensightFaces::flipMap() const
+{
+ return flipMap_;
+}
+
+
+inline Foam::label Foam::ensightFaces::operator[](const label i) const
+{
+ return address_[i];
+}
+
+
+// ************************************************************************* //