mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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.
This commit is contained in:
@ -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
|
||||
|
||||
@ -0,0 +1,83 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: dev |
|
||||
| \\ / A nd | Web: http://www.OpenFOAM.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class IOPtrList<coordinateSystem>;
|
||||
object coordinateSystems;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
7
|
||||
(
|
||||
system_9
|
||||
{
|
||||
type cartesian;
|
||||
origin (1.03291515 -0.114391257 -0.0826236662);
|
||||
e3 (1 0 0);
|
||||
e1 (0 1 0);
|
||||
// STARCDRotation (0 90 90);
|
||||
}
|
||||
|
||||
system_10
|
||||
{
|
||||
type cartesian;
|
||||
origin (0.623151719 -0.286472935 -0.113933262);
|
||||
e3 (0.99508851 0.09829095 0.01173645);
|
||||
e1 (0.01179356 0 -0.99993045);
|
||||
// STARCDRotation (5.6403745 -0.0664172952 89.3275351);
|
||||
}
|
||||
|
||||
system_15
|
||||
{
|
||||
type cartesian;
|
||||
origin (0.644772231 -0.240036493 0.155972187);
|
||||
e3 (-0.01346388 -0.90616979 -0.42269969);
|
||||
e1 (0.00627978 0.42265304 -0.90626981);
|
||||
// STARCDRotation (-90.8512386 0 115.005148);
|
||||
}
|
||||
|
||||
system_16
|
||||
{
|
||||
type cartesian;
|
||||
origin (0.540824938 -0.240036415 0.15928296);
|
||||
e3 (-0.01346388 -0.90616979 -0.42269969);
|
||||
e1 (0.00627978 0.42265304 -0.90626981);
|
||||
// STARCDRotation (-90.8512386 0 115.005148);
|
||||
}
|
||||
|
||||
system_17
|
||||
{
|
||||
type cartesian;
|
||||
origin (0.436877646 -0.240036339 0.162593737);
|
||||
e3 (-0.01346388 -0.90616979 -0.42269969);
|
||||
e1 (0.00627978 0.42265304 -0.90626981);
|
||||
// STARCDRotation (-90.8512386 0 115.005148);
|
||||
}
|
||||
|
||||
system_18
|
||||
{
|
||||
type cartesian;
|
||||
origin (0.332930354 -0.240036261 0.16590451);
|
||||
e3 (-0.01346388 -0.90616979 -0.42269969);
|
||||
e1 (0.00627978 0.42265304 -0.90626981);
|
||||
// STARCDRotation (-90.8512386 0 115.005148);
|
||||
}
|
||||
|
||||
system_21
|
||||
{
|
||||
type cartesian;
|
||||
origin (0.55863733 -0.300866705 0.00317260982);
|
||||
e3 (0.42110287 0.02470132 -0.90667647);
|
||||
e1 (0.90646036 0.02342535 0.42164069);
|
||||
// STARCDRotation (-178.185897 -0.71772221 -155.059695);
|
||||
}
|
||||
)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -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 \<scale\> \n
|
||||
Specify a scaling factor when reading files.
|
||||
|
||||
@param -scale \<scale\> \n
|
||||
Specify a scaling factor for writing the files
|
||||
@param -scaleOut \<scale\> \n
|
||||
Specify a scaling factor when writing files.
|
||||
|
||||
@param -triSurface \n
|
||||
Use triSurface library for input/output
|
||||
@param -dict \<dictionary\> \n
|
||||
Specify an alternative dictionary for constant/coordinateSystems.
|
||||
|
||||
@param -keyed \n
|
||||
Use keyedSurface for input/output
|
||||
@param -from \<coordinateSystem\> \n
|
||||
Specify a coordinate System when reading files.
|
||||
|
||||
@param -to \<coordinateSystem\> \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<face>::canRead(importName, true)
|
||||
|| !MeshedSurface<face>::canWriteType(exportName.ext(), true)
|
||||
)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (args.options().found("triSurface"))
|
||||
|
||||
// get the coordinate transformations
|
||||
autoPtr<coordinateSystem> fromCsys;
|
||||
autoPtr<coordinateSystem> toCsys;
|
||||
|
||||
if (args.options().found("from") || args.options().found("to"))
|
||||
{
|
||||
triSurface surf(importName);
|
||||
autoPtr<IOobject> 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<face> 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<triFace> 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<face> 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<pointField> tpf = fromCsys().localPosition(surf.points());
|
||||
surf.movePoints(tpf());
|
||||
}
|
||||
|
||||
if (toCsys.valid())
|
||||
{
|
||||
Info<< " -to " << toCsys().name() << endl;
|
||||
tmp<pointField> 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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user