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-2021 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"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeName(coordinateRotation);
37  defineRunTimeSelectionTable(coordinateRotation, dictionary);
38 }
39 
40 
41 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
42 
44 {
45  direction maxCmpt = 0;
46  scalar maxVal = mag(axis[maxCmpt]);
47 
48  for (direction cmpt=1; cmpt < vector::nComponents; ++cmpt)
49  {
50  const scalar val = mag(axis[cmpt]);
51 
52  if (maxVal < val)
53  {
54  maxVal = val;
55  maxCmpt = cmpt;
56  }
57  }
58 
59  direction cmpt = ((maxCmpt == vector::nComponents-1) ? 0 : (maxCmpt+1));
60 
61  vector dirn(Zero);
62  dirn.component(cmpt) = ((axis[maxCmpt] < 0) ? -1 : 1);
63 
64  return dirn;
65 }
66 
67 
68 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
69 
71 (
72  const dictionary& dict
73 )
74 {
75  const word modelType(dict.get<word>("type"));
76 
77  auto* ctorPtr = dictionaryConstructorTable(modelType);
78 
79  if (!ctorPtr)
80  {
82  (
83  dict,
84  "coordinateRotation",
85  modelType,
86  *dictionaryConstructorTablePtr_
87  ) << exit(FatalIOError);
88  }
89 
90  return autoPtr<coordinateRotation>(ctorPtr(dict));
91 }
92 
93 
94 // ************************************************************************* //
Foam::coordinateRotation::New
static autoPtr< coordinateRotation > New(const dictionary &dict)
Select constructed from dictionary.
Definition: coordinateRotation.C:71
Foam::VectorSpace::component
const Cmpt & component(const direction) const
Definition: VectorSpaceI.H:87
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::FatalIOError
IOerror FatalIOError
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:107
FatalIOErrorInLookup
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:478
Foam::defineTypeName
defineTypeName(ensightPart)
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::autoPtr< Foam::coordinateRotation >
Foam::Vector< scalar >
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::direction
uint8_t direction
Definition: direction.H:52
coordinateRotation.H
Foam::VectorSpace< Vector< scalar >, scalar, 3 >::nComponents
static constexpr direction nComponents
Number of components in this vector space.
Definition: VectorSpace.H:101
Foam::coordinateRotation::findOrthogonal
static vector findOrthogonal(const vector &axis)
Determine best-guess for an orthogonal axis.
Definition: coordinateRotation.C:43