fix face direction
[OpenFOAM-1.5.x.git] / applications / utilities / mesh / generation / extrudeMesh / extrudeModel / wedge / wedge.C
blob487be63c33547fdd89c902eb47f0a55519dd4ba9
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "wedge.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "mathematicalConstants.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 namespace Foam
35 namespace extrudeModels
38 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40 defineTypeNameAndDebug(wedge, 0);
42 addToRunTimeSelectionTable(extrudeModel, wedge, dictionary);
45 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
47 wedge::wedge(const dictionary& dict)
49     extrudeModel(typeName, dict),
50     axisPt_(coeffDict_.lookup("axisPt")),
51     axisNormal_(coeffDict_.lookup("axisNormal")),
52     angle_
53     (
54         readScalar(coeffDict_.lookup("angle"))
55        *mathematicalConstant::pi/180.0
56     )
60 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
62 wedge::~wedge()
66 // * * * * * * * * * * * * * * * * Operators * * * * * * * * * * * * * * * * //
68 point wedge::operator()
70     const point& surfacePoint,
71     const vector& surfaceNormal,
72     const label layer
73 ) const
75     scalar sliceAngle;
76     // For the case of a single layer extrusion assume a
77     // symmetric wedge about the reference plane is required
78     if (nLayers_ == 1)
79     {
80         if (layer == 0)
81         {
82             sliceAngle = -angle_/2.0;
83         }
84         else
85         {
86             sliceAngle = angle_/2.0;
87         }
88     }
89     else
90     {
91         //sliceAngle = angle_*(layer + 1)/nLayers_;
92         sliceAngle = angle_*layer/nLayers_;
93     }
95     // Find projection onto axis (or rather decompose surfacePoint
96     // into vector along edge (proj), vector normal to edge in plane
97     // of surface point and surface normal.
98     point d = surfacePoint - axisPt_;
100     d -= (axisNormal_ & d)*axisNormal_;
102     scalar dMag = mag(d);
104     point edgePt = surfacePoint - d;
106     // Rotate point around sliceAngle.
107     point rotatedPoint = edgePt;
109     if (dMag > VSMALL)
110     {
111         vector n = (d/dMag) ^ axisNormal_;
113         rotatedPoint +=
114           + cos(sliceAngle)*d
115           - sin(sliceAngle)*mag(d)*n; // Use either n or surfaceNormal
116     }
118     return rotatedPoint;
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124 } // End namespace extrudeModels
125 } // End namespace Foam
127 // ************************************************************************* //