Commit 0498967c authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: only use point/face/mesh references where needed in ensightPart*

- add points/faces constructor to ensightPartFaces with optional
  contiguousPoints flag.

- Remove the now redundantensightPartNonMeshFaces class.
parent 51df389d
......@@ -4,7 +4,6 @@ ensight/part/ensightPart.C
ensight/part/ensightPartIO.C
ensight/part/ensightPartCells.C
ensight/part/ensightPartFaces.C
ensight/part/ensightPartNonMeshFaces.C
ensight/part/ensightParts.C
meshTables/boundaryRegion.C
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -24,21 +24,22 @@ License
\*----------------------------------------------------------------------------*/
#include "ensightPart.H"
#include "addToRunTimeSelectionTable.H"
#include "dictionary.H"
#include "ListOps.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(ensightPart, 0);
defineTemplateTypeNameAndDebug(IOPtrList<ensightPart>, 0);
defineRunTimeSelectionTable(ensightPart, istream);
defineTypeNameAndDebug(ensightPart, 0);
defineTemplateTypeNameAndDebug(IOPtrList<ensightPart>, 0);
defineRunTimeSelectionTable(ensightPart, istream);
}
Foam::List<Foam::word> Foam::ensightPart::elemTypes_(0);
const Foam::List<Foam::word> Foam::ensightPart::elemTypes_(0);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
bool Foam::ensightPart::isFieldDefined(const List<scalar>& field) const
{
......@@ -72,7 +73,7 @@ Foam::ensightPart::ensightPart
size_(0),
isCellData_(true),
matId_(0),
meshPtr_(0)
points_(pointField::null())
{}
......@@ -89,7 +90,7 @@ Foam::ensightPart::ensightPart
size_(0),
isCellData_(true),
matId_(0),
meshPtr_(0)
points_(pointField::null())
{}
......@@ -97,7 +98,7 @@ Foam::ensightPart::ensightPart
(
label partNumber,
const string& partDescription,
const polyMesh& pMesh
const pointField& points
)
:
number_(partNumber),
......@@ -107,7 +108,7 @@ Foam::ensightPart::ensightPart
size_(0),
isCellData_(true),
matId_(0),
meshPtr_(&pMesh)
points_(points)
{}
......@@ -120,7 +121,7 @@ Foam::ensightPart::ensightPart(const ensightPart& part)
size_(part.size_),
isCellData_(part.isCellData_),
matId_(part.matId_),
meshPtr_(part.meshPtr_)
points_(part.points_)
{}
......@@ -158,31 +159,7 @@ Foam::ensightPart::~ensightPart()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::ensightPart::reconstruct(Istream& is)
{
dictionary dict(is);
dict.lookup("id") >> number_;
dict.lookup("name") >> name_;
dict.readIfPresent("offset", offset_);
// populate elemLists_
elemLists_.setSize(elementTypes().size());
forAll(elementTypes(), elemI)
{
word key(elementTypes()[elemI]);
elemLists_[elemI].clear();
dict.readIfPresent(key, elemLists_[elemI]);
size_ += elemLists_[elemI].size();
}
is.check("ensightPart::reconstruct(Istream&)");
}
void Foam::ensightPart::renumber(labelList const& origId)
void Foam::ensightPart::renumber(const labelList& origId)
{
// transform to global values first
if (offset_)
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -30,7 +30,7 @@ Description
SourceFiles
ensightPart.C
ensightPartIO.C
ensightPartI.H
ensightPartTemplates.C
\*---------------------------------------------------------------------------*/
......@@ -52,7 +52,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class ensightPart Declaration
Class ensightPart Declaration
\*---------------------------------------------------------------------------*/
class ensightPart
......@@ -60,7 +60,7 @@ class ensightPart
// Private data
// Static data members
static List<word> elemTypes_;
static const List<word> elemTypes_;
protected:
......@@ -88,8 +88,8 @@ protected:
//- material id (numeric)
label matId_;
//- mesh reference used
const polyMesh* meshPtr_;
//- pointField referenced
const pointField& points_;
// Protected Classes
......@@ -104,25 +104,27 @@ protected:
//- map global to local indices
labelList list;
// null constructor
//- null constructor
localPoints()
:
nPoints(0),
list(0)
{}
// construct for mesh points
localPoints(const polyMesh& pMesh)
//- construct for mesh points
localPoints(const pointField& pts)
:
nPoints(0),
list(pMesh.points().size(), -1)
list(pts.size(), -1)
{}
};
// Protected Member Functions
//- reconstruct contents from Istream
//- Reconstruct part characteristics (eg, element types) from Istream
// A part reconstructed in this manner can be used when writing fields,
// but cannot be used to write a new geometry
void reconstruct(Istream&);
//- check for fully defined fields
......@@ -170,12 +172,12 @@ public:
//- Construct empty part with number and description
ensightPart(label partNumber, const string& partDescription);
//- Construct empty part with number and description
//- Construct part with number, description and points reference
ensightPart
(
label partNumber,
const string& partDescription,
const polyMesh& pMesh
const pointField& points
);
//- Construct as copy
......@@ -202,8 +204,9 @@ public:
return autoPtr<ensightPart>(new ensightPart(*this));
};
//- Construct on freestore from Istream
static autoPtr<ensightPart> New(Istream& is);
//- Reconstruct part characteristics on freestore from Istream
// @sa reconstruct
static autoPtr<ensightPart> New(Istream&);
//- Destructor
......@@ -212,7 +215,7 @@ public:
// Static members
virtual List<word> const& elementTypes() const
virtual const List<word>& elementTypes() const
{
return elemTypes_;
}
......@@ -256,12 +259,13 @@ public:
return matId_;
}
//- non-const access
//- non-const access to part name or description
void name(const string& value)
{
name_ = value;
}
//- non-const access to material id
void materialId(const label value)
{
matId_ = value;
......@@ -283,7 +287,7 @@ public:
// Edit
//- renumber elements
void renumber(labelList const&);
void renumber(const labelList&);
//- write summary information about the object
bool writeSummary(Ostream&) const;
......@@ -296,7 +300,7 @@ public:
{}
//- Helper: write geometry given the pointField
void writeGeometry(ensightGeoFile&, const pointField& points) const;
void writeGeometry(ensightGeoFile&, const pointField&) const;
//- write scalar field
void writeScalarField
......@@ -316,7 +320,7 @@ public:
//- write generalized field components
template <class Type>
template<class Type>
void writeField
(
ensightFile&,
......@@ -339,11 +343,8 @@ public:
friend Ostream& operator<<(Ostream&, const ensightPart&);
//- write geometry
friend ensightGeoFile& operator<<
(
ensightGeoFile&,
const ensightPart&
);
friend ensightGeoFile& operator<<(ensightGeoFile&, const ensightPart&);
};
......@@ -354,7 +355,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "ensightPartI.H"
# include "ensightPartTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -24,22 +24,21 @@ License
\*----------------------------------------------------------------------------*/
#include "ensightPartCells.H"
#include "addToRunTimeSelectionTable.H"
#include "IOstream.H"
#include "IStringStream.H"
#include "dictionary.H"
#include "cellModeller.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(ensightPartCells, 0);
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream);
defineTypeNameAndDebug(ensightPartCells, 0);
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream);
}
Foam::List<Foam::word> Foam::ensightPartCells::elemTypes_
const Foam::List<Foam::word> Foam::ensightPartCells::elemTypes_
(
IStringStream
(
......@@ -50,7 +49,11 @@ Foam::List<Foam::word> Foam::ensightPartCells::elemTypes_
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::ensightPartCells::classify(const labelList& idList)
void Foam::ensightPartCells::classify
(
const polyMesh& mesh,
const labelList& idList
)
{
// References to cell shape models
const cellModel& tet = *(cellModeller::lookup("tet"));
......@@ -58,7 +61,6 @@ void Foam::ensightPartCells::classify(const labelList& idList)
const cellModel& prism = *(cellModeller::lookup("prism"));
const cellModel& hex = *(cellModeller::lookup("hex"));
const polyMesh& mesh = *meshPtr_;
const cellShapeList& cellShapes = mesh.cellShapes();
offset_ = 0;
......@@ -78,13 +80,6 @@ void Foam::ensightPartCells::classify(const labelList& idList)
label nHex = 0;
label nPoly = 0;
// TODO: allow tet-decomposition of polyhedral cells
#if 0
label nTetDecomp = 0;
label nPyrDecomp = 0;
#endif
for (label listI = 0; listI < size_; ++listI)
{
label cellId = listI;
......@@ -115,26 +110,6 @@ void Foam::ensightPartCells::classify(const labelList& idList)
else
{
nPoly++;
// TODO: allow tet-decomposition of polyhedral cells
#if 0
const cell& cFaces = mesh.cells()[cellI];
forAll(cFaces, cFaceI)
{
const face& f = mesh.faces()[cFaces[cFaceI]];
label nQuads = 0;
label nTris = 0;
f.nTrianglesQuads(mesh.points(), nTris, nQuads);
nTetDecomp += nTris;
nPyrDecomp += nQuads;
}
nAddCells--;
nAddPoints++;
#endif
}
}
......@@ -183,29 +158,6 @@ void Foam::ensightPartCells::classify(const labelList& idList)
else
{
polyCells[nPoly++] = cellId;
// TODO: allow tet-decomposition of polyhedral cells
#if 0
// Mapping from additional point to cell
addPointCellLabels_[api] = cellId;
const cell& cFaces = mesh.cells()[cellId];
forAll(cFaces, cFaceI)
{
const face& f = mesh.faces()[cFaces[cFaceI]];
label nQuads = 0;
label nTris = 0;
f.nTrianglesQuads(mesh.points(), nTris, nQuads);
nTetDecomp += nTris;
nPyrDecomp += nQuads;
}
nAddCells--;
nAddPoints++;
#endif
}
}
......@@ -213,11 +165,11 @@ void Foam::ensightPartCells::classify(const labelList& idList)
// MUST match with elementTypes
elemLists_.setSize(elementTypes().size());
elemLists_[tetra4Elements].transfer( tetCells );
elemLists_[pyramid5Elements].transfer( pyramidCells );
elemLists_[penta6Elements].transfer( prismCells );
elemLists_[hexa8Elements].transfer( hexCells );
elemLists_[nfacedElements].transfer( polyCells );
elemLists_[tetra4Elements].transfer(tetCells);
elemLists_[pyramid5Elements].transfer(pyramidCells);
elemLists_[penta6Elements].transfer(prismCells);
elemLists_[hexa8Elements].transfer(hexCells);
elemLists_[nfacedElements].transfer(polyCells);
}
......@@ -229,57 +181,63 @@ Foam::ensightPartCells::ensightPartCells
const string& partDescription
)
:
ensightPart(partNumber, partDescription)
ensightPart(partNumber, partDescription),
mesh_(*reinterpret_cast<polyMesh*>(0))
{}
Foam::ensightPartCells::ensightPartCells
(
label partNumber,
const polyMesh& pMesh
const polyMesh& mesh
)
:
ensightPart(partNumber, "cells", pMesh)
ensightPart(partNumber, "cells", mesh.points()),
mesh_(mesh)
{
classify();
classify(mesh);
}
Foam::ensightPartCells::ensightPartCells
(
label partNumber,
const polyMesh& pMesh,
const polyMesh& mesh,
const labelList& idList
)
:
ensightPart(partNumber, "cells", pMesh)
ensightPart(partNumber, "cells", mesh.points()),
mesh_(mesh)
{
classify(idList);
classify(mesh, idList);
}
Foam::ensightPartCells::ensightPartCells
(
label partNumber,
const polyMesh& pMesh,
const polyMesh& mesh,
const cellZone& cZone
)
:
ensightPart(partNumber, cZone.name(), pMesh)
ensightPart(partNumber, cZone.name(), mesh.points()),
mesh_(mesh)
{
classify(cZone);
classify(mesh, cZone);
}
Foam::ensightPartCells::ensightPartCells(const ensightPartCells& part)
:
ensightPart(part)
ensightPart(part),
mesh_(part.mesh_)
{}
Foam::ensightPartCells::ensightPartCells(Istream& is)
:
ensightPart()
ensightPart(),
mesh_(*reinterpret_cast<polyMesh*>(0))
{
reconstruct(is);
}
......@@ -295,9 +253,7 @@ Foam::ensightPartCells::~ensightPartCells()
Foam::ensightPart::localPoints Foam::ensightPartCells::calcLocalPoints() const
{
const polyMesh& mesh = *meshPtr_;
localPoints ptList(mesh);
localPoints ptList(points_);
labelList& usedPoints = ptList.list;
label nPoints = 0;
......@@ -309,11 +265,11 @@ Foam::ensightPart::localPoints Foam::ensightPartCells::calcLocalPoints() const
forAll(idList, i)
{
label id = idList[i] + offset_;
const labelList& cFaces = mesh.cells()[id];
const labelList& cFaces = mesh_.cells()[id];
forAll(cFaces, cFaceI)
{
const face& f = mesh.faces()[cFaces[cFaceI]];
const face& f = mesh_.faces()[cFaces[cFaceI]];
forAll(f, fp)
{
......@@ -353,20 +309,18 @@ void Foam::ensightPartCells::writeConnectivity
os.write(idList.size());
os.newline();
const polyMesh& mesh = *meshPtr_;
// write polyhedral
if (key == "nfaced")
{
const faceList& meshFaces = mesh.faces();
const faceList& meshFaces = mesh_.faces();
// write the number of faces per element
forAll(idList, i)
{
label id = idList[i] + offset_;
const labelList& cFace = mesh.cells()[id];
const labelList& cFace = mesh_.cells()[id];
os.write( cFace.size() );
os.write(cFace.size());
os.newline();
}
......@@ -374,13 +328,13 @@ void Foam::ensightPartCells::writeConnectivity
forAll(idList, i)
{
label id = idList[i] + offset_;
const labelList& cFace = mesh.cells()[id];
const labelList& cFace = mesh_.cells()[id];
forAll(cFace, faceI)
{
const face& cf = meshFaces[cFace[faceI]];
os.write( cf.size() );
os.write(cf.size());
os.newline();
}
}
......@@ -389,7 +343,7 @@ void Foam::ensightPartCells::writeConnectivity
forAll(idList, i)
{
label id = idList[i] + offset_;
const labelList& cFace = mesh.cells()[id];
const labelList& cFace = mesh_.cells()[id];