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 
28 #include "preservePatchTypes.H"
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  false
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 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::polyBoundaryMeshEntries
Read and store dictionary entries for boundary patches.
Definition: polyBoundaryMeshEntries.H:53
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:63
Foam::dictionary::found
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
Definition: dictionaryI.H:87
Foam::IOobject::typeHeaderOk
bool typeHeaderOk(const bool checkType=true, const bool search=true, const bool verbose=true)
Read header (uses typeFilePath to find file) and check its info.
Definition: IOobjectTemplates.C:39
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:35
preservePatchTypes.H
preservePatchTypes
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
polyBoundaryMeshEntries.H
defaultFacesType
word defaultFacesType
Definition: readKivaGrid.H:456
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
patchDicts
PtrList< dictionary > patchDicts
Definition: readKivaGrid.H:532
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::dictionary::subDict
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:460
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
patchNames
wordList patchNames(nPatches)
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::nl
constexpr char nl
Definition: Ostream.H:404
defaultFacesName
word defaultFacesName
Definition: readKivaGrid.H:455
Foam::List< word >
Foam::dictionary::clone
autoPtr< dictionary > clone() const
Construct and return clone.
Definition: dictionary.C:172
polyBoundaryMesh.H
Foam::dictionary::add
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
Definition: dictionary.C:640
Foam::dictionary::readIfPresent
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:405