mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
library: * routines for managing cellTable and boundaryRegion * writing ensight files and parts * mesh reader/writer for STARCD utils: * star4ToFoam * foamToStarMesh * foamToEnsightParts
320 lines
8.7 KiB
C++
320 lines
8.7 KiB
C++
/*---------------------------------------------------------------------------*\
|
|
========= |
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
\\ / O peration |
|
|
\\ / A nd | Copyright (C) 1991-2008 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 2 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, write to the Free Software Foundation,
|
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
Namespace
|
|
Foam::meshReaders
|
|
|
|
Description
|
|
A namespace for holding various types of mesh readers.
|
|
|
|
|
|
Class
|
|
Foam::meshReader
|
|
|
|
Description
|
|
This class supports creating polyMeshes with baffles.
|
|
|
|
The derived classes are responsible for providing the protected data.
|
|
This implementation is somewhat messy, but could/should be restructured
|
|
to provide a more generalized reader (at the moment it has been written
|
|
for converting pro-STAR data).
|
|
|
|
The meshReader supports cellTable information (see new user's guide entry).
|
|
|
|
Note
|
|
The boundary definitions are given as cell/face.
|
|
|
|
SourceFiles
|
|
calcPointCells.C
|
|
createPolyBoundary.C
|
|
createPolyCells.C
|
|
meshReader.C
|
|
meshReaderAux.C
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
#ifndef meshReader_H
|
|
#define meshReader_H
|
|
|
|
#include "polyMesh.H"
|
|
#include "HashTable.H"
|
|
#include "IOstream.H"
|
|
|
|
#include "cellTable.H"
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
namespace Foam
|
|
{
|
|
|
|
/*---------------------------------------------------------------------------*\
|
|
Class meshReader Declaration
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
class meshReader
|
|
{
|
|
protected:
|
|
//- identify cell faces in terms of cell Id and face Id
|
|
class cellFaceIdentifier
|
|
{
|
|
public:
|
|
//- cell Id
|
|
label cell;
|
|
|
|
//- face Id
|
|
label face;
|
|
|
|
//- Construct null
|
|
cellFaceIdentifier() : cell(-1), face(-1) {}
|
|
|
|
//- Construct from cell/face components
|
|
cellFaceIdentifier(label c, label f) : cell(c), face(f) {}
|
|
|
|
// Check
|
|
|
|
//- used if cell or face are non-negative
|
|
bool used() const
|
|
{
|
|
return (cell >= 0 && face >= 0);
|
|
}
|
|
|
|
//- unsed if cell or face are negative
|
|
bool unused() const
|
|
{
|
|
return (cell < 0 || face < 0);
|
|
}
|
|
|
|
// Member Operators
|
|
bool operator!=(const cellFaceIdentifier& cf) const
|
|
{
|
|
return (cell != cf.cell || face != cf.face);
|
|
}
|
|
|
|
bool operator==(const cellFaceIdentifier& cf) const
|
|
{
|
|
return (cell == cf.cell && face == cf.face);
|
|
}
|
|
|
|
// IOstream Operators
|
|
friend Ostream& operator<<(Ostream& os, const cellFaceIdentifier& cf)
|
|
{
|
|
os << "(" << cf.cell << "/" << cf.face << ")";
|
|
return os;
|
|
}
|
|
};
|
|
|
|
private:
|
|
|
|
// Private data
|
|
|
|
//- Point-cell addressing. Used for topological analysis
|
|
// Warning. This point cell addressing list potentially contains
|
|
// duplicate cell entries. Use additional checking
|
|
mutable labelListList* pointCellsPtr_;
|
|
|
|
//- Number of internal faces for polyMesh
|
|
label nInternalFaces_;
|
|
|
|
//- Polyhedral mesh boundary patch start indices and dimensions
|
|
labelList patchStarts_;
|
|
labelList patchSizes_;
|
|
|
|
//- association between two faces
|
|
List<labelPair> interfaces_;
|
|
|
|
//- list of cells/faces id pairs for each baffle
|
|
List<List<cellFaceIdentifier> > baffleIds_;
|
|
|
|
//- Global face list for polyMesh
|
|
faceList meshFaces_;
|
|
|
|
//- Cells as polyhedra for polyMesh
|
|
cellList cellPolys_;
|
|
|
|
//- Face sets for monitoring
|
|
HashTable<List<label>, word, string::hash> monitoringSets_;
|
|
|
|
// Private Member Functions
|
|
|
|
//- Disallow default bitwise copy construct
|
|
meshReader(const meshReader&);
|
|
|
|
//- Disallow default bitwise assignment
|
|
void operator=(const meshReader&);
|
|
|
|
//- Calculate pointCells
|
|
void calcPointCells() const;
|
|
|
|
const labelListList& pointCells() const;
|
|
|
|
//- Make polyhedral cells and global faces if the mesh is polyhedral
|
|
void createPolyCells();
|
|
|
|
//- add in boundary face
|
|
void addPolyBoundaryFace
|
|
(
|
|
const label cellId,
|
|
const label cellFaceId,
|
|
const label nCreatedFaces
|
|
);
|
|
|
|
//- add in boundary face
|
|
void addPolyBoundaryFace
|
|
(
|
|
const cellFaceIdentifier& identifier,
|
|
const label nCreatedFaces
|
|
);
|
|
|
|
//- add cellZones based on cellTable Id
|
|
void addCellZones(polyMesh&) const;
|
|
|
|
//- add faceZones based on monitoring boundary conditions
|
|
void addFaceZones(polyMesh&) const;
|
|
|
|
//- Make polyhedral boundary from shape boundary
|
|
// (adds more faces to the face list)
|
|
void createPolyBoundary();
|
|
|
|
//- Add polyhedral boundary
|
|
List<polyPatch*> polyBoundaryPatches(const polyMesh&);
|
|
|
|
//- Clear extra storage before creation of the mesh to remove
|
|
// a memory peak
|
|
void clearExtraStorage();
|
|
|
|
void writeInterfaces(const objectRegistry&) const;
|
|
|
|
// write List<label> in constant/polyMesh
|
|
void writeMeshLabelList
|
|
(
|
|
const objectRegistry& registry,
|
|
const word& propertyName,
|
|
const labelList& list,
|
|
IOstream::streamFormat fmt = IOstream::ASCII
|
|
) const;
|
|
|
|
//- Return list of faces for every cell
|
|
faceListList& cellFaces() const
|
|
{
|
|
return const_cast<faceListList&>(cellFaces_);
|
|
}
|
|
|
|
protected:
|
|
// Protected data
|
|
|
|
//- Pointers to cell shape models
|
|
static const cellModel* unknownModel;
|
|
static const cellModel* tetModel;
|
|
static const cellModel* pyrModel;
|
|
static const cellModel* prismModel;
|
|
static const cellModel* hexModel;
|
|
|
|
//- referenced filename
|
|
fileName geometryFile_;
|
|
|
|
//- geometry scaling
|
|
scalar scaleFactor_;
|
|
|
|
//- Points supporting the mesh
|
|
pointField points_;
|
|
|
|
//- lookup original Cell number for a given cell
|
|
labelList origCellId_;
|
|
|
|
//- identify boundary faces by cells and their faces
|
|
// for each patch
|
|
List<List<cellFaceIdentifier> > boundaryIds_;
|
|
|
|
//- Boundary patch types
|
|
wordList patchTypes_;
|
|
|
|
//- Boundary patch names
|
|
wordList patchNames_;
|
|
|
|
//- Boundary patch physical types
|
|
wordList patchPhysicalTypes_;
|
|
|
|
//- List of faces for every cell
|
|
faceListList cellFaces_;
|
|
|
|
//- List of each baffle face
|
|
faceList baffleFaces_;
|
|
|
|
// cell table id for each cell
|
|
labelList cellTableId_;
|
|
|
|
// cell table persistent data saved as a dictionary
|
|
cellTable cellTable_;
|
|
|
|
// Member Functions
|
|
|
|
//- subclasses are required to supply this information
|
|
virtual bool readGeometry
|
|
(
|
|
const scalar scaleFactor = 1.0
|
|
) = 0;
|
|
|
|
//- Return mesh points
|
|
pointField& points() const
|
|
{
|
|
return const_cast<pointField&>(points_);
|
|
}
|
|
|
|
public:
|
|
// Static Members
|
|
|
|
//- warn about repeated names
|
|
static void warnDuplicates(const word& context, const wordList&);
|
|
|
|
// Constructors
|
|
|
|
//- Construct from fileName
|
|
meshReader(const fileName&, const scalar scaleFactor = 1.0);
|
|
|
|
// Destructor
|
|
virtual ~meshReader();
|
|
|
|
// Member Functions
|
|
|
|
//- create and return polyMesh
|
|
virtual autoPtr<polyMesh> mesh(const objectRegistry&);
|
|
|
|
//- Write auxiliary information
|
|
void writeAux(const objectRegistry&) const;
|
|
|
|
//- Write mesh
|
|
void writeMesh
|
|
(
|
|
const polyMesh&,
|
|
IOstream::streamFormat fmt = IOstream::BINARY
|
|
) const;
|
|
};
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
} // End namespace Foam
|
|
|
|
#endif
|
|
|
|
// ************************************************************************* //
|