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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
30 #include "polyBoundaryMesh.H"
31 
32 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
33 
35 (
36  const objectRegistry& obr,
37  const word& meshInstance,
38  const fileName& meshDir,
39  const wordList& patchNames,
41  const word& defaultFacesName,
43 )
44 {
45  patchDicts.setSize(patchNames.size());
46 
47  dictionary patchDictionary;
48 
49  // Read boundary file as single dictionary
50  {
51  IOobject patchEntriesHeader
52  (
53  "boundary",
54  meshInstance,
55  meshDir,
56  obr,
57  IOobject::MUST_READ,
58  IOobject::NO_WRITE,
59  IOobject::NO_REGISTER
60  );
61 
62  if (patchEntriesHeader.typeHeaderOk<polyBoundaryMesh>(true))
63  {
64  // Create a list of entries from the boundary file.
65  polyBoundaryMeshEntries patchEntries(patchEntriesHeader);
66 
67  forAll(patchEntries, patchi)
68  {
69  patchDictionary.add(patchEntries[patchi]);
70  }
71  }
72  }
73 
74  forAll(patchNames, patchi)
75  {
76  if (patchDictionary.found(patchNames[patchi]))
77  {
78  const dictionary& patchDict =
79  patchDictionary.subDict(patchNames[patchi]);
80 
81  patchDicts.set(patchi, patchDict.clone());
82  patchDicts[patchi].remove("nFaces");
83  patchDicts[patchi].remove("startFace");
84  }
85  }
86 
87  if (patchDictionary.found(defaultFacesName))
88  {
89  const dictionary& patchDict =
90  patchDictionary.subDict(defaultFacesName);
91 
92  patchDict.readIfPresent("geometricType", defaultFacesType);
93  }
94 
95  Info<< nl << "Default patch type set to " << defaultFacesType << endl;
96 }
97 
98 
99 // ************************************************************************* //
word defaultFacesType
Definition: readKivaGrid.H:456
A class for handling file names.
Definition: fileName.H:72
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
Definition: dictionary.C:625
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:441
autoPtr< dictionary > clone() const
Construct and return clone.
Definition: dictionary.C:165
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
Definition: dictionaryI.H:104
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
A class for handling words, derived from Foam::string.
Definition: word.H:63
wordList patchNames(nPatches)
preservePatchTypes
bool typeHeaderOk(const bool checkType=true, const bool search=true, const bool verbose=true)
Read header (respects is_globalIOobject trait) and check its info.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
word defaultFacesName
Definition: readKivaGrid.H:455
void preservePatchTypes(const objectRegistry &obr, const word &meshInstance, const fileName &meshDir, const wordList &patchNames, PtrList< dictionary > &patchDicts, const word &defaultFacesName, word &defaultFacesType)
Preserve patch types.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
messageStream Info
Information stream (stdout output on master, null elsewhere)
PtrList< dictionary > patchDicts
Definition: readKivaGrid.H:532
Registry of regIOobjects.
Read and store dictionary entries for boundary patches The object is *never* registered to avoid regi...
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172