From a43df3bddd79edfcd0061ed4e8bfac1f3daa2ba7 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 4 Feb 2009 16:17:14 +0100 Subject: [PATCH] added surfMesh, reworked MeshedSurface - renamed surface regions (formerly patches or groups) to surfZone. - added surfMesh, but without any of the patch information needed to make it useful for finiteArea. - promoted coordinateSystem transformation to surfaceMeshConvert and moved old to surfaceMeshConvertTesting. --- .../Make/files | 3 - .../Make/options | 5 - .../surfaceCoordinateSystemTransform.C | 257 ---------- .../surface/surfaceMeshConvert/Make/options | 4 +- .../coordinateSystems | 0 .../surfaceMeshConvert/surfaceMeshConvert.C | 303 ++++++------ .../surfaceMeshConvertTesting/Make/files | 3 + .../surfaceMeshConvertTesting/Make/options | 5 + .../surfaceMeshConvertTesting.C | 323 +++++++++++++ .../BasicMeshedSurface/BasicMeshedSurface.H | 2 +- src/surfMesh/Make/files | 12 +- src/surfMesh/MeshedSurface/MeshedSurface.C | 291 ++++++------ src/surfMesh/MeshedSurface/MeshedSurface.H | 66 +-- src/surfMesh/MeshedSurface/MeshedSurfaceIO.C | 24 +- src/surfMesh/SurfGeoMesh/SurfGeoMesh.H | 105 +++++ .../UnsortedMeshedSurface.C | 183 +++---- .../UnsortedMeshedSurface.H | 89 ++-- .../UnsortedMeshedSurfaceIO.C | 18 +- src/surfMesh/surfFields/surfFields.C | 82 ++++ src/surfMesh/surfFields/surfFields.H | 73 +++ src/surfMesh/surfFields/surfFieldsFwd.H | 59 +++ src/surfMesh/surfFields/surfGeoMesh.H | 90 ++++ src/surfMesh/surfMesh/surfMesh.C | 446 ++++++++++++++++++ src/surfMesh/surfMesh/surfMesh.H | 334 +++++++++++++ src/surfMesh/surfMesh/surfMeshClear.C | 84 ++++ src/surfMesh/surfMesh/surfMeshIO.C | 215 +++++++++ .../surfZone/surfZone.C} | 68 +-- .../surfZone/surfZone.H} | 69 +-- .../surfZone/surfZoneIOList.C} | 48 +- .../surfZone/surfZoneIOList.H} | 32 +- .../surfZone/surfZoneList.H} | 12 +- .../surfZoneIdentifier/surfZoneIdentifier.C} | 38 +- .../surfZoneIdentifier/surfZoneIdentifier.H} | 64 ++- .../surfZoneIdentifierList.H} | 10 +- .../surfaceFormats/ac3d/AC3DsurfaceFormat.C | 86 ++-- .../surfaceFormats/ac3d/AC3DsurfaceFormat.H | 8 +- .../ac3d/AC3DsurfaceFormatCore.C | 14 +- .../ac3d/AC3DsurfaceFormatCore.H | 2 +- .../surfaceFormats/ftr/FTRsurfaceFormat.C | 20 +- .../surfaceFormats/gts/GTSsurfaceFormat.C | 66 +-- .../surfaceFormats/gts/GTSsurfaceFormat.H | 2 +- .../surfaceFormats/nas/NASsurfaceFormat.C | 60 +-- .../surfaceFormats/nas/NASsurfaceFormat.H | 2 +- .../surfaceFormats/obj/OBJsurfaceFormat.C | 58 +-- .../surfaceFormats/obj/OBJsurfaceFormat.H | 4 +- .../surfaceFormats/obj/OBJsurfaceFormatCore.C | 12 +- .../surfaceFormats/obj/OBJsurfaceFormatCore.H | 2 +- .../surfaceFormats/off/OFFsurfaceFormat.C | 38 +- .../surfaceFormats/off/OFFsurfaceFormat.H | 6 +- .../surfaceFormats/off/OFFsurfaceFormatCore.C | 12 +- .../surfaceFormats/off/OFFsurfaceFormatCore.H | 2 +- .../surfaceFormats/smesh/SMESHsurfaceFormat.C | 16 +- .../surfaceFormats/smesh/SMESHsurfaceFormat.H | 4 +- .../smesh/SMESHsurfaceFormatCore.C | 2 +- .../starcd/STARCDsurfaceFormat.C | 54 +-- .../starcd/STARCDsurfaceFormat.H | 2 +- .../starcd/STARCDsurfaceFormatCore.C | 10 +- .../starcd/STARCDsurfaceFormatCore.H | 2 +- .../surfaceFormats/stl/STLsurfaceFormat.C | 66 +-- .../surfaceFormats/stl/STLsurfaceFormat.H | 8 +- .../stl/STLsurfaceFormatASCII.L | 15 +- .../surfaceFormats/stl/STLsurfaceFormatCore.C | 38 +- .../surfaceFormats/stl/STLsurfaceFormatCore.H | 12 +- src/surfMesh/surfaceFormats/stl/STLtriangle.H | 11 +- .../surfaceFormats/stl/STLtriangleI.H | 14 +- .../surfaceFormats/surfaceFormatsCore.C | 64 +-- .../surfaceFormats/surfaceFormatsCore.H | 14 +- .../surfaceFormats/tri/TRIsurfaceFormat.C | 42 +- .../surfaceFormats/tri/TRIsurfaceFormat.H | 8 +- .../surfaceFormats/tri/TRIsurfaceFormatCore.C | 46 +- .../surfaceFormats/tri/TRIsurfaceFormatCore.H | 14 +- .../surfaceFormats/vtk/VTKsurfaceFormat.C | 10 +- .../surfaceFormats/vtk/VTKsurfaceFormat.H | 2 +- .../surfaceFormats/vtk/VTKsurfaceFormatCore.C | 29 +- .../surfaceFormats/vtk/VTKsurfaceFormatCore.H | 8 +- .../surfaceRegistry/surfaceRegistry.C | 62 +++ .../surfaceRegistry/surfaceRegistry.H | 91 ++++ 77 files changed, 3097 insertions(+), 1358 deletions(-) delete mode 100644 applications/utilities/surface/surfaceCoordinateSystemTransform/Make/files delete mode 100644 applications/utilities/surface/surfaceCoordinateSystemTransform/Make/options delete mode 100644 applications/utilities/surface/surfaceCoordinateSystemTransform/surfaceCoordinateSystemTransform.C rename applications/utilities/surface/{surfaceCoordinateSystemTransform => surfaceMeshConvert}/coordinateSystems (100%) create mode 100644 applications/utilities/surface/surfaceMeshConvertTesting/Make/files create mode 100644 applications/utilities/surface/surfaceMeshConvertTesting/Make/options create mode 100644 applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C create mode 100644 src/surfMesh/SurfGeoMesh/SurfGeoMesh.H create mode 100644 src/surfMesh/surfFields/surfFields.C create mode 100644 src/surfMesh/surfFields/surfFields.H create mode 100644 src/surfMesh/surfFields/surfFieldsFwd.H create mode 100644 src/surfMesh/surfFields/surfGeoMesh.H create mode 100644 src/surfMesh/surfMesh/surfMesh.C create mode 100644 src/surfMesh/surfMesh/surfMesh.H create mode 100644 src/surfMesh/surfMesh/surfMeshClear.C create mode 100644 src/surfMesh/surfMesh/surfMeshIO.C rename src/surfMesh/{surfRegion/surfRegion/surfRegion.C => surfZone/surfZone/surfZone.C} (65%) rename src/surfMesh/{surfRegion/surfRegion/surfRegion.H => surfZone/surfZone/surfZone.H} (69%) rename src/surfMesh/{surfRegion/surfRegion/surfRegionIOList.C => surfZone/surfZone/surfZoneIOList.C} (75%) rename src/surfMesh/{surfRegion/surfRegion/surfRegionIOList.H => surfZone/surfZone/surfZoneIOList.H} (79%) rename src/surfMesh/{surfRegion/surfRegion/surfRegionList.H => surfZone/surfZone/surfZoneList.H} (90%) rename src/surfMesh/{surfRegion/surfRegionIdentifier/surfRegionIdentifier.C => surfZone/surfZoneIdentifier/surfZoneIdentifier.C} (75%) rename src/surfMesh/{surfRegion/surfRegionIdentifier/surfRegionIdentifier.H => surfZone/surfZoneIdentifier/surfZoneIdentifier.H} (67%) rename src/surfMesh/{surfRegion/surfRegionIdentifier/surfRegionIdentifierList.H => surfZone/surfZoneIdentifier/surfZoneIdentifierList.H} (89%) create mode 100644 src/surfMesh/surfaceRegistry/surfaceRegistry.C create mode 100644 src/surfMesh/surfaceRegistry/surfaceRegistry.H diff --git a/applications/utilities/surface/surfaceCoordinateSystemTransform/Make/files b/applications/utilities/surface/surfaceCoordinateSystemTransform/Make/files deleted file mode 100644 index b937625a71..0000000000 --- a/applications/utilities/surface/surfaceCoordinateSystemTransform/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -surfaceCoordinateSystemTransform.C - -EXE = $(FOAM_APPBIN)/surfaceCoordinateSystemTransform diff --git a/applications/utilities/surface/surfaceCoordinateSystemTransform/Make/options b/applications/utilities/surface/surfaceCoordinateSystemTransform/Make/options deleted file mode 100644 index 42b30c8652..0000000000 --- a/applications/utilities/surface/surfaceCoordinateSystemTransform/Make/options +++ /dev/null @@ -1,5 +0,0 @@ -EXE_INC = \ - -I$(LIB_SRC)/meshTools/lnInclude \ - -I$(LIB_SRC)/surfMesh/lnInclude - -EXE_LIBS = -lmeshTools -lsurfMesh diff --git a/applications/utilities/surface/surfaceCoordinateSystemTransform/surfaceCoordinateSystemTransform.C b/applications/utilities/surface/surfaceCoordinateSystemTransform/surfaceCoordinateSystemTransform.C deleted file mode 100644 index f0578f4ab2..0000000000 --- a/applications/utilities/surface/surfaceCoordinateSystemTransform/surfaceCoordinateSystemTransform.C +++ /dev/null @@ -1,257 +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 - -Application - surfaceMeshCoordinateSystemTransform - -Description - - Transform (scale/rotate/translate) a surface based on - a coordinateSystem. - -Usage - - surfaceMeshCoordinateSystemTransform inputFile outputFile [OPTION] - - @param -clean \n - Perform some surface checking/cleanup on the input surface. - - @param -scaleIn \ \n - Specify a scaling factor when reading files. - - @param -scaleOut \ \n - Specify a scaling factor when writing files. - - @param -dict \ \n - Specify an alternative dictionary for coordinateSystems. - - @param -from \ \n - Specify a coordinate System when reading files. - - @param -to \ \n - Specify a coordinate System when writing files. - -Note - The filename extensions are used to determine the file format type. - -\*---------------------------------------------------------------------------*/ - -#include "argList.H" -#include "timeSelector.H" -#include "Time.H" - -#include "MeshedSurfaces.H" -#include "coordinateSystems.H" - -using namespace Foam; - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Main program: - -int main(int argc, char *argv[]) -{ - argList::noParallel(); - argList::validArgs.append("inputFile"); - argList::validArgs.append("outputFile"); - argList::validOptions.insert("clean", "scale"); - argList::validOptions.insert("scaleIn", "scale"); - argList::validOptions.insert("scaleOut", "scale"); - argList::validOptions.insert("dict", "coordinateSystemsDict"); - argList::validOptions.insert("from", "sourceCoordinateSystem"); - argList::validOptions.insert("to", "targetCoordinateSystem"); - - argList args(argc, argv); - Time runTime(args.rootPath(), args.caseName()); - const stringList& params = args.additionalArgs(); - - fileName importName(params[0]); - fileName exportName(params[1]); - - // disable inplace editing - if (importName == exportName) - { - FatalErrorIn(args.executable()) - << "Output file " << exportName << " would overwrite input file." - << exit(FatalError); - } - - // check that reading/writing is supported - if - ( - !MeshedSurface::canRead(importName, true) - || !MeshedSurface::canWriteType(exportName.ext(), true) - ) - { - return 1; - } - - - // get the coordinate transformations - autoPtr fromCsys; - autoPtr toCsys; - - if (args.options().found("from") || args.options().found("to")) - { - autoPtr csDictIoPtr; - - if (args.options().found("dict")) - { - fileName dictPath(args.options()["dict"]); - - csDictIoPtr.set - ( - new IOobject - ( - ( dictPath.isDir() ? dictPath/coordinateSystems::typeName : dictPath ), - runTime, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ) - ); - } - else - { - csDictIoPtr.set - ( - new IOobject - ( - coordinateSystems::typeName, - runTime.constant(), - runTime, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ) - ); - } - - - if (!csDictIoPtr->headerOk()) - { - FatalErrorIn(args.executable()) - << "Cannot open coordinateSystems file\n " - << csDictIoPtr->objectPath() << nl - << exit(FatalError); - } - - coordinateSystems csLst(csDictIoPtr()); - - if (args.options().found("from")) - { - const word csName(args.options()["from"]); - - label csId = csLst.find(csName); - if (csId < 0) - { - FatalErrorIn(args.executable()) - << "Cannot find -from " << csName << nl - << "available coordinateSystems: " << csLst.toc() << nl - << exit(FatalError); - } - - fromCsys.reset(new coordinateSystem(csLst[csId])); - } - - if (args.options().found("to")) - { - const word csName(args.options()["to"]); - - label csId = csLst.find(csName); - if (csId < 0) - { - FatalErrorIn(args.executable()) - << "Cannot find -to " << csName << nl - << "available coordinateSystems: " << csLst.toc() << nl - << exit(FatalError); - } - - toCsys.reset(new coordinateSystem(csLst[csId])); - } - - - // maybe fix this later - if (fromCsys.valid() && toCsys.valid()) - { - FatalErrorIn(args.executable()) - << "Only allowed '-from' or '-to' option at the moment." - << exit(FatalError); - } - } - - scalar scaleIn = 0; - scalar scaleOut = 0; - if (args.options().found("scaleIn")) - { - IStringStream(args.options()["scaleIn"])() >> scaleIn; - } - if (args.options().found("scaleOut")) - { - IStringStream(args.options()["scaleOut"])() >> scaleOut; - } - - - { - MeshedSurface surf(importName); - - if (args.options().found("clean")) - { - surf.cleanup(true); - } - - if (scaleIn > 0) - { - Info<< " -scaleIn " << scaleIn << endl; - surf.scalePoints(scaleIn); - } - - if (fromCsys.valid()) - { - Info<< " -from " << fromCsys().name() << endl; - tmp tpf = fromCsys().localPosition(surf.points()); - surf.movePoints(tpf()); - } - - if (toCsys.valid()) - { - Info<< " -to " << toCsys().name() << endl; - tmp tpf = toCsys().globalPosition(surf.points()); - surf.movePoints(tpf()); - } - - if (scaleOut > 0) - { - Info<< " -scaleOut " << scaleOut << endl; - surf.scalePoints(scaleOut); - } - - Info<< "writing " << exportName; - surf.write(exportName); - } - - Info<< "\nEnd\n" << endl; - - return 0; -} - -// ************************************************************************* // diff --git a/applications/utilities/surface/surfaceMeshConvert/Make/options b/applications/utilities/surface/surfaceMeshConvert/Make/options index 5293dabe4c..42b30c8652 100644 --- a/applications/utilities/surface/surfaceMeshConvert/Make/options +++ b/applications/utilities/surface/surfaceMeshConvert/Make/options @@ -1,5 +1,5 @@ EXE_INC = \ - -I$(LIB_SRC)/triSurface/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/surfMesh/lnInclude -EXE_LIBS = -lsurfMesh +EXE_LIBS = -lmeshTools -lsurfMesh diff --git a/applications/utilities/surface/surfaceCoordinateSystemTransform/coordinateSystems b/applications/utilities/surface/surfaceMeshConvert/coordinateSystems similarity index 100% rename from applications/utilities/surface/surfaceCoordinateSystemTransform/coordinateSystems rename to applications/utilities/surface/surfaceMeshConvert/coordinateSystems diff --git a/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C b/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C index 9b5c2cb8f7..c22534ecf5 100644 --- a/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C +++ b/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C @@ -26,25 +26,30 @@ Application surfaceMeshConvert Description - Converts from one surface mesh format to another + + Convert between surface formats with optional scaling or + transformations (rotate/translate) on a coordinateSystem. Usage - surfaceMeshConvert inputFile outputFile [OPTION] @param -clean \n - Perform some surface checking/cleanup on the input surface + Perform some surface checking/cleanup on the input surface. - @param -orient \n - Check face orientation on the input surface + @param -scaleIn \ \n + Specify a scaling factor when reading files. - @param -scale \ \n - Specify a scaling factor for writing the files + @param -scaleOut \ \n + Specify a scaling factor when writing files. - @param -triSurface \n - Use triSurface library for input/output + @param -dict \ \n + Specify an alternative dictionary for constant/coordinateSystems. - @param -keyed \n - Use keyedSurface for input/output + @param -from \ \n + Specify a coordinate System when reading files. + + @param -to \ \n + Specify a coordinate System when writing files. Note The filename extensions are used to determine the file format type. @@ -54,12 +59,9 @@ Note #include "argList.H" #include "timeSelector.H" #include "Time.H" -#include "polyMesh.H" -#include "triSurface.H" -#include "PackedBoolList.H" #include "MeshedSurfaces.H" -#include "UnsortedMeshedSurfaces.H" +#include "coordinateSystems.H" using namespace Foam; @@ -71,24 +73,21 @@ int main(int argc, char *argv[]) argList::noParallel(); argList::validArgs.append("inputFile"); argList::validArgs.append("outputFile"); - argList::validOptions.insert("clean", ""); - argList::validOptions.insert("orient", ""); - argList::validOptions.insert("scale", "scale"); - argList::validOptions.insert("triSurface", ""); - argList::validOptions.insert("unsorted", ""); - argList::validOptions.insert("triFace", ""); -# include "setRootCase.H" - const stringList& params = args.additionalArgs(); + argList::validOptions.insert("clean", "scale"); + argList::validOptions.insert("scaleIn", "scale"); + argList::validOptions.insert("scaleOut", "scale"); + argList::validOptions.insert("dict", "coordinateSystemsDict"); + argList::validOptions.insert("from", "sourceCoordinateSystem"); + argList::validOptions.insert("to", "targetCoordinateSystem"); - scalar scaleFactor = 0; - if (args.options().found("scale")) - { - IStringStream(args.options()["scale"])() >> scaleFactor; - } + argList args(argc, argv); + Time runTime(args.rootPath(), args.caseName()); + const stringList& params = args.additionalArgs(); fileName importName(params[0]); fileName exportName(params[1]); + // disable inplace editing if (importName == exportName) { FatalErrorIn(args.executable()) @@ -96,165 +95,157 @@ int main(int argc, char *argv[]) << exit(FatalError); } + // check that reading/writing is supported if ( - !meshedSurface::canRead(importName, true) - || !meshedSurface::canWriteType(exportName.ext(), true) + !MeshedSurface::canRead(importName, true) + || !MeshedSurface::canWriteType(exportName.ext(), true) ) { return 1; } - if (args.options().found("triSurface")) + + // get the coordinate transformations + autoPtr fromCsys; + autoPtr toCsys; + + if (args.options().found("from") || args.options().found("to")) { - triSurface surf(importName); + autoPtr csDictIoPtr; - Info<< "Read surface:" << endl; - surf.writeStats(Info); - Info<< endl; - - if (args.options().found("orient")) + if (args.options().found("dict")) { - Info<< "Checking surface orientation" << endl; - PatchTools::checkOrientation(surf, true); - Info<< endl; - } + fileName dictPath(args.options()["dict"]); - if (args.options().found("clean")) - { - Info<< "Cleaning up surface" << endl; - surf.cleanup(true); - surf.writeStats(Info); - Info<< endl; - } - - Info<< "writing " << exportName; - if (scaleFactor <= 0) - { - Info<< " without scaling" << endl; + csDictIoPtr.set + ( + new IOobject + ( + ( dictPath.isDir() ? dictPath/coordinateSystems::typeName : dictPath ), + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); } else { - Info<< " with scaling " << scaleFactor << endl; - surf.scalePoints(scaleFactor); - surf.writeStats(Info); - Info<< endl; + csDictIoPtr.set + ( + new IOobject + ( + coordinateSystems::typeName, + runTime.constant(), + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); } - // write sorted by region - surf.write(exportName, true); + + if (!csDictIoPtr->headerOk()) + { + FatalErrorIn(args.executable()) + << "Cannot open coordinateSystems file\n " + << csDictIoPtr->objectPath() << nl + << exit(FatalError); + } + + coordinateSystems csLst(csDictIoPtr()); + + if (args.options().found("from")) + { + const word csName(args.options()["from"]); + + label csId = csLst.find(csName); + if (csId < 0) + { + FatalErrorIn(args.executable()) + << "Cannot find -from " << csName << nl + << "available coordinateSystems: " << csLst.toc() << nl + << exit(FatalError); + } + + fromCsys.reset(new coordinateSystem(csLst[csId])); + } + + if (args.options().found("to")) + { + const word csName(args.options()["to"]); + + label csId = csLst.find(csName); + if (csId < 0) + { + FatalErrorIn(args.executable()) + << "Cannot find -to " << csName << nl + << "available coordinateSystems: " << csLst.toc() << nl + << exit(FatalError); + } + + toCsys.reset(new coordinateSystem(csLst[csId])); + } + + + // maybe fix this later + if (fromCsys.valid() && toCsys.valid()) + { + FatalErrorIn(args.executable()) + << "Only allowed '-from' or '-to' option at the moment." + << exit(FatalError); + } } - else if (args.options().found("unsorted")) + + scalar scaleIn = 0; + scalar scaleOut = 0; + if (args.options().found("scaleIn")) { - UnsortedMeshedSurface surf(importName); - - Info<< "Read surface:" << endl; - surf.writeStats(Info); - Info<< endl; - - if (args.options().found("orient")) - { - Info<< "Checking surface orientation" << endl; - PatchTools::checkOrientation(surf, true); - Info<< endl; - } - - if (args.options().found("clean")) - { - Info<< "Cleaning up surface" << endl; - surf.cleanup(true); - surf.writeStats(Info); - Info<< endl; - } - - Info<< "writing " << exportName; - if (scaleFactor <= 0) - { - Info<< " without scaling" << endl; - } - else - { - Info<< " with scaling " << scaleFactor << endl; - surf.scalePoints(scaleFactor); - surf.writeStats(Info); - Info<< endl; - } - surf.write(exportName); + IStringStream(args.options()["scaleIn"])() >> scaleIn; } -#if 1 - else if (args.options().found("triFace")) + if (args.options().found("scaleOut")) { - MeshedSurface surf(importName); - - Info<< "Read surface:" << endl; - surf.writeStats(Info); - Info<< endl; - - if (args.options().found("orient")) - { - Info<< "Checking surface orientation" << endl; - PatchTools::checkOrientation(surf, true); - Info<< endl; - } - - if (args.options().found("clean")) - { - Info<< "Cleaning up surface" << endl; - surf.cleanup(true); - surf.writeStats(Info); - Info<< endl; - } - - Info<< "writing " << exportName; - if (scaleFactor <= 0) - { - Info<< " without scaling" << endl; - } - else - { - Info<< " with scaling " << scaleFactor << endl; - surf.scalePoints(scaleFactor); - surf.writeStats(Info); - Info<< endl; - } - surf.write(exportName); + IStringStream(args.options()["scaleOut"])() >> scaleOut; } -#endif - else + + { MeshedSurface surf(importName); - Info<< "Read surface:" << endl; - surf.writeStats(Info); - Info<< endl; - - if (args.options().found("orient")) - { - Info<< "Checking surface orientation" << endl; - PatchTools::checkOrientation(surf, true); - Info<< endl; - } - if (args.options().found("clean")) { - Info<< "Cleaning up surface" << endl; surf.cleanup(true); - surf.writeStats(Info); - Info<< endl; + } + + if (scaleIn > 0) + { + Info<< " -scaleIn " << scaleIn << endl; + surf.scalePoints(scaleIn); + } + + if (fromCsys.valid()) + { + Info<< " -from " << fromCsys().name() << endl; + tmp tpf = fromCsys().localPosition(surf.points()); + surf.movePoints(tpf()); + } + + if (toCsys.valid()) + { + Info<< " -to " << toCsys().name() << endl; + tmp tpf = toCsys().globalPosition(surf.points()); + surf.movePoints(tpf()); + } + + if (scaleOut > 0) + { + Info<< " -scaleOut " << scaleOut << endl; + surf.scalePoints(scaleOut); } Info<< "writing " << exportName; - if (scaleFactor <= 0) - { - Info<< " without scaling" << endl; - } - else - { - Info<< " with scaling " << scaleFactor << endl; - surf.scalePoints(scaleFactor); - surf.writeStats(Info); - Info<< endl; - } surf.write(exportName); } diff --git a/applications/utilities/surface/surfaceMeshConvertTesting/Make/files b/applications/utilities/surface/surfaceMeshConvertTesting/Make/files new file mode 100644 index 0000000000..6fd163a054 --- /dev/null +++ b/applications/utilities/surface/surfaceMeshConvertTesting/Make/files @@ -0,0 +1,3 @@ +surfaceMeshConvertTesting.C + +EXE = $(FOAM_APPBIN)/surfaceMeshConvertTesting diff --git a/applications/utilities/surface/surfaceMeshConvertTesting/Make/options b/applications/utilities/surface/surfaceMeshConvertTesting/Make/options new file mode 100644 index 0000000000..5293dabe4c --- /dev/null +++ b/applications/utilities/surface/surfaceMeshConvertTesting/Make/options @@ -0,0 +1,5 @@ +EXE_INC = \ + -I$(LIB_SRC)/triSurface/lnInclude \ + -I$(LIB_SRC)/surfMesh/lnInclude + +EXE_LIBS = -lsurfMesh diff --git a/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C b/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C new file mode 100644 index 0000000000..c7cc9b862f --- /dev/null +++ b/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C @@ -0,0 +1,323 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +Application + surfaceMeshConvertTesting + +Description + Converts from one surface mesh format to another, but primarily + used for testing functionality. + +Usage + - surfaceMeshConvertTesting inputFile outputFile [OPTION] + + @param -clean \n + Perform some surface checking/cleanup on the input surface + + @param -orient \n + Check face orientation on the input surface + + @param -scale \ \n + Specify a scaling factor for writing the files + + @param -triSurface \n + Use triSurface library for input/output + + @param -keyed \n + Use keyedSurface for input/output + +Note + The filename extensions are used to determine the file format type. + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "timeSelector.H" +#include "Time.H" +#include "polyMesh.H" +#include "triSurface.H" +#include "surfMesh.H" +#include "surfFields.H" +#include "PackedBoolList.H" + +#include "MeshedSurfaces.H" +#include "UnsortedMeshedSurfaces.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + argList::noParallel(); + argList::validArgs.append("inputFile"); + argList::validArgs.append("outputFile"); + argList::validOptions.insert("clean", ""); + argList::validOptions.insert("orient", ""); + argList::validOptions.insert("surfMesh", ""); + argList::validOptions.insert("scale", "scale"); + argList::validOptions.insert("triSurface", ""); + argList::validOptions.insert("unsorted", ""); + argList::validOptions.insert("triFace", ""); +# include "setRootCase.H" + const stringList& params = args.additionalArgs(); + + scalar scaleFactor = 0; + if (args.options().found("scale")) + { + IStringStream(args.options()["scale"])() >> scaleFactor; + } + + fileName importName(params[0]); + fileName exportName(params[1]); + + if (importName == exportName) + { + FatalErrorIn(args.executable()) + << "Output file " << exportName << " would overwrite input file." + << exit(FatalError); + } + + if + ( + !meshedSurface::canRead(importName, true) + || !meshedSurface::canWriteType(exportName.ext(), true) + ) + { + return 1; + } + + if (args.options().found("triSurface")) + { + triSurface surf(importName); + + Info<< "Read surface:" << endl; + surf.writeStats(Info); + Info<< endl; + + if (args.options().found("orient")) + { + Info<< "Checking surface orientation" << endl; + PatchTools::checkOrientation(surf, true); + Info<< endl; + } + + if (args.options().found("clean")) + { + Info<< "Cleaning up surface" << endl; + surf.cleanup(true); + surf.writeStats(Info); + Info<< endl; + } + + Info<< "writing " << exportName; + if (scaleFactor <= 0) + { + Info<< " without scaling" << endl; + } + else + { + Info<< " with scaling " << scaleFactor << endl; + surf.scalePoints(scaleFactor); + surf.writeStats(Info); + Info<< endl; + } + + // write sorted by region + surf.write(exportName, true); + } + else if (args.options().found("unsorted")) + { + UnsortedMeshedSurface surf(importName); + + Info<< "Read surface:" << endl; + surf.writeStats(Info); + Info<< endl; + + if (args.options().found("orient")) + { + Info<< "Checking surface orientation" << endl; + PatchTools::checkOrientation(surf, true); + Info<< endl; + } + + if (args.options().found("clean")) + { + Info<< "Cleaning up surface" << endl; + surf.cleanup(true); + surf.writeStats(Info); + Info<< endl; + } + + Info<< "writing " << exportName; + if (scaleFactor <= 0) + { + Info<< " without scaling" << endl; + } + else + { + Info<< " with scaling " << scaleFactor << endl; + surf.scalePoints(scaleFactor); + surf.writeStats(Info); + Info<< endl; + } + surf.write(exportName); + } +#if 1 + else if (args.options().found("triFace")) + { + MeshedSurface surf(importName); + + Info<< "Read surface:" << endl; + surf.writeStats(Info); + Info<< endl; + + if (args.options().found("orient")) + { + Info<< "Checking surface orientation" << endl; + PatchTools::checkOrientation(surf, true); + Info<< endl; + } + + if (args.options().found("clean")) + { + Info<< "Cleaning up surface" << endl; + surf.cleanup(true); + surf.writeStats(Info); + Info<< endl; + } + + Info<< "writing " << exportName; + if (scaleFactor <= 0) + { + Info<< " without scaling" << endl; + } + else + { + Info<< " with scaling " << scaleFactor << endl; + surf.scalePoints(scaleFactor); + surf.writeStats(Info); + Info<< endl; + } + surf.write(exportName); + } +#endif + else + { + MeshedSurface surf(importName); + + Info<< "Read surface:" << endl; + surf.writeStats(Info); + Info<< endl; + + if (args.options().found("orient")) + { + Info<< "Checking surface orientation" << endl; + PatchTools::checkOrientation(surf, true); + Info<< endl; + } + + if (args.options().found("clean")) + { + Info<< "Cleaning up surface" << endl; + surf.cleanup(true); + surf.writeStats(Info); + Info<< endl; + } + + + Info<< "writing " << exportName; + if (scaleFactor <= 0) + { + Info<< " without scaling" << endl; + } + else + { + Info<< " with scaling " << scaleFactor << endl; + surf.scalePoints(scaleFactor); + surf.writeStats(Info); + Info<< endl; + } + surf.write(exportName); + + if (args.options().found("surfMesh")) + { + Foam::Time runTime + ( + args.rootPath(), + args.caseName() + ); + + surfMesh surfOut + ( + IOobject + ( + "mySurf", + runTime.instance(), + runTime + ), + surf.xfer() + ); + + Info<< "writing surfMesh as well: " << surfOut.objectPath() << endl; + surfOut.write(); + + surfLabelField zoneIds + ( + IOobject + ( + "zoneIds", + surfOut.instance(), + surfOut, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + surfOut, + dimless + ); + + const surfZoneList& zones = surfOut.surfZones(); + forAll(zones, zoneI) + { + SubList