FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

wedge.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "wedge.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 #include <OpenFOAM/mathematicalConstants.H>
00029 
00030 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034 namespace extrudeModels
00035 {
00036 
00037 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00038 
00039 defineTypeNameAndDebug(wedge, 0);
00040 
00041 addToRunTimeSelectionTable(extrudeModel, wedge, dictionary);
00042 
00043 
00044 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00045 
00046 wedge::wedge(const dictionary& dict)
00047 :
00048     extrudeModel(typeName, dict),
00049     axisPt_(coeffDict_.lookup("axisPt")),
00050     axis_(coeffDict_.lookup("axis")),
00051     angle_
00052     (
00053         readScalar(coeffDict_.lookup("angle"))
00054        *mathematicalConstant::pi/180.0
00055     )
00056 {}
00057 
00058 
00059 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00060 
00061 wedge::~wedge()
00062 {}
00063 
00064 
00065 // * * * * * * * * * * * * * * * * Operators * * * * * * * * * * * * * * * * //
00066 
00067 point wedge::operator()
00068 (
00069     const point& surfacePoint,
00070     const vector& surfaceNormal,
00071     const label layer
00072 ) const
00073 {
00074     scalar sliceAngle;
00075     // For the case of a single layer extrusion assume a
00076     // symmetric wedge about the reference plane is required
00077     if (nLayers_ == 1)
00078     {
00079         if (layer == 0)
00080         {
00081             sliceAngle = -angle_/2.0;
00082         }
00083         else
00084         {
00085             sliceAngle = angle_/2.0;
00086         }
00087     }
00088     else
00089     {
00090         //sliceAngle = angle_*(layer + 1)/nLayers_;
00091         sliceAngle = angle_*layer/nLayers_;
00092     }
00093 
00094     // Find projection onto axis (or rather decompose surfacePoint
00095     // into vector along edge (proj), vector normal to edge in plane
00096     // of surface point and surface normal.
00097     point d = surfacePoint - axisPt_;
00098 
00099     d -= (axis_ & d)*axis_;
00100 
00101     scalar dMag = mag(d);
00102 
00103     point edgePt = surfacePoint - d;
00104 
00105     // Rotate point around sliceAngle.
00106     point rotatedPoint = edgePt;
00107 
00108     if (dMag > VSMALL)
00109     {
00110         vector n = (d/dMag) ^ axis_;
00111 
00112         rotatedPoint +=
00113           + cos(sliceAngle)*d
00114           - sin(sliceAngle)*mag(d)*n; // Use either n or surfaceNormal
00115     }
00116 
00117     return rotatedPoint;
00118 }
00119 
00120 
00121 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00122 
00123 } // End namespace extrudeModels
00124 } // End namespace Foam
00125 
00126 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines