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-------------------------------------------------------------------------------
11License
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
35namespace Foam
36{
37namespace extrudeModels
38{
39
40// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
41
43
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
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// ************************************************************************* //
label n
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Vector< Cmpt > & normalise(const scalar tol=ROOTVSMALL)
Inplace normalise the vector by its magnitude.
Definition: VectorI.H:123
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Top level extrusion model class.
Definition: extrudeModel.H:77
Extrudes by rotating a surface around an axis.
Definition: sector.H:93
friend Ostream & operator(Ostream &, const faMatrix< Type > &)
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
Namespace for OpenFOAM.
dimensionedScalar sin(const dimensionedScalar &ds)
constexpr scalar degToRad() noexcept
Multiplication factor for degrees to radians conversion.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
dimensionedScalar cos(const dimensionedScalar &ds)
dictionary dict
Unit conversion functions.