diff --git a/applications/utilities/mesh/generation/blockMesh/Make/options b/applications/utilities/mesh/generation/blockMesh/Make/options index abb7181f13..2e07c477da 100644 --- a/applications/utilities/mesh/generation/blockMesh/Make/options +++ b/applications/utilities/mesh/generation/blockMesh/Make/options @@ -1,5 +1,5 @@ EXE_INC = \ - -I$(LIB_SRC)/meshing/blockMesh/lnInclude \ + -I$(LIB_SRC)/mesh/blockMesh/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude diff --git a/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C b/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C index 73c1e783c0..501b45c132 100644 --- a/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C +++ b/applications/utilities/mesh/generation/blockMesh/blockMeshApp.C @@ -203,6 +203,7 @@ int main(int argc, char *argv[]) word defaultFacesType = emptyPolyPatch::typeName; wordList patchPhysicalTypes = blocks.patchPhysicalTypes(); + preservePatchTypes ( runTime, @@ -338,7 +339,7 @@ int main(int argc, char *argv[]) // Set the precision of the points data to 10 IOstream::defaultPrecision(10); - Info << nl << "Writing polyMesh" << endl; + Info<< nl << "Writing polyMesh" << endl; mesh.removeFiles(); if (!mesh.write()) { @@ -347,6 +348,38 @@ int main(int argc, char *argv[]) << 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; return 0; diff --git a/applications/utilities/miscellaneous/foamDebugSwitches/Make/options b/applications/utilities/miscellaneous/foamDebugSwitches/Make/options index ed65d15437..421e59a7f1 100644 --- a/applications/utilities/miscellaneous/foamDebugSwitches/Make/options +++ b/applications/utilities/miscellaneous/foamDebugSwitches/Make/options @@ -39,4 +39,5 @@ EXE_LIBS = \ -lthermophysicalFunctions \ -ltopoChangerFvMesh \ -ltriSurface \ - -lautoMesh + -lautoMesh \ + -lblockMesh diff --git a/src/Allwmake b/src/Allwmake index ebef2d8d0d..acbc2c3f0f 100755 --- a/src/Allwmake +++ b/src/Allwmake @@ -51,6 +51,7 @@ lagrangian/Allwmake postProcessing/Allwmake conversion/Allwmake +mesh/Allwmake wmake libso autoMesh wmake libso errorEstimation diff --git a/src/meshing/Allwmake b/src/mesh/Allwmake similarity index 100% rename from src/meshing/Allwmake rename to src/mesh/Allwmake diff --git a/src/meshing/blockMesh/Make/files b/src/mesh/blockMesh/Make/files similarity index 76% rename from src/meshing/blockMesh/Make/files rename to src/mesh/blockMesh/Make/files index ca3f2670d7..cc7a1c1bb5 100644 --- a/src/meshing/blockMesh/Make/files +++ b/src/mesh/blockMesh/Make/files @@ -16,12 +16,9 @@ block/block.C block/blockCreate.C blockMesh/blockMesh.C -blockMesh/blockMeshCells.C -blockMesh/blockMeshPatches.C -blockMesh/blockMeshPoints.C +blockMesh/blockMeshCreate.C blockMesh/blockMeshTopology.C blockMesh/blockMeshCheck.C -blockMesh/blockMeshOffsets.C -blockMesh/blockMeshMergeList.C +blockMesh/blockMeshMerge.C LIB = $(FOAM_LIBBIN)/libblockMesh diff --git a/src/meshing/blockMesh/Make/options b/src/mesh/blockMesh/Make/options similarity index 100% rename from src/meshing/blockMesh/Make/options rename to src/mesh/blockMesh/Make/options diff --git a/src/meshing/blockMesh/block/block.C b/src/mesh/blockMesh/block/block.C similarity index 77% rename from src/meshing/blockMesh/block/block.C rename to src/mesh/blockMesh/block/block.C index 0fe19e2ba7..094b592bd5 100644 --- a/src/meshing/blockMesh/block/block.C +++ b/src/mesh/blockMesh/block/block.C @@ -27,52 +27,68 @@ License #include "error.H" #include "block.H" - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::block::block ( - const pointField& blockMeshPoints, + const pointField& blockPointField, const curvedEdgeList& edges, Istream& is ) : - blockDescriptor(blockMeshPoints, edges, is), - vertices_(nPoints()), - cells_(nCells()), - boundaryPatches_(6) -{ - createPrimitives(); -} + blockDescriptor(blockPointField, edges, is), + vertices_(0), + cells_(0), + boundaryPatches_(0) +{} -Foam::block::block(const blockDescriptor& definition) +Foam::block::block(const blockDescriptor& blockDesc) : - blockDescriptor(definition), - vertices_(nPoints()), - cells_(nCells()), - boundaryPatches_(6) -{ - createPrimitives(); -} + blockDescriptor(blockDesc), + vertices_(0), + cells_(0), + boundaryPatches_(0) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::block::~block() +{} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // const Foam::pointField& Foam::block::points() const { + if (vertices_.empty()) + { + createPoints(); + } + return vertices_; } const Foam::labelListList& Foam::block::cells() const { + if (cells_.empty()) + { + createCells(); + } + return cells_; } const Foam::labelListListList& Foam::block::boundaryPatches() const { + if (boundaryPatches_.empty()) + { + createBoundary(); + } + return boundaryPatches_; } diff --git a/src/meshing/blockMesh/block/block.H b/src/mesh/blockMesh/block/block.H similarity index 79% rename from src/meshing/blockMesh/block/block.H rename to src/mesh/blockMesh/block/block.H index a53a067c60..943d38bdfc 100644 --- a/src/meshing/blockMesh/block/block.H +++ b/src/mesh/blockMesh/block/block.H @@ -29,6 +29,9 @@ Description Creates a single block of cells from point coordinates, numbers of cells in each direction and an expansion ratio. +Note + The vertices and cells for filling the block are demand-driven. + SourceFiles block.C blockCreate.C @@ -51,6 +54,10 @@ namespace Foam class Istream; class Ostream; +// Forward declaration of friend functions and operators +class block; +Ostream& operator<<(Ostream&, const block&); + /*---------------------------------------------------------------------------*\ Class block Declaration \*---------------------------------------------------------------------------*/ @@ -62,13 +69,13 @@ class block // Private data //- List of vertices - pointField vertices_; + mutable pointField vertices_; //- List of cells - labelListList cells_; + mutable labelListList cells_; //- Boundary patches - labelListListList boundaryPatches_; + mutable labelListListList boundaryPatches_; // Private Member Functions @@ -76,17 +83,14 @@ class block //- Vertex label offset for a particular i,j,k position label vtxLabel(label i, label j, label k) const; - //- Creates vertices for cells filling the block. - void createPoints(); + //- Creates vertices for cells filling the block + void createPoints() const; - //- Creates cells for the block. - void createCells(); + //- Creates cells for filling the block + void createCells() const; - //- Creates boundary patches for the block - void createBoundary(); - - //- Creates vertices, cells, boundary patches for the block - void createPrimitives(); + //- Creates boundary patch faces for the block + void createBoundary() const; //- Disallow default bitwise copy construct block(const block&); @@ -101,7 +105,7 @@ public: //- Construct from components with Istream block ( - const pointField& blockMeshPoints, + const pointField& blockPointField, const curvedEdgeList&, Istream& ); @@ -117,6 +121,11 @@ public: } + //- Destructor + + ~block(); + + // Member Functions // Access @@ -127,13 +136,20 @@ public: return *this; } + //- Return the points for filling the block const pointField& points() const; + //- Return the cells for filling the block const labelListList& cells() const; + //- Return the boundary patch faces for the block const labelListListList& boundaryPatches() const; + //- Clear geometry + void clearGeom(); + + // Ostream Operator friend Ostream& operator<<(Ostream&, const block&); diff --git a/src/meshing/blockMesh/block/blockCreate.C b/src/mesh/blockMesh/block/blockCreate.C similarity index 88% rename from src/meshing/blockMesh/block/blockCreate.C rename to src/mesh/blockMesh/block/blockCreate.C index d3d09edc97..3f741fd587 100644 --- a/src/meshing/blockMesh/block/blockCreate.C +++ b/src/mesh/blockMesh/block/blockCreate.C @@ -27,7 +27,6 @@ License #include "error.H" #include "block.H" - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // 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 const label ni = meshDensity().x(); @@ -63,7 +62,11 @@ void Foam::block::createPoints() const List< List >& p = blockEdgePoints(); const scalarListList& w = blockEdgeWeights(); + // // generate vertices + // + vertices_.clear(); + vertices_.setSize(nPoints()); for (label k = 0; k <= nk; k++) { @@ -71,7 +74,7 @@ void Foam::block::createPoints() { for (label i = 0; i <= ni; i++) { - label vertexNo = vtxLabel(i, j, k); + const label vertexNo = vtxLabel(i, j, k); // points on edges 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 edgez4 = p010 + (p011 - p010)*w[11][k]; + // calculate the importance factors for all edges // x-direction @@ -110,7 +114,6 @@ void Foam::block::createPoints() + w[2][i]*w[6][j]*w[10][k] ); - scalar impx4 = ( (1.0 - w[3][i])*(1.0 - w[7][j])*w[8][k] @@ -187,6 +190,7 @@ void Foam::block::createPoints() impz3 /= magImpz; impz4 /= magImpz; + // calculate the correction vectors vector corx1 = impx1*(p[0][i] - edgex1); vector corx2 = impx2*(p[1][i] - edgex2); @@ -226,34 +230,44 @@ void Foam::block::createPoints() // add the contributions - vertices_[vertexNo] = edgex1 + edgex2 + edgex3 + edgex4; - vertices_[vertexNo] += edgey1 + edgey2 + edgey3 + edgey4; - vertices_[vertexNo] += edgez1 + edgez2 + edgez3 + edgez4; + vertices_[vertexNo] = + ( + edgex1 + edgex2 + edgex3 + edgex4 + + edgey1 + edgey2 + edgey3 + edgey4 + + edgez1 + edgez2 + edgez3 + edgez4 + ) / 3.0; - vertices_[vertexNo] /= 3.0; - - vertices_[vertexNo] += corx1 + corx2 + corx3 + corx4; - vertices_[vertexNo] += cory1 + cory2 + cory3 + cory4; - vertices_[vertexNo] += corz1 + corz2 + corz3 + corz4; + vertices_[vertexNo] += + ( + corx1 + corx2 + corx3 + corx4 + + cory1 + cory2 + cory3 + cory4 + + corz1 + corz2 + corz3 + corz4 + ); } } } } -void Foam::block::createCells() +void Foam::block::createCells() const { const label ni = meshDensity().x(); const label nj = meshDensity().y(); const label nk = meshDensity().z(); + // + // generate cells + // + cells_.clear(); + cells_.setSize(nCells()); + 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); @@ -272,12 +286,19 @@ void Foam::block::createCells() } -void Foam::block::createBoundary() +void Foam::block::createBoundary() const { const label ni = meshDensity().x(); const label nj = meshDensity().y(); const label nk = meshDensity().z(); + // + // generate boundaries on each side of the hex + // + boundaryPatches_.clear(); + boundaryPatches_.setSize(6); + + // x-direction label wallLabel = 0; @@ -285,9 +306,9 @@ void Foam::block::createBoundary() // x-min 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); @@ -312,9 +333,9 @@ void Foam::block::createBoundary() 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); @@ -340,9 +361,9 @@ void Foam::block::createBoundary() wallCellLabel = 0; 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); @@ -367,9 +388,9 @@ void Foam::block::createBoundary() 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); @@ -396,9 +417,9 @@ void Foam::block::createBoundary() 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); @@ -423,9 +444,9 @@ void Foam::block::createBoundary() 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); @@ -446,16 +467,11 @@ void Foam::block::createBoundary() } -void Foam::block::createPrimitives() +void Foam::block::clearGeom() { - // create points - createPoints(); - - // generate internal cells - createCells(); - - // generate boundary patches - createBoundary(); + vertices_.clear(); + cells_.clear(); + boundaryPatches_.clear(); } diff --git a/src/meshing/blockMesh/block/blockList.H b/src/mesh/blockMesh/block/blockList.H similarity index 100% rename from src/meshing/blockMesh/block/blockList.H rename to src/mesh/blockMesh/block/blockList.H diff --git a/src/meshing/blockMesh/blockDescriptor/blockDescriptor.C b/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C similarity index 94% rename from src/meshing/blockMesh/blockDescriptor/blockDescriptor.C rename to src/mesh/blockMesh/blockDescriptor/blockDescriptor.C index 7551cc6459..7b7a0bdcac 100644 --- a/src/meshing/blockMesh/blockDescriptor/blockDescriptor.C +++ b/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C @@ -32,14 +32,14 @@ License Foam::blockDescriptor::blockDescriptor ( const cellShape& bshape, - const pointField& blockMeshPoints, + const pointField& blockPointField, const curvedEdgeList& edges, const Vector