From 67b1f80dc908b8b889c063f28b6020f6b26e0850 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Tue, 23 Oct 2012 15:32:42 +0100 Subject: [PATCH] ENH: fvMesh: add construct from cellShape --- applications/test/mesh/Test-mesh.C | 54 +++++++++++++++++++++++++++++- src/finiteVolume/fvMesh/fvMesh.C | 48 ++++++++++++++++++++++++++ src/finiteVolume/fvMesh/fvMesh.H | 14 ++++++++ 3 files changed, 115 insertions(+), 1 deletion(-) diff --git a/applications/test/mesh/Test-mesh.C b/applications/test/mesh/Test-mesh.C index 2616a2fd72b..bab19bcc5eb 100644 --- a/applications/test/mesh/Test-mesh.C +++ b/applications/test/mesh/Test-mesh.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-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -58,6 +58,58 @@ int main(int argc, char *argv[]) Info<< Cf << endl; + // Test construct from cellShapes + { + pointField points(mesh.points()); + cellShapeList shapes(mesh.cellShapes()); + + const polyBoundaryMesh& pbm = mesh.boundaryMesh(); + + faceListList boundaryFaces(pbm.size()); + forAll(pbm, patchI) + { + boundaryFaces[patchI] = pbm[patchI]; + } + wordList boundaryPatchNames(pbm.names()); + PtrList<dictionary> boundaryDicts(pbm.size()); + forAll(pbm, patchI) + { + OStringStream os; + os << pbm[patchI]; + IStringStream is(os.str()); + boundaryDicts.set(patchI, new dictionary(is)); + } + + word defaultBoundaryPatchName = "defaultFaces"; + word defaultBoundaryPatchType = emptyPolyPatch::typeName; + + fvMesh newMesh + ( + IOobject + ( + "newMesh", + runTime.timeName(), + runTime, + Foam::IOobject::NO_READ + ), + Xfer<pointField>(points), + shapes, + boundaryFaces, + boundaryPatchNames, + boundaryDicts, + defaultBoundaryPatchName, + defaultBoundaryPatchType + ); + + Info<< newMesh.C() << endl; + Info<< newMesh.V() << endl; + + surfaceVectorField Cf = newMesh.Cf(); + + Info<< Cf << endl; + } + + Info<< "End\n" << endl; return 0; diff --git a/src/finiteVolume/fvMesh/fvMesh.C b/src/finiteVolume/fvMesh/fvMesh.C index 95ff899be98..e40d0a8a227 100644 --- a/src/finiteVolume/fvMesh/fvMesh.C +++ b/src/finiteVolume/fvMesh/fvMesh.C @@ -280,6 +280,54 @@ Foam::fvMesh::fvMesh(const IOobject& io) } +Foam::fvMesh::fvMesh +( + const IOobject& io, + const Xfer<pointField>& points, + const cellShapeList& shapes, + const faceListList& boundaryFaces, + const wordList& boundaryPatchNames, + const PtrList<dictionary>& boundaryDicts, + const word& defaultBoundaryPatchName, + const word& defaultBoundaryPatchType, + const bool syncPar +) +: + polyMesh + ( + io, + points, + shapes, + boundaryFaces, + boundaryPatchNames, + boundaryDicts, + defaultBoundaryPatchName, + defaultBoundaryPatchType, + syncPar + ), + surfaceInterpolation(*this), + fvSchemes(static_cast<const objectRegistry&>(*this)), + fvSolution(static_cast<const objectRegistry&>(*this)), + data(static_cast<const objectRegistry&>(*this)), + boundary_(*this, boundaryMesh()), + lduPtr_(NULL), + curTimeIndex_(time().timeIndex()), + VPtr_(NULL), + V0Ptr_(NULL), + V00Ptr_(NULL), + SfPtr_(NULL), + magSfPtr_(NULL), + CPtr_(NULL), + CfPtr_(NULL), + phiPtr_(NULL) +{ + if (debug) + { + Info<< "Constructing fvMesh from cellShapes" << endl; + } +} + + Foam::fvMesh::fvMesh ( const IOobject& io, diff --git a/src/finiteVolume/fvMesh/fvMesh.H b/src/finiteVolume/fvMesh/fvMesh.H index 907cc418fde..97c1b0db589 100644 --- a/src/finiteVolume/fvMesh/fvMesh.H +++ b/src/finiteVolume/fvMesh/fvMesh.H @@ -177,6 +177,20 @@ public: //- Construct from IOobject explicit fvMesh(const IOobject& io); + //- Construct from cellShapes with boundary. + fvMesh + ( + const IOobject& io, + const Xfer<pointField>& points, + const cellShapeList& shapes, + const faceListList& boundaryFaces, + const wordList& boundaryPatchNames, + const PtrList<dictionary>& boundaryDicts, + const word& defaultBoundaryPatchName, + const word& defaultBoundaryPatchType, + const bool syncPar = true + ); + //- Construct from components without boundary. // Boundary is added using addFvPatches() member function fvMesh -- GitLab