sector.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "sector.H"
28 #include "unitConversion.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace extrudeModels
35 {
36 
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 
40 
42 
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
47 :
48  extrudeModel(typeName, dict),
49  axisPt_(coeffDict_.lookup("axisPt")),
50  axis_(coeffDict_.lookup("axis")),
51  angle_(coeffDict_.lookup<scalar>("angle", unitDegrees))
52 {}
53 
54 
55 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
56 
58 {}
59 
60 
61 // * * * * * * * * * * * * * * * * Operators * * * * * * * * * * * * * * * * //
62 
63 point sector::operator()
64 (
65  const point& surfacePoint,
66  const vector& surfaceNormal,
67  const label layer
68 ) const
69 {
70  scalar sliceAngle;
71 
72  // For the case of a single layer extrusion assume a
73  // symmetric sector about the reference plane is required
74  if (nLayers_ == 1)
75  {
76  if (layer == 0)
77  {
78  sliceAngle = -angle_/2.0;
79  }
80  else
81  {
82  sliceAngle = angle_/2.0;
83  }
84  }
85  else
86  {
87  sliceAngle = angle_*sumThickness(layer);
88  }
89 
90  // Find projection onto axis (or rather decompose surfacePoint
91  // into vector along edge (proj), vector normal to edge in plane
92  // of surface point and surface normal.
93  point d = surfacePoint - axisPt_;
94 
95  d -= (axis_ & d)*axis_;
96 
97  scalar dMag = mag(d);
98 
99  point edgePt = surfacePoint - d;
100 
101  // Rotate point around sliceAngle.
102  point rotatedPoint = edgePt;
103 
104  if (dMag > vSmall)
105  {
106  vector n = (d/dMag) ^ axis_;
107 
108  rotatedPoint +=
109  + cos(sliceAngle)*d
110  - sin(sliceAngle)*mag(d)*n; // Use either n or surfaceNormal
111  }
112 
113  return rotatedPoint;
114 }
115 
116 
117 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
118 
119 } // End namespace extrudeModels
120 } // End namespace Foam
121 
122 // ************************************************************************* //
label n
Macros for easy insertion into run-time selection tables.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Top level extrusion model class.
Definition: extrudeModel.H:52
Extrudes by rotating a surface around an axis.
Definition: sector.H:58
sector(const dictionary &dict)
Construct from dictionary.
Definition: sector.C:46
virtual ~sector()
Destructor.
Definition: sector.C:57
defineTypeNameAndDebug(cyclicSector, 0)
addToRunTimeSelectionTable(extrudeModel, cyclicSector, dictionary)
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
dimensionedScalar sin(const dimensionedScalar &ds)
dimensioned< scalar > mag(const dimensioned< Type > &)
dimensionedScalar cos(const dimensionedScalar &ds)
const unitConversion unitDegrees
dictionary dict