Loading...
Searching...
No Matches
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\*---------------------------------------------------------------------------*/
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,
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// ************************************************************************* //
@ NO_REGISTER
Do not request registration (bool: false).
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
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 void type suppresses trait and t...
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
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.
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...
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
Definition dictionary.C:625
A class for handling file names.
Definition fileName.H:75
Registry of regIOobjects.
Read and store dictionary entries for boundary patches The object is *never* registered to avoid regi...
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
A class for handling words, derived from Foam::string.
Definition word.H:66
List< word > wordList
List of word.
Definition fileName.H:60
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
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:50
preservePatchTypes
wordList patchNames(nPatches)
PtrList< dictionary > patchDicts
word defaultFacesName
word defaultFacesType
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299