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-2019 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 "dictionary.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  defineTypeName(coordinateRotation);
38  defineRunTimeSelectionTable(coordinateRotation, dictionary);
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  const dictionary& dict
74 )
75 {
76  const word modelType(dict.get<word>("type"));
77 
78  auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
79 
80  if (!cstrIter.found())
81  {
83  (
84  dict,
85  "coordinateRotation",
86  modelType,
87  *dictionaryConstructorTablePtr_
88  ) << exit(FatalIOError);
89  }
90 
91  return autoPtr<coordinateRotation>(cstrIter()(dict));
92 }
93 
94 
95 // ************************************************************************* //
Foam::coordinateRotation::New
static autoPtr< coordinateRotation > New(const dictionary &dict)
Select constructed from dictionary.
Definition: coordinateRotation.C:72
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:62
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:81
FatalIOErrorInLookup
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:406
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:121
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)
dictionary.H
Foam::direction
uint8_t direction
Definition: direction.H:52
coordinateRotation.H
Foam::VectorSpace< Vector< Cmpt >, Cmpt, 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:44