diff --git a/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C b/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C index bcedb1b9c5..47f543b521 100644 --- a/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C +++ b/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -41,9 +41,6 @@ Usage - \par -scaleOut \ Specify a scaling factor when writing files. - - \par -dict \ - Specify an alternative dictionary for constant/coordinateSystems. - - \par -from \ Specify a coordinate System when reading files. @@ -96,7 +93,6 @@ int main(int argc, char *argv[]) "factor", "geometry scaling factor on output" ); - #include "addDictOption.H" argList::addOption ( "from", @@ -141,109 +137,24 @@ int main(int argc, char *argv[]) } - // get the coordinate transformations + // Get the coordinate transformations autoPtr fromCsys; autoPtr toCsys; if (args.optionFound("from") || args.optionFound("to")) { - autoPtr csDictIoPtr; - - const word dictName("coordinateSystems::typeName"); - - // Note: cannot use setSystemRunTimeDictionaryIO.H since dictionary - // is in constant - - fileName dictPath = ""; - if (args.optionFound("dict")) - { - dictPath = args["dict"]; - if (isDir(dictPath)) - { - dictPath = dictPath / dictName; - } - } - - if (dictPath.size()) - { - csDictIoPtr.set - ( - new IOobject - ( - dictPath, - runTime, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ) - ); - } - else - { - csDictIoPtr.set - ( - new IOobject - ( - dictName, - runTime.constant(), - runTime, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ) - ); - } - - - if (!csDictIoPtr->typeHeaderOk(false)) - { - FatalErrorInFunction - << "Cannot open coordinateSystems file\n " - << csDictIoPtr->objectPath() << nl - << exit(FatalError); - } - - coordinateSystems csLst(csDictIoPtr()); + coordinateSystems::coordinateSystems csLst(runTime); if (args.optionFound("from")) { const word csName = args["from"]; - - const label csIndex = csLst.findIndex(csName); - if (csIndex < 0) - { - FatalErrorInFunction - << "Cannot find -from " << csName << nl - << "available coordinateSystems: " << csLst.toc() << nl - << exit(FatalError); - } - - fromCsys.reset(new coordinateSystem(csLst[csIndex])); + fromCsys = csLst[csName].clone(); } if (args.optionFound("to")) { const word csName = args["to"]; - - const label csIndex = csLst.findIndex(csName); - if (csIndex < 0) - { - FatalErrorInFunction - << "Cannot find -to " << csName << nl - << "available coordinateSystems: " << csLst.toc() << nl - << exit(FatalError); - } - - toCsys.reset(new coordinateSystem(csLst[csIndex])); - } - - - // maybe fix this later - if (fromCsys.valid() && toCsys.valid()) - { - FatalErrorInFunction - << "Only allowed '-from' or '-to' option at the moment." - << exit(FatalError); + toCsys = csLst[csName].clone(); } } diff --git a/applications/utilities/surface/surfaceMeshExport/surfaceMeshExport.C b/applications/utilities/surface/surfaceMeshExport/surfaceMeshExport.C index f6a0a57f3a..86f413547c 100644 --- a/applications/utilities/surface/surfaceMeshExport/surfaceMeshExport.C +++ b/applications/utilities/surface/surfaceMeshExport/surfaceMeshExport.C @@ -45,9 +45,6 @@ Usage - \par -scaleOut \ Specify a scaling factor when writing files. - - \par -dict \ - Specify an alternative dictionary for constant/coordinateSystems. - - \par -from \ Specify a coordinate system when reading files. @@ -103,7 +100,6 @@ int main(int argc, char *argv[]) "factor", "geometry scaling factor on output - default is 1" ); - #include "addDictOption.H" argList::addOption ( "from", @@ -130,98 +126,24 @@ int main(int argc, char *argv[]) } - // get the coordinate transformations + // Get the coordinate transformations autoPtr fromCsys; autoPtr toCsys; if (args.optionFound("from") || args.optionFound("to")) { - autoPtr ioPtr; - - if (args.optionFound("dict")) - { - const fileName dictPath = args["dict"]; - - ioPtr.set - ( - new IOobject - ( - ( - isDir(dictPath) - ? dictPath/coordinateSystems::typeName - : dictPath - ), - runTime, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ) - ); - } - else - { - ioPtr.set - ( - new IOobject - ( - coordinateSystems::typeName, - runTime.constant(), - runTime, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ) - ); - } - - - if (!ioPtr->typeHeaderOk(false)) - { - FatalErrorInFunction - << ioPtr->objectPath() << nl - << exit(FatalError); - } - - coordinateSystems csLst(ioPtr()); + coordinateSystems::coordinateSystems csLst(runTime); if (args.optionFound("from")) { const word csName = args["from"]; - - const label csIndex = csLst.findIndex(csName); - if (csIndex < 0) - { - FatalErrorInFunction - << "Cannot find -from " << csName << nl - << "available coordinateSystems: " << csLst.toc() << nl - << exit(FatalError); - } - - fromCsys.reset(new coordinateSystem(csLst[csIndex])); + fromCsys = csLst[csName].clone(); } if (args.optionFound("to")) { const word csName = args["to"]; - - const label csIndex = csLst.findIndex(csName); - if (csIndex < 0) - { - FatalErrorInFunction - << "Cannot find -to " << csName << nl - << "available coordinateSystems: " << csLst.toc() << nl - << exit(FatalError); - } - - toCsys.reset(new coordinateSystem(csLst[csIndex])); - } - - - // maybe fix this later - if (fromCsys.valid() && toCsys.valid()) - { - FatalErrorInFunction - << exit(FatalError); + toCsys = csLst[csName].clone(); } } diff --git a/applications/utilities/surface/surfaceMeshImport/surfaceMeshImport.C b/applications/utilities/surface/surfaceMeshImport/surfaceMeshImport.C index da477195eb..33fcf3dba7 100644 --- a/applications/utilities/surface/surfaceMeshImport/surfaceMeshImport.C +++ b/applications/utilities/surface/surfaceMeshImport/surfaceMeshImport.C @@ -45,9 +45,6 @@ Usage - \par -scaleOut \ \n Specify a scaling factor when writing files. - - \par -dict \ \n - Specify an alternative dictionary for constant/coordinateSystems. - - \par -from \ \n Specify a coordinate system when reading files. @@ -103,7 +100,6 @@ int main(int argc, char *argv[]) "factor", "geometry scaling factor on output - default is 1" ); - #include "addDictOption.H" argList::addOption ( "from", @@ -143,103 +139,28 @@ int main(int argc, char *argv[]) } - // get the coordinate transformations + // Get the coordinate transformations autoPtr fromCsys; autoPtr toCsys; if (args.optionFound("from") || args.optionFound("to")) { - autoPtr ioPtr; - - if (args.optionFound("dict")) - { - const fileName dictPath = args["dict"]; - - ioPtr.set - ( - new IOobject - ( - ( - isDir(dictPath) - ? dictPath/coordinateSystems::typeName - : dictPath - ), - runTime, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ) - ); - } - else - { - ioPtr.set - ( - new IOobject - ( - coordinateSystems::typeName, - runTime.constant(), - runTime, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ) - ); - } - - - if (!ioPtr->typeHeaderOk(false)) - { - FatalErrorInFunction - << ioPtr->objectPath() << nl - << exit(FatalError); - } - - coordinateSystems csLst(ioPtr()); + coordinateSystems::coordinateSystems csLst(runTime); if (args.optionFound("from")) { const word csName = args["from"]; - - const label csIndex = csLst.findIndex(csName); - if (csIndex < 0) - { - FatalErrorInFunction - << "Cannot find -from " << csName << nl - << "available coordinateSystems: " << csLst.toc() << nl - << exit(FatalError); - } - - fromCsys.reset(new coordinateSystem(csLst[csIndex])); + fromCsys = csLst[csName].clone(); } if (args.optionFound("to")) { const word csName = args["to"]; - - const label csIndex = csLst.findIndex(csName); - if (csIndex < 0) - { - FatalErrorInFunction - << "Cannot find -to " << csName << nl - << "available coordinateSystems: " << csLst.toc() << nl - << exit(FatalError); - } - - toCsys.reset(new coordinateSystem(csLst[csIndex])); - } - - - // maybe fix this later - if (fromCsys.valid() && toCsys.valid()) - { - FatalErrorInFunction - << exit(FatalError); + toCsys = csLst[csName].clone(); } } - MeshedSurface surf(importName); if (args.optionFound("clean"))