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

preservePatchTypes.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 "preservePatchTypes.H"
00028 #include "polyBoundaryMeshEntries.H"
00029 #include "dictionary.H"
00030 
00031 // * * * * * * * * * * * * * * * Global Functions  * * * * * * * * * * * * * //
00032 
00033 void Foam::preservePatchTypes
00034 (
00035     const objectRegistry& obr,
00036     const word& meshInstance,
00037     const fileName& meshDir,
00038     const wordList& patchNames,
00039     wordList& patchTypes,
00040     const word& defaultFacesName,
00041     word& defaultFacesType,
00042     wordList& patchPhysicalTypes
00043 )
00044 {
00045     dictionary patchDictionary;
00046 
00047     {
00048         IOobject patchEntriesHeader
00049         (
00050             "boundary",
00051             meshInstance,
00052             meshDir,
00053             obr,
00054             IOobject::MUST_READ,
00055             IOobject::NO_WRITE,
00056             false
00057         );
00058 
00059         if (patchEntriesHeader.headerOk())
00060         {
00061             // Create a list of entries from the boundary file.
00062             polyBoundaryMeshEntries patchEntries(patchEntriesHeader);
00063 
00064             forAll(patchEntries, patchi)
00065             {
00066                 patchDictionary.add(patchEntries[patchi]);
00067             }
00068         }
00069     }
00070 
00071     if (patchDictionary.size())
00072     {
00073         forAll(patchNames, patchi)
00074         {
00075             if (patchDictionary.found(patchNames[patchi]))
00076             {
00077                 const dictionary& patchDict = 
00078                     patchDictionary.subDict(patchNames[patchi]);
00079 
00080                 patchDict.lookup("type") >> patchTypes[patchi];
00081 
00082                 patchDict.readIfPresent("geometricType", patchTypes[patchi]);
00083                 patchDict.readIfPresent
00084                 (
00085                     "physicalType",
00086                     patchPhysicalTypes[patchi]
00087                 );
00088             }
00089         }
00090 
00091         if (patchDictionary.found(defaultFacesName))
00092         {
00093             const dictionary& patchDict = 
00094                 patchDictionary.subDict(defaultFacesName);
00095 
00096             patchDict.readIfPresent("geometricType", defaultFacesType);
00097         }
00098     }
00099 
00100     Info << nl << "Default patch type set to " << defaultFacesType << endl;
00101 }
00102 
00103 
00104 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd