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) 2011 OpenFOAM Foundation
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 
29 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
30 
32 (
33  const objectRegistry& obr,
34  const word& meshInstance,
35  const fileName& meshDir,
36  const wordList& patchNames,
38  const word& defaultFacesName,
40 )
41 {
42  patchDicts.setSize(patchNames.size());
43 
44  dictionary patchDictionary;
45 
46  // Read boundary file as single dictionary
47  {
48  IOobject patchEntriesHeader
49  (
50  "boundary",
51  meshInstance,
52  meshDir,
53  obr,
54  IOobject::MUST_READ,
55  IOobject::NO_WRITE,
56  false
57  );
58 
59  if (patchEntriesHeader.headerOk())
60  {
61  // Create a list of entries from the boundary file.
62  polyBoundaryMeshEntries patchEntries(patchEntriesHeader);
63 
64  forAll(patchEntries, patchi)
65  {
66  patchDictionary.add(patchEntries[patchi]);
67  }
68  }
69  }
70 
72  {
73  if (patchDictionary.found(patchNames[patchi]))
74  {
75  const dictionary& patchDict =
76  patchDictionary.subDict(patchNames[patchi]);
77 
78  patchDicts.set(patchi, patchDict.clone());
79  patchDicts[patchi].remove("nFaces");
80  patchDicts[patchi].remove("startFace");
81  }
82  }
83 
84  if (patchDictionary.found(defaultFacesName))
85  {
86  const dictionary& patchDict =
87  patchDictionary.subDict(defaultFacesName);
88 
89  patchDict.readIfPresent("geometricType", defaultFacesType);
90  }
91 
92  Info<< nl << "Default patch type set to " << defaultFacesType << endl;
93 }
94 
95 
96 // ************************************************************************* //
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::polyBoundaryMeshEntries
Foam::polyBoundaryMeshEntries.
Definition: polyBoundaryMeshEntries.H:48
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::dictionary::readIfPresent
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
Definition: dictionaryTemplates.C:94
Foam::preservePatchTypes
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.
Definition: preservePatchTypes.C:32
preservePatchTypes.H
preservePatchTypes
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
polyBoundaryMeshEntries.H
defaultFacesType
word defaultFacesType
Definition: readKivaGrid.H:461
patchDicts
PtrList< dictionary > patchDicts
Definition: readKivaGrid.H:537
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::IOobject::headerOk
bool headerOk()
Read and check header info.
Definition: IOobject.C:439
Foam::dictionary::found
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:304
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::PtrList
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:61
patchNames
wordList patchNames(nPatches)
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
defaultFacesName
word defaultFacesName
Definition: readKivaGrid.H:460
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
patchi
label patchi
Definition: getPatchFieldScalar.H:1
Foam::dictionary::clone
autoPtr< dictionary > clone() const
Construct and return clone.
Definition: dictionary.C:215
Foam::dictionary::subDict
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:631
Foam::dictionary::add
bool add(entry *, bool mergeEntry=false)
Add a new entry.
Definition: dictionary.C:729