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-------------------------------------------------------------------------------
11License
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
35namespace 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
72(
73 word modelType,
74 const dictionary& dict
75)
76{
77 if (modelType.empty())
78 {
79 modelType = coordinateRotations::axes::typeName_();
80 }
81
82 auto* ctorPtr = dictionaryConstructorTable(modelType);
83
84 if (!ctorPtr)
85 {
87 (
88 dict,
89 "rotation",
90 modelType,
91 *dictionaryConstructorTablePtr_
92 ) << exit(FatalIOError);
93 }
94
95 return autoPtr<coordinateRotation>(ctorPtr(dict));
96}
97
98
100(
101 const dictionary& dict
102)
103{
104 return coordinateRotation::New(dict.get<word>("type"), dict);
105}
106
107
108// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
const Cmpt & component(const direction) const
Definition: VectorSpaceI.H:87
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
User specification of a coordinate rotation.
static vector findOrthogonal(const vector &axis)
Determine best-guess for an orthogonal axis.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
static constexpr direction nComponents
Number of components in bool is 1.
Definition: bool.H:98
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeName(Type)
Define the typeName.
Definition: className.H:96
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:478
Namespace for OpenFOAM.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
uint8_t direction
Definition: direction.H:56
IOerror FatalIOError
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
dictionary dict