From 26fee7bc71d6e260063306282a7eac38e2bcbb77 Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 7 Sep 2012 10:24:34 +0100 Subject: [PATCH] COMP: extrudedMesh: move templates to separate file --- .../generation/extrude/extrudeMesh/Make/files | 1 + .../extrudeMesh/extrudedMesh/extrudedMesh.C | 342 ---------------- .../extrudeMesh/extrudedMesh/extrudedMesh.H | 10 +- .../extrudedMesh/extrudedMeshTemplates.C | 376 ++++++++++++++++++ 4 files changed, 381 insertions(+), 348 deletions(-) create mode 100644 applications/utilities/mesh/generation/extrude/extrudeMesh/extrudedMesh/extrudedMeshTemplates.C diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/Make/files b/applications/utilities/mesh/generation/extrude/extrudeMesh/Make/files index f5a718066d..211c09c94e 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/Make/files +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/Make/files @@ -1,3 +1,4 @@ +extrudedMesh/extrudedMesh.C extrudeMesh.C EXE = $(FOAM_APPBIN)/extrudeMesh diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudedMesh/extrudedMesh.C b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudedMesh/extrudedMesh.C index 16180be1b8..8b2b4659cb 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudedMesh/extrudedMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudedMesh/extrudedMesh.C @@ -41,346 +41,4 @@ bool Foam::extrudedMesh::sameOrder(const face& f, const edge& e) } -template -< - class Face, - template class FaceList, - class PointField -> -Foam::Xfer Foam::extrudedMesh::extrudedPoints -( - const PrimitivePatch& extrudePatch, - const extrudeModel& model -) -{ - const pointField& surfacePoints = extrudePatch.localPoints(); - const vectorField& surfaceNormals = extrudePatch.pointNormals(); - - const label nLayers = model.nLayers(); - - pointField ePoints((nLayers + 1)*surfacePoints.size()); - - for (label layer=0; layer<=nLayers; layer++) - { - label offset = layer*surfacePoints.size(); - - forAll(surfacePoints, i) - { - ePoints[offset + i] = model - ( - surfacePoints[i], - surfaceNormals[i], - layer - ); - } - } - - // return points for transferring - return xferMove(ePoints); -} - - -template class FaceList, class PointField> -Foam::Xfer Foam::extrudedMesh::extrudedFaces -( - const PrimitivePatch& extrudePatch, - const extrudeModel& model -) -{ - const pointField& surfacePoints = extrudePatch.localPoints(); - const List& surfaceFaces = extrudePatch.localFaces(); - const edgeList& surfaceEdges = extrudePatch.edges(); - const label nInternalEdges = extrudePatch.nInternalEdges(); - - const label nLayers = model.nLayers(); - - label nFaces = - (nLayers + 1)*surfaceFaces.size() + nLayers*surfaceEdges.size(); - - faceList eFaces(nFaces); - - labelList quad(4); - label facei = 0; - - // Internal faces - for (label layer=0; layer class FaceList, class PointField> -Foam::Xfer Foam::extrudedMesh::extrudedCells -( - const PrimitivePatch& extrudePatch, - const extrudeModel& model -) -{ - const List& surfaceFaces = extrudePatch.localFaces(); - const edgeList& surfaceEdges = extrudePatch.edges(); - const label nInternalEdges = extrudePatch.nInternalEdges(); - - const label nLayers = model.nLayers(); - - cellList eCells(nLayers*surfaceFaces.size()); - - // Size the cells - forAll(surfaceFaces, i) - { - const face& f = surfaceFaces[i]; - - for (label layer=0; layer class FaceList, - class PointField -> -Foam::extrudedMesh::extrudedMesh -( - const IOobject& io, - const PrimitivePatch& extrudePatch, - const extrudeModel& model -) -: - polyMesh - ( - io, - extrudedPoints(extrudePatch, model), - extrudedFaces(extrudePatch, model), - extrudedCells(extrudePatch, model) - ), - model_(model) -{ - List patches(3); - - label facei = nInternalFaces(); - - label sz = - model_.nLayers() - *(extrudePatch.nEdges() - extrudePatch.nInternalEdges()); - - patches[0] = new wallPolyPatch - ( - "sides", - sz, - facei, - 0, - boundaryMesh(), - wallPolyPatch::typeName - ); - - facei += sz; - - patches[1] = new polyPatch - ( - "originalPatch", - extrudePatch.size(), - facei, - 1, - boundaryMesh(), - polyPatch::typeName - ); - - facei += extrudePatch.size(); - - patches[2] = new polyPatch - ( - "otherSide", - extrudePatch.size(), - facei, - 2, - boundaryMesh(), - polyPatch::typeName - ); - - addPatches(patches); -} - - // ************************************************************************* // diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudedMesh/extrudedMesh.H b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudedMesh/extrudedMesh.H index c0aac4bcdd..78351f714f 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudedMesh/extrudedMesh.H +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudedMesh/extrudedMesh.H @@ -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-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -114,13 +114,11 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #ifdef NoRepository -# include "extrudedMesh.C" -#else -# ifdef xlC -# pragma implementation("extrudedMesh.C") -# endif +# include "extrudedMeshTemplates.C" #endif +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #endif // ************************************************************************* // diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudedMesh/extrudedMeshTemplates.C b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudedMesh/extrudedMeshTemplates.C new file mode 100644 index 0000000000..9ea14b8c35 --- /dev/null +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudedMesh/extrudedMeshTemplates.C @@ -0,0 +1,376 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 "extrudedMesh.H" +#include "wallPolyPatch.H" +#include "meshTools.H" +#include "ListOps.H" +#include "OFstream.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +< + class Face, + template class FaceList, + class PointField +> +Foam::Xfer Foam::extrudedMesh::extrudedPoints +( + const PrimitivePatch& extrudePatch, + const extrudeModel& model +) +{ + const pointField& surfacePoints = extrudePatch.localPoints(); + const vectorField& surfaceNormals = extrudePatch.pointNormals(); + + const label nLayers = model.nLayers(); + + pointField ePoints((nLayers + 1)*surfacePoints.size()); + + for (label layer=0; layer<=nLayers; layer++) + { + label offset = layer*surfacePoints.size(); + + forAll(surfacePoints, i) + { + ePoints[offset + i] = model + ( + surfacePoints[i], + surfaceNormals[i], + layer + ); + } + } + + // return points for transferring + return xferMove(ePoints); +} + + +template class FaceList, class PointField> +Foam::Xfer Foam::extrudedMesh::extrudedFaces +( + const PrimitivePatch& extrudePatch, + const extrudeModel& model +) +{ + const pointField& surfacePoints = extrudePatch.localPoints(); + const List& surfaceFaces = extrudePatch.localFaces(); + const edgeList& surfaceEdges = extrudePatch.edges(); + const label nInternalEdges = extrudePatch.nInternalEdges(); + + const label nLayers = model.nLayers(); + + label nFaces = + (nLayers + 1)*surfaceFaces.size() + nLayers*surfaceEdges.size(); + + faceList eFaces(nFaces); + + labelList quad(4); + label facei = 0; + + // Internal faces + for (label layer=0; layer class FaceList, class PointField> +Foam::Xfer Foam::extrudedMesh::extrudedCells +( + const PrimitivePatch& extrudePatch, + const extrudeModel& model +) +{ + const List& surfaceFaces = extrudePatch.localFaces(); + const edgeList& surfaceEdges = extrudePatch.edges(); + const label nInternalEdges = extrudePatch.nInternalEdges(); + + const label nLayers = model.nLayers(); + + cellList eCells(nLayers*surfaceFaces.size()); + + // Size the cells + forAll(surfaceFaces, i) + { + const face& f = surfaceFaces[i]; + + for (label layer=0; layer class FaceList, + class PointField +> +Foam::extrudedMesh::extrudedMesh +( + const IOobject& io, + const PrimitivePatch& extrudePatch, + const extrudeModel& model +) +: + polyMesh + ( + io, + extrudedPoints(extrudePatch, model), + extrudedFaces(extrudePatch, model), + extrudedCells(extrudePatch, model) + ), + model_(model) +{ + List patches(3); + + label facei = nInternalFaces(); + + label sz = + model_.nLayers() + *(extrudePatch.nEdges() - extrudePatch.nInternalEdges()); + + patches[0] = new wallPolyPatch + ( + "sides", + sz, + facei, + 0, + boundaryMesh(), + wallPolyPatch::typeName + ); + + facei += sz; + + patches[1] = new polyPatch + ( + "originalPatch", + extrudePatch.size(), + facei, + 1, + boundaryMesh(), + polyPatch::typeName + ); + + facei += extrudePatch.size(); + + patches[2] = new polyPatch + ( + "otherSide", + extrudePatch.size(), + facei, + 2, + boundaryMesh(), + polyPatch::typeName + ); + + addPatches(patches); +} + + +// ************************************************************************* //