mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: ensightSurfaceWriter : rewrite to use conversion library.
This commit is contained in:
@ -4,6 +4,7 @@ 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
|
||||
|
||||
@ -267,6 +267,12 @@ public:
|
||||
matId_ = value;
|
||||
}
|
||||
|
||||
//- simple labelList with a name
|
||||
const labelListList& elemLists() const
|
||||
{
|
||||
return elemLists_;
|
||||
}
|
||||
|
||||
//- offset for element ids
|
||||
label offset() const
|
||||
{
|
||||
@ -285,8 +291,12 @@ public:
|
||||
//- write reconstruction information for the object
|
||||
bool writeData(Ostream&) const;
|
||||
|
||||
//- write geometry
|
||||
void writeGeometry(ensightGeoFile&) const;
|
||||
//- Write geometry
|
||||
virtual void writeGeometry(ensightGeoFile&) const
|
||||
{}
|
||||
|
||||
//- Helper: write geometry given the pointField
|
||||
void writeGeometry(ensightGeoFile&, const pointField& points) const;
|
||||
|
||||
//- write scalar field
|
||||
void writeScalarField
|
||||
|
||||
@ -427,4 +427,11 @@ void Foam::ensightPartCells::writeConnectivity
|
||||
}
|
||||
|
||||
|
||||
void Foam::ensightPartCells::writeGeometry(ensightGeoFile& os) const
|
||||
{
|
||||
const polyMesh& mesh = *meshPtr_;
|
||||
ensightPart::writeGeometry(os, mesh.points());
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -74,6 +74,9 @@ class ensightPartCells
|
||||
const labelList& pointMap
|
||||
) const;
|
||||
|
||||
//- write geometry
|
||||
virtual void writeGeometry(ensightGeoFile& os) const;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@ -47,41 +47,18 @@ Foam::List<Foam::word> Foam::ensightPartFaces::elemTypes_
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::ensightPartFaces::ensightPartFaces
|
||||
(
|
||||
label partNumber,
|
||||
const string& partDescription
|
||||
)
|
||||
:
|
||||
ensightPart(partNumber, partDescription)
|
||||
void Foam::ensightPartFaces::binShapes(const faceList& faces)
|
||||
{
|
||||
isCellData_ = false;
|
||||
}
|
||||
|
||||
|
||||
Foam::ensightPartFaces::ensightPartFaces
|
||||
(
|
||||
label partNumber,
|
||||
const polyMesh& pMesh,
|
||||
const polyPatch& pPatch
|
||||
)
|
||||
:
|
||||
ensightPart(partNumber, pPatch.name(), pMesh)
|
||||
{
|
||||
isCellData_ = false;
|
||||
offset_ = pPatch.start();
|
||||
size_ = pPatch.size();
|
||||
|
||||
// count the shapes
|
||||
label nTri = 0;
|
||||
label nQuad = 0;
|
||||
label nPoly = 0;
|
||||
|
||||
forAll(pPatch, patchfaceI)
|
||||
forAll(faces, faceI)
|
||||
{
|
||||
const face& f = pMesh.faces()[patchfaceI + offset_];
|
||||
const face& f = faces[faceI];
|
||||
|
||||
if (f.size() == 3)
|
||||
{
|
||||
@ -108,21 +85,21 @@ Foam::ensightPartFaces::ensightPartFaces
|
||||
nPoly = 0;
|
||||
|
||||
// classify the shapes
|
||||
forAll(pPatch, patchfaceI)
|
||||
forAll(faces, faceI)
|
||||
{
|
||||
const face& f = pMesh.faces()[patchfaceI + offset_];
|
||||
const face& f = faces[faceI];
|
||||
|
||||
if (f.size() == 3)
|
||||
{
|
||||
triCells[nTri++] = patchfaceI;
|
||||
triCells[nTri++] = faceI;
|
||||
}
|
||||
else if (f.size() == 4)
|
||||
{
|
||||
quadCells[nQuad++] = patchfaceI;
|
||||
quadCells[nQuad++] = faceI;
|
||||
}
|
||||
else
|
||||
{
|
||||
polygonCells[nPoly++] = patchfaceI;
|
||||
polygonCells[nPoly++] = faceI;
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,10 +110,45 @@ Foam::ensightPartFaces::ensightPartFaces
|
||||
elemLists_[tria3Elements].transfer( triCells );
|
||||
elemLists_[quad4Elements].transfer( quadCells );
|
||||
elemLists_[nsidedElements].transfer( polygonCells );
|
||||
|
||||
size_ = faces.size();
|
||||
}
|
||||
|
||||
|
||||
Foam::ensightPartFaces::ensightPartFaces(const ensightPartFaces &part)
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::ensightPartFaces::ensightPartFaces
|
||||
(
|
||||
label partNumber,
|
||||
const string& partDescription
|
||||
)
|
||||
:
|
||||
ensightPart(partNumber, partDescription)
|
||||
{
|
||||
isCellData_ = false;
|
||||
offset_ = 0;
|
||||
size_ = 0;
|
||||
}
|
||||
|
||||
|
||||
Foam::ensightPartFaces::ensightPartFaces
|
||||
(
|
||||
label partNumber,
|
||||
const polyMesh& pMesh,
|
||||
const polyPatch& pPatch
|
||||
)
|
||||
:
|
||||
ensightPart(partNumber, pPatch.name(), pMesh)
|
||||
{
|
||||
isCellData_ = false;
|
||||
offset_ = pPatch.start();
|
||||
|
||||
// count the shapes
|
||||
binShapes(pPatch);
|
||||
}
|
||||
|
||||
|
||||
Foam::ensightPartFaces::ensightPartFaces(const ensightPartFaces& part)
|
||||
:
|
||||
ensightPart(part)
|
||||
{}
|
||||
@ -206,6 +218,7 @@ void Foam::ensightPartFaces::writeConnectivity
|
||||
(
|
||||
ensightGeoFile& os,
|
||||
const word& key,
|
||||
const faceList& faces,
|
||||
const labelList& idList,
|
||||
const labelList& pointMap
|
||||
) const
|
||||
@ -214,8 +227,6 @@ void Foam::ensightPartFaces::writeConnectivity
|
||||
os.write(idList.size());
|
||||
os.newline();
|
||||
|
||||
const faceList& meshFaces = meshPtr_->faces();
|
||||
|
||||
// write (polygon) face sizes
|
||||
if (key == "nsided")
|
||||
{
|
||||
@ -223,7 +234,7 @@ void Foam::ensightPartFaces::writeConnectivity
|
||||
forAll(idList, i)
|
||||
{
|
||||
label id = idList[i] + offset_;
|
||||
const face& f = meshFaces[id];
|
||||
const face& f = faces[id];
|
||||
|
||||
os.write( f.size() );
|
||||
os.newline();
|
||||
@ -234,7 +245,7 @@ void Foam::ensightPartFaces::writeConnectivity
|
||||
forAll(idList, i)
|
||||
{
|
||||
label id = idList[i] + offset_;
|
||||
const face& f = meshFaces[id];
|
||||
const face& f = faces[id];
|
||||
|
||||
// convert global -> local index
|
||||
// (note: Ensight indices start with 1)
|
||||
@ -247,4 +258,31 @@ void Foam::ensightPartFaces::writeConnectivity
|
||||
}
|
||||
|
||||
|
||||
void Foam::ensightPartFaces::writeConnectivity
|
||||
(
|
||||
ensightGeoFile& os,
|
||||
const word& key,
|
||||
const labelList& idList,
|
||||
const labelList& pointMap
|
||||
) const
|
||||
{
|
||||
writeConnectivity
|
||||
(
|
||||
os,
|
||||
key,
|
||||
meshPtr_->faces(),
|
||||
idList,
|
||||
pointMap
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void Foam::ensightPartFaces::writeGeometry(ensightGeoFile& os) const
|
||||
{
|
||||
const polyMesh& mesh = *meshPtr_;
|
||||
const pointField& points = mesh.points();
|
||||
ensightPart::writeGeometry(os, points);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -67,6 +67,9 @@ class ensightPartFaces
|
||||
const labelList& pointMap
|
||||
) const;
|
||||
|
||||
//- write geometry
|
||||
virtual void writeGeometry(ensightGeoFile& os) const;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@ -81,6 +84,19 @@ protected:
|
||||
// Static data members
|
||||
static List<word> elemTypes_;
|
||||
|
||||
//- Divide the shapes, set elemLists.
|
||||
void binShapes(const faceList& faces);
|
||||
|
||||
//- Helper: write connectivity
|
||||
void writeConnectivity
|
||||
(
|
||||
ensightGeoFile& os,
|
||||
const word& key,
|
||||
const faceList& faces,
|
||||
const labelList& idList,
|
||||
const labelList& pointMap
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
@ -118,15 +118,16 @@ bool Foam::ensightPart::writeData(Ostream& os) const
|
||||
}
|
||||
|
||||
|
||||
void Foam::ensightPart::writeGeometry(ensightGeoFile& os) const
|
||||
void Foam::ensightPart::writeGeometry
|
||||
(
|
||||
ensightGeoFile& os,
|
||||
const pointField& points
|
||||
) const
|
||||
{
|
||||
if (size() && meshPtr_)
|
||||
if (size())
|
||||
{
|
||||
const polyMesh& mesh = *meshPtr_;
|
||||
const pointField& meshPoints = mesh.points();
|
||||
|
||||
localPoints ptList = calcLocalPoints();
|
||||
labelList& pointMap = ptList.list;
|
||||
const localPoints ptList = calcLocalPoints();
|
||||
const labelList& pointMap = ptList.list;
|
||||
|
||||
writeHeader(os, true);
|
||||
|
||||
@ -141,7 +142,7 @@ void Foam::ensightPart::writeGeometry(ensightGeoFile& os) const
|
||||
{
|
||||
if (pointMap[ptI] > -1)
|
||||
{
|
||||
os.write( meshPoints[ptI].component(cmpt) );
|
||||
os.write( points[ptI].component(cmpt) );
|
||||
os.newline();
|
||||
}
|
||||
}
|
||||
|
||||
122
src/conversion/ensight/part/ensightPartNonMeshFaces.C
Normal file
122
src/conversion/ensight/part/ensightPartNonMeshFaces.C
Normal file
@ -0,0 +1,122 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2010 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ensightPartNonMeshFaces.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(ensightPartNonMeshFaces, 0);
|
||||
addToRunTimeSelectionTable(ensightPart, ensightPartNonMeshFaces, istream);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::ensightPart::localPoints
|
||||
Foam::ensightPartNonMeshFaces::calcLocalPoints() const
|
||||
{
|
||||
localPoints ptList;
|
||||
ptList.list = identity(points_.size());
|
||||
ptList.nPoints = points_.size();
|
||||
return ptList;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::ensightPartNonMeshFaces::ensightPartNonMeshFaces
|
||||
(
|
||||
label partNumber,
|
||||
const string& partDescription,
|
||||
const faceList& faces,
|
||||
const pointField& points
|
||||
)
|
||||
:
|
||||
ensightPartFaces(partNumber, partDescription),
|
||||
faces_(faces),
|
||||
points_(points)
|
||||
{
|
||||
binShapes(faces);
|
||||
}
|
||||
|
||||
|
||||
//- Construct as copy
|
||||
Foam::ensightPartNonMeshFaces::ensightPartNonMeshFaces
|
||||
(
|
||||
const ensightPartNonMeshFaces& part
|
||||
)
|
||||
:
|
||||
ensightPartFaces(part),
|
||||
faces_(part.faces_),
|
||||
points_(part.points_)
|
||||
{}
|
||||
|
||||
|
||||
//- Construct from Istream
|
||||
Foam::ensightPartNonMeshFaces::ensightPartNonMeshFaces(Istream& is)
|
||||
:
|
||||
ensightPartFaces(is),
|
||||
faces_(is),
|
||||
points_(is)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::ensightPartNonMeshFaces::~ensightPartNonMeshFaces()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::ensightPartNonMeshFaces::writeConnectivity
|
||||
(
|
||||
ensightGeoFile& os,
|
||||
const word& key,
|
||||
const labelList& idList,
|
||||
const labelList& pointMap
|
||||
) const
|
||||
{
|
||||
ensightPartFaces::writeConnectivity
|
||||
(
|
||||
os,
|
||||
key,
|
||||
faces_,
|
||||
idList,
|
||||
pointMap
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void Foam::ensightPartNonMeshFaces::writeGeometry(ensightGeoFile& os) const
|
||||
{
|
||||
ensightPart::writeGeometry(os, points_);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
131
src/conversion/ensight/part/ensightPartNonMeshFaces.H
Normal file
131
src/conversion/ensight/part/ensightPartNonMeshFaces.H
Normal file
@ -0,0 +1,131 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2010 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::ensightPartNonMeshFaces
|
||||
|
||||
Description
|
||||
An implementation of ensightPart to work on self-contained faces and points
|
||||
(without a mesh).
|
||||
|
||||
SourceFiles
|
||||
ensightPartNonMeshFaces.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ensightPartNonMeshFaces_H
|
||||
#define ensightPartNonMeshFaces_H
|
||||
|
||||
#include "ensightPartFaces.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ensightPartNonMeshFaces Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class ensightPartNonMeshFaces
|
||||
:
|
||||
public ensightPartFaces
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- faces (reference)
|
||||
const faceList& faces_;
|
||||
|
||||
//- points (reference)
|
||||
const pointField& points_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const ensightPartNonMeshFaces&);
|
||||
|
||||
//- track points used
|
||||
virtual localPoints calcLocalPoints() const;
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("ensightNonMeshFaces");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from faces and points
|
||||
ensightPartNonMeshFaces
|
||||
(
|
||||
label partNumber,
|
||||
const string& partDescription,
|
||||
const faceList& faces,
|
||||
const pointField& points
|
||||
);
|
||||
|
||||
//- Construct as copy
|
||||
ensightPartNonMeshFaces(const ensightPartNonMeshFaces& part);
|
||||
|
||||
//- Construct from Istream
|
||||
ensightPartNonMeshFaces(Istream& is);
|
||||
|
||||
//- Construct on freestore from Istream
|
||||
static autoPtr<ensightPartNonMeshFaces> New(Istream& is)
|
||||
{
|
||||
return autoPtr<ensightPartNonMeshFaces>
|
||||
(
|
||||
new ensightPartNonMeshFaces(is)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~ensightPartNonMeshFaces();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- element connectivity
|
||||
virtual void writeConnectivity
|
||||
(
|
||||
ensightGeoFile& os,
|
||||
const word& key,
|
||||
const labelList& idList,
|
||||
const labelList& pointMap
|
||||
) const;
|
||||
|
||||
virtual void writeGeometry(ensightGeoFile& os) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user