Loading...
Searching...
No Matches
cloudFunctionObjectTools.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) 2023 OpenCFD Ltd.
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/>.
26\*---------------------------------------------------------------------------*/
27
29
30// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31
33(
34 const dictionary& dict,
35 const polyMesh& mesh
36)
37:
38 isPatch_(false),
39 IDs_(),
40 names_(),
41 BBs_()
42{
43 wordRes matcher;
44
45 if (dict.readIfPresent("patches", matcher) && !matcher.empty())
46 {
47 isPatch_ = true;
48
49 IDs_ = mesh.boundaryMesh().indices(matcher);
50
51 names_.resize(IDs_.size());
52
53 label count = 0;
54 for (const label patchi : IDs_)
55 {
56 names_[count] = mesh.boundaryMesh()[patchi].name();
57 ++count;
58 }
59 }
60 else if (dict.readIfPresent("faceZones", matcher))
61 {
62 const faceZoneMesh& fzm = mesh.faceZones();
63
64 IDs_ = fzm.indices(matcher);
65
66 BBs_.resize(IDs_.size());
67 names_.resize(IDs_.size());
68
69 label count = 0;
70 for (const label zonei : IDs_)
71 {
72 const faceZone& fz = fzm[zonei];
73 names_[count] = fz.name();
74
75 auto& bb = BBs_[count];
76 ++count;
77
78 bb.reset();
79
80 const auto& faces = mesh.faces();
81 const auto& points = mesh.points();
82 for (const label facei : fz)
83 {
84 bb.add(points, faces[facei]);
85 }
86 bb.reduce();
87 bb.inflate(0.05);
88 }
89 }
90
91 if (matcher.empty() || IDs_.size() < 1)
92 {
93 FatalIOErrorInFunction(dict)
94 << "No matching patches or face zones found: "
95 << flatOutput(matcher) << nl
96 << exit(FatalIOError);
97 }
98}
99
100
102(
103 const collector& phc
104)
105:
106 isPatch_(phc.isPatch_),
107 IDs_(phc.IDs_),
108 names_(phc.names_),
109 BBs_(phc.BBs_)
110{}
111
112
113// ************************************************************************* //
bool empty() const noexcept
True if List is empty (ie, size() is zero).
Definition UList.H:701
Implementation of template-invariant tools for various function objects such as Foam::ParticleHistogr...
collector(const dictionary &dict, const polyMesh &mesh)
Construct from dictionary.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
A List of wordRe with additional matching capabilities.
Definition wordRes.H:56
dynamicFvMesh & mesh
dictionary dict