diff --git a/applications/test/mesh/Test-mesh.C b/applications/test/mesh/Test-mesh.C index 2616a2fd72b2463557057484bb544866688a744e..bab19bcc5eb817d022100530d4319a1c72e6f845 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 95ff899be987577da368654539431426878642c0..e40d0a8a227c1c35d6cc55d98755bef728cabe0b 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 907cc418fde3b90c644b5ae3064a68e5cffb68ac..97c1b0db589b4305f568d1a34a798dd8c53c820f 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