All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2019 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 
39 defineTypeNameAndDebug(sector, 0);
40 
41 addToRunTimeSelectionTable(extrudeModel, sector, dictionary);
42 
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
47 :
48  extrudeModel(typeName, dict),
49  axisPt_(coeffDict_.lookup("axisPt")),
50  axis_(coeffDict_.lookup("axis")),
51  angle_
52  (
53  degToRad(coeffDict_.lookup<scalar>("angle"))
54  )
55 {}
56 
57 
58 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
59 
61 {}
62 
63 
64 // * * * * * * * * * * * * * * * * Operators * * * * * * * * * * * * * * * * //
65 
66 point sector::operator()
67 (
68  const point& surfacePoint,
69  const vector& surfaceNormal,
70  const label layer
71 ) const
72 {
73  scalar sliceAngle;
74 
75  // For the case of a single layer extrusion assume a
76  // symmetric sector about the reference plane is required
77  if (nLayers_ == 1)
78  {
79  if (layer == 0)
80  {
81  sliceAngle = -angle_/2.0;
82  }
83  else
84  {
85  sliceAngle = angle_/2.0;
86  }
87  }
88  else
89  {
90  sliceAngle = angle_*sumThickness(layer);
91  }
92 
93  // Find projection onto axis (or rather decompose surfacePoint
94  // into vector along edge (proj), vector normal to edge in plane
95  // of surface point and surface normal.
96  point d = surfacePoint - axisPt_;
97 
98  d -= (axis_ & d)*axis_;
99 
100  scalar dMag = mag(d);
101 
102  point edgePt = surfacePoint - d;
103 
104  // Rotate point around sliceAngle.
105  point rotatedPoint = edgePt;
106 
107  if (dMag > vSmall)
108  {
109  vector n = (d/dMag) ^ axis_;
110 
111  rotatedPoint +=
112  + cos(sliceAngle)*d
113  - sin(sliceAngle)*mag(d)*n; // Use either n or surfaceNormal
114  }
115 
116  return rotatedPoint;
117 }
118 
119 
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 
122 } // End namespace extrudeModels
123 } // End namespace Foam
124 
125 // ************************************************************************* //
dictionary dict
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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
Unit conversion functions.
defineTypeNameAndDebug(cyclicSector, 0)
Macros for easy insertion into run-time selection tables.
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
Top level extrusion model class.
Definition: extrudeModel.H:51
stressControl lookup("compactNormalStress") >> compactNormalStress
dimensionedScalar cos(const dimensionedScalar &ds)
dimensionedScalar sin(const dimensionedScalar &ds)
scalar sumThickness(const label layer) const
Helper: calculate cumulative relative thickness for layer.
Definition: extrudeModel.C:71
virtual ~sector()
Destructor.
Definition: sector.C:60
addToRunTimeSelectionTable(extrudeModel, cyclicSector, dictionary)
dimensioned< scalar > mag(const dimensioned< Type > &)
label n
sector(const dictionary &dict)
Construct from dictionary.
Definition: sector.C:46
Namespace for OpenFOAM.