Commit 00920318 by Henry Weller

### blockMesh: New experimental support for projecting block face point to geometric surfaces

```For example, to mesh a sphere with a single block the geometry is defined in the
blockMeshDict as a searchableSurface:

geometry
{
sphere
{
type searchableSphere;
centre (0 0 0);
}
}

The vertices, block topology and curved edges are defined in the usual
way, for example

v 0.5773502;
mv -0.5773502;

a 0.7071067;
ma -0.7071067;

vertices
(
(\$mv \$mv \$mv)
( \$v \$mv \$mv)
( \$v  \$v \$mv)
(\$mv  \$v \$mv)
(\$mv \$mv  \$v)
( \$v \$mv  \$v)
( \$v  \$v  \$v)
(\$mv  \$v  \$v)
);

blocks
(
hex (0 1 2 3 4 5 6 7) (10 10 10) simpleGrading (1 1 1)
);

edges
(
arc 0 1 (0 \$ma \$ma)
arc 2 3 (0 \$a \$ma)
arc 6 7 (0 \$a \$a)
arc 4 5 (0 \$ma \$a)

arc 0 3 (\$ma 0 \$ma)
arc 1 2 (\$a 0 \$ma)
arc 5 6 (\$a 0 \$a)
arc 4 7 (\$ma 0 \$a)

arc 0 4 (\$ma \$ma 0)
arc 1 5 (\$a \$ma 0)
arc 2 6 (\$a \$a 0)
arc 3 7 (\$ma \$a 0)
);

which will produce a mesh in which the block edges conform to the sphere
but the faces of the block lie somewhere between the original cube and
the spherical surface which is a consequence of the edge-based
transfinite interpolation.

Now the projection of the block faces to the geometry specified above
can also be specified:

faces
(
project (0 4 7 3) sphere
project (2 6 5 1) sphere
project (1 5 4 0) sphere
project (3 7 6 2) sphere
project (0 3 2 1) sphere
project (4 5 6 7) sphere
);

which produces a mesh that actually conforms to the sphere.

See OpenFOAM-dev/tutorials/mesh/blockMesh/sphere

This functionality is experimental and will undergo further development
and generalization in the future to support more complex surfaces,
feature edge specification and extraction etc.  Please get involved if
you would like to see blockMesh become a more flexible block-structured
mesher.

Henry G. Weller, CFD Direct.```
parent 12d0707b
 EXE_INC = \ -I\$(LIB_SRC)/mesh/blockMesh/lnInclude \ -I\$(LIB_SRC)/meshTools/lnInclude \ -I\$(LIB_SRC)/fileFormats/lnInclude \ -I\$(LIB_SRC)/dynamicMesh/lnInclude EXE_LIBS = \ -lblockMesh \ -lmeshTools \ -lfileFormats \ -ldynamicMesh
 ... ... @@ -176,8 +176,6 @@ int main(int argc, char *argv[]) Info<< "Creating block mesh from\n " << meshDictIO.objectPath() << endl; blockMesh::verbose(true); IOdictionary meshDict(meshDictIO); blockMesh blocks(meshDict, regionName); ... ... @@ -286,8 +284,8 @@ int main(int argc, char *argv[]) forAll(blocks, blockI) { const block& b = blocks[blockI]; const labelListList& blockCells = b.cells(); const word& zoneName = b.blockDef().zoneName(); const List> blockCells = b.cells(); const word& zoneName = b.zoneName(); if (zoneName.size()) { ... ...
 ... ... @@ -75,7 +75,7 @@ void Foam::vtkPV3blockMesh::updateInfoBlocks const int nBlocks = blkMesh.size(); for (int blockI = 0; blockI < nBlocks; ++blockI) { const blockDescriptor& blockDef = blkMesh[blockI].blockDef(); const blockDescriptor& blockDef = blkMesh[blockI]; word partName = Foam::name(blockI); ... ...
 ... ... @@ -77,7 +77,7 @@ void Foam::vtkPV3blockMesh::convertMeshBlocks continue; } const blockDescriptor& blockDef = blkMesh[blockI].blockDef(); const blockDescriptor& blockDef = blkMesh[blockI]; vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New(); ... ... @@ -168,7 +168,7 @@ void Foam::vtkPV3blockMesh::convertMeshEdges // search each block forAll(blkMesh, blockI) { const blockDescriptor& blockDef = blkMesh[blockI].blockDef(); const blockDescriptor& blockDef = blkMesh[blockI]; edgeList blkEdges = blockDef.blockShape().edges(); ... ...
 EXE_INC = \ -I\$(LIB_SRC)/meshTools/lnInclude \ -I\$(LIB_SRC)/fileFormats/lnInclude \ -I\$(LIB_SRC)/mesh/blockMesh/lnInclude \ -I\$(ParaView_INCLUDE_DIR) \ -I\$(ParaView_INCLUDE_DIR)/vtkkwiml \ ... ... @@ -8,6 +9,7 @@ EXE_INC = \ LIB_LIBS = \ -lmeshTools \ -lfileFormats \ -lblockMesh \ -L\$(FOAM_LIBBIN) -lvtkPVReaders \ \$(GLIBS)
 ... ... @@ -75,7 +75,7 @@ void Foam::vtkPVblockMesh::updateInfoBlocks const int nBlocks = blkMesh.size(); for (int blockI = 0; blockI < nBlocks; ++blockI) { const blockDescriptor& blockDef = blkMesh[blockI].blockDef(); const blockDescriptor& blockDef = blkMesh[blockI]; word partName = Foam::name(blockI); ... ...
 ... ... @@ -77,7 +77,7 @@ void Foam::vtkPVblockMesh::convertMeshBlocks continue; } const blockDescriptor& blockDef = blkMesh[blockI].blockDef(); const blockDescriptor& blockDef = blkMesh[blockI]; vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New(); ... ... @@ -168,12 +168,12 @@ void Foam::vtkPVblockMesh::convertMeshEdges // search each block forAll(blkMesh, blockI) { const blockDescriptor& blockDef = blkMesh[blockI].blockDef(); const blockDescriptor& blockDef = blkMesh[blockI]; edgeList blkEdges = blockDef.blockShape().edges(); // List of edge point and weighting factors List edgesPoints[12]; pointField edgesPoints[12]; scalarList edgesWeights[12]; blockDef.edgesPointsWeights(edgesPoints, edgesWeights); ... ...
 blockEdges/BSpline.C blockEdges/CatmullRomSpline.C blockEdges/polyLine.C blockEdges/blockEdge/blockEdge.C blockEdges/lineDivide/lineDivide.C blockEdges/lineEdge/lineEdge.C blockEdges/polyLineEdge/polyLine.C blockEdges/polyLineEdge/polyLineEdge.C blockEdges/arcEdge/arcEdge.C blockEdges/BSplineEdge/BSpline.C blockEdges/BSplineEdge/BSplineEdge.C blockEdges/splineEdge/CatmullRomSpline.C blockEdges/splineEdge/splineEdge.C blockEdges/arcEdge.C blockEdges/blockEdge.C blockEdges/lineEdge.C blockEdges/polyLineEdge.C blockEdges/lineDivide.C blockEdges/BSplineEdge.C blockEdges/splineEdge.C blockFaces/blockFace/blockFace.C blockFaces/projectFace/projectFace.C gradingDescriptor/gradingDescriptor.C gradingDescriptor/gradingDescriptors.C ... ...
 EXE_INC = \ -I\$(LIB_SRC)/meshTools/lnInclude \ -I\$(LIB_SRC)/dynamicMesh/lnInclude -I\$(LIB_SRC)/fileFormats/lnInclude LIB_LIBS = \ -lmeshTools \ -ldynamicMesh -lfileFormats
 ... ... @@ -31,63 +31,23 @@ Foam::block::block ( const pointField& vertices, const blockEdgeList& edges, const blockFaceList& faces, Istream& is ) : blockDescriptor(vertices, edges, is), points_(0), cells_(0), boundaryPatches_(0) {} Foam::block::block(const blockDescriptor& blockDesc) : blockDescriptor(blockDesc), points_(0), cells_(0), boundaryPatches_(0) {} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::block::~block() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // const Foam::pointField& Foam::block::points() const blockDescriptor(vertices, edges, faces, is) { if (points_.empty()) { createPoints(); } return points_; createPoints(); createBoundary(); } const Foam::labelListList& Foam::block::cells() const { if (cells_.empty()) { createCells(); } return cells_; } const Foam::labelListListList& Foam::block::boundaryPatches() const Foam::block::block(const blockDescriptor& blockDesc) : blockDescriptor(blockDesc) { if (boundaryPatches_.empty()) { createBoundary(); } return boundaryPatches_; createPoints(); createBoundary(); } ... ...
 ... ... @@ -68,25 +68,19 @@ class block // Private data //- List of points mutable pointField points_; //- List of cells mutable labelListList cells_; pointField points_; //- Boundary patches mutable labelListListList boundaryPatches_; FixedList>, 6> boundaryPatches_; // Private Member Functions //- Creates vertices for cells filling the block void createPoints() const; //- Creates cells for filling the block void createCells() const; void createPoints(); //- Creates boundary patch faces for the block void createBoundary() const; void createBoundary(); //- Disallow default bitwise copy construct block(const block&); ... ... @@ -94,6 +88,7 @@ class block //- Disallow default bitwise assignment void operator=(const block&); public: // Constructors ... ... @@ -103,6 +98,7 @@ public: ( const pointField& vertices, const blockEdgeList& edges, const blockFaceList& faces, Istream& is ); ... ... @@ -122,50 +118,42 @@ public: { const pointField& points_; const blockEdgeList& edges_; const blockFaceList& faces_; public: iNew(const pointField& points, const blockEdgeList& edges) iNew ( const pointField& points, const blockEdgeList& edges, const blockFaceList& faces ) : points_(points), edges_(edges) edges_(edges), faces_(faces) {} autoPtr operator()(Istream& is) const { return autoPtr(new block(points_, edges_, is)); return autoPtr(new block(points_, edges_, faces_, is)); } }; //- Destructor ~block(); // Member Functions // Access //- Return the block definition inline const blockDescriptor& blockDef() const; //- Vertex label offset for a particular i,j,k position inline label vtxLabel(label i, label j, label k) const; //- Return the points for filling the block const pointField& points() const; inline const pointField& points() const; //- Return the cells for filling the block const labelListList& cells() const; List> cells() const; //- Return the boundary patch faces for the block const labelListListList& boundaryPatches() const; // Edit //- Clear geometry (internal points, cells, boundaryPatches) void clearGeom(); inline const FixedList>, 6>& boundaryPatches() const; // Ostream Operator ... ...
This diff is collapsed.
 ... ... @@ -23,24 +23,18 @@ License \*---------------------------------------------------------------------------*/ // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // inline Foam::label Foam::block::vtxLabel(label i, label j, label k) const inline const Foam::pointField& Foam::block::points() const { return ( i + j * (density().x() + 1) + k * (density().x() + 1) * (density().y() + 1) ); return points_; } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // inline const Foam::blockDescriptor& Foam::block::blockDef() const inline const Foam::FixedList>, 6>& Foam::block::boundaryPatches() const { return *this; return boundaryPatches_; } ... ...
 ... ... @@ -102,6 +102,32 @@ void Foam::blockDescriptor::check(const Istream& is) } void Foam::blockDescriptor::findCurvedFaces() { const faceList blockFaces(blockShape().faces()); forAll(blockFaces, blockFacei) { forAll(faces_, facei) { if ( face::sameVertices ( faces_[facei].vertices(), blockFaces[blockFacei] ) ) { curvedFaces_[blockFacei] = facei; nCurvedFaces_++; break; } } } } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::blockDescriptor::blockDescriptor ... ... @@ -109,6 +135,7 @@ Foam::blockDescriptor::blockDescriptor const cellShape& bshape, const pointField& vertices, const blockEdgeList& edges, const blockFaceList& faces, const Vector
 /*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------* \ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | ... ... @@ -31,14 +31,14 @@ Description For a given block, the correspondence between the ordering of vertex labels and face labels is shown below. For vertex numbering in the sequence 0 to 7 (block, centre): faces 0 (f0) and 1 are left and right, respectively; faces 2 and 3 are bottom and top; and faces 4 and 5 are front the back: 2 and 3 are front the back; and faces 4 and 5 are bottom and top: \verbatim 4 ---- 5 f3 |\ |\ f5 f5 |\ |\ f3 | | 7 ---- 6 \ | 0 |--- 1 | \ | \| \| f4 f2 3 ---- 2 | \| \| f2 f4 3 ---- 2 f0 ----- f1 \endverbatim ... ... @@ -56,6 +56,7 @@ SourceFiles #include "pointField.H" #include "scalarList.H" #include "blockEdgeList.H" #include "blockFaceList.H" #include "gradingDescriptors.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ... ... @@ -84,6 +85,9 @@ class blockDescriptor //- Reference to a list of block edges const blockEdgeList& edges_; //- Reference to the list of curved faces const blockFaceList& faces_; //- Block shape cellShape blockShape_; ... ... @@ -96,16 +100,23 @@ class blockDescriptor //- Name of the zone (empty word if none) word zoneName_; //- Curved-face labels for each block-face (-1 for flat faces) FixedList curvedFaces_; //- Number of curved faces in this block label nCurvedFaces_; // Private Member Functions //- Check block has outward-pointing faces void check(const Istream& is); //- Calculate the points and weights for the specified edge void edgePointsWeights //- Calculate the points and weights for the specified edge. // Return the number of curved edges label edgePointsWeights ( List (&edgePoints)[12],