surfaceMeshConvert,surfaceMeshConvert,surfaceMeshImport: Updated coordinateSystem support

This commit is contained in:
Henry Weller
2020-09-29 16:10:06 +01:00
parent 31891a38b2
commit fe5e403cf9
3 changed files with 13 additions and 259 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -41,9 +41,6 @@ Usage
- \par -scaleOut \<scale\> - \par -scaleOut \<scale\>
Specify a scaling factor when writing files. Specify a scaling factor when writing files.
- \par -dict \<dictionary\>
Specify an alternative dictionary for constant/coordinateSystems.
- \par -from \<coordinateSystem\> - \par -from \<coordinateSystem\>
Specify a coordinate System when reading files. Specify a coordinate System when reading files.
@ -96,7 +93,6 @@ int main(int argc, char *argv[])
"factor", "factor",
"geometry scaling factor on output" "geometry scaling factor on output"
); );
#include "addDictOption.H"
argList::addOption argList::addOption
( (
"from", "from",
@ -141,109 +137,24 @@ int main(int argc, char *argv[])
} }
// get the coordinate transformations // Get the coordinate transformations
autoPtr<coordinateSystem> fromCsys; autoPtr<coordinateSystem> fromCsys;
autoPtr<coordinateSystem> toCsys; autoPtr<coordinateSystem> toCsys;
if (args.optionFound("from") || args.optionFound("to")) if (args.optionFound("from") || args.optionFound("to"))
{ {
autoPtr<IOobject> csDictIoPtr; coordinateSystems::coordinateSystems csLst(runTime);
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<coordinateSystems>(false))
{
FatalErrorInFunction
<< "Cannot open coordinateSystems file\n "
<< csDictIoPtr->objectPath() << nl
<< exit(FatalError);
}
coordinateSystems csLst(csDictIoPtr());
if (args.optionFound("from")) if (args.optionFound("from"))
{ {
const word csName = args["from"]; const word csName = args["from"];
fromCsys = csLst[csName].clone();
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]));
} }
if (args.optionFound("to")) if (args.optionFound("to"))
{ {
const word csName = args["to"]; const word csName = args["to"];
toCsys = csLst[csName].clone();
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);
} }
} }

View File

@ -45,9 +45,6 @@ Usage
- \par -scaleOut \<scale\> - \par -scaleOut \<scale\>
Specify a scaling factor when writing files. Specify a scaling factor when writing files.
- \par -dict \<dictionary\>
Specify an alternative dictionary for constant/coordinateSystems.
- \par -from \<coordinateSystem\> - \par -from \<coordinateSystem\>
Specify a coordinate system when reading files. Specify a coordinate system when reading files.
@ -103,7 +100,6 @@ int main(int argc, char *argv[])
"factor", "factor",
"geometry scaling factor on output - default is 1" "geometry scaling factor on output - default is 1"
); );
#include "addDictOption.H"
argList::addOption argList::addOption
( (
"from", "from",
@ -130,98 +126,24 @@ int main(int argc, char *argv[])
} }
// get the coordinate transformations // Get the coordinate transformations
autoPtr<coordinateSystem> fromCsys; autoPtr<coordinateSystem> fromCsys;
autoPtr<coordinateSystem> toCsys; autoPtr<coordinateSystem> toCsys;
if (args.optionFound("from") || args.optionFound("to")) if (args.optionFound("from") || args.optionFound("to"))
{ {
autoPtr<IOobject> ioPtr; coordinateSystems::coordinateSystems csLst(runTime);
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<coordinateSystems>(false))
{
FatalErrorInFunction
<< ioPtr->objectPath() << nl
<< exit(FatalError);
}
coordinateSystems csLst(ioPtr());
if (args.optionFound("from")) if (args.optionFound("from"))
{ {
const word csName = args["from"]; const word csName = args["from"];
fromCsys = csLst[csName].clone();
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]));
} }
if (args.optionFound("to")) if (args.optionFound("to"))
{ {
const word csName = args["to"]; const word csName = args["to"];
toCsys = csLst[csName].clone();
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);
} }
} }

View File

@ -45,9 +45,6 @@ Usage
- \par -scaleOut \<scale\> \n - \par -scaleOut \<scale\> \n
Specify a scaling factor when writing files. Specify a scaling factor when writing files.
- \par -dict \<dictionary\> \n
Specify an alternative dictionary for constant/coordinateSystems.
- \par -from \<coordinateSystem\> \n - \par -from \<coordinateSystem\> \n
Specify a coordinate system when reading files. Specify a coordinate system when reading files.
@ -103,7 +100,6 @@ int main(int argc, char *argv[])
"factor", "factor",
"geometry scaling factor on output - default is 1" "geometry scaling factor on output - default is 1"
); );
#include "addDictOption.H"
argList::addOption argList::addOption
( (
"from", "from",
@ -143,103 +139,28 @@ int main(int argc, char *argv[])
} }
// get the coordinate transformations // Get the coordinate transformations
autoPtr<coordinateSystem> fromCsys; autoPtr<coordinateSystem> fromCsys;
autoPtr<coordinateSystem> toCsys; autoPtr<coordinateSystem> toCsys;
if (args.optionFound("from") || args.optionFound("to")) if (args.optionFound("from") || args.optionFound("to"))
{ {
autoPtr<IOobject> ioPtr; coordinateSystems::coordinateSystems csLst(runTime);
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<coordinateSystems>(false))
{
FatalErrorInFunction
<< ioPtr->objectPath() << nl
<< exit(FatalError);
}
coordinateSystems csLst(ioPtr());
if (args.optionFound("from")) if (args.optionFound("from"))
{ {
const word csName = args["from"]; const word csName = args["from"];
fromCsys = csLst[csName].clone();
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]));
} }
if (args.optionFound("to")) if (args.optionFound("to"))
{ {
const word csName = args["to"]; const word csName = args["to"];
toCsys = csLst[csName].clone();
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);
} }
} }
MeshedSurface<face> surf(importName); MeshedSurface<face> surf(importName);
if (args.optionFound("clean")) if (args.optionFound("clean"))