transformPoints: Added option to restrict transformation to a point set

Transformation can now be restricted to a specific point set by means of
a new -pointSet option. For example, to move the rotating part of a
geometry through 45 degrees around the Z axis, the following command
could be used:

    transformPoints -pointSet rotating "Rz=45"

This assumes a point set called "rotating" has been defined during
meshing or by calling topoSet.
This commit is contained in:
Will Bainbridge
2022-05-06 22:03:12 +01:00
parent d0ccea2196
commit 774ff647b0
2 changed files with 53 additions and 3 deletions

View File

@ -1,8 +1,10 @@
EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude
EXE_LIBS = \
-lmeshTools \
-lfiniteVolume \
-lgenericPatchFields \
-lregionModels

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -51,6 +51,8 @@ Usage
Options:
- \par -rotateFields \n
Additionally transform vector and tensor fields.
- \par -pointSet \<name\> \n
Only transform points in the given point set.
Example usage:
transformPoints \
@ -71,6 +73,7 @@ See also
#include "surfaceFields.H"
#include "ReadFields.H"
#include "pointFields.H"
#include "pointSet.H"
#include "transformField.H"
#include "transformGeometricField.H"
#include "unitConversion.H"
@ -164,7 +167,6 @@ int main(int argc, char *argv[])
"\"translate=(1.2 0 0), Rx=90, translate=(-1.2 0 0)\""
);
argList::validArgs.append("transformations");
argList::addBoolOption
@ -173,6 +175,13 @@ int main(int argc, char *argv[])
"transform vector and tensor fields"
);
argList::addOption
(
"pointSet",
"pointSet",
"Point set to limit the transformation to"
);
#include "addRegionOption.H"
#include "addAllRegionsOption.H"
#include "setRootCase.H"
@ -186,6 +195,17 @@ int main(int argc, char *argv[])
const bool doRotateFields = args.optionFound("rotateFields");
word pointSetName = word::null;
const bool doPointSet = args.optionReadIfPresent("pointSet", pointSetName);
if (doRotateFields && doPointSet)
{
FatalErrorInFunction
<< "Rotation of fields across the entire mesh, and limiting the "
<< "transformation of points to a set, cannot be done "
<< "simultaneously" << exit(FatalError);
}
forAll(regionNames, regioni)
{
const word& regionName = regionNames[regioni];
@ -207,7 +227,35 @@ int main(int argc, char *argv[])
)
);
if (doPointSet)
{
const labelList setPointIDs
(
pointSet
(
IOobject
(
pointSetName,
runTime.findInstance(meshDir/"sets", word::null),
polyMesh::meshSubDir/"sets",
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
).toc()
);
pointField setPoints(UIndirectList<point>(points, setPointIDs));
transforms.transformPosition(setPoints, setPoints);
UIndirectList<point>(points, setPointIDs) = setPoints;
}
else
{
transforms.transformPosition(points, points);
}
if (doRotateFields)
{