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-------------------------------------------------------------------------------
10License
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,
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// ************************************************************************* //
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
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.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:460
autoPtr< dictionary > clone() const
Construct and return clone.
Definition: dictionary.C:172
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
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
Definition: dictionary.C:640
A class for handling file names.
Definition: fileName.H:76
Registry of regIOobjects.
Read and store dictionary entries for boundary patches.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
A class for handling words, derived from Foam::string.
Definition: word.H:68
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
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.
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
preservePatchTypes
wordList patchNames(nPatches)
PtrList< dictionary > patchDicts
Definition: readKivaGrid.H:532
word defaultFacesName
Definition: readKivaGrid.H:455
word defaultFacesType
Definition: readKivaGrid.H:456
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333