FreeFOAM The Cross-Platform CFD Toolkit
wedgePolyPatch.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "wedgePolyPatch.H"
28 #include <OpenFOAM/SubField.H>
29 #include <OpenFOAM/transform.H>
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(wedgePolyPatch, 0);
36 
37  addToRunTimeSelectionTable(polyPatch, wedgePolyPatch, word);
38  addToRunTimeSelectionTable(polyPatch, wedgePolyPatch, dictionary);
39 }
40 
41 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
42 
43 void Foam::wedgePolyPatch::initTransforms()
44 {
45  if (size() > 0)
46  {
47  const pointField& points = this->points();
48 
49  patchNormal_ = operator[](0).normal(points);
50  patchNormal_ /= mag(patchNormal_);
51 
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_);
60 
61  if
62  (
63  mag(centreNormal_.x() + centreNormal_.y() + centreNormal_.z())
64  < (1 - SMALL)
65  )
66  {
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  }
77 
78  axis_ = centreNormal_ ^ patchNormal_;
79  scalar magAxis = mag(axis_);
80  axis_ /= magAxis;
81 
82  if (magAxis < SMALL)
83  {
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  }
97 
98  faceT_ = rotationTensor(centreNormal_, patchNormal_);
99  cellT_ = faceT_ & faceT_;
100  }
101 }
102 
103 
104 // * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * //
105 
107 (
108  const word& name,
109  const label size,
110  const label start,
111  const label index,
112  const polyBoundaryMesh& bm
113 )
114 :
115  polyPatch(name, size, start, index, bm)
116 {
117  initTransforms();
118 }
119 
120 
122 (
123  const word& name,
124  const dictionary& dict,
125  const label index,
126  const polyBoundaryMesh& bm
127 )
128 :
129  polyPatch(name, dict, index, bm)
130 {
131  initTransforms();
132 }
133 
134 
136 (
137  const wedgePolyPatch& pp,
138  const polyBoundaryMesh& bm
139 )
140 :
141  polyPatch(pp, bm)
142 {
143  initTransforms();
144 }
145 
146 
148 (
149  const wedgePolyPatch& pp,
150  const polyBoundaryMesh& bm,
151  const label index,
152  const label newSize,
153  const label newStart
154 )
155 :
156  polyPatch(pp, bm, index, newSize, newStart)
157 {
158  initTransforms();
159 }
160 
161 
162 // ************************ vim: set sw=4 sts=4 et: ************************ //