102template<
class GeoField>
103void readAndRotateFields
112 for (GeoField&
fld : flds)
138 readAndRotateFields(vsFlds,
mesh,
T, objects);
141 readAndRotateFields(vvFlds,
mesh,
T, objects);
144 readAndRotateFields(vstFlds,
mesh,
T, objects);
147 readAndRotateFields(vsymtFlds,
mesh,
T, objects);
150 readAndRotateFields(vtFlds,
mesh,
T, objects);
155 readAndRotateFields(ssFlds,
mesh,
T, objects);
158 readAndRotateFields(svFlds,
mesh,
T, objects);
161 readAndRotateFields(sstFlds,
mesh,
T, objects);
164 readAndRotateFields(ssymtFlds,
mesh,
T, objects);
167 readAndRotateFields(stFlds,
mesh,
T, objects);
185 if (scaling.
size() == 1)
189 else if (scaling.
size() == 3)
194 equal(scaling[0], scaling[1])
195 &&
equal(scaling[0], scaling[2])
201 else if (!scaling.
empty())
204 <<
"Incorrect number of components, must be 1 or 3." <<
nl
205 <<
" -" << optName <<
' ' <<
args[optName].c_str() <<
endl
209 if (scaling.
size() == 1 &&
equal(scaling[0], 1))
223 if (scaling.
size() == 1)
225 Info<<
"Scaling points uniformly by " << scaling[0] <<
nl;
228 else if (scaling.
size() == 3)
230 Info<<
"Scaling points by ("
233 << scaling[2] <<
')' <<
nl;
244int main(
int argc,
char *argv[])
248 "Transform (translate / rotate / scale) mesh points.\n"
249 "Note: roll=rotate about x, pitch=rotate about y, yaw=rotate about z"
255 "Specify the time to search from and apply the transformation"
256 " (default is latest)"
258 argList::addBoolOption
261 "Recentre the bounding box before other operations"
267 "Translate by specified <vector> before rotations"
269 argList::addBoolOption
272 "Use bounding box centre as origin for rotations"
278 "Use specified <point> as origin for rotations"
284 "Rotate from <vectorA> to <vectorB> - eg, '((1 0 0) (0 0 1))'"
290 "Rotate <angle> degrees about <vector> - eg, '((1 0 0) 45)'"
295 "Rotate (degrees) about x-axis"
300 "Rotate (degrees) about y-axis"
305 "Rotate (degrees) about z-axis"
311 "Rotate by '(roll pitch yaw)' degrees"
317 "Rotate by '(yaw pitch roll)' degrees"
319 argList::addBoolOption
322 "Read and transform vector and tensor fields too"
328 "Scale by the specified amount - Eg, for uniform [mm] to [m] scaling "
329 "use either '(0.001 0.001 0.001)' or simply '0.001'"
333 argList::addOptionCompat(
"scale", {
"write-scale", 0});
338 const bool doRotateFields =
args.
found(
"rotateFields");
359 <<
"No operation supplied, "
360 <<
"use at least one of the following:" <<
nl
363 for (
const auto& opName : operationNames)
370 <<
nl <<
exit(FatalError);
380 if (
args[
"time"] ==
"constant")
386 const scalar timeValue =
args.
get<scalar>(
"time");
401 polyMesh::regionName(
regionName)/polyMesh::meshSubDir
414 runTime.findInstance(meshDir,
"points"),
430 Info<<
"Adjust centre " << v <<
" -> (0 0 0)" <<
endl;
436 Info<<
"Translating points by " << v <<
endl;
442 if (
args.
found(
"auto-origin") && !useOrigin)
450 Info<<
"Set origin for rotations to " << origin <<
endl;
458 bool useRotation(
false);
479 const vector& axis = rotAxisAngle.first();
480 const scalar angle = rotAxisAngle.second();
482 Info<<
"Rotating points " <<
nl
483 <<
" about " << axis <<
nl
484 <<
" angle " << angle <<
nl;
486 rot = axisAngle::rotation(axis, angle,
true);
491 const scalar angle =
args.
get<scalar>(
"rotate-x");
493 Info<<
"Rotating points about x-axis: " << angle <<
nl;
495 rot = axisAngle::rotation(
vector::X, angle,
true);
500 const scalar angle =
args.
get<scalar>(
"rotate-y");
502 Info<<
"Rotating points about y-axis: " << angle <<
nl;
504 rot = axisAngle::rotation(
vector::Y, angle,
true);
509 const scalar angle =
args.
get<scalar>(
"rotate-z");
511 Info<<
"Rotating points about z-axis: " << angle <<
nl;
513 rot = axisAngle::rotation(
vector::Z, angle,
true);
518 Info<<
"Rotating points by" <<
nl
519 <<
" roll " << v.x() <<
nl
520 <<
" pitch " << v.y() <<
nl
521 <<
" yaw " << v.z() <<
nl;
523 rot = euler::rotation(euler::eulerOrder::ROLL_PITCH_YAW, v,
true);
528 Info<<
"Rotating points by" <<
nl
529 <<
" yaw " << v.x() <<
nl
530 <<
" pitch " << v.y() <<
nl
531 <<
" roll " << v.z() <<
nl;
533 rot = euler::rotation(euler::eulerOrder::YAW_PITCH_ROLL, v,
true);
539 Info<<
"Rotating points by " << rot <<
endl;
549 applyScaling(
points, getScalingOpt(
"scale",
args));
553 Info<<
"Unset origin for rotations from " << origin <<
endl;
559 IOstream::defaultPrecision(
max(10u, IOstream::defaultPrecision()));
561 Info<<
"Writing points into directory "
Field reading functions for post-processing utilities.
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
A primitive field of type <T> with automated input and output.
List of IOobjects with searching and retrieving facilities.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void resize(const label len)
Adjust allocated size of list.
void clear()
Clear the list, i.e. set size to zero.
An ordered pair of two objects of type <T> with first() and second() elements.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
void size(const label n)
Older name for setAddressableSize.
Extract command arguments and options from the supplied argc and argv parameters.
T get(const label index) const
Get a value from the argument at index.
bool readListIfPresent(const word &optName, List< T > &list) const
label count(const UList< word > &optionNames) const
Return how many of the specified options were used.
bool found(const word &optName) const
Return true if the named option is found.
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
ITstream lookup(const word &optName) const
Return an input stream from the named option.
A bounding box defined in terms of min/max extrema points.
point centre() const
The centre (midpoint) of the bounding box.
Generic dimensioned Type class.
A class for handling file names.
Mesh data needed to do the Finite Volume discretisation.
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name.
Tensor of scalars, i.e. Tensor<scalar>.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
Foam::word regionName(Foam::polyMesh::defaultRegion)
Namespace for coordinate system rotations.
wordList ReadFields(const typename GeoMesh::Mesh &mesh, const IOobjectList &objects, PtrList< GeometricField< Type, PatchField, GeoMesh > > &fields, const bool syncPar=true, const bool readOldTime=false)
Read Geometric fields of templated type.
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
tensor rotationTensor(const vector &n1, const vector &n2)
Rotational transformation tensor from vector n1 to n2.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.