OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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