diff --git a/applications/solvers/combustion/chemFoam/createSingleCellMesh.H b/applications/solvers/combustion/chemFoam/createSingleCellMesh.H index a01b5a75d0..45fe584d54 100644 --- a/applications/solvers/combustion/chemFoam/createSingleCellMesh.H +++ b/applications/solvers/combustion/chemFoam/createSingleCellMesh.H @@ -1,4 +1,3 @@ Info<< "Constructing single cell mesh" << nl << endl; -autoPtr meshPtr = dummyFvMesh::singleCellMesh(runTime); -fvMesh& mesh = meshPtr(); +Foam::proxyMeshes::hexCellFvMesh mesh(runTime); diff --git a/src/OpenFOAM/include/createMesh.H b/src/OpenFOAM/include/createMesh.H index 9468e82200..a91c970732 100644 --- a/src/OpenFOAM/include/createMesh.H +++ b/src/OpenFOAM/include/createMesh.H @@ -9,7 +9,7 @@ if (args.optionFound("dry-run") || args.optionFound("dry-run-write")) Foam::FieldBase::allowConstructFromLargerSize = true; // Create a simplified 1D mesh and attempt to re-create boundary conditions - meshPtr.reset(Foam::dummyFvMesh::equivalent1DMesh(runTime)); + meshPtr.reset(new Foam::proxyMeshes::columnFvMesh(runTime)); // Stopping after 1 iteration of the simplified mesh // Note: using saNoWriteNow will only trigger the function object execute diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index cde0f47b9e..ec674a23c5 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -3,7 +3,9 @@ fvMesh/fvMesh.C fvMesh/singleCellFvMesh/singleCellFvMesh.C -fvMesh/dummyFvMesh/dummyFvMesh.C +fvMesh/proxyFvMesh/proxyFvMesh.C +fvMesh/proxyFvMesh/columnFvMesh.C +fvMesh/proxyFvMesh/hexCellFvMesh.C fvBoundaryMesh = fvMesh/fvBoundaryMesh $(fvBoundaryMesh)/fvBoundaryMesh.C diff --git a/src/finiteVolume/cfdTools/general/include/fvCFD.H b/src/finiteVolume/cfdTools/general/include/fvCFD.H index 5fc2f56e45..7a6ee39aff 100644 --- a/src/finiteVolume/cfdTools/general/include/fvCFD.H +++ b/src/finiteVolume/cfdTools/general/include/fvCFD.H @@ -21,7 +21,10 @@ #include "findRefCell.H" #include "IOMRFZoneList.H" #include "constants.H" -#include "dummyFvMesh.H" + +#include "proxyFvMesh.H" +#include "columnFvMesh.H" +#include "hexCellFvMesh.H" #include "OSspecific.H" #include "argList.H" diff --git a/src/finiteVolume/fvMesh/dummyFvMesh/dummyFvMesh.C b/src/finiteVolume/fvMesh/proxyFvMesh/columnFvMesh.C similarity index 55% rename from src/finiteVolume/fvMesh/dummyFvMesh/dummyFvMesh.C rename to src/finiteVolume/fvMesh/proxyFvMesh/columnFvMesh.C index 4813c5dd66..a103451dfc 100644 --- a/src/finiteVolume/fvMesh/dummyFvMesh/dummyFvMesh.C +++ b/src/finiteVolume/fvMesh/proxyFvMesh/columnFvMesh.C @@ -23,122 +23,45 @@ License \*---------------------------------------------------------------------------*/ -#include "dummyFvMesh.H" -#include "Time.H" +#include "columnFvMesh.H" #include "polyBoundaryMeshEntries.H" #include "IOobjectList.H" #include "fieldDictionary.H" -#include "topoSet.H" - -#include "calculatedFvPatchField.H" +#include "vectorIOField.H" #include "emptyPolyPatch.H" -#include "processorPolyPatch.H" -#include "processorCyclicPolyPatch.H" -#include "cyclicPolyPatch.H" -#include "cyclicAMIPolyPatch.H" -#include "cyclicACMIPolyPatch.H" - -#include "fvPatchField.H" -#include "pointPatchField.H" +#include "topoSet.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * // namespace Foam { -defineTypeNameAndDebug(dummyFvMesh, 0); -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool Foam::dummyFvMesh::fvPatchFieldExists(const word& patchType) +namespace proxyMeshes { - if - ( - fvPatchField::dictionaryConstructorTablePtr_->found(patchType) - || fvPatchField::dictionaryConstructorTablePtr_->found(patchType) - || fvPatchField:: - dictionaryConstructorTablePtr_->found(patchType) - || fvPatchField:: - dictionaryConstructorTablePtr_->found(patchType) - || fvPatchField::dictionaryConstructorTablePtr_->found(patchType) - ) - { - return true; - } + defineTypeNameAndDebug(columnFvMeshInfo, 0); + defineTypeNameAndDebug(columnFvMesh, 0); - return false; + addToRunTimeSelectionTable + ( + proxyFvMesh, + columnFvMesh, + time + ); } - -Foam::autoPtr Foam::dummyFvMesh::singleCellMesh -( - const Time& runTime, - const scalar d -) -{ - pointField points(8); - points[0] = vector(0, 0, 0); - points[1] = vector(d, 0, 0); - points[2] = vector(d, d, 0); - points[3] = vector(0, d, 0); - points[4] = vector(0, 0, d); - points[5] = vector(d, 0, d); - points[6] = vector(d, d, d); - points[7] = vector(0, d, d); - - faceList faces = cellModel::ref(cellModel::HEX).modelFaces(); - - autoPtr meshPtr - ( - new Foam::fvMesh - ( - IOobject - ( - polyMesh::defaultRegion, - runTime.timeName(), - runTime, - IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE - ), - std::move(points), - std::move(faces), - labelList(6, Zero), - labelList() - ) - ); - - fvMesh& mesh = meshPtr(); - - List patches(1); - - patches[0] = new emptyPolyPatch - ( - "boundary", - 6, - 0, - 0, - mesh.boundaryMesh(), - emptyPolyPatch::typeName - ); - - mesh.addFvPatches(patches); - - return meshPtr; } -bool Foam::dummyFvMesh::setPatchEntries +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +bool Foam::proxyMeshes::columnFvMeshInfo::setPatchEntries ( - const Time& runTime, - const word& instance, - dictionary& patchEntries, - label& nPatchWithFace + const Time& runTime ) { IOobject boundaryIO ( "boundary", - instance, + localInstance_, polyMesh::meshSubDir, runTime, IOobject::MUST_READ, @@ -152,7 +75,7 @@ bool Foam::dummyFvMesh::setPatchEntries { polyBoundaryMeshEntries allPatchEntries(boundaryIO); - Info<< "Creating dummy mesh using " << allPatchEntries.path() << endl; + Info<< "Creating proxy mesh using " << allPatchEntries.path() << endl; for (const entry& e : allPatchEntries) { @@ -162,9 +85,9 @@ bool Foam::dummyFvMesh::setPatchEntries { if (readLabel(e.dict().lookup("nFaces"))) { - ++nPatchWithFace; + ++nPatchWithFace_; } - patchEntries.add(e.keyword(), e.dict()); + patchEntries_.add(e.keyword(), e.dict()); } } @@ -192,7 +115,7 @@ bool Foam::dummyFvMesh::setPatchEntries const fieldDictionary fieldDict(io, io.headerClassName()); - Info<< "Creating dummy mesh from field " + Info<< "Creating proxy mesh from field " << fieldDict.objectPath() << endl; @@ -203,17 +126,17 @@ bool Foam::dummyFvMesh::setPatchEntries { const word type(e.dict().lookup("type")); - if (fvPatchFieldExists(type)) + if (proxyFvMesh::fvPatchFieldExists(type)) { if (!constraintPatches.found(type)) { - ++nPatchWithFace; - dictionary dummyEntries; - dummyEntries.add("startFace", 0); - dummyEntries.add("nFaces", 1); - dummyEntries.add("type", "wall"); // default to wall type + ++nPatchWithFace_; + dictionary proxyEntries; + proxyEntries.add("startFace", 0); + proxyEntries.add("nFaces", 1); + proxyEntries.add("type", "wall"); // default to wall type - patchEntries.add(e.keyword(), dummyEntries); + patchEntries_.add(e.keyword(), proxyEntries); } } else @@ -227,28 +150,14 @@ bool Foam::dummyFvMesh::setPatchEntries } -Foam::autoPtr Foam::dummyFvMesh::equivalent1DMesh -( - const Time& runTime -) +void Foam::proxyMeshes::columnFvMeshInfo::initialise(const Time& runTime) { DebugInfo << "Constructing 1-D mesh" << nl << endl; - const word instance = - runTime.findInstance - ( - polyMesh::meshSubDir, - "boundary", - IOobject::READ_IF_PRESENT - ); - // Read patches - filter out proc patches for parallel runs - dictionary patchEntries; - label nPatchWithFace = 0; - bool createFromMesh = - setPatchEntries(runTime, instance, patchEntries, nPatchWithFace); + createFromMesh_ = setPatchEntries(runTime); - const label nPatch = patchEntries.size(); + const label nPatch = patchEntries_.size(); DebugPout << "Read " << nPatch << " patches" << endl; @@ -272,11 +181,11 @@ Foam::autoPtr Foam::dummyFvMesh::equivalent1DMesh // - rotational cyclic - convert to separated and warn not handled? // - proc patches - faces need to be collocated? - pointField points(nPatchWithFace*4 + 4); - faceList faces(nPatchWithFace*5 + 1); + points1D_.setSize(nPatchWithFace_*4 + 4); + faces1D_.setSize(nPatchWithFace_*5 + 1); - labelList owner(faces.size(), label(-1)); - labelList neighbour(owner); + owner1D_.setSize(faces1D_.size(), label(-1)); + neighbour1D_.setSize(owner1D_.size(), label(-1)); vector dx(Zero); { @@ -284,7 +193,7 @@ Foam::autoPtr Foam::dummyFvMesh::equivalent1DMesh IOobject pointsIO ( "points", - instance, + localInstance_, polyMesh::meshSubDir, runTime, IOobject::MUST_READ, @@ -307,7 +216,7 @@ Foam::autoPtr Foam::dummyFvMesh::equivalent1DMesh origin = meshBb.min(); vector span = meshBb.span(); - dxi = span.x()/scalar(nPatchWithFace); + dxi = span.x()/scalar(nPatchWithFace_); dyi = span.y(); dzi = span.z(); } @@ -315,7 +224,7 @@ Foam::autoPtr Foam::dummyFvMesh::equivalent1DMesh { scalar Lref = GREAT; origin = point(-Lref, -Lref, -Lref); - dxi = 2.0*Lref/scalar(nPatchWithFace); + dxi = 2.0*Lref/scalar(nPatchWithFace_); dyi = Lref; dzi = Lref; } @@ -325,109 +234,139 @@ Foam::autoPtr Foam::dummyFvMesh::equivalent1DMesh const vector dz(0, 0, dzi); // End face - points[0] = origin; - points[1] = origin + dy; - points[2] = origin + dy + dz; - points[3] = origin + dz; + points1D_[0] = origin; + points1D_[1] = origin + dy; + points1D_[2] = origin + dy + dz; + points1D_[3] = origin + dz; } label n = 4; - for (label i = 1; i <= nPatchWithFace; ++i) + for (label i = 1; i <= nPatchWithFace_; ++i) { const vector idx(i*dx); - points[i*n] = points[0] + idx; - points[i*n + 1] = points[1] + idx; - points[i*n + 2] = points[2] + idx; - points[i*n + 3] = points[3] + idx; + points1D_[i*n] = points1D_[0] + idx; + points1D_[i*n + 1] = points1D_[1] + idx; + points1D_[i*n + 2] = points1D_[2] + idx; + points1D_[i*n + 3] = points1D_[3] + idx; } - if (debug) Pout<< "points:" << points << endl; + if (debug) Pout<< "points:" << points1D_ << endl; label facei = 0; // Internal faces first - for (label i = 0; i < nPatchWithFace - 1; ++i) + for (label i = 0; i < nPatchWithFace_ - 1; ++i) { label o = i*4; - faces[facei] = face({4 + o, 5 + o, 6 + o, 7 + o}); - owner[facei] = i; - neighbour[facei] = i + 1; + faces1D_[facei] = face({4 + o, 5 + o, 6 + o, 7 + o}); + owner1D_[facei] = i; + neighbour1D_[facei] = i + 1; ++facei; } // Boundary conditions - for (label i = 0; i < nPatchWithFace; ++i) + for (label i = 0; i < nPatchWithFace_; ++i) { label o = i*4; - faces[facei] = face({0 + o, 4 + o, 7 + o, 3 + o}); - owner[facei] = i; + faces1D_[facei] = face({0 + o, 4 + o, 7 + o, 3 + o}); + owner1D_[facei] = i; ++facei; - faces[facei] = face({0 + o, 1 + o, 5 + o, 4 + o}); - owner[facei] = i; + faces1D_[facei] = face({0 + o, 1 + o, 5 + o, 4 + o}); + owner1D_[facei] = i; ++facei; - faces[facei] = face({1 + o, 2 + o, 6 + o, 5 + o}); - owner[facei] = i; + faces1D_[facei] = face({1 + o, 2 + o, 6 + o, 5 + o}); + owner1D_[facei] = i; ++facei; - faces[facei] = face({3 + o, 7 + o, 6 + o, 2 + o}); - owner[facei] = i; + faces1D_[facei] = face({3 + o, 7 + o, 6 + o, 2 + o}); + owner1D_[facei] = i; ++facei; } { // End caps - faces[facei] = face({0, 3, 2, 1}); - owner[facei] = 0; + faces1D_[facei] = face({0, 3, 2, 1}); + owner1D_[facei] = 0; ++facei; - label o = 4*nPatchWithFace; - faces[facei] = face({0 + o, 1 + o, 2 + o, 3 + o}); - owner[facei] = nPatchWithFace - 1; + label o = 4*nPatchWithFace_; + faces1D_[facei] = face({0 + o, 1 + o, 2 + o, 3 + o}); + owner1D_[facei] = nPatchWithFace_ - 1; ++facei; } DebugPout - << "faces:" << faces << nl - << "owner:" << owner << nl - << "neighbour:" << neighbour + << "faces:" << faces1D_ << nl + << "owner:" << owner1D_ << nl + << "neighbour:" << neighbour1D_ << endl; +} - autoPtr meshPtr + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::proxyMeshes::columnFvMeshInfo::columnFvMeshInfo(const Time& runTime) +: + localInstance_ ( - new Foam::fvMesh + runTime.findInstance ( - IOobject - ( - fvMesh::defaultRegion, - runTime.constant(), - runTime, - IOobject::NO_READ, // Do not read any existing mesh - IOobject::NO_WRITE - ), - std::move(points), - std::move(faces), - std::move(owner), - std::move(neighbour) + polyMesh::meshSubDir, + "boundary", + IOobject::READ_IF_PRESENT ) - ); + ), + createFromMesh_(false), + points1D_(), + faces1D_(), + owner1D_(), + neighbour1D_(), + patchEntries_(), + nPatchWithFace_(0) +{ + initialise(runTime); +} - Foam::fvMesh& mesh = meshPtr(); - // Workaround to read fvSchemes and fvSolution +Foam::proxyMeshes::columnFvMesh::columnFvMesh(const Time& runTime) +: + columnFvMeshInfo(runTime), + proxyFvMesh + ( + IOobject + ( + fvMesh::defaultRegion, + runTime.constant(), + runTime, + IOobject::NO_READ, // Do not read any existing mesh + IOobject::NO_WRITE + ), + std::move(points1D_), + std::move(faces1D_), + std::move(owner1D_), + std::move(neighbour1D_) + ) +{ + // Workaround to read fvSchemes and fvSolution after setting NO_READ + // when creating the mesh { - mesh.fvSchemes::readOpt() = IOobject::MUST_READ; - mesh.fvSchemes::read(); - mesh.fvSolution::readOpt() = IOobject::MUST_READ; - mesh.fvSolution::read(); + fvSchemes::readOpt() = IOobject::MUST_READ; + fvSchemes::read(); + fvSolution::readOpt() = IOobject::MUST_READ; + fvSolution::read(); } + // Add the patches + + const label nPatch = patchEntries_.size(); + List patches(nPatch + 1); - label nInternalFace = nPatchWithFace - 1; + label nInternalFace = nPatchWithFace_ - 1; label startFace = nInternalFace; label entryi = 0; - for (const entry& e : patchEntries) + for (const entry& e : patchEntries_) { // Re-create boundary types, but reset nFaces and startFace settings dictionary patchDict = e.dict(); @@ -451,7 +390,7 @@ Foam::autoPtr Foam::dummyFvMesh::equivalent1DMesh patchName, patchDict, entryi, - mesh.boundaryMesh() + boundaryMesh() ).ptr(); ++entryi; @@ -462,13 +401,13 @@ Foam::autoPtr Foam::dummyFvMesh::equivalent1DMesh ( typeName + ":default", // name 2, // number of faces - nInternalFace + 4*nPatchWithFace, // start face + nInternalFace + 4*nPatchWithFace_, // start face nPatch - 1, // index in boundary list - mesh.boundaryMesh(), // polyBoundaryMesh + boundaryMesh(), // polyBoundaryMesh emptyPolyPatch::typeName // patchType ); - mesh.addFvPatches(patches); + addFvPatches(patches); if (debug) { @@ -480,12 +419,14 @@ Foam::autoPtr Foam::dummyFvMesh::equivalent1DMesh } } - if (createFromMesh) + // Add the zones + + if (createFromMesh_) { // Initialise the zones - initialiseZone("point", instance, mesh.pointZones()); - initialiseZone("face", instance, mesh.faceZones()); - initialiseZone("cell", instance, mesh.cellZones()); + initialiseZone("point", localInstance_, pointZones()); + initialiseZone("face", localInstance_, faceZones()); + initialiseZone("cell", localInstance_, cellZones()); // Dummy sets created on demand topoSet::disallowGenericSets = 1; @@ -499,11 +440,9 @@ Foam::autoPtr Foam::dummyFvMesh::equivalent1DMesh if (debug) { - mesh.setInstance(runTime.timeName()); - mesh.objectRegistry::write(); + setInstance(runTime.timeName()); + objectRegistry::write(); } - - return meshPtr; } diff --git a/src/finiteVolume/fvMesh/proxyFvMesh/columnFvMesh.H b/src/finiteVolume/fvMesh/proxyFvMesh/columnFvMesh.H new file mode 100644 index 0000000000..2ab775b294 --- /dev/null +++ b/src/finiteVolume/fvMesh/proxyFvMesh/columnFvMesh.H @@ -0,0 +1,133 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 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 3 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, see . + +Class + Foam::proxyMeshes::columnFvMesh + +Description + Generates a 1D column representation of a mesh based on an existing mesh + and/or fields + +SourceFiles + columnFvMesh.C + +\*---------------------------------------------------------------------------*/ + +#ifndef proxyMeshes_columnFvMesh_H +#define proxyMeshes_columnFvMesh_H + +#include "proxyFvMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace proxyMeshes +{ + +/*---------------------------------------------------------------------------*\ + Class columnFvMesh Declaration +\*---------------------------------------------------------------------------*/ + +class columnFvMeshInfo +{ + // Private Member Funtions + + //- Set the patch dictionary entries using the mesh or field files + bool setPatchEntries(const Time& runTime); + + //- Initialise + void initialise(const Time& runTime); + + +protected: + + // Protected data + + //- Location of existing mesh (if present) + const word localInstance_; + + //- Created from existing mesh (false = from field) + bool createFromMesh_; + + // Temporary mesh data used during construction of columnFvMesh + // Note: transferred to columnFvMesh + + //- Points + pointField points1D_; + + //- Faces + faceList faces1D_; + + //- Owner addressing + labelList owner1D_; + + //- Neighbour addressing + labelList neighbour1D_; + + + // Patch data + + //- Dictionary of patch information + dictionary patchEntries_; + + //- Number of patches with at least 1 local face + label nPatchWithFace_; + + +public: + + //- Runtime type information + ClassName("columnFvMeshInfo"); + + // Constructor + columnFvMeshInfo(const Time& runTime); +}; + + +class columnFvMesh +: + public columnFvMeshInfo, + public proxyFvMesh +{ + +public: + + //- Runtime type information + TypeName("columnFvMesh"); + + //- Constructor + columnFvMesh(const Time& runTime); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace proxyMeshes +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/proxyFvMesh/hexCellFvMesh.C b/src/finiteVolume/fvMesh/proxyFvMesh/hexCellFvMesh.C new file mode 100644 index 0000000000..d9a8a9ddbd --- /dev/null +++ b/src/finiteVolume/fvMesh/proxyFvMesh/hexCellFvMesh.C @@ -0,0 +1,100 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "hexCellFvMesh.H" +#include "emptyPolyPatch.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace proxyMeshes +{ + defineTypeNameAndDebug(hexCellFvMesh, 0); + + addToRunTimeSelectionTable + ( + proxyFvMesh, + hexCellFvMesh, + time + ); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::proxyMeshes::hexCellFvMesh::hexCellFvMesh +( + const Time& runTime, + const scalar d +) +: + proxyFvMesh + ( + IOobject + ( + polyMesh::defaultRegion, + runTime.timeName(), + runTime, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE + ), + pointField + ( + { + point(0, 0, 0), + point(d, 0, 0), + point(d, d, 0), + point(0, d, 0), + point(0, 0, d), + point(d, 0, d), + point(d, d, d), + point(0, d, d) + } + ), + faceList(cellModel::ref(cellModel::HEX).modelFaces()), + labelList(6, Zero), + labelList() + ) +{ + List patches(1); + + patches[0] = new emptyPolyPatch + ( + "boundary", + 6, + 0, + 0, + boundaryMesh(), + emptyPolyPatch::typeName + ); + + addFvPatches(patches); +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/proxyFvMesh/hexCellFvMesh.H b/src/finiteVolume/fvMesh/proxyFvMesh/hexCellFvMesh.H new file mode 100644 index 0000000000..b8687efb2b --- /dev/null +++ b/src/finiteVolume/fvMesh/proxyFvMesh/hexCellFvMesh.H @@ -0,0 +1,75 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 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 3 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, see . + +Class + Foam::proxyMeshes::hexCellFvMesh + +Description + Generates a single hex cell representation of a mesh + +SourceFiles + hexCellFvMesh.C + +\*---------------------------------------------------------------------------*/ + +#ifndef proxyMeshes_hexCellFvMesh_H +#define proxyMeshes_hexCellFvMesh_H + +#include "proxyFvMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace proxyMeshes +{ + +/*---------------------------------------------------------------------------*\ + Class hexCellFvMesh Declaration +\*---------------------------------------------------------------------------*/ + +class hexCellFvMesh +: + public proxyFvMesh +{ + +public: + + //- Runtime type information + TypeName("hexCellFvMesh"); + + //- Constructor + hexCellFvMesh(const Time& runTime, const scalar d = 1); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace proxyMeshes +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/proxyFvMesh/proxyFvMesh.C b/src/finiteVolume/fvMesh/proxyFvMesh/proxyFvMesh.C new file mode 100644 index 0000000000..25ada4281e --- /dev/null +++ b/src/finiteVolume/fvMesh/proxyFvMesh/proxyFvMesh.C @@ -0,0 +1,104 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "proxyFvMesh.H" +#include "fvPatchField.H" + +// * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * // + +namespace Foam +{ +defineTypeNameAndDebug(proxyFvMesh, 0); +defineRunTimeSelectionTable(proxyFvMesh, time); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::proxyFvMesh::fvPatchFieldExists(const word& patchType) +{ + if + ( + fvPatchField::dictionaryConstructorTablePtr_->found(patchType) + || fvPatchField::dictionaryConstructorTablePtr_->found(patchType) + || fvPatchField:: + dictionaryConstructorTablePtr_->found(patchType) + || fvPatchField:: + dictionaryConstructorTablePtr_->found(patchType) + || fvPatchField::dictionaryConstructorTablePtr_->found(patchType) + ) + { + return true; + } + + return false; +} + + +Foam::proxyFvMesh::proxyFvMesh +( + const IOobject& io, + pointField&& points, + faceList&& faces, + labelList&& allOwner, + labelList&& allNeighbour +) +: + fvMesh + ( + io, + std::move(points), + std::move(faces), + std::move(allOwner), + std::move(allNeighbour) + ) +{} + + +Foam::autoPtr Foam::proxyFvMesh::New +( + const word& modelType, + const Time& runTime +) +{ + Info<< "Selecting proxy mesh model " << modelType << endl; + + auto cstrIter = timeConstructorTablePtr_->cfind(modelType); + + if (!cstrIter.found()) + { + FatalErrorInFunction + << "Unknown proxy mesh type " + << modelType << nl << nl + << "Valid dumy meshes :" << endl + << timeConstructorTablePtr_->sortedToc() + << exit(FatalError); + } + + return autoPtr(cstrIter()(runTime)); +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/dummyFvMesh/dummyFvMesh.H b/src/finiteVolume/fvMesh/proxyFvMesh/proxyFvMesh.H similarity index 61% rename from src/finiteVolume/fvMesh/dummyFvMesh/dummyFvMesh.H rename to src/finiteVolume/fvMesh/proxyFvMesh/proxyFvMesh.H index 3bf4475819..11abb1de49 100644 --- a/src/finiteVolume/fvMesh/dummyFvMesh/dummyFvMesh.H +++ b/src/finiteVolume/fvMesh/proxyFvMesh/proxyFvMesh.H @@ -22,54 +22,41 @@ License along with OpenFOAM. If not, see . Class - Foam::dummyFvMesh + Foam::proxyFvMesh Description - Functions to generate dummy finite volume meshes + Functions to generate proxy finite volume meshes SourceFiles - dummyFvMesh.C + proxyFvMesh.C \*---------------------------------------------------------------------------*/ -#ifndef dummyFvMesh_H -#define dummyFvMesh_H +#ifndef proxyFvMesh_H +#define proxyFvMesh_H -#include "className.H" -#include "autoPtr.H" -#include "HashSet.H" +#include "runTimeSelectionTables.H" +#include "fvMesh.H" +#include "Time.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -class fvMesh; -class Time; -template class List; - /*---------------------------------------------------------------------------*\ - Class dummyFvMesh Declaration + Class proxyFvMesh Declaration \*---------------------------------------------------------------------------*/ -class dummyFvMesh +class proxyFvMesh +: + public fvMesh { - //- Helper function to see if the patch type exists in the run-time - //- selection tables - static bool fvPatchFieldExists(const word& patchType); - - //- Set the patch information. Returns true if setting based on a real mesh - static bool setPatchEntries - ( - const Time& runTime, - const word& instance, - dictionary& patchEntries, - label& nPatchWithFace - ); +protected: //- Helper function to initialise empty zones template - static void initialiseZone + void initialiseZone ( const word& zoneTypeName, const fileName& instance, @@ -79,19 +66,49 @@ class dummyFvMesh public: - ClassName("dummyFvMesh"); + //- Runtime type information + TypeName("proxyFvMesh"); - //- Create a single cell mesh with empty boundary conditions all-round - static autoPtr singleCellMesh + // Declare run-time constructor selection table + + declareRunTimeSelectionTable + ( + autoPtr, + proxyFvMesh, + time, + ( + const Time& runTime + ), + (runTime) + ); + + + // Selectors + + //- Return a reference to the selected proxy mesh + static autoPtr New + ( + const word& modelType, + const Time& runTime + ); + + + //- Constructor + proxyFvMesh ( - const Time& runTime, - const scalar d = 1 + const IOobject& io, + pointField&& points, + faceList&& faces, + labelList&& allOwner, + labelList&& allNeighbour ); - //- Create an equivalent 1D mesh using the same boundary types as - //- described in the polyMesh/boundary file, complete with (empty) - //- [point|face|cell] zones - static autoPtr equivalent1DMesh(const Time& runTime); + + // Member Functions + + //- Helper function to see if the patch type exists in the run-time + //- selection tables + static bool fvPatchFieldExists(const word& patchType); }; @@ -102,7 +119,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #ifdef NoRepository - #include "dummyFvMeshTemplates.C" + #include "proxyFvMeshTemplates.C" #endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/fvMesh/dummyFvMesh/dummyFvMeshTemplates.C b/src/finiteVolume/fvMesh/proxyFvMesh/proxyFvMeshTemplates.C similarity index 98% rename from src/finiteVolume/fvMesh/dummyFvMesh/dummyFvMeshTemplates.C rename to src/finiteVolume/fvMesh/proxyFvMesh/proxyFvMeshTemplates.C index 4226fb7888..460e1d81b1 100644 --- a/src/finiteVolume/fvMesh/dummyFvMesh/dummyFvMeshTemplates.C +++ b/src/finiteVolume/fvMesh/proxyFvMesh/proxyFvMeshTemplates.C @@ -26,7 +26,7 @@ License #include "polyMesh.H" template -void Foam::dummyFvMesh::initialiseZone +void Foam::proxyFvMesh::initialiseZone ( const word& zoneTypeName, const fileName& instance,