102 template<
class GeoField>
103 void 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 const vector factor(scaling[0], scaling[1], scaling[2]);
231 Info<<
"Scaling points by " << factor <<
nl;
239 int main(
int argc,
char *argv[])
243 "Transform (translate / rotate / scale) mesh points.\n" 244 "Note: roll=rotate about x, pitch=rotate about y, yaw=rotate about z" 250 "Specify the time to search from and apply the transformation" 251 " (default is latest)" 256 "Recentre the bounding box before other operations" 262 "Translate by specified <vector> before rotations" 267 "Use bounding box centre as centre for rotations" 273 "Use specified <point> as centre for rotations" 282 "Rotate from <vectorA> to <vectorB> - eg, '((1 0 0) (0 0 1))'" 288 "Rotate <angle> degrees about <vector> - eg, '((1 0 0) 45)'" 293 "Rotate (degrees) about x-axis" 298 "Rotate (degrees) about y-axis" 303 "Rotate (degrees) about z-axis" 309 "Rotate by '(roll pitch yaw)' degrees" 315 "Rotate by '(yaw pitch roll)' degrees" 320 "Read and transform vector and tensor fields too" 326 "Scale by the specified amount - Eg, for uniform [mm] to [m] scaling " 327 "use either '(0.001 0.001 0.001)' or simply '0.001'" 336 const bool doRotateFields =
args.
found(
"rotateFields");
357 <<
"No operation supplied, " 358 <<
"use at least one of the following:" <<
nl 361 for (
const auto& opName : operationNames)
378 if (
args[
"time"] ==
"constant")
384 const scalar timeValue =
args.
get<scalar>(
"time");
428 Info<<
"Adjust centre " << v <<
" -> (0 0 0)" <<
endl;
434 Info<<
"Translating points by " << v <<
endl;
440 if (
args.
found(
"auto-centre") && !useRotationCentre)
442 useRotationCentre =
true;
446 if (useRotationCentre)
448 Info<<
"Set centre of rotation to " << rotationCentre <<
endl;
456 bool useRotation(
false);
477 const vector& axis = rotAxisAngle.first();
478 const scalar angle = rotAxisAngle.second();
480 Info<<
"Rotating points " <<
nl 481 <<
" about " << axis <<
nl 482 <<
" angle " << angle <<
nl;
489 const scalar angle =
args.
get<scalar>(
"rotate-x");
491 Info<<
"Rotating points about x-axis: " << angle <<
nl;
498 const scalar angle =
args.
get<scalar>(
"rotate-y");
500 Info<<
"Rotating points about y-axis: " << angle <<
nl;
507 const scalar angle =
args.
get<scalar>(
"rotate-z");
509 Info<<
"Rotating points about z-axis: " << angle <<
nl;
516 Info<<
"Rotating points by" <<
nl 517 <<
" roll " << v.x() <<
nl 518 <<
" pitch " << v.y() <<
nl 519 <<
" yaw " << v.z() <<
nl;
526 Info<<
"Rotating points by" <<
nl 527 <<
" yaw " << v.x() <<
nl 528 <<
" pitch " << v.y() <<
nl 529 <<
" roll " << v.z() <<
nl;
537 Info<<
"Rotating points by " << rot <<
endl;
546 if (useRotationCentre)
548 Info<<
"Unset centre of rotation from " << rotationCentre <<
endl;
553 applyScaling(
points, getScalingOpt(
"scale",
args));
559 Info<<
"Writing points into directory "
static void addNote(const string ¬e)
Add extra notes for the usage information.
void size(const label n)
Older name for setAddressableSize.
A class for handling file names.
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.
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable, so the various sorted methods should be used if traversing in parallel.
errorManipArg< error, int > exit(error &err, const int errNo=1)
word findInstance(const fileName &dir, const word &name=word::null, IOobjectOption::readOption rOpt=IOobjectOption::MUST_READ, const word &stopInstance=word::null) const
Return time instance (location) of dir that contains the file name (eg, used in reading mesh data)...
void resize(const label len)
Adjust allocated size of list.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
bool equal(const T &a, const T &b)
Compare two values for equality.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
constexpr char nl
The newline '\n' character (0x0a)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
Ostream & endl(Ostream &os)
Add newline and flush stream.
fileName relativePath(const fileName &input, const bool caseTag=false) const
Return the input relative to the globalPath by stripping off a leading value of the globalPath...
static unsigned int defaultPrecision() noexcept
Return the default precision.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with 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.
Field reading functions for post-processing utilities.
Generic dimensioned Type class.
Ignore writing from objectRegistry::writeObject()
tensor rotationTensor(const vector &n1, const vector &n2)
Rotational transformation tensor from vector n1 to n2.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
#define forAll(list, i)
Loop across all elements in list.
Namespace for coordinate system rotations.
An ordered pair of two objects of type <T> with first() and second() elements.
void clear()
Clear the list, i.e. set size to zero.
A class for handling words, derived from Foam::string.
Extract command arguments and options from the supplied argc and argv parameters. ...
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
ITstream lookup(const word &optName) const
Return an input stream from the named option.
virtual bool write(const bool writeOnProc=true) const
Write mesh using IO settings from time.
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
bool readListIfPresent(const word &optName, List< T > &list) const
If named option is present, get a List of values treating a single entry like a list of size 1...
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name...
T get(const label index) const
Get a value from the argument at index.
static tensor rotation(const vector &angles, bool degrees=false)
Rotation tensor calculated for the intrinsic Euler angles in z-x-z order.
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
PtrList< volScalarField > & Y
Mesh data needed to do the Finite Volume discretisation.
fileName meshDir() const
Return the local mesh directory (dbDir()/meshSubDir)
static tensor rotation(const vector &axis, const scalar angle, bool degrees=false)
The rotation tensor for given axis/angle.
messageStream Info
Information stream (stdout output on master, null elsewhere)
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
point centre() const
The centre (midpoint) of the bounding box.
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Foam::argList args(argc, argv)
Tensor of scalars, i.e. Tensor<scalar>.
Defines the attributes of an object for which implicit objectRegistry management is supported...
A primitive field of type <T> with automated input and output.
label count(const UList< word > &optionNames) const
Return how many of the specified options were used.
Do not request registration (bool: false)
bool found(const word &optName) const
Return true if the named option is found.
static constexpr const zero Zero
Global zero (0)