102 using namespace Foam;
107 template<
class GeoField>
108 void readAndRotateFields
117 for (GeoField&
fld : flds)
143 readAndRotateFields(vsFlds,
mesh,
T, objects);
146 readAndRotateFields(vvFlds,
mesh,
T, objects);
149 readAndRotateFields(vstFlds,
mesh,
T, objects);
152 readAndRotateFields(vsymtFlds,
mesh,
T, objects);
155 readAndRotateFields(vtFlds,
mesh,
T, objects);
160 readAndRotateFields(ssFlds,
mesh,
T, objects);
163 readAndRotateFields(svFlds,
mesh,
T, objects);
166 readAndRotateFields(sstFlds,
mesh,
T, objects);
169 readAndRotateFields(ssymtFlds,
mesh,
T, objects);
172 readAndRotateFields(stFlds,
mesh,
T, objects);
190 if (scaling.
size() == 1)
194 else if (scaling.
size() == 3)
199 equal(scaling[0], scaling[1])
200 &&
equal(scaling[0], scaling[2])
206 else if (!scaling.
empty())
209 <<
"Incorrect number of components, must be 1 or 3." <<
nl 210 <<
" -" << optName <<
' ' <<
args[optName].c_str() <<
endl 214 if (scaling.
size() == 1 &&
equal(scaling[0], 1))
228 if (scaling.
size() == 1)
230 Info<<
"Scaling points uniformly by " << scaling[0] <<
nl;
233 else if (scaling.
size() == 3)
235 const vector factor(scaling[0], scaling[1], scaling[2]);
236 Info<<
"Scaling points by " << factor <<
nl;
244 int 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)" 261 "Recentre the bounding box before other operations" 267 "Translate by specified <vector> before rotations" 272 "Use bounding box centre as centre for rotations" 278 "Use specified <point> as centre for rotations" 287 "Rotate from <vectorA> to <vectorB> - eg, '((1 0 0) (0 0 1))'" 293 "Rotate <angle> degrees about <vector> - eg, '((1 0 0) 45)'" 298 "Rotate (degrees) about x-axis" 303 "Rotate (degrees) about y-axis" 308 "Rotate (degrees) about z-axis" 314 "Rotate by '(roll pitch yaw)' degrees" 320 "Rotate by '(yaw pitch roll)' degrees" 325 "Read and transform vector and tensor fields too" 331 "Scale by the specified amount - Eg, for uniform [mm] to [m] scaling " 332 "use either '(0.001 0.001 0.001)' or simply '0.001'" 337 "(originVec axisVec directionVec)",
338 "Tranform cylindrical coordinates to cartesian coordinates" 348 const bool doRotateFields =
args.
found(
"rotateFields");
370 <<
"No operation supplied, " 371 <<
"use at least one of the following:" <<
nl 374 for (
const auto& opName : operationNames)
391 if (
args[
"time"] ==
"constant")
397 const scalar timeValue =
args.
get<scalar>(
"time");
441 Info<<
"Adjust centre " << v <<
" -> (0 0 0)" <<
endl;
447 Info<<
"Translating points by " << v <<
endl;
453 if (
args.
found(
"auto-centre") && !useRotationCentre)
455 useRotationCentre =
true;
459 if (useRotationCentre)
461 Info<<
"Set centre of rotation to " << rotationCentre <<
endl;
469 bool useRotation(
false);
490 const vector& axis = rotAxisAngle.first();
491 const scalar angle = rotAxisAngle.second();
493 Info<<
"Rotating points " <<
nl 494 <<
" about " << axis <<
nl 495 <<
" angle " << angle <<
nl;
502 const scalar angle =
args.
get<scalar>(
"rotate-x");
504 Info<<
"Rotating points about x-axis: " << angle <<
nl;
511 const scalar angle =
args.
get<scalar>(
"rotate-y");
513 Info<<
"Rotating points about y-axis: " << angle <<
nl;
520 const scalar angle =
args.
get<scalar>(
"rotate-z");
522 Info<<
"Rotating points about z-axis: " << angle <<
nl;
529 Info<<
"Rotating points by" <<
nl 530 <<
" roll " << v.x() <<
nl 531 <<
" pitch " << v.y() <<
nl 532 <<
" yaw " << v.z() <<
nl;
539 Info<<
"Rotating points by" <<
nl 540 <<
" yaw " << v.x() <<
nl 541 <<
" pitch " << v.y() <<
nl 542 <<
" roll " << v.z() <<
nl;
550 Info<<
"Rotating points by " << rot <<
endl;
559 if (useRotationCentre)
561 Info<<
"Unset centre of rotation from " << rotationCentre <<
endl;
566 applyScaling(
points, getScalingOpt(
"scale",
args));
588 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.
A cylindrical coordinate system (r-theta-z). The coordinate system angle theta is always in radians...
errorManipArg< error, int > exit(error &err, const int errNo=1)
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.
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 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.
word findInstance(const fileName &directory, const word &name=word::null, IOobjectOption::readOption rOpt=IOobjectOption::MUST_READ, const word &stopInstance=word::null, const bool constant_fallback=true) const
Return time instance (location) of directory containing the file name (eg, used in reading mesh data)...
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.
static unsigned int minPrecision(unsigned int prec) noexcept
Set the minimum default precision.
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)