FreeFOAM The Cross-Platform CFD Toolkit
preservePatchTypes.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "preservePatchTypes.H"
28 #include <OpenFOAM/dictionary.H>
29 
30 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
31 
33 (
34  const objectRegistry& obr,
35  const word& meshInstance,
36  const fileName& meshDir,
37  const wordList& patchNames,
39  const word& defaultFacesName,
42 )
43 {
44  dictionary patchDictionary;
45 
46  {
47  IOobject patchEntriesHeader
48  (
49  "boundary",
50  meshInstance,
51  meshDir,
52  obr,
53  IOobject::MUST_READ,
54  IOobject::NO_WRITE,
55  false
56  );
57 
58  if (patchEntriesHeader.headerOk())
59  {
60  // Create a list of entries from the boundary file.
61  polyBoundaryMeshEntries patchEntries(patchEntriesHeader);
62 
63  forAll(patchEntries, patchi)
64  {
65  patchDictionary.add(patchEntries[patchi]);
66  }
67  }
68  }
69 
70  if (patchDictionary.size())
71  {
72  forAll(patchNames, patchi)
73  {
74  if (patchDictionary.found(patchNames[patchi]))
75  {
76  const dictionary& patchDict =
77  patchDictionary.subDict(patchNames[patchi]);
78 
79  patchDict.lookup("type") >> patchTypes[patchi];
80 
81  patchDict.readIfPresent("geometricType", patchTypes[patchi]);
82  patchDict.readIfPresent
83  (
84  "physicalType",
85  patchPhysicalTypes[patchi]
86  );
87  }
88  }
89 
90  if (patchDictionary.found(defaultFacesName))
91  {
92  const dictionary& patchDict =
93  patchDictionary.subDict(defaultFacesName);
94 
95  patchDict.readIfPresent("geometricType", defaultFacesType);
96  }
97  }
98 
99  Info << nl << "Default patch type set to " << defaultFacesType << endl;
100 }
101 
102 
103 // ************************ vim: set sw=4 sts=4 et: ************************ //