From d7e1d5c24d40d238ffb65d0467ae26064a757ded Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 4 May 2015 20:54:39 +0100 Subject: [PATCH] extrudeMesh: Add sector extrusion type and specialize wedge and plane to create single layer extrusions with wedge and empty front and back patches respectively. --- .../extrude/extrudeMesh/extrudeMesh.C | 83 +++++++++++- .../extrude/extrudeMesh/extrudeMeshDict | 19 ++- src/mesh/extrudeModel/Make/files | 3 + .../extrudeModel/cyclicSector/cyclicSector.C | 62 +++++++++ .../extrudeModel/cyclicSector/cyclicSector.H | 81 ++++++++++++ .../extrudeModel/extrudeModel/extrudeModel.C | 4 +- .../extrudeModel/extrudeModel/extrudeModel.H | 4 +- .../extrudeModel/linearNormal/linearNormal.H | 2 +- src/mesh/extrudeModel/plane/plane.C | 70 ++++++++++ src/mesh/extrudeModel/plane/plane.H | 82 ++++++++++++ src/mesh/extrudeModel/sector/sector.C | 125 ++++++++++++++++++ src/mesh/extrudeModel/sector/sector.H | 107 +++++++++++++++ src/mesh/extrudeModel/wedge/wedge.C | 77 ++--------- src/mesh/extrudeModel/wedge/wedge.H | 40 +----- 14 files changed, 646 insertions(+), 113 deletions(-) create mode 100644 src/mesh/extrudeModel/cyclicSector/cyclicSector.C create mode 100644 src/mesh/extrudeModel/cyclicSector/cyclicSector.H create mode 100644 src/mesh/extrudeModel/plane/plane.C create mode 100644 src/mesh/extrudeModel/plane/plane.H create mode 100644 src/mesh/extrudeModel/sector/sector.C create mode 100644 src/mesh/extrudeModel/sector/sector.H diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C index e1387379a4..0589ca5cec 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -36,12 +36,9 @@ Description #include "argList.H" #include "Time.H" -#include "dimensionedTypes.H" -#include "IFstream.H" #include "polyTopoChange.H" #include "polyTopoChanger.H" #include "edgeCollapser.H" -#include "globalMeshData.H" #include "perfectInterface.H" #include "addPatchCellLayer.H" #include "fvMesh.H" @@ -52,6 +49,11 @@ Description #include "extrudedMesh.H" #include "extrudeModel.H" +#include "wedge.H" +#include "wedgePolyPatch.H" +#include "plane.H" +#include "emptyPolyPatch.H" + using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -212,6 +214,52 @@ void updateCellSet(const mapPolyMesh& map, labelHashSet& cellLabels) } +template +void changeFrontBackPatches +( + polyMesh& mesh, + const word& frontPatchName, + const word& backPatchName +) +{ + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + + label frontPatchI = findPatchID(patches, frontPatchName); + label backPatchI = findPatchID(patches, backPatchName); + + DynamicList newPatches(patches.size()); + + forAll(patches, patchI) + { + const polyPatch& pp(patches[patchI]); + + if (patchI == frontPatchI || patchI == backPatchI) + { + newPatches.append + ( + new PatchType + ( + pp.name(), + pp.size(), + pp.start(), + pp.index(), + mesh.boundaryMesh(), + PatchType::typeName + ) + ); + } + else + { + newPatches.append(pp.clone(mesh.boundaryMesh()).ptr()); + } + } + + // Edit patches + mesh.removeBoundary(); + mesh.addPatches(newPatches, true); +} + + int main(int argc, char *argv[]) { #include "addRegionOption.H" @@ -583,8 +631,10 @@ int main(int argc, char *argv[]) // Layers per face labelList nFaceLayers(extrudePatch.size(), model().nLayers()); + // Layers per point labelList nPointLayers(extrudePatch.nPoints(), model().nLayers()); + // Displacement for first layer vectorField firstLayerDisp(displacement*model().sumThickness(1)); @@ -791,6 +841,31 @@ int main(int argc, char *argv[]) << endl; + // Change the front and back patch types as required + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + word frontBackType(word::null); + + if (isType(model())) + { + changeFrontBackPatches + ( + mesh, + frontPatchName, + backPatchName + ); + } + else if (isType(model())) + { + changeFrontBackPatches + ( + mesh, + frontPatchName, + backPatchName + ); + } + + // Collapse edges // ~~~~~~~~~~~~~~ diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMeshDict b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMeshDict index a355ede3da..0728864488 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMeshDict +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMeshDict @@ -26,8 +26,10 @@ constructFrom patch; // If construct from patch/mesh: sourceCase "../cavity"; sourcePatches (movingWall); + // If construct from patch: patch to use for back (can be same as sourcePatch) exposedPatchName movingWall; + // If construct from surface: surface "movingWall.stl"; @@ -38,10 +40,18 @@ flipNormals false; //- Linear extrusion in point-normal direction //extrudeModel linearNormal; +//- Single layer linear extrusion in point-normal direction +// with empty patches on front and back +//extrudeModel plane; + //- Linear extrusion in specified direction //extrudeModel linearDirection; -//- Wedge extrusion. If nLayers is 1 assumes symmetry around plane. +//- Sector extrusion +//extrudeModel sector; + +//- Wedge extrusion of a single layer +// with wedge patches on front and back extrudeModel wedge; //- Extrudes into sphere around (0 0 0) @@ -55,9 +65,9 @@ extrudeModel wedge; nLayers 10; -expansionRatio 1.0; //0.9; +expansionRatio 1.0; -wedgeCoeffs +sectorCoeffs { axisPt (0 0.1 -0.05); axis (-1 0 0); @@ -88,7 +98,6 @@ radialCoeffs R table ((0 0.01)(3 0.03)(10 0.1)); } - sigmaRadialCoeffs { RTbyg 1; @@ -98,7 +107,7 @@ sigmaRadialCoeffs // Do front and back need to be merged? Usually only makes sense for 360 // degree wedges. -mergeFaces false; //true; +mergeFaces false; // Merge small edges. Fraction of bounding box. mergeTol 0; diff --git a/src/mesh/extrudeModel/Make/files b/src/mesh/extrudeModel/Make/files index 600f591693..f7c9034f97 100644 --- a/src/mesh/extrudeModel/Make/files +++ b/src/mesh/extrudeModel/Make/files @@ -1,10 +1,13 @@ extrudeModel/extrudeModel.C extrudeModel/extrudeModelNew.C linearNormal/linearNormal.C +plane/plane.C linearDirection/linearDirection.C linearRadial/linearRadial.C radial/radial.C sigmaRadial/sigmaRadial.C +sector/sector.C +cyclicSector/cyclicSector.C wedge/wedge.C LIB = $(FOAM_LIBBIN)/libextrudeModel diff --git a/src/mesh/extrudeModel/cyclicSector/cyclicSector.C b/src/mesh/extrudeModel/cyclicSector/cyclicSector.C new file mode 100644 index 0000000000..2d2e65b9a3 --- /dev/null +++ b/src/mesh/extrudeModel/cyclicSector/cyclicSector.C @@ -0,0 +1,62 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation + \\/ 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 "cyclicSector.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace extrudeModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(cyclicSector, 0); + +addToRunTimeSelectionTable(extrudeModel, cyclicSector, dictionary); + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +cyclicSector::cyclicSector(const dictionary& dict) +: + sector(dict) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +cyclicSector::~cyclicSector() +{} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace extrudeModels +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/mesh/extrudeModel/cyclicSector/cyclicSector.H b/src/mesh/extrudeModel/cyclicSector/cyclicSector.H new file mode 100644 index 0000000000..590b923b01 --- /dev/null +++ b/src/mesh/extrudeModel/cyclicSector/cyclicSector.H @@ -0,0 +1,81 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation + \\/ 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::extrudeModels::cyclicSector + +Description + Extrudes a sector. + +SeeAlso + Foam::extrudeModels::sector + +\*---------------------------------------------------------------------------*/ + +#ifndef cyclicSector_H +#define cyclicSector_H + +#include "sector.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace extrudeModels +{ + +/*---------------------------------------------------------------------------*\ + Class cyclicSector Declaration +\*---------------------------------------------------------------------------*/ + +class cyclicSector +: + public sector +{ + +public: + + //- Runtime type information + TypeName("cyclicSector"); + + // Constructors + + //- Construct from dictionary + cyclicSector(const dictionary& dict); + + + //- Destructor + virtual ~cyclicSector(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace extrudeModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/mesh/extrudeModel/extrudeModel/extrudeModel.C b/src/mesh/extrudeModel/extrudeModel/extrudeModel.C index 02c9048375..541626a1ae 100644 --- a/src/mesh/extrudeModel/extrudeModel/extrudeModel.C +++ b/src/mesh/extrudeModel/extrudeModel/extrudeModel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -41,7 +41,7 @@ Foam::extrudeModel::extrudeModel const dictionary& dict ) : - nLayers_(readLabel(dict.lookup("nLayers"))), + nLayers_(dict.lookupOrDefault