BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / OpenFOAM / meshes / polyMesh / polyPatches / constraint / wedge / wedgePolyPatch.C
blob35b18aaf69949cf53961d34f47c944dd31dfffe0
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "wedgePolyPatch.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "SubField.H"
29 #include "transform.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 namespace Foam
35     defineTypeNameAndDebug(wedgePolyPatch, 0);
37     addToRunTimeSelectionTable(polyPatch, wedgePolyPatch, word);
38     addToRunTimeSelectionTable(polyPatch, wedgePolyPatch, dictionary);
41 // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
43 void Foam::wedgePolyPatch::initTransforms()
45     if (size() > 0)
46     {
47         const pointField& points = this->points();
49         patchNormal_ = operator[](0).normal(points);
50         patchNormal_ /= mag(patchNormal_);
52         centreNormal_ =
53             vector
54             (
55                 sign(patchNormal_.x())*(max(mag(patchNormal_.x()), 0.5) - 0.5),
56                 sign(patchNormal_.y())*(max(mag(patchNormal_.y()), 0.5) - 0.5),
57                 sign(patchNormal_.z())*(max(mag(patchNormal_.z()), 0.5) - 0.5)
58             );
59         centreNormal_ /= mag(centreNormal_);
61         if
62         (
63             mag(centreNormal_.x() + centreNormal_.y() + centreNormal_.z())
64             < (1 - SMALL)
65         )
66         {
67             FatalErrorIn
68             (
69                 "wedgePolyPatch::wedgePolyPatch(const polyPatch&, "
70                 "const fvBoundaryMesh&)"
71             )   << "wedge " << name()
72                 << " centre plane does not align with a coordinate plane by "
73                 << 1
74                  - mag(centreNormal_.x()+centreNormal_.y()+centreNormal_.z())
75                 << exit(FatalError);
76         }
78         axis_ = centreNormal_ ^ patchNormal_;
79         scalar magAxis = mag(axis_);
80         axis_ /= magAxis;
82         if (magAxis < SMALL)
83         {
84             FatalErrorIn
85             (
86                 "wedgePolyPatch::initTransforms()"
87             )   << "wedge " << name()
88                 << " plane aligns with a coordinate plane." << nl
89                 << "    The wedge plane should make a small angle (~2.5deg)"
90                    " with the coordinate plane" << nl
91                 << "    and the the pair of wedge planes should be symmetric"
92                 << " about the coordinate plane." << nl
93                 << "    Normal of face " << 0 << " is " << patchNormal_
94                 << " , implied coordinate plane direction is " << centreNormal_
95                 << exit(FatalError);
96         }
98         faceT_ = rotationTensor(centreNormal_, patchNormal_);
99         cellT_ = faceT_ & faceT_;
100     }
104 // * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * * * * * //
106 Foam::wedgePolyPatch::wedgePolyPatch
108     const word& name,
109     const label size,
110     const label start,
111     const label index,
112     const polyBoundaryMesh& bm
115     polyPatch(name, size, start, index, bm)
117     initTransforms();
121 Foam::wedgePolyPatch::wedgePolyPatch
123     const word& name,
124     const dictionary& dict,
125     const label index,
126     const polyBoundaryMesh& bm
129     polyPatch(name, dict, index, bm)
131     initTransforms();
135 Foam::wedgePolyPatch::wedgePolyPatch
137     const wedgePolyPatch& pp,
138     const polyBoundaryMesh& bm
141     polyPatch(pp, bm)
143     initTransforms();
147 Foam::wedgePolyPatch::wedgePolyPatch
149     const wedgePolyPatch& pp,
150     const polyBoundaryMesh& bm,
151     const label index,
152     const label newSize,
153     const label newStart
156     polyPatch(pp, bm, index, newSize, newStart)
158     initTransforms();
162 Foam::wedgePolyPatch::wedgePolyPatch
164     const wedgePolyPatch& pp,
165     const polyBoundaryMesh& bm,
166     const label index,
167     const labelUList& mapAddressing,
168     const label newStart
171     polyPatch(pp, bm, index, mapAddressing, newStart)
173     initTransforms();
177 // ************************************************************************* //