createTransforms.H
Go to the documentation of this file.
1 transformer transforms;
2 
3 {
4  List<Tuple2<wordRe, label>> simpleTransformations;
5  List<Tuple3<word, string, label>> transformations;
7  (
8  {transformationString, 0},
9  simpleTransformations,
11  );
12 
14  {
15  if (transformations[i].first() == "translate")
16  {
17  const vector v(IStringStream(transformations[i].second())());
18  transforms = transformer::translation(v) & transforms;
19  }
20  else if (transformations[i].first() == "rotate")
21  {
22  Pair<vector> n1n2(IStringStream(transformations[i].second())());
23 
24  n1n2[0] /= mag(n1n2[0]);
25  n1n2[1] /= mag(n1n2[1]);
26 
27  transforms =
28  transformer::rotation(rotationTensor(n1n2[0], n1n2[1]))
29  & transforms;
30  }
31  else if (transformations[i].first() == "Rx")
32  {
33  const scalar a
34  (
35  readScalar(IStringStream(transformations[i].second())())
36  );
37  transforms = transformer::rotation(Rx(degToRad(a))) & transforms;
38  }
39  else if (transformations[i].first() == "Ry")
40  {
41  const scalar a
42  (
43  readScalar(IStringStream(transformations[i].second())())
44  );
45  transforms = transformer::rotation(Ry(degToRad(a))) & transforms;
46  }
47  else if (transformations[i].first() == "Rz")
48  {
49  const scalar a
50  (
51  readScalar(IStringStream(transformations[i].second())())
52  );
53  transforms = transformer::rotation(Rz(degToRad(a))) & transforms;
54  }
55  else if (transformations[i].first() == "Ra")
56  {
57  IStringStream istr(transformations[i].second());
58  const vector v(istr);
59  const scalar a(readScalar(istr));
60  transforms = transformer::rotation(Ra(v, degToRad(a))) & transforms;
61  }
62  else if (transformations[i].first() == "scale")
63  {
64  const vector v(IStringStream(transformations[i].second())());
65  transforms =
66  transformer::scaling(diagTensor(v.x(), v.y(), v.z()))
67  & transforms;
68  }
69  else
70  {
71  args.printUsage();
73  << "Unknown transformation " << transformations[i].first()
74  << exit(FatalError);
75  }
76  }
77 }
void printUsage() const
Print usage.
Definition: argList.C:1238
dictArgList({transformationString, 0}, simpleTransformations, transformations)
forAll(transformations, i)
List< Tuple3< word, string, label > > transformations
transformer transforms
#define readScalar
Definition: doubleScalar.C:39
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
scalar degToRad(const scalar deg)
Convert degrees to radians.
tensor rotationTensor(const vector &n1, const vector &n2)
Rotational transformation tensor from unit vector n1 to n2.
Definition: transform.H:47
tensor Ra(const vector &a, const scalar omega)
Rotational transformation tensor about axis a by omega radians.
Definition: transform.H:140
tensor Rx(const scalar &omega)
Rotational transformation tensor about the x-axis by omega radians.
Definition: transform.H:89
labelList second(const UList< labelPair > &p)
Definition: patchToPatch.C:49
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
tensor Ry(const scalar &omega)
Rotational transformation tensor about the y-axis by omega radians.
Definition: transform.H:106
labelList first(const UList< labelPair > &p)
Definition: patchToPatch.C:39
DiagTensor< scalar > diagTensor
A scalar version of the templated DiagTensor.
Definition: diagTensor.H:48
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
tensor Rz(const scalar &omega)
Rotational transformation tensor about the z-axis by omega radians.
Definition: transform.H:123
error FatalError
Foam::argList args(argc, argv)