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