initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / meshes / polyMesh / polyPatches / constraint / wedge / wedgePolyPatch.C
blob9795b3d33289889ebb6899270b94d9347b711bf0
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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 "wedgePolyPatch.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "SubField.H"
30 #include "transform.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 namespace Foam
36     defineTypeNameAndDebug(wedgePolyPatch, 0);
38     addToRunTimeSelectionTable(polyPatch, wedgePolyPatch, word);
39     addToRunTimeSelectionTable(polyPatch, wedgePolyPatch, dictionary);
42 // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
44 void Foam::wedgePolyPatch::initTransforms()
46     const pointField& points = this->points();
48     patchNormal_ = operator[](0).normal(points);
49     patchNormal_ /= mag(patchNormal_);
51     centreNormal_ =
52         vector
53         (
54             sign(patchNormal_.x())*(max(mag(patchNormal_.x()), 0.5) - 0.5),
55             sign(patchNormal_.y())*(max(mag(patchNormal_.y()), 0.5) - 0.5),
56             sign(patchNormal_.z())*(max(mag(patchNormal_.z()), 0.5) - 0.5)
57         );
58     centreNormal_ /= mag(centreNormal_);
60     if
61     (
62         mag(centreNormal_.x() + centreNormal_.y() + centreNormal_.z())
63         < (1 - SMALL)
64     )
65     {
66         FatalErrorIn
67         (
68             "wedgePolyPatch::wedgePolyPatch(const polyPatch&, "
69             "const fvBoundaryMesh&)"
70         )   << "wedge " << name()
71             << " centre plane does not align with a coordinate plane by "
72             << 1
73              - mag(centreNormal_.x() + centreNormal_.y() + centreNormal_.z())
74             << exit(FatalError);
75     }
77     axis_ = centreNormal_ ^ patchNormal_;
78     scalar magAxis = mag(axis_);
79     axis_ /= magAxis;
81     if (magAxis < SMALL)
82     {
83         FatalErrorIn
84         (
85             "wedgePolyPatch::initTransforms()"
86         )   << "wedge " << name()
87             << " plane aligns with a coordinate plane." << nl
88             << "    The wedge plane should make a small angle (~2.5deg)"
89                " with the coordinate plane" << nl
90             << "    and the the pair of wedge planes should be symmetric"
91             << " about the coordinate plane." << nl
92             << "    Normal of face " << 0 << " is " << patchNormal_
93             << " , implied coordinate plane direction is " << centreNormal_
94             << exit(FatalError);
95     }
97     faceT_ = rotationTensor(centreNormal_, patchNormal_);
98     cellT_ = faceT_ & faceT_;
102 // * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * * * * * //
104 Foam::wedgePolyPatch::wedgePolyPatch
106     const word& name,
107     const label size,
108     const label start,
109     const label index,
110     const polyBoundaryMesh& bm
113     polyPatch(name, size, start, index, bm)
115     initTransforms();
119 Foam::wedgePolyPatch::wedgePolyPatch
121     const word& name,
122     const dictionary& dict,
123     const label index,
124     const polyBoundaryMesh& bm
127     polyPatch(name, dict, index, bm)
129     initTransforms();
133 Foam::wedgePolyPatch::wedgePolyPatch
135     const wedgePolyPatch& pp,
136     const polyBoundaryMesh& bm
139     polyPatch(pp, bm)
141     initTransforms();
145 Foam::wedgePolyPatch::wedgePolyPatch
147     const wedgePolyPatch& pp,
148     const polyBoundaryMesh& bm,
149     const label index,
150     const label newSize,
151     const label newStart
154     polyPatch(pp, bm, index, newSize, newStart)
156     initTransforms();
160 // ************************************************************************* //