blockMesh: most mesh data are now demand-driven

- Unless the points(), cells(), patches() methods are called, the classes
  should know maintain a lightweight representation for as long as possible.

- bugfix: old-code used xferMove() instead of xferCopy() when creating the
  topology mesh - causing const pointField& to break if the code order was
  changed

- relocate blockMesh from src/meshing -> src/mesh
This commit is contained in:
Mark Olesen
2009-09-17 23:45:52 +02:00
parent c2ad2d1bd6
commit 897baf81c0
44 changed files with 462 additions and 438 deletions

View File

@ -1,5 +1,5 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/meshing/blockMesh/lnInclude \ -I$(LIB_SRC)/mesh/blockMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude -I$(LIB_SRC)/dynamicMesh/lnInclude

View File

@ -203,6 +203,7 @@ int main(int argc, char *argv[])
word defaultFacesType = emptyPolyPatch::typeName; word defaultFacesType = emptyPolyPatch::typeName;
wordList patchPhysicalTypes = blocks.patchPhysicalTypes(); wordList patchPhysicalTypes = blocks.patchPhysicalTypes();
preservePatchTypes preservePatchTypes
( (
runTime, runTime,
@ -338,7 +339,7 @@ int main(int argc, char *argv[])
// Set the precision of the points data to 10 // Set the precision of the points data to 10
IOstream::defaultPrecision(10); IOstream::defaultPrecision(10);
Info << nl << "Writing polyMesh" << endl; Info<< nl << "Writing polyMesh" << endl;
mesh.removeFiles(); mesh.removeFiles();
if (!mesh.write()) if (!mesh.write())
{ {
@ -347,6 +348,38 @@ int main(int argc, char *argv[])
<< exit(FatalError); << exit(FatalError);
} }
//
// write some information
//
{
const polyPatchList& patches = mesh.boundaryMesh();
Info<< "----------------" << nl
<< "Mesh Information" << nl
<< "----------------" << nl
<< " " << "boundingBox: " << boundBox(mesh.points()) << nl
<< " " << "nPoints: " << mesh.nPoints() << nl
<< " " << "nCells: " << mesh.nCells() << nl
<< " " << "nFaces: " << mesh.nFaces() << nl
<< " " << "nInternalFaces: " << mesh.nInternalFaces() << nl;
Info<< "----------------" << nl
<< "Patches" << nl
<< "----------------" << nl;
forAll(patches, patchI)
{
const polyPatch& p = patches[patchI];
Info<< " " << "patch " << patchI
<< " (start: " << p.start()
<< " size: " << p.size()
<< ") name: " << p.name()
<< nl;
}
}
Info<< nl << "End" << endl; Info<< nl << "End" << endl;
return 0; return 0;

View File

@ -39,4 +39,5 @@ EXE_LIBS = \
-lthermophysicalFunctions \ -lthermophysicalFunctions \
-ltopoChangerFvMesh \ -ltopoChangerFvMesh \
-ltriSurface \ -ltriSurface \
-lautoMesh -lautoMesh \
-lblockMesh

View File

@ -51,6 +51,7 @@ lagrangian/Allwmake
postProcessing/Allwmake postProcessing/Allwmake
conversion/Allwmake conversion/Allwmake
mesh/Allwmake
wmake libso autoMesh wmake libso autoMesh
wmake libso errorEstimation wmake libso errorEstimation

View File

@ -16,12 +16,9 @@ block/block.C
block/blockCreate.C block/blockCreate.C
blockMesh/blockMesh.C blockMesh/blockMesh.C
blockMesh/blockMeshCells.C blockMesh/blockMeshCreate.C
blockMesh/blockMeshPatches.C
blockMesh/blockMeshPoints.C
blockMesh/blockMeshTopology.C blockMesh/blockMeshTopology.C
blockMesh/blockMeshCheck.C blockMesh/blockMeshCheck.C
blockMesh/blockMeshOffsets.C blockMesh/blockMeshMerge.C
blockMesh/blockMeshMergeList.C
LIB = $(FOAM_LIBBIN)/libblockMesh LIB = $(FOAM_LIBBIN)/libblockMesh

View File

@ -27,52 +27,68 @@ License
#include "error.H" #include "error.H"
#include "block.H" #include "block.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::block::block Foam::block::block
( (
const pointField& blockMeshPoints, const pointField& blockPointField,
const curvedEdgeList& edges, const curvedEdgeList& edges,
Istream& is Istream& is
) )
: :
blockDescriptor(blockMeshPoints, edges, is), blockDescriptor(blockPointField, edges, is),
vertices_(nPoints()), vertices_(0),
cells_(nCells()), cells_(0),
boundaryPatches_(6) boundaryPatches_(0)
{ {}
createPrimitives();
}
Foam::block::block(const blockDescriptor& definition) Foam::block::block(const blockDescriptor& blockDesc)
: :
blockDescriptor(definition), blockDescriptor(blockDesc),
vertices_(nPoints()), vertices_(0),
cells_(nCells()), cells_(0),
boundaryPatches_(6) boundaryPatches_(0)
{ {}
createPrimitives();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::block::~block()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::pointField& Foam::block::points() const const Foam::pointField& Foam::block::points() const
{ {
if (vertices_.empty())
{
createPoints();
}
return vertices_; return vertices_;
} }
const Foam::labelListList& Foam::block::cells() const const Foam::labelListList& Foam::block::cells() const
{ {
if (cells_.empty())
{
createCells();
}
return cells_; return cells_;
} }
const Foam::labelListListList& Foam::block::boundaryPatches() const const Foam::labelListListList& Foam::block::boundaryPatches() const
{ {
if (boundaryPatches_.empty())
{
createBoundary();
}
return boundaryPatches_; return boundaryPatches_;
} }

View File

@ -29,6 +29,9 @@ Description
Creates a single block of cells from point coordinates, numbers of Creates a single block of cells from point coordinates, numbers of
cells in each direction and an expansion ratio. cells in each direction and an expansion ratio.
Note
The vertices and cells for filling the block are demand-driven.
SourceFiles SourceFiles
block.C block.C
blockCreate.C blockCreate.C
@ -51,6 +54,10 @@ namespace Foam
class Istream; class Istream;
class Ostream; class Ostream;
// Forward declaration of friend functions and operators
class block;
Ostream& operator<<(Ostream&, const block&);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class block Declaration Class block Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -62,13 +69,13 @@ class block
// Private data // Private data
//- List of vertices //- List of vertices
pointField vertices_; mutable pointField vertices_;
//- List of cells //- List of cells
labelListList cells_; mutable labelListList cells_;
//- Boundary patches //- Boundary patches
labelListListList boundaryPatches_; mutable labelListListList boundaryPatches_;
// Private Member Functions // Private Member Functions
@ -76,17 +83,14 @@ class block
//- Vertex label offset for a particular i,j,k position //- Vertex label offset for a particular i,j,k position
label vtxLabel(label i, label j, label k) const; label vtxLabel(label i, label j, label k) const;
//- Creates vertices for cells filling the block. //- Creates vertices for cells filling the block
void createPoints(); void createPoints() const;
//- Creates cells for the block. //- Creates cells for filling the block
void createCells(); void createCells() const;
//- Creates boundary patches for the block //- Creates boundary patch faces for the block
void createBoundary(); void createBoundary() const;
//- Creates vertices, cells, boundary patches for the block
void createPrimitives();
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
block(const block&); block(const block&);
@ -101,7 +105,7 @@ public:
//- Construct from components with Istream //- Construct from components with Istream
block block
( (
const pointField& blockMeshPoints, const pointField& blockPointField,
const curvedEdgeList&, const curvedEdgeList&,
Istream& Istream&
); );
@ -117,6 +121,11 @@ public:
} }
//- Destructor
~block();
// Member Functions // Member Functions
// Access // Access
@ -127,13 +136,20 @@ public:
return *this; return *this;
} }
//- Return the points for filling the block
const pointField& points() const; const pointField& points() const;
//- Return the cells for filling the block
const labelListList& cells() const; const labelListList& cells() const;
//- Return the boundary patch faces for the block
const labelListListList& boundaryPatches() const; const labelListListList& boundaryPatches() const;
//- Clear geometry
void clearGeom();
// Ostream Operator // Ostream Operator
friend Ostream& operator<<(Ostream&, const block&); friend Ostream& operator<<(Ostream&, const block&);

View File

@ -27,7 +27,6 @@ License
#include "error.H" #include "error.H"
#include "block.H" #include "block.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::label Foam::block::vtxLabel(label i, label j, label k) const Foam::label Foam::block::vtxLabel(label i, label j, label k) const
@ -41,7 +40,7 @@ Foam::label Foam::block::vtxLabel(label i, label j, label k) const
} }
void Foam::block::createPoints() void Foam::block::createPoints() const
{ {
// set local variables for mesh specification // set local variables for mesh specification
const label ni = meshDensity().x(); const label ni = meshDensity().x();
@ -63,7 +62,11 @@ void Foam::block::createPoints()
const List< List<point> >& p = blockEdgePoints(); const List< List<point> >& p = blockEdgePoints();
const scalarListList& w = blockEdgeWeights(); const scalarListList& w = blockEdgeWeights();
//
// generate vertices // generate vertices
//
vertices_.clear();
vertices_.setSize(nPoints());
for (label k = 0; k <= nk; k++) for (label k = 0; k <= nk; k++)
{ {
@ -71,7 +74,7 @@ void Foam::block::createPoints()
{ {
for (label i = 0; i <= ni; i++) for (label i = 0; i <= ni; i++)
{ {
label vertexNo = vtxLabel(i, j, k); const label vertexNo = vtxLabel(i, j, k);
// points on edges // points on edges
vector edgex1 = p000 + (p100 - p000)*w[0][i]; vector edgex1 = p000 + (p100 - p000)*w[0][i];
@ -89,6 +92,7 @@ void Foam::block::createPoints()
vector edgez3 = p110 + (p111 - p110)*w[10][k]; vector edgez3 = p110 + (p111 - p110)*w[10][k];
vector edgez4 = p010 + (p011 - p010)*w[11][k]; vector edgez4 = p010 + (p011 - p010)*w[11][k];
// calculate the importance factors for all edges // calculate the importance factors for all edges
// x-direction // x-direction
@ -110,7 +114,6 @@ void Foam::block::createPoints()
+ w[2][i]*w[6][j]*w[10][k] + w[2][i]*w[6][j]*w[10][k]
); );
scalar impx4 = scalar impx4 =
( (
(1.0 - w[3][i])*(1.0 - w[7][j])*w[8][k] (1.0 - w[3][i])*(1.0 - w[7][j])*w[8][k]
@ -187,6 +190,7 @@ void Foam::block::createPoints()
impz3 /= magImpz; impz3 /= magImpz;
impz4 /= magImpz; impz4 /= magImpz;
// calculate the correction vectors // calculate the correction vectors
vector corx1 = impx1*(p[0][i] - edgex1); vector corx1 = impx1*(p[0][i] - edgex1);
vector corx2 = impx2*(p[1][i] - edgex2); vector corx2 = impx2*(p[1][i] - edgex2);
@ -226,34 +230,44 @@ void Foam::block::createPoints()
// add the contributions // add the contributions
vertices_[vertexNo] = edgex1 + edgex2 + edgex3 + edgex4; vertices_[vertexNo] =
vertices_[vertexNo] += edgey1 + edgey2 + edgey3 + edgey4; (
vertices_[vertexNo] += edgez1 + edgez2 + edgez3 + edgez4; edgex1 + edgex2 + edgex3 + edgex4
+ edgey1 + edgey2 + edgey3 + edgey4
+ edgez1 + edgez2 + edgez3 + edgez4
) / 3.0;
vertices_[vertexNo] /= 3.0; vertices_[vertexNo] +=
(
vertices_[vertexNo] += corx1 + corx2 + corx3 + corx4; corx1 + corx2 + corx3 + corx4
vertices_[vertexNo] += cory1 + cory2 + cory3 + cory4; + cory1 + cory2 + cory3 + cory4
vertices_[vertexNo] += corz1 + corz2 + corz3 + corz4; + corz1 + corz2 + corz3 + corz4
);
} }
} }
} }
} }
void Foam::block::createCells() void Foam::block::createCells() const
{ {
const label ni = meshDensity().x(); const label ni = meshDensity().x();
const label nj = meshDensity().y(); const label nj = meshDensity().y();
const label nk = meshDensity().z(); const label nk = meshDensity().z();
//
// generate cells
//
cells_.clear();
cells_.setSize(nCells());
label cellNo = 0; label cellNo = 0;
for (label k = 0; k <= nk - 1; k++) for (label k = 0; k < nk; k++)
{ {
for (label j = 0; j <= nj - 1; j++) for (label j = 0; j < nj; j++)
{ {
for (label i = 0; i <= ni - 1; i++) for (label i = 0; i < ni; i++)
{ {
cells_[cellNo].setSize(8); cells_[cellNo].setSize(8);
@ -272,12 +286,19 @@ void Foam::block::createCells()
} }
void Foam::block::createBoundary() void Foam::block::createBoundary() const
{ {
const label ni = meshDensity().x(); const label ni = meshDensity().x();
const label nj = meshDensity().y(); const label nj = meshDensity().y();
const label nk = meshDensity().z(); const label nk = meshDensity().z();
//
// generate boundaries on each side of the hex
//
boundaryPatches_.clear();
boundaryPatches_.setSize(6);
// x-direction // x-direction
label wallLabel = 0; label wallLabel = 0;
@ -285,9 +306,9 @@ void Foam::block::createBoundary()
// x-min // x-min
boundaryPatches_[wallLabel].setSize(nj*nk); boundaryPatches_[wallLabel].setSize(nj*nk);
for (label k = 0; k <= nk - 1; k++) for (label k = 0; k < nk; k++)
{ {
for (label j = 0; j <= nj - 1; j++) for (label j = 0; j < nj; j++)
{ {
boundaryPatches_[wallLabel][wallCellLabel].setSize(4); boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
@ -312,9 +333,9 @@ void Foam::block::createBoundary()
boundaryPatches_[wallLabel].setSize(nj*nk); boundaryPatches_[wallLabel].setSize(nj*nk);
for (label k = 0; k <= nk - 1; k++) for (label k = 0; k < nk; k++)
{ {
for (label j = 0; j <= nj - 1; j++) for (label j = 0; j < nj; j++)
{ {
boundaryPatches_[wallLabel][wallCellLabel].setSize(4); boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
@ -340,9 +361,9 @@ void Foam::block::createBoundary()
wallCellLabel = 0; wallCellLabel = 0;
boundaryPatches_[wallLabel].setSize(ni*nk); boundaryPatches_[wallLabel].setSize(ni*nk);
for (label i = 0; i <= ni - 1; i++) for (label i = 0; i < ni; i++)
{ {
for (label k = 0; k <= nk - 1; k++) for (label k = 0; k < nk; k++)
{ {
boundaryPatches_[wallLabel][wallCellLabel].setSize(4); boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
@ -367,9 +388,9 @@ void Foam::block::createBoundary()
boundaryPatches_[wallLabel].setSize(ni*nk); boundaryPatches_[wallLabel].setSize(ni*nk);
for (label i = 0; i <= ni - 1; i++) for (label i = 0; i < ni; i++)
{ {
for (label k = 0; k <= nk - 1; k++) for (label k = 0; k < nk; k++)
{ {
boundaryPatches_[wallLabel][wallCellLabel].setSize(4); boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
@ -396,9 +417,9 @@ void Foam::block::createBoundary()
boundaryPatches_[wallLabel].setSize(ni*nj); boundaryPatches_[wallLabel].setSize(ni*nj);
for (label i = 0; i <= ni - 1; i++) for (label i = 0; i < ni; i++)
{ {
for (label j = 0; j <= nj - 1; j++) for (label j = 0; j < nj; j++)
{ {
boundaryPatches_[wallLabel][wallCellLabel].setSize(4); boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
@ -423,9 +444,9 @@ void Foam::block::createBoundary()
boundaryPatches_[wallLabel].setSize(ni*nj); boundaryPatches_[wallLabel].setSize(ni*nj);
for (label i = 0; i <= ni - 1; i++) for (label i = 0; i < ni; i++)
{ {
for (label j = 0; j <= nj - 1; j++) for (label j = 0; j < nj; j++)
{ {
boundaryPatches_[wallLabel][wallCellLabel].setSize(4); boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
@ -446,16 +467,11 @@ void Foam::block::createBoundary()
} }
void Foam::block::createPrimitives() void Foam::block::clearGeom()
{ {
// create points vertices_.clear();
createPoints(); cells_.clear();
boundaryPatches_.clear();
// generate internal cells
createCells();
// generate boundary patches
createBoundary();
} }

View File

@ -32,14 +32,14 @@ License
Foam::blockDescriptor::blockDescriptor Foam::blockDescriptor::blockDescriptor
( (
const cellShape& bshape, const cellShape& bshape,
const pointField& blockMeshPoints, const pointField& blockPointField,
const curvedEdgeList& edges, const curvedEdgeList& edges,
const Vector<label>& meshDensity, const Vector<label>& meshDensity,
const UList<scalar>& expand, const UList<scalar>& expand,
const word& zoneName const word& zoneName
) )
: :
blockMeshPoints_(blockMeshPoints), blockPointField_(blockPointField),
curvedEdges_(edges), curvedEdges_(edges),
blockShape_(bshape), blockShape_(bshape),
meshDensity_(meshDensity), meshDensity_(meshDensity),
@ -53,7 +53,7 @@ Foam::blockDescriptor::blockDescriptor
FatalErrorIn FatalErrorIn
( (
"blockDescriptor::blockDescriptor" "blockDescriptor::blockDescriptor"
"(const cellShape&, const pointField& blockMeshPoints, " "(const cellShape&, const pointField& blockPointField, "
"const curvedEdgeList&, const Vector<label>& meshDensity, " "const curvedEdgeList&, const Vector<label>& meshDensity, "
"const scalarList& expand, const word& zoneName)" "const scalarList& expand, const word& zoneName)"
) << "Unknown definition of expansion ratios" ) << "Unknown definition of expansion ratios"
@ -67,12 +67,12 @@ Foam::blockDescriptor::blockDescriptor
Foam::blockDescriptor::blockDescriptor Foam::blockDescriptor::blockDescriptor
( (
const pointField& blockMeshPoints, const pointField& blockPointField,
const curvedEdgeList& edges, const curvedEdgeList& edges,
Istream& is Istream& is
) )
: :
blockMeshPoints_(blockMeshPoints), blockPointField_(blockPointField),
curvedEdges_(edges), curvedEdges_(edges),
blockShape_(is), blockShape_(is),
meshDensity_(), meshDensity_(),
@ -168,11 +168,17 @@ Foam::blockDescriptor::blockDescriptor
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::blockDescriptor::~blockDescriptor()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::pointField& Foam::blockDescriptor::blockPointField() const const Foam::pointField& Foam::blockDescriptor::blockPointField() const
{ {
return blockMeshPoints_; return blockPointField_;
} }
@ -231,11 +237,10 @@ Foam::label Foam::blockDescriptor::nCells() const
const Foam::point& Foam::blockDescriptor::blockPoint(const label i) const const Foam::point& Foam::blockDescriptor::blockPoint(const label i) const
{ {
return blockMeshPoints_[blockShape_[i]]; return blockPointField_[blockShape_[i]];
} }
// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const blockDescriptor& bd) Foam::Ostream& Foam::operator<<(Ostream& os, const blockDescriptor& bd)

View File

@ -38,8 +38,8 @@ SourceFiles
#ifndef blockDescriptor_H #ifndef blockDescriptor_H
#define blockDescriptor_H #define blockDescriptor_H
#include "point.H"
#include "cellShape.H" #include "cellShape.H"
#include "pointField.H"
#include "scalarList.H" #include "scalarList.H"
#include "curvedEdgeList.H" #include "curvedEdgeList.H"
@ -51,6 +51,11 @@ namespace Foam
class Istream; class Istream;
class Ostream; class Ostream;
// Forward declaration of friend functions and operators
class blockMesh;
class blockDescriptor;
Ostream& operator<<(Ostream&, const blockDescriptor&);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class blockDescriptor Declaration Class blockDescriptor Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -60,7 +65,7 @@ class blockDescriptor
// Private data // Private data
//- Reference to point field defining the block mesh //- Reference to point field defining the block mesh
const pointField& blockMeshPoints_; const pointField& blockPointField_;
//- Reference to a list of curved edges //- Reference to a list of curved edges
const curvedEdgeList& curvedEdges_; const curvedEdgeList& curvedEdges_;
@ -106,7 +111,7 @@ public:
blockDescriptor blockDescriptor
( (
const cellShape&, const cellShape&,
const pointField& blockMeshPoints, const pointField& blockPointField,
const curvedEdgeList&, const curvedEdgeList&,
const Vector<label>& meshDensity, const Vector<label>& meshDensity,
const UList<scalar>& expand, const UList<scalar>& expand,
@ -116,7 +121,7 @@ public:
//- Construct from Istream //- Construct from Istream
blockDescriptor blockDescriptor
( (
const pointField& blockMeshPoints, const pointField& blockPointField,
const curvedEdgeList&, const curvedEdgeList&,
Istream& Istream&
); );
@ -129,6 +134,11 @@ public:
} }
// Destructor
~blockDescriptor();
// Member Functions // Member Functions
// Access // Access

View File

@ -26,6 +26,7 @@ License
#include "error.H" #include "error.H"
#include "blockDescriptor.H" #include "blockDescriptor.H"
#include "lineEdge.H" #include "lineEdge.H"
#include "lineDivide.H" #include "lineDivide.H"
@ -86,7 +87,7 @@ void Foam::blockDescriptor::setEdge
const labelList& blockLabels = blockShape_; const labelList& blockLabels = blockShape_;
// set reference to global list of points // set reference to global list of points
const pointField blockPoints = blockShape_.points(blockMeshPoints_); const pointField blockPoints = blockShape_.points(blockPointField_);
// Set the edge points/weights // Set the edge points/weights
// The edge is a straight-line if it is not in the list of curvedEdges // The edge is a straight-line if it is not in the list of curvedEdges

View File

@ -26,18 +26,16 @@ License
#include "blockMesh.H" #include "blockMesh.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::blockMesh::blockMesh(IOdictionary& meshDescription) Foam::blockMesh::blockMesh(IOdictionary& dict)
: :
topologyPtr_(createTopology(meshDescription)), blockPointField_(dict.lookup("vertices")),
blockOffsets_(createBlockOffsets()), scaleFactor_(1.0),
mergeList_(createMergeList()), topologyPtr_(createTopology(dict))
points_(createPoints(meshDescription)), {
cells_(createCells()), calcMergeInfo();
patches_(createPatches()) }
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -63,45 +61,54 @@ const Foam::polyMesh& Foam::blockMesh::topology() const
} }
Foam::wordList Foam::blockMesh::patchNames() const const Foam::pointField& Foam::blockMesh::points() const
{ {
const polyPatchList& patchTopologies = topology().boundaryMesh(); if (points_.empty())
wordList names(patchTopologies.size());
forAll(names, patchI)
{ {
names[patchI] = patchTopologies[patchI].name(); createPoints();
} }
return names; return points_;
}
const Foam::cellShapeList& Foam::blockMesh::cells() const
{
if (cells_.empty())
{
createCells();
}
return cells_;
}
const Foam::faceListList& Foam::blockMesh::patches() const
{
if (patches_.empty())
{
createPatches();
}
return patches_;
}
Foam::wordList Foam::blockMesh::patchNames() const
{
return topology().boundaryMesh().names();
} }
Foam::wordList Foam::blockMesh::patchTypes() const Foam::wordList Foam::blockMesh::patchTypes() const
{ {
const polyPatchList& patchTopologies = topology().boundaryMesh(); return topology().boundaryMesh().types();
wordList types(patchTopologies.size());
forAll(types, patchI)
{
types[patchI] = patchTopologies[patchI].type();
}
return types;
} }
Foam::wordList Foam::blockMesh::patchPhysicalTypes() const Foam::wordList Foam::blockMesh::patchPhysicalTypes() const
{ {
const polyPatchList& patchTopologies = topology().boundaryMesh(); return topology().boundaryMesh().physicalTypes();
wordList physicalTypes(patchTopologies.size());
forAll(physicalTypes, patchI)
{
physicalTypes[patchI] = patchTopologies[patchI].physicalType();
}
return physicalTypes;
} }

View File

@ -26,15 +26,16 @@ Class
Foam::blockMesh Foam::blockMesh
Description Description
A multi-block mesh generator
Note
The vertices, cells and patches for filling the blocks are demand-driven.
SourceFiles SourceFiles
blockMesh.C blockMesh.C
blockMeshCells.C
blockMeshCheck.C blockMeshCheck.C
blockMeshMergeList.C blockMeshCreate.C
blockMeshOffsets.C blockMeshMerge.C
blockMeshPatches.C
blockMeshPoints.C
blockMeshTopology.C blockMeshTopology.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -62,19 +63,34 @@ class blockMesh
{ {
// Private data // Private data
label nPoints_; //- Point field defining the block mesh (corners)
label nCells_; pointField blockPointField_;
//- The list of curved edges
curvedEdgeList edges_; curvedEdgeList edges_;
//- The scaling factor to convert to meters
scalar scaleFactor_;
//- The blocks themselves (the topology) as a polyMesh
polyMesh* topologyPtr_; polyMesh* topologyPtr_;
label nPoints_;
//- The sum of all cells in each block
label nCells_;
//- The point offset added to each block
labelList blockOffsets_; labelList blockOffsets_;
//- The merge points information
labelList mergeList_; labelList mergeList_;
pointField points_; mutable pointField points_;
cellShapeList cells_;
faceListList patches_; mutable cellShapeList cells_;
mutable faceListList patches_;
// Private Member Functions // Private Member Functions
@ -96,14 +112,14 @@ class blockMesh
polyMesh* createTopology(IOdictionary&); polyMesh* createTopology(IOdictionary&);
void checkBlockMesh(const polyMesh&) const; void checkBlockMesh(const polyMesh&) const;
labelList createBlockOffsets(); //- Determine the merge info and the final number of cells/points
labelList createMergeList(); void calcMergeInfo();
pointField createPoints(const dictionary&) const;
cellShapeList createCells() const;
faceList createPatchFaces(const polyPatch& patchTopologyFaces) const; faceList createPatchFaces(const polyPatch& patchTopologyFaces) const;
faceListList createPatches() const;
void createPoints() const;
void createCells() const;
void createPatches() const;
//- as copy (not implemented) //- as copy (not implemented)
blockMesh(const blockMesh&); blockMesh(const blockMesh&);
@ -133,20 +149,11 @@ public:
return edges_; return edges_;
} }
const pointField& points() const const pointField& points() const;
{
return points_;
}
const cellShapeList& cells() const const cellShapeList& cells() const;
{
return cells_;
}
const faceListList& patches() const const faceListList& patches() const;
{
return patches_;
}
wordList patchNames() const; wordList patchNames() const;

View File

@ -31,7 +31,7 @@ License
// Check the blockMesh topology // Check the blockMesh topology
void Foam::blockMesh::checkBlockMesh(const polyMesh& bm) const void Foam::blockMesh::checkBlockMesh(const polyMesh& bm) const
{ {
Info<< nl << "Check blockMesh topology" << endl; Info<< nl << "Check topology" << endl;
bool ok = true; bool ok = true;
@ -55,19 +55,19 @@ void Foam::blockMesh::checkBlockMesh(const polyMesh& bm) const
} }
Info<< nl << tab << "Basic statistics" << endl; Info<< nl << tab << "Basic statistics" << nl;
Info<< tab << tab << "Number of internal faces : " Info<< tab << tab << "Number of internal faces : "
<< bm.nInternalFaces() << endl; << bm.nInternalFaces() << nl;
Info<< tab << tab << "Number of boundary faces : " Info<< tab << tab << "Number of boundary faces : "
<< nBoundaryFaces << endl; << nBoundaryFaces << nl;
Info<< tab << tab << "Number of defined boundary faces : " Info<< tab << tab << "Number of defined boundary faces : "
<< nDefinedBoundaryFaces << endl; << nDefinedBoundaryFaces << nl;
Info<< tab << tab << "Number of undefined boundary faces : " Info<< tab << tab << "Number of undefined boundary faces : "
<< nBoundaryFaces - nDefinedBoundaryFaces << endl; << nBoundaryFaces - nDefinedBoundaryFaces << nl;
if ((nBoundaryFaces - nDefinedBoundaryFaces) > 0) if ((nBoundaryFaces - nDefinedBoundaryFaces) > 0)
{ {
@ -76,7 +76,7 @@ void Foam::blockMesh::checkBlockMesh(const polyMesh& bm) const
<< "of 2D planar geometries!)" << endl; << "of 2D planar geometries!)" << endl;
} }
Info<< nl << tab << "Checking patch -> block consistency" << endl; Info<< tab << "Checking patch -> block consistency" << endl;
forAll(patches, patchi) forAll(patches, patchi)

View File

@ -24,10 +24,84 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "error.H"
#include "blockMesh.H" #include "blockMesh.H"
#include "cellModeller.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::blockMesh::createPoints() const
{
const blockMesh& blocks = *this;
Info<< "Creating points with scale " << scaleFactor_ << endl;
//
// generate points
//
points_.clear();
points_.setSize(nPoints_);
forAll(blocks, blockI)
{
const pointField& blockPoints = blocks[blockI].points();
forAll(blockPoints, blockPointI)
{
points_
[
mergeList_
[
blockOffsets_[blockI] + blockPointI
]
] = scaleFactor_ * blockPoints[blockPointI];
}
}
}
void Foam::blockMesh::createCells() const
{
const blockMesh& blocks = *this;
const cellModel& hex = *(cellModeller::lookup("hex"));
Info<< "Creating cells" << endl;
//
// generate cells
//
cells_.clear();
cells_.setSize(nCells_);
label cellLabel = 0;
forAll(blocks, blockI)
{
const labelListList& blockCells = blocks[blockI].cells();
forAll(blockCells, blockCellI)
{
labelList cellPoints(blockCells[blockCellI].size());
forAll(cellPoints, cellPointI)
{
cellPoints[cellPointI] =
mergeList_
[
blockCells[blockCellI][cellPointI]
+ blockOffsets_[blockI]
];
}
// Construct collapsed cell and add to list
cells_[cellLabel] = cellShape(hex, cellPoints, true);
cellLabel++;
}
}
}
Foam::faceList Foam::blockMesh::createPatchFaces Foam::faceList Foam::blockMesh::createPatchFaces
( (
const polyPatch& patchTopologyFaces const polyPatch& patchTopologyFaces
@ -37,7 +111,7 @@ Foam::faceList Foam::blockMesh::createPatchFaces
labelList blockLabels = patchTopologyFaces.polyPatch::faceCells(); labelList blockLabels = patchTopologyFaces.polyPatch::faceCells();
label nFaces=0; label nFaces = 0;
forAll(patchTopologyFaces, patchTopologyFaceLabel) forAll(patchTopologyFaces, patchTopologyFaceLabel)
{ {
@ -143,20 +217,24 @@ Foam::faceList Foam::blockMesh::createPatchFaces
} }
Foam::faceListList Foam::blockMesh::createPatches() const void Foam::blockMesh::createPatches() const
{ {
const polyPatchList& topoPatches = topology().boundaryMesh();
Info<< "Creating patches" << endl; Info<< "Creating patches" << endl;
const polyPatchList& patchTopologies = topology().boundaryMesh(); //
faceListList patches(patchTopologies.size()); // generate points
//
forAll(patchTopologies, patchLabel) patches_.clear();
patches_.setSize(topoPatches.size());
forAll(topoPatches, patchI)
{ {
patches[patchLabel] = patches_[patchI] = createPatchFaces(topoPatches[patchI]);
createPatchFaces(patchTopologies[patchLabel]);
} }
return patches;
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -28,13 +28,32 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::labelList Foam::blockMesh::createMergeList() void Foam::blockMesh::calcMergeInfo()
{ {
const blockMesh& blocks = *this;
Info<< "Creating block offsets" << endl;
blockOffsets_.setSize(blocks.size());
nPoints_ = 0;
nCells_ = 0;
forAll(blocks, blockI)
{
blockOffsets_[blockI] = nPoints_;
nPoints_ += blocks[blockI].nPoints();
nCells_ += blocks[blockI].nCells();
}
Info<< "Creating merge list " << flush; Info<< "Creating merge list " << flush;
labelList MergeList(nPoints_, -1); // set unused to -1
mergeList_.setSize(nPoints_);
mergeList_ = -1;
const blockMesh& blocks = *this;
const pointField& blockPoints = topology().points(); const pointField& blockPoints = topology().points();
const cellList& blockCells = topology().cells(); const cellList& blockCells = topology().cells();
@ -46,6 +65,7 @@ Foam::labelList Foam::blockMesh::createMergeList()
const labelList& faceNeighbourBlocks = topology().faceNeighbour(); const labelList& faceNeighbourBlocks = topology().faceNeighbour();
forAll(blockFaces, blockFaceLabel) forAll(blockFaces, blockFaceLabel)
{ {
label blockPlabel = faceOwnerBlocks[blockFaceLabel]; label blockPlabel = faceOwnerBlocks[blockFaceLabel];
@ -74,7 +94,7 @@ Foam::labelList Foam::blockMesh::createMergeList()
if (!foundFace) if (!foundFace)
{ {
FatalErrorIn("blockMesh::createMergeList()") FatalErrorIn("blockMesh::calcMergeInfo()")
<< "Cannot find merge face for block " << blockPlabel << "Cannot find merge face for block " << blockPlabel
<< exit(FatalError); << exit(FatalError);
}; };
@ -130,17 +150,17 @@ Foam::labelList Foam::blockMesh::createMergeList()
label minPP2 = min(PpointLabel, PpointLabel2); label minPP2 = min(PpointLabel, PpointLabel2);
if (MergeList[PpointLabel] != -1) if (mergeList_[PpointLabel] != -1)
{ {
minPP2 = min(minPP2, MergeList[PpointLabel]); minPP2 = min(minPP2, mergeList_[PpointLabel]);
} }
if (MergeList[PpointLabel2] != -1) if (mergeList_[PpointLabel2] != -1)
{ {
minPP2 = min(minPP2, MergeList[PpointLabel2]); minPP2 = min(minPP2, mergeList_[PpointLabel2]);
} }
MergeList[PpointLabel] = MergeList[PpointLabel2] mergeList_[PpointLabel] = mergeList_[PpointLabel2]
= minPP2; = minPP2;
} }
else else
@ -183,7 +203,7 @@ Foam::labelList Foam::blockMesh::createMergeList()
if (!foundFace) if (!foundFace)
{ {
FatalErrorIn("blockMesh::createMergeList()") FatalErrorIn("blockMesh::calcMergeInfo()")
<< "Cannot find merge face for block " << blockNlabel << "Cannot find merge face for block " << blockNlabel
<< exit(FatalError); << exit(FatalError);
}; };
@ -193,7 +213,7 @@ Foam::labelList Foam::blockMesh::createMergeList()
if (blockPfaceFaces.size() != blockNfaceFaces.size()) if (blockPfaceFaces.size() != blockNfaceFaces.size())
{ {
FatalErrorIn("blockMesh::createMergeList()") FatalErrorIn("blockMesh::calcMergeInfo()")
<< "Inconsistent number of faces between block pair " << "Inconsistent number of faces between block pair "
<< blockPlabel << " and " << blockNlabel << blockPlabel << " and " << blockNlabel
<< exit(FatalError); << exit(FatalError);
@ -251,17 +271,17 @@ Foam::labelList Foam::blockMesh::createMergeList()
label minPN = min(PpointLabel, NpointLabel); label minPN = min(PpointLabel, NpointLabel);
if (MergeList[PpointLabel] != -1) if (mergeList_[PpointLabel] != -1)
{ {
minPN = min(minPN, MergeList[PpointLabel]); minPN = min(minPN, mergeList_[PpointLabel]);
} }
if (MergeList[NpointLabel] != -1) if (mergeList_[NpointLabel] != -1)
{ {
minPN = min(minPN, MergeList[NpointLabel]); minPN = min(minPN, mergeList_[NpointLabel]);
} }
MergeList[PpointLabel] = MergeList[NpointLabel] mergeList_[PpointLabel] = mergeList_[NpointLabel]
= minPN; = minPN;
} }
} }
@ -271,7 +291,7 @@ Foam::labelList Foam::blockMesh::createMergeList()
{ {
if (cp[blockPfaceFacePointLabel] == -1) if (cp[blockPfaceFacePointLabel] == -1)
{ {
FatalErrorIn("blockMesh::createMergeList()") FatalErrorIn("blockMesh::calcMergeInfo()")
<< "Inconsistent point locations between block pair " << "Inconsistent point locations between block pair "
<< blockPlabel << " and " << blockNlabel << nl << blockPlabel << " and " << blockNlabel << nl
<< " probably due to inconsistent grading." << " probably due to inconsistent grading."
@ -374,18 +394,18 @@ Foam::labelList Foam::blockMesh::createMergeList()
if if
( (
MergeList[PpointLabel] mergeList_[PpointLabel]
!= MergeList[NpointLabel] != mergeList_[NpointLabel]
) )
{ {
changedPointMerge = true; changedPointMerge = true;
MergeList[PpointLabel] mergeList_[PpointLabel]
= MergeList[NpointLabel] = mergeList_[NpointLabel]
= min = min
( (
MergeList[PpointLabel], mergeList_[PpointLabel],
MergeList[NpointLabel] mergeList_[NpointLabel]
); );
} }
} }
@ -395,7 +415,7 @@ Foam::labelList Foam::blockMesh::createMergeList()
if (nPasses > 100) if (nPasses > 100)
{ {
FatalErrorIn("blockMesh::createMergeList()") FatalErrorIn("blockMesh::calcMergeInfo()")
<< "Point merging failed after max number of passes." << "Point merging failed after max number of passes."
<< abort(FatalError); << abort(FatalError);
} }
@ -436,7 +456,7 @@ Foam::labelList Foam::blockMesh::createMergeList()
if (!foundFace) if (!foundFace)
{ {
FatalErrorIn("blockMesh::createMergeList()") FatalErrorIn("blockMesh::calcMergeInfo()")
<< "Cannot find merge face for block " << blockPlabel << "Cannot find merge face for block " << blockPlabel
<< exit(FatalError); << exit(FatalError);
}; };
@ -463,7 +483,7 @@ Foam::labelList Foam::blockMesh::createMergeList()
if (!foundFace) if (!foundFace)
{ {
FatalErrorIn("blockMesh::createMergeList()") FatalErrorIn("blockMesh::calcMergeInfo()")
<< "Cannot find merge face for block " << blockNlabel << "Cannot find merge face for block " << blockNlabel
<< exit(FatalError); << exit(FatalError);
}; };
@ -485,9 +505,9 @@ Foam::labelList Foam::blockMesh::createMergeList()
blockPfaceFacePoints[blockPfaceFacePointLabel] blockPfaceFacePoints[blockPfaceFacePointLabel]
+ blockOffsets_[blockPlabel]; + blockOffsets_[blockPlabel];
if (MergeList[PpointLabel] == -1) if (mergeList_[PpointLabel] == -1)
{ {
FatalErrorIn("blockMesh::createMergeList()") FatalErrorIn("blockMesh::calcMergeInfo()")
<< "Unable to merge point " << "Unable to merge point "
<< blockPfaceFacePointLabel << blockPfaceFacePointLabel
<< ' ' << blockPpoints[blockPfaceFacePointLabel] << ' ' << blockPpoints[blockPfaceFacePointLabel]
@ -511,9 +531,9 @@ Foam::labelList Foam::blockMesh::createMergeList()
blockNfaceFacePoints[blockNfaceFacePointLabel] blockNfaceFacePoints[blockNfaceFacePointLabel]
+ blockOffsets_[blockNlabel]; + blockOffsets_[blockNlabel];
if (MergeList[NpointLabel] == -1) if (mergeList_[NpointLabel] == -1)
{ {
FatalErrorIn("blockMesh::createMergeList()") FatalErrorIn("blockMesh::calcMergeInfo()")
<< "unable to merge point " << "unable to merge point "
<< blockNfaceFacePointLabel << blockNfaceFacePointLabel
<< ' ' << blockNpoints[blockNfaceFacePointLabel] << ' ' << blockNpoints[blockNfaceFacePointLabel]
@ -532,33 +552,31 @@ Foam::labelList Foam::blockMesh::createMergeList()
// given old point label // given old point label
label newPointLabel = 0; label newPointLabel = 0;
forAll(MergeList, pointLabel) forAll(mergeList_, pointLabel)
{ {
if (MergeList[pointLabel] > pointLabel) if (mergeList_[pointLabel] > pointLabel)
{ {
FatalErrorIn("blockMesh::createMergeList()") FatalErrorIn("blockMesh::calcMergeInfo()")
<< "ouch" << exit(FatalError); << "ouch" << exit(FatalError);
} }
if if
( (
(MergeList[pointLabel] == -1) mergeList_[pointLabel] == -1
|| MergeList[pointLabel] == pointLabel || mergeList_[pointLabel] == pointLabel
) )
{ {
MergeList[pointLabel] = newPointLabel; mergeList_[pointLabel] = newPointLabel;
newPointLabel++; newPointLabel++;
} }
else else
{ {
MergeList[pointLabel] = MergeList[MergeList[pointLabel]]; mergeList_[pointLabel] = mergeList_[mergeList_[pointLabel]];
} }
} }
nPoints_ = newPointLabel; nPoints_ = newPointLabel;
return MergeList;
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -32,7 +32,7 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription) Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& dict)
{ {
bool topologyOK = true; bool topologyOK = true;
@ -44,24 +44,29 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
// get names/types for the unassigned patch faces // get names/types for the unassigned patch faces
// this is a bit heavy handed (and ugly), but there is currently // this is a bit heavy handed (and ugly), but there is currently
// no easy way to rename polyMesh patches subsequently // no easy way to rename polyMesh patches subsequently
if (const dictionary* dictPtr = meshDescription.subDictPtr("defaultPatch")) if (const dictionary* dictPtr = dict.subDictPtr("defaultPatch"))
{ {
dictPtr->readIfPresent("name", defaultPatchName); dictPtr->readIfPresent("name", defaultPatchName);
dictPtr->readIfPresent("type", defaultPatchType); dictPtr->readIfPresent("type", defaultPatchType);
} }
Info<< "Creating block corners" << endl; // optional 'convertToMeters' or 'scale' scaling factor
if (!dict.readIfPresent("convertToMeters", scaleFactor_))
// create blockCorners {
pointField tmpBlockPoints(meshDescription.lookup("vertices")); dict.readIfPresent("scale", scaleFactor_);
}
if (meshDescription.found("edges"))
//
// get the non-linear edges in mesh
//
if (dict.found("edges"))
{ {
// read number of non-linear edges in mesh
Info<< "Creating curved edges" << endl; Info<< "Creating curved edges" << endl;
ITstream& is(meshDescription.lookup("edges")); ITstream& is(dict.lookup("edges"));
// read number of edges in mesh
label nEdges = 0; label nEdges = 0;
token firstToken(is); token firstToken(is);
@ -84,9 +89,9 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
token lastToken(is); token lastToken(is);
while while
( (
!( !(
lastToken.isPunctuation() lastToken.isPunctuation()
&& lastToken.pToken() == token::END_LIST && lastToken.pToken() == token::END_LIST
) )
) )
{ {
@ -100,7 +105,7 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
edges_.set edges_.set
( (
nEdges, nEdges,
curvedEdge::New(tmpBlockPoints, is) curvedEdge::New(blockPointField_, is)
); );
nEdges++; nEdges++;
@ -114,13 +119,16 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
} }
else else
{ {
Info<< "No non-linear edges" << endl; Info<< "No non-linear edges defined" << endl;
} }
Info<< "Creating blocks" << endl; //
// Create the blocks
//
Info<< "Creating topology blocks" << endl;
{ {
ITstream& is(meshDescription.lookup("blocks")); ITstream& is(dict.lookup("blocks"));
// read number of blocks in mesh // read number of blocks in mesh
label nBlocks = 0; label nBlocks = 0;
@ -145,9 +153,9 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
token lastToken(is); token lastToken(is);
while while
( (
!( !(
lastToken.isPunctuation() lastToken.isPunctuation()
&& lastToken.pToken() == token::END_LIST && lastToken.pToken() == token::END_LIST
) )
) )
{ {
@ -163,7 +171,7 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
nBlocks, nBlocks,
new block new block
( (
tmpBlockPoints, blockPointField_,
edges_, edges_,
is is
) )
@ -172,7 +180,7 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
topologyOK = topologyOK && blockLabelsOK topologyOK = topologyOK && blockLabelsOK
( (
nBlocks, nBlocks,
tmpBlockPoints, blockPointField_,
blocks[nBlocks].blockShape() blocks[nBlocks].blockShape()
); );
@ -187,14 +195,17 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
} }
Info<< "Creating patches" << endl; //
// Create the patches
//
Info<< "Creating topology patches" << endl;
faceListList tmpBlocksPatches; faceListList tmpBlocksPatches;
wordList patchNames; wordList patchNames;
wordList patchTypes; wordList patchTypes;
{ {
ITstream& is(meshDescription.lookup("patches")); ITstream& is(dict.lookup("patches"));
// read number of patches in mesh // read number of patches in mesh
label nPatches = 0; label nPatches = 0;
@ -223,9 +234,9 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
while while
( (
!( !(
lastToken.isPunctuation() lastToken.isPunctuation()
&& lastToken.pToken() == token::END_LIST && lastToken.pToken() == token::END_LIST
) )
) )
{ {
if (tmpBlocksPatches.size() <= nPatches) if (tmpBlocksPatches.size() <= nPatches)
@ -261,7 +272,7 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
topologyOK = topologyOK && patchLabelsOK topologyOK = topologyOK && patchLabelsOK
( (
nPatches, nPatches,
tmpBlockPoints, blockPointField_,
tmpBlocksPatches[nPatches] tmpBlocksPatches[nPatches]
); );
@ -284,7 +295,10 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
} }
Info<< "Creating topology" << endl; //
// Create the topology
//
Info<< "Creating topology mesh" << endl;
PtrList<cellShape> tmpBlockShapes(blocks.size()); PtrList<cellShape> tmpBlockShapes(blocks.size());
forAll(blocks, blockI) forAll(blocks, blockI)
@ -295,7 +309,7 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
new cellShape(blocks[blockI].blockShape()) new cellShape(blocks[blockI].blockShape())
); );
if (tmpBlockShapes[blockI].mag(tmpBlockPoints) < 0.0) if (tmpBlockShapes[blockI].mag(blockPointField_) < 0.0)
{ {
WarningIn WarningIn
( (
@ -309,8 +323,8 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
preservePatchTypes preservePatchTypes
( (
meshDescription.time(), dict.time(),
meshDescription.time().constant(), dict.time().constant(),
polyMesh::meshSubDir, polyMesh::meshSubDir,
patchNames, patchNames,
patchTypes, patchTypes,
@ -319,18 +333,20 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
patchPhysicalTypes patchPhysicalTypes
); );
// construct the topology as its own mesh
polyMesh* blockMeshPtr = new polyMesh polyMesh* blockMeshPtr = new polyMesh
( (
IOobject IOobject
( (
"blockMesh", "blockMesh",
meshDescription.time().constant(), dict.time().constant(),
meshDescription.time(), dict.time(),
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false false
), ),
xferMove(tmpBlockPoints), xferCopy(blockPointField_), // copy these points, do NOT move
tmpBlockShapes, tmpBlockShapes,
tmpBlocksPatches, tmpBlocksPatches,
patchNames, patchNames,

View File

@ -1,73 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "blockMesh.H"
#include "cellModeller.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::cellShapeList Foam::blockMesh::createCells() const
{
Info<< "Creating cells" << endl;
PtrList<cellShape> cells(nCells_);
const blockMesh& blocks = *this;
const cellModel& hex = *(cellModeller::lookup("hex"));
label cellLabel = 0;
forAll(blocks, blockI)
{
const labelListList& blockCells = blocks[blockI].cells();
forAll(blockCells, blockCellI)
{
labelList cellPoints(blockCells[blockCellI].size());
forAll(cellPoints, cellPointI)
{
cellPoints[cellPointI] =
mergeList_
[
blockCells[blockCellI][cellPointI]
+ blockOffsets_[blockI]
];
}
// Construct collapsed cell and add to list
cells.set(cellLabel, new cellShape(hex, cellPoints, true));
cellLabel++;
}
}
return cells;
}
// ************************************************************************* //

View File

@ -1,57 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "blockMesh.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::labelList Foam::blockMesh::createBlockOffsets()
{
Info<< "Creating block offsets" << endl;
const blockMesh& blocks = *this;
labelList BlockOffsets(blocks.size());
BlockOffsets[0] = 0;
nPoints_ = blocks[0].points().size();
nCells_ = blocks[0].cells().size();
for (label blockI=1; blockI < blocks.size(); blockI++)
{
BlockOffsets[blockI]
= BlockOffsets[blockI-1]
+ blocks[blockI-1].points().size();
nPoints_ += blocks[blockI].points().size();
nCells_ += blocks[blockI].cells().size();
}
return BlockOffsets;
}
// ************************************************************************* //

View File

@ -1,68 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "blockMesh.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::pointField Foam::blockMesh::createPoints(const dictionary& dict) const
{
const blockMesh& blocks = *this;
scalar scaleFactor = 1.0;
// optional 'convertToMeters' (or 'scale'?)
if (!dict.readIfPresent("convertToMeters", scaleFactor))
{
dict.readIfPresent("scale", scaleFactor);
}
Info<< "Creating points with scale " << scaleFactor << endl;
pointField points(nPoints_);
forAll(blocks, blockI)
{
const pointField& blockPoints = blocks[blockI].points();
forAll(blockPoints, blockPointLabel)
{
points
[
mergeList_
[
blockPointLabel
+ blockOffsets_[blockI]
]
] = scaleFactor * blockPoints[blockPointLabel];
}
}
return points;
}
// ************************************************************************* //