1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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"
31 #include "primitiveMesh.H"
34 #include "dictionary.H"
35 #include "pointPatchField.H"
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
41 defineTypeNameAndDebug(polyPatch, 0);
43 int polyPatch::disallowGenericPolyPatch
45 debug::debugSwitch("disallowGenericPolyPatch", 0)
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()
69 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
71 Foam::polyPatch::polyPatch
77 const polyBoundaryMesh& bm
80 patchIdentifier(name, index),
83 faceSubList(bm.mesh().faces(), size, start),
93 Foam::polyPatch::polyPatch
96 const dictionary& dict,
98 const polyBoundaryMesh& bm
101 patchIdentifier(name, dict, index),
107 readLabel(dict.lookup("nFaces")),
108 readLabel(dict.lookup("startFace"))
112 start_(readLabel(dict.lookup("startFace"))),
119 Foam::polyPatch::polyPatch
122 const polyBoundaryMesh& bm
143 Foam::polyPatch::polyPatch
146 const polyBoundaryMesh& bm,
152 patchIdentifier(pp, index),
170 Foam::polyPatch::polyPatch(const polyPatch& p)
175 boundaryMesh_(p.boundaryMesh_),
181 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
183 Foam::polyPatch::~polyPatch()
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());
205 dictionaryConstructorTable::iterator cstrIter =
206 dictionaryConstructorTablePtr_->begin();
207 cstrIter != dictionaryConstructorTablePtr_->end();
211 if (constraintType(cstrIter.key()))
213 cTypes[i++] = cstrIter.key();
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)
254 cc[facei] = gcc[faceCells[facei]];
261 const Foam::unallocLabelList& Foam::polyPatch::faceCells() const
265 faceCellsPtr_ = new labelList::subList
267 patchSlice(boundaryMesh().mesh().faceOwner())
271 return *faceCellsPtr_;
275 const Foam::labelList& Foam::polyPatch::meshEdges() const
282 primitivePatch::meshEdges
284 boundaryMesh().mesh().edges(),
285 boundaryMesh().mesh().pointEdges()
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&,
326 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
328 void Foam::polyPatch::operator=(const polyPatch& p)
332 patchIdentifier::operator=(p);
333 primitivePatch::operator=(p);
338 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
340 Foam::Ostream& Foam::operator<<(Ostream& os, const polyPatch& p)
343 os.check("Ostream& operator<<(Ostream& os, const polyPatch& p");
348 // ************************************************************************* //