coordinateRotation.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2013 OpenFOAM Foundation
9  Copyright (C) 2017-2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "coordinateRotation.H"
30 #include "axesRotation.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
39 }
40 
41 
42 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
43 
45 {
46  direction maxCmpt = 0;
47  scalar maxVal = mag(axis[maxCmpt]);
48 
49  for (direction cmpt = 1; cmpt < vector::nComponents; ++cmpt)
50  {
51  const scalar val = mag(axis[cmpt]);
52 
53  if (maxVal < val)
54  {
55  maxVal = val;
56  maxCmpt = cmpt;
57  }
58  }
59 
60  direction cmpt = ((maxCmpt == vector::nComponents-1) ? 0 : (maxCmpt+1));
61 
62  vector dirn(Zero);
63  dirn.component(cmpt) = ((axis[maxCmpt] < 0) ? -1 : 1);
64 
65  return dirn;
66 }
67 
68 
69 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
70 
73 (
74  const word& modelType,
75  const dictionary& dict
76 )
77 {
78  // Direct dispatch
79  // - treat missing modelType as 'axes' (eg, e1/e3 specification)
80 
81  if (modelType.empty())
82  {
84  }
85 
86  auto* ctorPtr = dictionaryConstructorTable(modelType);
87 
88  if (!ctorPtr)
89  {
91  (
92  dict,
93  "rotation",
94  modelType,
95  *dictionaryConstructorTablePtr_
96  ) << exit(FatalIOError);
97  }
98 
99  return autoPtr<coordinateRotation>(ctorPtr(dict));
100 }
101 
102 
105 (
106  const dictionary& dict
107 )
108 {
109  return coordinateRotation::New(dict.get<word>("type"), dict);
110 }
111 
112 
113 // ************************************************************************* //
User specification of a coordinate rotation.
dictionary dict
uint8_t direction
Definition: direction.H:46
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
::Foam::direction nComponents(const expressions::valueTypeCode) noexcept
The number of components associated with given valueTypeCode.
Definition: exprTraits.C:40
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
Macros for easy insertion into run-time selection tables.
defineTypeName(manifoldCellsMeshObject)
A class for handling words, derived from Foam::string.
Definition: word.H:63
Vector< scalar > vector
Definition: vector.H:57
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
static vector findOrthogonal(const vector &axis)
Determine best-guess for an orthogonal axis.
A coordinateRotation specified using global axes.
Definition: axesRotation.H:101
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:635
Namespace for OpenFOAM.
static autoPtr< coordinateRotation > New(const word &modelType, const dictionary &dict)
Select construct the specified coordinate rotation type.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127