initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / meshes / polyMesh / polyPatches / polyPatch / polyPatch.C
blob7c3d206db46746dcd55c6e7eec2ef2da74e98807
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 "polyPatch.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "polyBoundaryMesh.H"
30 #include "polyMesh.H"
31 #include "primitiveMesh.H"
32 #include "SubField.H"
33 #include "entry.H"
34 #include "dictionary.H"
35 #include "pointPatchField.H"
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
39 namespace Foam
41     defineTypeNameAndDebug(polyPatch, 0);
43     int polyPatch::disallowGenericPolyPatch
44     (
45         debug::debugSwitch("disallowGenericPolyPatch", 0)
46     );
48     defineRunTimeSelectionTable(polyPatch, word);
49     defineRunTimeSelectionTable(polyPatch, dictionary);
51     addToRunTimeSelectionTable(polyPatch, polyPatch, word);
52     addToRunTimeSelectionTable(polyPatch, polyPatch, dictionary);
56 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
58 void Foam::polyPatch::movePoints(const pointField& p)
60     primitivePatch::movePoints(p);
63 void Foam::polyPatch::updateMesh()
65     clearAddressing();
69 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
71 Foam::polyPatch::polyPatch
73     const word& name,
74     const label size,
75     const label start,
76     const label index,
77     const polyBoundaryMesh& bm
80     patchIdentifier(name, index),
81     primitivePatch
82     (
83         faceSubList(bm.mesh().faces(), size, start),
84         bm.mesh().points()
85     ),
86     start_(start),
87     boundaryMesh_(bm),
88     faceCellsPtr_(NULL),
89     mePtr_(NULL)
93 Foam::polyPatch::polyPatch
95     const word& name,
96     const dictionary& dict,
97     const label index,
98     const polyBoundaryMesh& bm
101     patchIdentifier(name, dict, index),
102     primitivePatch
103     (
104         faceSubList
105         (
106             bm.mesh().faces(),
107             readLabel(dict.lookup("nFaces")),
108             readLabel(dict.lookup("startFace"))
109         ),
110         bm.mesh().points()
111     ),
112     start_(readLabel(dict.lookup("startFace"))),
113     boundaryMesh_(bm),
114     faceCellsPtr_(NULL),
115     mePtr_(NULL)
119 Foam::polyPatch::polyPatch
121     const polyPatch& pp,
122     const polyBoundaryMesh& bm
125     patchIdentifier(pp),
126     primitivePatch
127     (
128         faceSubList
129         (
130             bm.mesh().faces(),
131             pp.size(),
132             pp.start()
133         ),
134         bm.mesh().points()
135     ),
136     start_(pp.start()),
137     boundaryMesh_(bm),
138     faceCellsPtr_(NULL),
139     mePtr_(NULL)
143 Foam::polyPatch::polyPatch
145     const polyPatch& pp,
146     const polyBoundaryMesh& bm,
147     const label index,
148     const label newSize,
149     const label newStart
152     patchIdentifier(pp, index),
153     primitivePatch
154     (
155         faceSubList
156         (
157             bm.mesh().faces(),
158             newSize,
159             newStart
160         ),
161         bm.mesh().points()
162     ),
163     start_(newStart),
164     boundaryMesh_(bm),
165     faceCellsPtr_(NULL),
166     mePtr_(NULL)
170 Foam::polyPatch::polyPatch(const polyPatch& p)
172     patchIdentifier(p),
173     primitivePatch(p),
174     start_(p.start_),
175     boundaryMesh_(p.boundaryMesh_),
176     faceCellsPtr_(NULL),
177     mePtr_(NULL)
181 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
183 Foam::polyPatch::~polyPatch()
185     clearAddressing();
189 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
191 bool Foam::polyPatch::constraintType(const word& pt)
193     return pointPatchField<scalar>::pointPatchConstructorTablePtr_->found(pt);
197 Foam::wordList Foam::polyPatch::constraintTypes()
199     wordList cTypes(dictionaryConstructorTablePtr_->size());
201     label i = 0;
203     for
204     (
205         dictionaryConstructorTable::iterator cstrIter =
206             dictionaryConstructorTablePtr_->begin();
207         cstrIter != dictionaryConstructorTablePtr_->end();
208         ++cstrIter
209     )
210     {
211         if (constraintType(cstrIter.key()))
212         {
213             cTypes[i++] = cstrIter.key();
214         }
215     }
217     cTypes.setSize(i);
219     return cTypes;
223 const Foam::polyBoundaryMesh& Foam::polyPatch::boundaryMesh() const
225     return boundaryMesh_;
229 const Foam::vectorField::subField Foam::polyPatch::faceCentres() const
231     return patchSlice(boundaryMesh().mesh().faceCentres());
235 const Foam::vectorField::subField Foam::polyPatch::faceAreas() const
237     return patchSlice(boundaryMesh().mesh().faceAreas());
241 // Return the patch face neighbour cell centres
242 Foam::tmp<Foam::vectorField> Foam::polyPatch::faceCellCentres() const
244     tmp<vectorField> tcc(new vectorField(size()));
245     vectorField& cc = tcc();
247     // get reference to global cell centres
248     const vectorField& gcc = boundaryMesh_.mesh().cellCentres();
250     const unallocLabelList& faceCells = this->faceCells();
252     forAll (faceCells, facei)
253     {
254         cc[facei] = gcc[faceCells[facei]];
255     }
257     return tcc;
261 const Foam::unallocLabelList& Foam::polyPatch::faceCells() const
263     if (!faceCellsPtr_)
264     {
265         faceCellsPtr_ = new labelList::subList
266         (
267             patchSlice(boundaryMesh().mesh().faceOwner())
268         );
269     }
271     return *faceCellsPtr_;
275 const Foam::labelList& Foam::polyPatch::meshEdges() const
277     if (!mePtr_)
278     {
279         mePtr_ =
280             new labelList
281             (
282                 primitivePatch::meshEdges
283                 (
284                     boundaryMesh().mesh().edges(),
285                     boundaryMesh().mesh().pointEdges()
286                 )
287             );
288     }
290     return *mePtr_;
294 void Foam::polyPatch::clearAddressing()
296     deleteDemandDrivenData(faceCellsPtr_);
297     deleteDemandDrivenData(mePtr_);
301 void Foam::polyPatch::write(Ostream& os) const
303     os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
304     patchIdentifier::write(os);
305     os.writeKeyword("nFaces") << size() << token::END_STATEMENT << nl;
306     os.writeKeyword("startFace") << start() << token::END_STATEMENT << nl;
310 void Foam::polyPatch::initOrder(const primitivePatch&) const
314 bool Foam::polyPatch::order
316     const primitivePatch&,
317     labelList& faceMap,
318     labelList& rotation
319 ) const
321     // Nothing changed.
322     return false;
326 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
328 void Foam::polyPatch::operator=(const polyPatch& p)
330     clearAddressing();
332     patchIdentifier::operator=(p);
333     primitivePatch::operator=(p);
334     start_ = p.start_;
338 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
340 Foam::Ostream& Foam::operator<<(Ostream& os, const polyPatch& p)
342     p.write(os);
343     os.check("Ostream& operator<<(Ostream& os, const polyPatch& p");
344     return os;
348 // ************************************************************************* //