From 24b2335f190bb94a687613ea2e8a21798f039223 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Mon, 31 Oct 2016 18:00:15 +0000 Subject: [PATCH] blockMesh: Added edge projection New functionality contributed by Mattijs Janssens: - new edge projection: projectCurve for use with new geometry 'searchableCurve' - new tutorial 'pipe' - naming of vertices and blocks (see pipe tutorial). Including back substitution for error messages. --- .../meshes/meshShapes/cellShape/cellShape.H | 10 +- .../meshes/meshShapes/cellShape/cellShapeI.H | 18 + src/mesh/blockMesh/Make/files | 9 +- src/mesh/blockMesh/Make/options | 2 + .../blockDescriptor/blockDescriptor.C | 99 +++- .../blockDescriptor/blockDescriptor.H | 26 ++ .../blockDescriptor/blockDescriptorI.H | 6 + .../blockDescriptorTemplates.C | 114 +++++ .../blockEdges/BSplineEdge/BSplineEdge.C | 4 +- .../blockEdges/BSplineEdge/BSplineEdge.H | 2 + .../blockMesh/blockEdges/arcEdge/arcEdge.C | 4 +- .../blockMesh/blockEdges/arcEdge/arcEdge.H | 2 + .../blockEdges/blockEdge/blockEdge.C | 30 +- .../blockEdges/blockEdge/blockEdge.H | 26 +- .../blockMesh/blockEdges/lineEdge/lineEdge.C | 4 +- .../blockMesh/blockEdges/lineEdge/lineEdge.H | 2 + .../blockEdges/polyLineEdge/polyLineEdge.C | 4 +- .../blockEdges/polyLineEdge/polyLineEdge.H | 2 + .../projectCurveEdge/projectCurveEdge.C | 255 +++++++++++ .../projectCurveEdge/projectCurveEdge.H | 128 ++++++ .../blockEdges/projectEdge/projectEdge.C | 131 ++++-- .../blockEdges/projectEdge/projectEdge.H | 2 + .../blockEdges/splineEdge/splineEdge.C | 4 +- .../blockEdges/splineEdge/splineEdge.H | 2 + .../blockFaces/blockFace/blockFace.C | 50 +- .../blockFaces/blockFace/blockFace.H | 26 +- .../blockFaces/projectFace/projectFace.C | 278 ++++++++++- .../blockFaces/projectFace/projectFace.H | 18 + src/mesh/blockMesh/blockMesh/blockMesh.C | 2 +- src/mesh/blockMesh/blockMesh/blockMesh.H | 2 +- src/mesh/blockMesh/blockMesh/blockMeshCheck.C | 26 +- .../blockMesh/blockMesh/blockMeshTopology.C | 31 +- .../blockVertices/blockVertex/blockVertex.C | 8 +- .../blockVertices/blockVertex/blockVertex.H | 16 +- .../blockVertices/namedVertex/namedVertex.C | 81 ++++ .../blockVertices/namedVertex/namedVertex.H | 104 +++++ .../blockVertices/pointVertex/pointVertex.C | 2 + .../blockVertices/pointVertex/pointVertex.H | 2 + .../projectVertex/projectVertex.C | 9 +- .../projectVertex/projectVertex.H | 2 + src/mesh/blockMesh/{ => blocks}/block/block.C | 55 ++- src/mesh/blockMesh/{ => blocks}/block/block.H | 50 +- .../{ => blocks}/block/blockCreate.C | 0 .../blockMesh/{ => blocks}/block/blockI.H | 0 .../blockMesh/{ => blocks}/block/blockList.H | 3 +- .../blockMesh/blocks/namedBlock/namedBlock.C | 75 +++ .../blockMesh/blocks/namedBlock/namedBlock.H | 91 ++++ .../searchableCurve/searchableCurve.C | 432 ++++++++++++++++++ .../searchableCurve/searchableCurve.H | 245 ++++++++++ tutorials/mesh/blockMesh/pipe/Allrun | 9 + .../pipe/constant/triSurface/curve.obj | 9 + .../pipe/constant/triSurface/curve2.vtk | 13 + .../mesh/blockMesh/pipe/system/blockMeshDict | 177 +++++++ .../mesh/blockMesh/pipe/system/controlDict | 58 +++ .../mesh/blockMesh/pipe/system/fvSchemes | 37 ++ .../mesh/blockMesh/pipe/system/fvSolution | 18 + 56 files changed, 2701 insertions(+), 114 deletions(-) create mode 100644 src/mesh/blockMesh/blockDescriptor/blockDescriptorTemplates.C create mode 100644 src/mesh/blockMesh/blockEdges/projectCurveEdge/projectCurveEdge.C create mode 100644 src/mesh/blockMesh/blockEdges/projectCurveEdge/projectCurveEdge.H create mode 100644 src/mesh/blockMesh/blockVertices/namedVertex/namedVertex.C create mode 100644 src/mesh/blockMesh/blockVertices/namedVertex/namedVertex.H rename src/mesh/blockMesh/{ => blocks}/block/block.C (61%) rename src/mesh/blockMesh/{ => blocks}/block/block.H (78%) rename src/mesh/blockMesh/{ => blocks}/block/blockCreate.C (100%) rename src/mesh/blockMesh/{ => blocks}/block/blockI.H (100%) rename src/mesh/blockMesh/{ => blocks}/block/blockList.H (95%) create mode 100644 src/mesh/blockMesh/blocks/namedBlock/namedBlock.C create mode 100644 src/mesh/blockMesh/blocks/namedBlock/namedBlock.H create mode 100644 src/mesh/blockMesh/searchableCurve/searchableCurve.C create mode 100644 src/mesh/blockMesh/searchableCurve/searchableCurve.H create mode 100755 tutorials/mesh/blockMesh/pipe/Allrun create mode 100644 tutorials/mesh/blockMesh/pipe/constant/triSurface/curve.obj create mode 100644 tutorials/mesh/blockMesh/pipe/constant/triSurface/curve2.vtk create mode 100644 tutorials/mesh/blockMesh/pipe/system/blockMeshDict create mode 100644 tutorials/mesh/blockMesh/pipe/system/controlDict create mode 100644 tutorials/mesh/blockMesh/pipe/system/fvSchemes create mode 100644 tutorials/mesh/blockMesh/pipe/system/fvSolution diff --git a/src/OpenFOAM/meshes/meshShapes/cellShape/cellShape.H b/src/OpenFOAM/meshes/meshShapes/cellShape/cellShape.H index 371d95a063..653da9c46d 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellShape/cellShape.H +++ b/src/OpenFOAM/meshes/meshShapes/cellShape/cellShape.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -92,6 +92,14 @@ public: const bool doCollapse = false ); + //- Construct from components + inline cellShape + ( + const word& model, + const labelList&, + const bool doCollapse = false + ); + //- Construct from Istream inline cellShape(Istream& is); diff --git a/src/OpenFOAM/meshes/meshShapes/cellShape/cellShapeI.H b/src/OpenFOAM/meshes/meshShapes/cellShape/cellShapeI.H index 5120cd4dfa..42055e04c9 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellShape/cellShapeI.H +++ b/src/OpenFOAM/meshes/meshShapes/cellShape/cellShapeI.H @@ -25,6 +25,7 @@ License #include "Istream.H" #include "cell.H" +#include "cellModeller.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -51,6 +52,23 @@ inline Foam::cellShape::cellShape } +inline Foam::cellShape::cellShape +( + const word& model, + const labelList& l, + const bool doCollapse +) +: + labelList(l), + m(cellModeller::lookup(model)) +{ + if (doCollapse) + { + collapse(); + } +} + + inline Foam::cellShape::cellShape(Istream& is) { is >> *this; diff --git a/src/mesh/blockMesh/Make/files b/src/mesh/blockMesh/Make/files index 4d1da72068..f552dec8f9 100644 --- a/src/mesh/blockMesh/Make/files +++ b/src/mesh/blockMesh/Make/files @@ -1,6 +1,7 @@ blockVertices/blockVertex/blockVertex.C blockVertices/pointVertex/pointVertex.C blockVertices/projectVertex/projectVertex.C +blockVertices/namedVertex/namedVertex.C blockEdges/blockEdge/blockEdge.C blockEdges/lineDivide/lineDivide.C @@ -13,6 +14,7 @@ blockEdges/BSplineEdge/BSplineEdge.C blockEdges/splineEdge/CatmullRomSpline.C blockEdges/splineEdge/splineEdge.C blockEdges/projectEdge/projectEdge.C +blockEdges/projectCurveEdge/projectCurveEdge.C blockFaces/blockFace/blockFace.C blockFaces/projectFace/projectFace.C @@ -23,8 +25,9 @@ gradingDescriptor/gradingDescriptors.C blockDescriptor/blockDescriptor.C blockDescriptor/blockDescriptorEdges.C -block/block.C -block/blockCreate.C +blocks/block/block.C +blocks/block/blockCreate.C +blocks/namedBlock/namedBlock.C blockMesh/blockMesh.C blockMesh/blockMeshCreate.C @@ -33,4 +36,6 @@ blockMesh/blockMeshCheck.C blockMesh/blockMeshMerge.C blockMesh/blockMeshMergeFast.C +searchableCurve/searchableCurve.C + LIB = $(FOAM_LIBBIN)/libblockMesh diff --git a/src/mesh/blockMesh/Make/options b/src/mesh/blockMesh/Make/options index bf6ca71abf..5467dc3ce3 100644 --- a/src/mesh/blockMesh/Make/options +++ b/src/mesh/blockMesh/Make/options @@ -1,9 +1,11 @@ EXE_INC = \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/fileFormats/lnInclude \ + -I$(LIB_SRC)/edgeMesh/lnInclude \ -I$(LIB_SRC)/surfMesh/lnInclude LIB_LIBS = \ -lmeshTools \ -lfileFormats \ + -ledgeMesh \ -lsurfMesh diff --git a/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C b/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C index fb9a413013..ddcb9466e0 100644 --- a/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C +++ b/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C @@ -128,6 +128,90 @@ void Foam::blockDescriptor::findCurvedFaces() } +void Foam::blockDescriptor::read +( + Istream& is, + label& val, + const dictionary& dict +) +{ + token t(is); + if (t.isLabel()) + { + val = t.labelToken(); + } + else if (t.isWord()) + { + const word& varName = t.wordToken(); + const entry* ePtr = dict.lookupScopedEntryPtr + ( + varName, + true, + true + ); + if (ePtr) + { + // Read as label + val = Foam::readLabel(ePtr->stream()); + } + else + { + FatalIOErrorInFunction(is) + << "Undefined variable " + << varName << ". Valid variables are " << dict + << exit(FatalIOError); + } + } + else + { + FatalIOErrorInFunction(is) + << "Illegal token " << t.info() + << " when trying to read label" + << exit(FatalIOError); + } + + is.fatalCheck + ( + "operator>>(Istream&, List&) : reading entry" + ); +} + + +Foam::label Foam::blockDescriptor::read +( + Istream& is, + const dictionary& dict +) +{ + label val; + read(is, val, dict); + return val; +} + + +void Foam::blockDescriptor::write +( + Ostream& os, + const label val, + const dictionary& dict +) +{ + forAllConstIter(dictionary, dict, iter) + { + if (iter().isStream()) + { + label keyVal(Foam::readLabel(iter().stream())); + if (keyVal == val) + { + os << iter().keyword(); + return; + } + } + } + os << val; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::blockDescriptor::blockDescriptor @@ -164,6 +248,8 @@ Foam::blockDescriptor::blockDescriptor Foam::blockDescriptor::blockDescriptor ( + const dictionary& dict, + const label index, const pointField& vertices, const blockEdgeList& edges, const blockFaceList& faces, @@ -173,13 +259,24 @@ Foam::blockDescriptor::blockDescriptor vertices_(vertices), edges_(edges), faces_(faces), - blockShape_(is), density_(), expand_(12, gradingDescriptors()), zoneName_(), curvedFaces_(-1), nCurvedFaces_(0) { + // Read cell model and list of vertices (potentially with variables) + word model(is); + blockShape_ = cellShape + ( + model, + read