sector.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-2015 OpenFOAM Foundation
9  Copyright (C) 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 "sector.H"
31 #include "unitConversion.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace extrudeModels
38 {
39 
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
41 
42 defineTypeNameAndDebug(sector, 0);
43 
44 addToRunTimeSelectionTable(extrudeModel, sector, dictionary);
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
50 :
51  extrudeModel(typeName, dict),
52  refPoint_(coeffDict_.getCompat<point>("point", {{"axisPt", -1812}})),
53  axis_(coeffDict_.get<vector>("axis").normalise()),
54  angle_(degToRad(coeffDict_.get<scalar>("angle")))
55 {}
56 
57 
58 // * * * * * * * * * * * * * * * * Operators * * * * * * * * * * * * * * * * //
59 
60 point sector::operator()
61 (
62  const point& surfacePoint,
63  const vector& surfaceNormal,
64  const label layer
65 ) const
66 {
67  scalar sliceAngle;
68 
69  // For the case of a single layer extrusion assume a
70  // symmetric sector about the reference plane is required
71  if (nLayers_ == 1)
72  {
73  if (layer == 0)
74  {
75  sliceAngle = -angle_/2.0;
76  }
77  else
78  {
79  sliceAngle = angle_/2.0;
80  }
81  }
82  else
83  {
84  sliceAngle = angle_*sumThickness(layer);
85  }
86 
87  // Find projection onto axis (or rather decompose surfacePoint
88  // into vector along edge (proj), vector normal to edge in plane
89  // of surface point and surface normal.
90  point d = surfacePoint - refPoint_;
91 
92  d -= (axis_ & d)*axis_;
93 
94  scalar dMag = mag(d);
95 
96  point edgePt = surfacePoint - d;
97 
98  // Rotate point around sliceAngle.
99  point rotatedPoint = edgePt;
100 
101  if (dMag > VSMALL)
102  {
103  vector n = (d/dMag) ^ axis_;
104 
105  rotatedPoint +=
106  + cos(sliceAngle)*d
107  - sin(sliceAngle)*mag(d)*n; // Use either n or surfaceNormal
108  }
109 
110  return rotatedPoint;
111 }
112 
113 
114 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
115 
116 } // End namespace extrudeModels
117 } // End namespace Foam
118 
119 // ************************************************************************* //
Foam::extrudeModels::defineTypeNameAndDebug
defineTypeNameAndDebug(cyclicSector, 0)
Foam::extrudeModel
Top level extrusion model class.
Definition: extrudeModel.H:76
Foam::sin
dimensionedScalar sin(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:264
unitConversion.H
Unit conversion functions.
Foam::Vector::normalise
Vector< Cmpt > & normalise()
Normalise the vector by its magnitude.
Definition: VectorI.H:123
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::extrudeModels::sector::sector
sector(const dictionary &dict)
Construct from dictionary.
Definition: sector.C:49
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
Foam::extrudeModels::addToRunTimeSelectionTable
addToRunTimeSelectionTable(extrudeModel, cyclicSector, dictionary)
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::degToRad
constexpr scalar degToRad(const scalar deg) noexcept
Conversion from degrees to radians.
Definition: unitConversion.H:48
Foam::Vector< scalar >
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
sector.H
Foam::cos
dimensionedScalar cos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:265