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

wedgePolyPatch.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 "wedgePolyPatch.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 #include <OpenFOAM/SubField.H>
00029 #include <OpenFOAM/transform.H>
00030 
00031 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00032 
00033 namespace Foam
00034 {
00035     defineTypeNameAndDebug(wedgePolyPatch, 0);
00036 
00037     addToRunTimeSelectionTable(polyPatch, wedgePolyPatch, word);
00038     addToRunTimeSelectionTable(polyPatch, wedgePolyPatch, dictionary);
00039 }
00040 
00041 // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
00042 
00043 void Foam::wedgePolyPatch::initTransforms()
00044 {
00045     if (size() > 0)
00046     {
00047         const pointField& points = this->points();
00048 
00049         patchNormal_ = operator[](0).normal(points);
00050         patchNormal_ /= mag(patchNormal_);
00051 
00052         centreNormal_ =
00053             vector
00054             (
00055                 sign(patchNormal_.x())*(max(mag(patchNormal_.x()), 0.5) - 0.5),
00056                 sign(patchNormal_.y())*(max(mag(patchNormal_.y()), 0.5) - 0.5),
00057                 sign(patchNormal_.z())*(max(mag(patchNormal_.z()), 0.5) - 0.5)
00058             );
00059         centreNormal_ /= mag(centreNormal_);
00060 
00061         if
00062         (
00063             mag(centreNormal_.x() + centreNormal_.y() + centreNormal_.z())
00064             < (1 - SMALL)
00065         )
00066         {
00067             FatalErrorIn
00068             (
00069                 "wedgePolyPatch::wedgePolyPatch(const polyPatch&, "
00070                 "const fvBoundaryMesh&)"
00071             )   << "wedge " << name()
00072                 << " centre plane does not align with a coordinate plane by "
00073                 << 1
00074                  - mag(centreNormal_.x()+centreNormal_.y()+centreNormal_.z())
00075                 << exit(FatalError);
00076         }
00077 
00078         axis_ = centreNormal_ ^ patchNormal_;
00079         scalar magAxis = mag(axis_);
00080         axis_ /= magAxis;
00081 
00082         if (magAxis < SMALL)
00083         {
00084             FatalErrorIn
00085             (
00086                 "wedgePolyPatch::initTransforms()"
00087             )   << "wedge " << name()
00088                 << " plane aligns with a coordinate plane." << nl
00089                 << "    The wedge plane should make a small angle (~2.5deg)"
00090                    " with the coordinate plane" << nl
00091                 << "    and the the pair of wedge planes should be symmetric"
00092                 << " about the coordinate plane." << nl
00093                 << "    Normal of face " << 0 << " is " << patchNormal_
00094                 << " , implied coordinate plane direction is " << centreNormal_
00095                 << exit(FatalError);
00096         }
00097 
00098         faceT_ = rotationTensor(centreNormal_, patchNormal_);
00099         cellT_ = faceT_ & faceT_;
00100     }
00101 }
00102 
00103 
00104 // * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * * * * * //
00105 
00106 Foam::wedgePolyPatch::wedgePolyPatch
00107 (
00108     const word& name,
00109     const label size,
00110     const label start,
00111     const label index,
00112     const polyBoundaryMesh& bm
00113 )
00114 :
00115     polyPatch(name, size, start, index, bm)
00116 {
00117     initTransforms();
00118 }
00119 
00120 
00121 Foam::wedgePolyPatch::wedgePolyPatch
00122 (
00123     const word& name,
00124     const dictionary& dict,
00125     const label index,
00126     const polyBoundaryMesh& bm
00127 )
00128 :
00129     polyPatch(name, dict, index, bm)
00130 {
00131     initTransforms();
00132 }
00133 
00134 
00135 Foam::wedgePolyPatch::wedgePolyPatch
00136 (
00137     const wedgePolyPatch& pp,
00138     const polyBoundaryMesh& bm
00139 )
00140 :
00141     polyPatch(pp, bm)
00142 {
00143     initTransforms();
00144 }
00145 
00146 
00147 Foam::wedgePolyPatch::wedgePolyPatch
00148 (
00149     const wedgePolyPatch& pp,
00150     const polyBoundaryMesh& bm,
00151     const label index,
00152     const label newSize,
00153     const label newStart
00154 )
00155 :
00156     polyPatch(pp, bm, index, newSize, newStart)
00157 {
00158     initTransforms();
00159 }
00160 
00161 
00162 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines