OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

PatchToolsEdgeOwner.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "PatchTools.H"
00028 
00029 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00030 
00031 template
00032 <
00033     class Face,
00034     template<class> class FaceList,
00035     class PointField,
00036     class PointType
00037 >
00038 
00039 Foam::labelList
00040 Foam::PatchTools::edgeOwner
00041 (
00042     const PrimitivePatch<Face, FaceList, PointField, PointType>& p
00043 )
00044 {
00045     const edgeList& edges = p.edges();
00046     const labelListList& edgeFaces = p.edgeFaces();
00047     const List<Face>& localFaces = p.localFaces();
00048 
00049     // create the owner list
00050     labelList edgeOwner(edges.size(), -1);
00051 
00052     forAll(edges, edgeI)
00053     {
00054         const labelList& nbrFaces = edgeFaces[edgeI];
00055 
00056         if (nbrFaces.size() == 1)
00057         {
00058             edgeOwner[edgeI] = nbrFaces[0];
00059         }
00060         else
00061         {
00062             // Find the first face whose vertices are aligned with the edge.
00063             // with multiply connected edges, this is the best we can do
00064             forAll(nbrFaces, i)
00065             {
00066                 const Face& f = localFaces[nbrFaces[i]];
00067 
00068                 if (f.edgeDirection(edges[edgeI]) > 0)
00069                 {
00070                     edgeOwner[edgeI] = nbrFaces[i];
00071                     break;
00072                 }
00073             }
00074 
00075             if (edgeOwner[edgeI] == -1)
00076             {
00077                 FatalErrorIn
00078                 (
00079                     "PatchTools::edgeOwner()"
00080                 )
00081                     << "Edge " << edgeI << " vertices:" << edges[edgeI]
00082                     << " is used by faces " << nbrFaces
00083                     << " vertices:"
00084                     << UIndirectList<Face>(localFaces, nbrFaces)()
00085                     << " none of which use the edge vertices in the same order"
00086                     << nl << "I give up" << abort(FatalError);
00087             }
00088         }
00089     }
00090 
00091     return edgeOwner;
00092 }
00093 
00094 
00095 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd