111template<
class GeoField>
112void readAndRotateFields
121 for (GeoField&
fld : flds)
147 readAndRotateFields(vsFlds,
mesh,
T, objects);
150 readAndRotateFields(vvFlds,
mesh,
T, objects);
153 readAndRotateFields(vstFlds,
mesh,
T, objects);
156 readAndRotateFields(vsymtFlds,
mesh,
T, objects);
159 readAndRotateFields(vtFlds,
mesh,
T, objects);
164 readAndRotateFields(ssFlds,
mesh,
T, objects);
167 readAndRotateFields(svFlds,
mesh,
T, objects);
170 readAndRotateFields(sstFlds,
mesh,
T, objects);
173 readAndRotateFields(ssymtFlds,
mesh,
T, objects);
176 readAndRotateFields(stFlds,
mesh,
T, objects);
191 List<scalar> scaling;
192 args.readListIfPresent(optName, scaling);
194 if (scaling.
size() == 1)
198 else if (scaling.
size() == 3)
203 equal(scaling[0], scaling[1])
204 &&
equal(scaling[0], scaling[2])
210 else if (!scaling.
empty())
213 <<
"Incorrect number of components, must be 1 or 3." <<
nl
214 <<
" -" << optName <<
' ' <<
args[optName].c_str() <<
endl
218 if (scaling.
size() == 1 &&
equal(scaling[0], 1))
232 if (scaling.
size() == 1)
234 Info<<
"Scaling points uniformly by " << scaling[0] <<
nl;
237 else if (scaling.
size() == 3)
239 const vector factor(scaling[0], scaling[1], scaling[2]);
240 Info<<
"Scaling points by " << factor <<
nl;
248int main(
int argc,
char *argv[])
252 "Transform (translate / rotate / scale) mesh points.\n"
253 "Note: roll=rotate about x, pitch=rotate about y, yaw=rotate about z"
259 "Specify the time to search from and apply the transformation"
260 " (default is latest)"
265 "Recentre the bounding box before other operations"
271 "Translate by specified <vector> before rotations"
276 "Use bounding box centre as centre for rotations"
282 "Use specified <point> as centre for rotations"
291 "Rotate from <vectorA> to <vectorB> - eg, '((1 0 0) (0 0 1))'"
297 "Rotate <angle> degrees about <vector> - eg, '((1 0 0) 45)'"
302 "Rotate (degrees) about x-axis"
307 "Rotate (degrees) about y-axis"
312 "Rotate (degrees) about z-axis"
318 "Rotate by '(roll pitch yaw)' degrees"
324 "Rotate by '(yaw pitch roll)' degrees"
329 "Read and transform vector and tensor fields too"
335 "Scale by the specified amount - Eg, for uniform [mm] to [m] scaling "
336 "use either '(0.001 0.001 0.001)' or simply '0.001'"
341 "(originVec axisVec directionVec)",
342 "Tranform cylindrical coordinates to cartesian coordinates"
352 const bool doRotateFields =
args.found(
"rotateFields");
356 const List<word> operationNames
371 if (!
args.count(operationNames))
374 <<
"No operation supplied, "
375 <<
"use at least one of the following:" <<
nl
378 for (
const auto& opName : operationNames)
393 if (
args.found(
"time"))
395 if (
args[
"time"] ==
"constant")
401 const scalar timeValue =
args.get<scalar>(
"time");
429 runTime.findInstance(meshDir,
"points"),
442 if (
args.found(
"recentre"))
445 Info<<
"Adjust centre " << v <<
" -> (0 0 0)" <<
endl;
449 if (
args.readIfPresent(
"translate", v))
451 Info<<
"Translating points by " << v <<
endl;
456 bool useRotationCentre =
args.readIfPresent(
"centre", rotationCentre);
457 if (
args.found(
"auto-centre") && !useRotationCentre)
459 useRotationCentre =
true;
463 if (useRotationCentre)
465 Info<<
"Set centre of rotation to " << rotationCentre <<
endl;
473 bool useRotation(
false);
475 if (
args.found(
"rotate"))
479 args.lookup(
"rotate")()
487 else if (
args.found(
"rotate-angle"))
491 args.lookup(
"rotate-angle")()
494 const vector& axis = rotAxisAngle.first();
495 const scalar angle = rotAxisAngle.second();
497 Info<<
"Rotating points " <<
nl
498 <<
" about " << axis <<
nl
499 <<
" angle " << angle <<
nl;
504 else if (
args.found(
"rotate-x"))
506 const scalar angle =
args.get<scalar>(
"rotate-x");
508 Info<<
"Rotating points about x-axis: " << angle <<
nl;
513 else if (
args.found(
"rotate-y"))
515 const scalar angle =
args.get<scalar>(
"rotate-y");
517 Info<<
"Rotating points about y-axis: " << angle <<
nl;
522 else if (
args.found(
"rotate-z"))
524 const scalar angle =
args.get<scalar>(
"rotate-z");
526 Info<<
"Rotating points about z-axis: " << angle <<
nl;
531 else if (
args.readIfPresent(
"rollPitchYaw", v))
533 Info<<
"Rotating points by" <<
nl
534 <<
" roll " << v.x() <<
nl
535 <<
" pitch " << v.y() <<
nl
536 <<
" yaw " << v.z() <<
nl;
541 else if (
args.readIfPresent(
"yawPitchRoll", v))
543 Info<<
"Rotating points by" <<
nl
544 <<
" yaw " << v.x() <<
nl
545 <<
" pitch " << v.y() <<
nl
546 <<
" roll " << v.z() <<
nl;
554 Info<<
"Rotating points by " << rot <<
endl;
563 if (useRotationCentre)
565 Info<<
"Unset centre of rotation from " << rotationCentre <<
endl;
570 applyScaling(
points, getScalingOpt(
"scale",
args));
572 if (
args.found(
"cylToCart"))
592 Info<<
"Writing points into directory "
Field reading functions for post-processing utilities.
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable,...
@ NO_REGISTER
Do not request registration (bool: false).
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
static unsigned int minPrecision(unsigned int prec) noexcept
Set the minimum default precision.
void resize(const label len)
Adjust allocated size of list.
void clear()
Clear the list, i.e. set size to zero.
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 List 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.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
static void addNote(const string ¬e)
Add extra notes for the usage information.
static void addOptionCompat(const word &optName, std::pair< const char *, int > compat)
Specify an alias for the option name.
A bounding box defined in terms of min/max extrema points.
point centre() const
The centre (midpoint) of the bounding box.
static tensor rotation(const vector &axis, const scalar angle, bool degrees=false)
The rotation tensor for given axis/angle.
static tensor rotation(const vector &angles, bool degrees=false)
Rotation tensor calculated for the intrinsic Euler angles in z-x-z order.
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.
fileName meshDir() const
Return the local mesh directory (dbDir()/meshSubDir).
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(args.getOrDefault< word >("region", 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.
tensor rotationTensor(const vector &n1, const vector &n2)
Rotational transformation tensor from vector n1 to n2.
bool equal(const T &a, const T &b)
Compare two values for equality.
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
messageStream Info
Information stream (stdout output on master, null elsewhere).
vectorIOField pointIOField
pointIOField is a vectorIOField.
Ostream & endl(Ostream &os)
Add newline and flush stream.
coordSystem::cylindrical cylindricalCS
Compatibility typedef 1806.
Field< vector > vectorField
Specialisation of Field<T> for vector.
static constexpr const zero Zero
Global zero (0).
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< tensor > dimensionedTensor
Dimensioned tensor obtained from generic dimensioned type.
constexpr char nl
The newline '\n' character (0x0a).
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.