From 6309810e2e4873cb94ece54010666ea8a3a245d1 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Sun, 8 Mar 2009 00:59:33 +0100 Subject: [PATCH] surfMesh reworked - treat 'ofs' IO just like any other format - dropped BasicMeshedSurface, since MeshedSurface can now also have zero or more zones - UnsortedMeshedSurface is a special type of MeshedSurface with zero zones, but with additional zoneId labels - use MeshedSurfaceProxy for writing surfaces with points/faces/zones and optional faceMap - provides output interface for MeshedSurface, UnsortedMeshedSurface and surfMesh. - simplify output to filenames only, I can't see that the Ostream is needed anywhere - surfMesh renaming now works, after the objectRegistry fix --- .../surfaceMeshConvertTesting.C | 57 +- src/sampling/cuttingPlane/cuttingPlane.H | 4 +- .../sampledPatch/sampledPatch.H | 4 +- .../BasicMeshedSurface/BasicMeshedSurface.C | 572 ---------- .../BasicMeshedSurface/BasicMeshedSurface.H | 223 ---- src/surfMesh/Make/files | 13 +- src/surfMesh/MeshedSurface/MeshedSurface.C | 993 ++++++++++++------ src/surfMesh/MeshedSurface/MeshedSurface.H | 232 ++-- .../MeshedSurface/MeshedSurfaceCore.C | 2 +- src/surfMesh/MeshedSurface/MeshedSurfaceIO.C | 123 +-- src/surfMesh/MeshedSurface/MeshedSurfaceNew.C | 9 +- .../MeshedSurface/MeshedSurfaceZones.C | 214 ++++ .../MeshedSurfaceIOAllocator.C | 147 +++ .../MeshedSurfaceIOAllocator.H | 194 ++++ .../MeshedSurfaceProxy/MeshedSurfaceProxy.C | 153 +++ .../MeshedSurfaceProxy/MeshedSurfaceProxy.H | 207 ++++ .../MeshedSurfaceProxyCore.C} | 48 +- .../UnsortedMeshedSurface.C | 332 +++--- .../UnsortedMeshedSurface.H | 75 +- .../UnsortedMeshedSurfaceIO.C | 108 -- .../UnsortedMeshedSurfaceNew.C | 11 +- .../surfFields/{ => surfFields}/surfFields.C | 0 .../surfFields/{ => surfFields}/surfFields.H | 0 .../{ => surfFields}/surfFieldsFwd.H | 0 .../surfFields/{ => surfFields}/surfGeoMesh.H | 0 .../surfPointFields/surfPointFields.C | 0 .../surfPointFields/surfPointFields.H | 0 .../surfPointFields/surfPointFieldsFwd.H | 0 .../surfPointFields/surfPointGeoMesh.H | 0 src/surfMesh/surfMesh/surfMesh.C | 235 +++-- src/surfMesh/surfMesh/surfMesh.H | 141 +-- src/surfMesh/surfMesh/surfMeshClear.C | 2 +- src/surfMesh/surfMesh/surfMeshIO.C | 41 +- .../surfaceFormats/ac3d/AC3DsurfaceFormat.C | 173 +-- .../surfaceFormats/ac3d/AC3DsurfaceFormat.H | 64 +- .../ac3d/AC3DsurfaceFormatCore.H | 2 +- .../ac3d/AC3DsurfaceFormatRunTime.C | 11 +- .../surfaceFormats/ftr/FTRsurfaceFormat.H | 3 +- .../ftr/FTRsurfaceFormatRunTime.C | 4 +- .../surfaceFormats/gts/GTSsurfaceFormat.C | 75 +- .../surfaceFormats/gts/GTSsurfaceFormat.H | 53 +- .../gts/GTSsurfaceFormatRunTime.C | 6 +- .../surfaceFormats/nas/NASsurfaceFormat.C | 10 +- .../surfaceFormats/nas/NASsurfaceFormat.H | 3 +- .../surfaceFormats/nas/NASsurfaceFormatCore.C | 3 +- .../nas/NASsurfaceFormatRunTime.C | 7 +- .../surfaceFormats/obj/OBJsurfaceFormat.C | 155 +-- .../surfaceFormats/obj/OBJsurfaceFormat.H | 61 +- .../obj/OBJsurfaceFormatRunTime.C | 30 +- .../surfaceFormats/off/OFFsurfaceFormat.C | 139 +-- .../surfaceFormats/off/OFFsurfaceFormat.H | 60 +- .../surfaceFormats/off/OFFsurfaceFormatCore.C | 78 -- .../off/OFFsurfaceFormatRunTime.C | 29 +- .../surfaceFormats/ofs/OFSsurfaceFormat.C | 260 +++++ .../surfaceFormats/ofs/OFSsurfaceFormat.H | 155 +++ .../OFSsurfaceFormatCore.C} | 52 +- .../OFSsurfaceFormatCore.H} | 17 +- .../OFSsurfaceFormatRunTime.C} | 85 +- .../surfaceFormats/smesh/SMESHsurfaceFormat.C | 142 ++- .../surfaceFormats/smesh/SMESHsurfaceFormat.H | 57 +- .../smesh/SMESHsurfaceFormatCore.C | 71 -- .../smesh/SMESHsurfaceFormatRunTime.C | 27 +- .../starcd/STARCDsurfaceFormat.C | 104 +- .../starcd/STARCDsurfaceFormat.H | 37 +- .../starcd/STARCDsurfaceFormatCore.C | 2 +- .../starcd/STARCDsurfaceFormatCore.H | 2 +- .../starcd/STARCDsurfaceFormatRunTime.C | 29 +- .../surfaceFormats/stl/STLsurfaceFormat.C | 346 +++--- .../surfaceFormats/stl/STLsurfaceFormat.H | 85 +- .../stl/STLsurfaceFormatASCII.L | 4 +- .../surfaceFormats/stl/STLsurfaceFormatCore.C | 22 +- .../surfaceFormats/stl/STLsurfaceFormatCore.H | 7 +- .../stl/STLsurfaceFormatRunTime.C | 17 +- .../surfaceFormats/surfaceFormatsCore.C | 2 +- .../surfaceFormats/surfaceFormatsCore.H | 61 +- .../surfaceFormats/tri/TRIsurfaceFormat.C | 100 +- .../surfaceFormats/tri/TRIsurfaceFormat.H | 60 +- .../surfaceFormats/tri/TRIsurfaceFormatCore.H | 1 + .../tri/TRIsurfaceFormatRunTime.C | 11 +- .../surfaceFormats/vtk/VTKsurfaceFormat.C | 95 +- .../surfaceFormats/vtk/VTKsurfaceFormat.H | 51 +- .../surfaceFormats/vtk/VTKsurfaceFormatCore.C | 6 +- .../surfaceFormats/vtk/VTKsurfaceFormatCore.H | 1 - .../vtk/VTKsurfaceFormatRunTime.C | 9 +- 84 files changed, 3800 insertions(+), 3224 deletions(-) delete mode 100644 src/surfMesh/BasicMeshedSurface/BasicMeshedSurface.C delete mode 100644 src/surfMesh/BasicMeshedSurface/BasicMeshedSurface.H create mode 100644 src/surfMesh/MeshedSurface/MeshedSurfaceZones.C create mode 100644 src/surfMesh/MeshedSurfaceAllocator/MeshedSurfaceIOAllocator.C create mode 100644 src/surfMesh/MeshedSurfaceAllocator/MeshedSurfaceIOAllocator.H create mode 100644 src/surfMesh/MeshedSurfaceProxy/MeshedSurfaceProxy.C create mode 100644 src/surfMesh/MeshedSurfaceProxy/MeshedSurfaceProxy.H rename src/surfMesh/{surfaceFormats/off/OFFsurfaceFormatCore.H => MeshedSurfaceProxy/MeshedSurfaceProxyCore.C} (61%) delete mode 100644 src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurfaceIO.C rename src/surfMesh/surfFields/{ => surfFields}/surfFields.C (100%) rename src/surfMesh/surfFields/{ => surfFields}/surfFields.H (100%) rename src/surfMesh/surfFields/{ => surfFields}/surfFieldsFwd.H (100%) rename src/surfMesh/surfFields/{ => surfFields}/surfGeoMesh.H (100%) rename src/surfMesh/{ => surfFields}/surfPointFields/surfPointFields.C (100%) rename src/surfMesh/{ => surfFields}/surfPointFields/surfPointFields.H (100%) rename src/surfMesh/{ => surfFields}/surfPointFields/surfPointFieldsFwd.H (100%) rename src/surfMesh/{ => surfFields}/surfPointFields/surfPointGeoMesh.H (100%) delete mode 100644 src/surfMesh/surfaceFormats/off/OFFsurfaceFormatCore.C create mode 100644 src/surfMesh/surfaceFormats/ofs/OFSsurfaceFormat.C create mode 100644 src/surfMesh/surfaceFormats/ofs/OFSsurfaceFormat.H rename src/surfMesh/surfaceFormats/{obj/OBJsurfaceFormatCore.C => ofs/OFSsurfaceFormatCore.C} (63%) rename src/surfMesh/surfaceFormats/{obj/OBJsurfaceFormatCore.H => ofs/OFSsurfaceFormatCore.H} (86%) rename src/surfMesh/surfaceFormats/{smesh/SMESHsurfaceFormatCore.H => ofs/OFSsurfaceFormatRunTime.C} (54%) delete mode 100644 src/surfMesh/surfaceFormats/smesh/SMESHsurfaceFormatCore.C diff --git a/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C b/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C index ccd85d8e5a..daece06c1d 100644 --- a/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C +++ b/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C @@ -271,13 +271,40 @@ int main(int argc, char *argv[]) args.caseName() ); + // start with "constant" + runTime.setTime(instant(0, runTime.constant()), 0); + + Info<< "runTime.instance() = " << runTime.instance() << endl; + Info<< "runTime.timeName() = " << runTime.timeName() << endl; + + + surfMesh surfIn + ( + IOobject + ( + "default", + runTime.timeName(), + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + + + Info<< "surfIn = " << surfIn.nFaces() << endl; + + Info<< "runTime.instance() = " << runTime.instance() << endl; + surfMesh surfOut ( IOobject ( "mySurf", runTime.instance(), - runTime + runTime, + IOobject::NO_READ, + IOobject::NO_WRITE, + false ), surf.xfer() ); @@ -299,6 +326,25 @@ int main(int argc, char *argv[]) dimless ); + Info<<" surf name= " << surfOut.name() < + public MeshedSurface { //- Private typedefs for convenience - typedef BasicMeshedSurface MeshStorage; + typedef MeshedSurface MeshStorage; // Private data diff --git a/src/sampling/sampledSurface/sampledPatch/sampledPatch.H b/src/sampling/sampledSurface/sampledPatch/sampledPatch.H index fbc0b56ebe..2890a7bd34 100644 --- a/src/sampling/sampledSurface/sampledPatch/sampledPatch.H +++ b/src/sampling/sampledSurface/sampledPatch/sampledPatch.H @@ -50,11 +50,11 @@ namespace Foam class sampledPatch : - public BasicMeshedSurface, + public MeshedSurface, public sampledSurface { //- Private typedefs for convenience - typedef BasicMeshedSurface MeshStorage; + typedef MeshedSurface MeshStorage; // Private data diff --git a/src/surfMesh/BasicMeshedSurface/BasicMeshedSurface.C b/src/surfMesh/BasicMeshedSurface/BasicMeshedSurface.C deleted file mode 100644 index 41295b44b6..0000000000 --- a/src/surfMesh/BasicMeshedSurface/BasicMeshedSurface.C +++ /dev/null @@ -1,572 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -\*---------------------------------------------------------------------------*/ - -#include "BasicMeshedSurface.H" -#include "boundBox.H" -#include "mergePoints.H" - -// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // - -template -inline bool Foam::BasicMeshedSurface::isTri() -{ - return false; -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template -Foam::BasicMeshedSurface::BasicMeshedSurface() -: - ParentType(List(), pointField()) -{} - - -template -Foam::BasicMeshedSurface::BasicMeshedSurface -( - const Xfer< pointField >& pointLst, - const Xfer< List >& faceLst -) -: - ParentType(List(), pointField()) -{ - reset(pointLst, faceLst); -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template -Foam::BasicMeshedSurface::~BasicMeshedSurface() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -void Foam::BasicMeshedSurface::clear() -{ - ParentType::clearOut(); - - storedPoints().clear(); - storedFaces().clear(); -} - - -template -void Foam::BasicMeshedSurface::movePoints(const pointField& newPoints) -{ - // Remove all geometry dependent data - ParentType::clearTopology(); - - // Adapt for new point position - ParentType::movePoints(newPoints); - - // Copy new points - storedPoints() = newPoints; -} - - -template -void Foam::BasicMeshedSurface::scalePoints(const scalar& scaleFactor) -{ - // avoid bad scaling - if (scaleFactor > 0 && scaleFactor != 1.0) - { - // Remove all geometry dependent data - ParentType::clearTopology(); - - // Adapt for new point position - ParentType::movePoints(pointField()); - - storedPoints() *= scaleFactor; - } -} - - -template -void Foam::BasicMeshedSurface::reset -( - const Xfer< pointField >& pointLst, - const Xfer< List >& faceLst -) -{ - ParentType::clearOut(); - - // Take over new primitive data. - // Optimized to avoid overwriting data at all - if (&pointLst) - { - storedPoints().transfer(pointLst()); - } - - if (&faceLst) - { - storedFaces().transfer(faceLst()); - } -} - - -template -void Foam::BasicMeshedSurface::reset -( - const Xfer< List >& pointLst, - const Xfer< List >& faceLst -) -{ - ParentType::clearOut(); - - // Take over new primitive data. - // Optimized to avoid overwriting data at all - if (&pointLst) - { - storedPoints().transfer(pointLst()); - } - - if (&faceLst) - { - storedFaces().transfer(faceLst()); - } -} - - -// Remove badly degenerate faces, double faces. -template -void Foam::BasicMeshedSurface::cleanup(const bool verbose) -{ - // merge points (already done for STL, TRI) - stitchFaces(SMALL, verbose); - - checkFaces(verbose); - this->checkTopology(verbose); -} - - -template -bool Foam::BasicMeshedSurface::stitchFaces -( - const scalar tol, - const bool verbose -) -{ - pointField& pointLst = this->storedPoints(); - - // Merge points - labelList pointMap(pointLst.size()); - pointField newPoints(pointLst.size()); - - bool hasMerged = mergePoints(pointLst, tol, verbose, pointMap, newPoints); - - if (!hasMerged) - { - return false; - } - - if (verbose) - { - Info<< "BasicMeshedSurface::stitchFaces : Renumbering all faces" - << endl; - } - - // Set the coordinates to the merged ones - pointLst.transfer(newPoints); - - List& faceLst = this->storedFaces(); - - List