Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / finiteVolume / fvMesh / fvBoundaryMesh / fvBoundaryMesh.C
blob2e25b3ef8500c325f6c9d20dae117b61ee933c38
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 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
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 "fvMesh.H"
27 #include "fvBoundaryMesh.H"
30 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
32 void Foam::fvBoundaryMesh::addPatches(const polyBoundaryMesh& basicBdry)
34     setSize(basicBdry.size());
36     // Set boundary patches
37     fvPatchList& Patches = *this;
39     forAll(Patches, patchI)
40     {
41         Patches.set(patchI, fvPatch::New(basicBdry[patchI], *this));
42     }
46 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
48 Foam::fvBoundaryMesh::fvBoundaryMesh
50     const fvMesh& m
53     fvPatchList(0),
54     mesh_(m)
58 Foam::fvBoundaryMesh::fvBoundaryMesh
60     const fvMesh& m,
61     const polyBoundaryMesh& basicBdry
64     fvPatchList(basicBdry.size()),
65     mesh_(m)
67     addPatches(basicBdry);
71 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
73 Foam::label Foam::fvBoundaryMesh::findPatchID(const word& patchName) const
75     const fvPatchList& patches = *this;
77     forAll(patches, patchI)
78     {
79         if (patches[patchI].name() == patchName)
80         {
81             return patchI;
82         }
83     }
85     // Not found, return -1
86     return -1;
90 void Foam::fvBoundaryMesh::movePoints()
92     forAll(*this, patchI)
93     {
94         operator[](patchI).initMovePoints();
95     }
97     forAll(*this, patchI)
98     {
99         operator[](patchI).movePoints();
100     }
104 Foam::lduInterfacePtrsList Foam::fvBoundaryMesh::interfaces() const
106     lduInterfacePtrsList interfaces(size());
108     forAll(interfaces, patchI)
109     {
110         if (isA<lduInterface>(this->operator[](patchI)))
111         {
112             interfaces.set
113             (
114                 patchI,
115                &refCast<const lduInterface>(this->operator[](patchI))
116             );
117         }
118     }
120     return interfaces;
124 void Foam::fvBoundaryMesh::readUpdate(const polyBoundaryMesh& basicBdry)
126     clear();
127     addPatches(basicBdry);
131 // * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * * //
133 const Foam::fvPatch& Foam::fvBoundaryMesh::operator[]
135     const word& patchName
136 ) const
138     const label patchI = findPatchID(patchName);
140     if (patchI < 0)
141     {
142         FatalErrorIn
143         (
144             "fvBoundaryMesh::operator[](const word&) const"
145         )   << "Patch named " << patchName << " not found." << nl
146             << abort(FatalError);
147     }
149     return operator[](patchI);
153 Foam::fvPatch& Foam::fvBoundaryMesh::operator[]
155     const word& patchName
158     const label patchI = findPatchID(patchName);
160     if (patchI < 0)
161     {
162         FatalErrorIn
163         (
164             "fvBoundaryMesh::operator[](const word&)"
165         )   << "Patch named " << patchName << " not found." << nl
166             << abort(FatalError);
167     }
169     return operator[](patchI);
173 // ************************************************************************* //