diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtkPVblockMesh/vtkPVblockMesh.C b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtkPVblockMesh/vtkPVblockMesh.C index a9932ffcc9..dd40c8e359 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtkPVblockMesh/vtkPVblockMesh.C +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/vtkPVblockMesh/vtkPVblockMesh.C @@ -72,12 +72,17 @@ void Foam::vtkPVblockMesh::updateInfoBlocks arrayRangeBlocks_.reset( arraySelection->GetNumberOfArrays() ); const blockMesh& blkMesh = *meshPtr_; + const int nBlocks = blkMesh.size(); for (int blockI = 0; blockI < nBlocks; ++blockI) { const blockDescriptor& blockDef = blkMesh[blockI]; - word partName = Foam::name(blockI); + // Display either blockI as a number or with its name + // (looked up from blockMeshDict) + OStringStream os; + blockDescriptor::write(os, blockI, blkMesh.meshDict()); + word partName(os.str()); // append the (optional) zone name if (!blockDef.zoneName().empty()) @@ -121,9 +126,10 @@ void Foam::vtkPVblockMesh::updateInfoEdges forAll(edges, edgeI) { OStringStream ostr; - - ostr<< edges[edgeI].start() << ":" << edges[edgeI].end() << " - " - << edges[edgeI].type(); + blockVertex::write(ostr, edges[edgeI].start(), blkMesh.meshDict()); + ostr<< ":"; + blockVertex::write(ostr, edges[edgeI].end(), blkMesh.meshDict()); + ostr << " - " << edges[edgeI].type(); // Add "beg:end - type" to GUI list arraySelection->AddArray(ostr.str().c_str()); @@ -352,7 +358,9 @@ void Foam::vtkPVblockMesh::updateFoamMesh() dictPath = dbPtr_().constant()/polyMesh::meshSubDir/dictName; } - IOdictionary meshDict + // Store dictionary since is used as database inside blockMesh class + // for names of vertices and blocks + IOdictionary* meshDictPtr = new IOdictionary ( IOobject ( @@ -360,11 +368,12 @@ void Foam::vtkPVblockMesh::updateFoamMesh() dbPtr_(), IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE, - false + true ) ); + meshDictPtr->store(); - meshPtr_ = new blockMesh(meshDict, meshRegion_); + meshPtr_ = new blockMesh(*meshDictPtr, meshRegion_); } @@ -429,15 +438,22 @@ void Foam::vtkPVblockMesh::renderPointNumbers if (show && meshPtr_) { - const pointField& cornerPts = meshPtr_->vertices(); - const scalar scaleFactor = meshPtr_->scaleFactor(); + const blockMesh& blkMesh = *meshPtr_; + const pointField& cornerPts = blkMesh.vertices(); + const scalar scaleFactor = blkMesh.scaleFactor(); pointNumberTextActorsPtrs_.setSize(cornerPts.size()); forAll(cornerPts, pointi) { vtkTextActor* txt = vtkTextActor::New(); - txt->SetInput(Foam::name(pointi).c_str()); + // Display either pointi as a number or with its name + // (looked up from blockMeshDict) + { + OStringStream os; + blockVertex::write(os, pointi, blkMesh.meshDict()); + txt->SetInput(os.str().c_str()); + } // Set text properties vtkTextProperty* tprop = txt->GetTextProperty(); diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C index 6512ce1e2b..d039b07ca9 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.C +++ b/src/OpenFOAM/db/dictionary/dictionary.C @@ -630,6 +630,21 @@ const Foam::dictionary* Foam::dictionary::subDictPtr(const word& keyword) const } +Foam::dictionary* Foam::dictionary::subDictPtr(const word& keyword) +{ + entry* entryPtr = lookupEntryPtr(keyword, false, true); + + if (entryPtr) + { + return &entryPtr->dict(); + } + else + { + return nullptr; + } +} + + const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const { const entry* entryPtr = lookupEntryPtr(keyword, false, true); diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H index 14ed0db635..235a5aefc8 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.H +++ b/src/OpenFOAM/db/dictionary/dictionary.H @@ -379,6 +379,10 @@ public: // otherwise return nullptr. const dictionary* subDictPtr(const word&) const; + //- Find and return a sub-dictionary pointer if present + // otherwise return nullptr. + dictionary* subDictPtr(const word&); + //- Find and return a sub-dictionary const dictionary& subDict(const word&) const; diff --git a/src/mesh/blockMesh/Make/files b/src/mesh/blockMesh/Make/files index f552dec8f9..a6564d64ab 100644 --- a/src/mesh/blockMesh/Make/files +++ b/src/mesh/blockMesh/Make/files @@ -36,6 +36,8 @@ blockMesh/blockMeshCheck.C blockMesh/blockMeshMerge.C blockMesh/blockMeshMergeFast.C +blockMeshTools/blockMeshTools.C + searchableCurve/searchableCurve.C LIB = $(FOAM_LIBBIN)/libblockMesh diff --git a/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C b/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C index ddcb9466e0..7593b3763e 100644 --- a/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C +++ b/src/mesh/blockMesh/blockDescriptor/blockDescriptor.C @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "blockDescriptor.H" +#include "blockMeshTools.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -128,90 +129,6 @@ 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 @@ -270,7 +187,7 @@ Foam::blockDescriptor::blockDescriptor blockShape_ = cellShape ( model, - read