generatedCellZone.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2022-2026 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 "generatedCellZone.H"
27 #include "polyMesh.H"
28 #include "containsPoints.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
33 :
34  mesh_(mesh),
35  all_(true)
36 {}
37 
38 
40 (
41  const polyMesh& mesh,
42  const dictionary& dict,
43  const bool defaultIsAll,
44  const bool onDemand
45 )
46 :
47  mesh_(mesh),
48  all_(true)
49 {
50  read(dict, defaultIsAll, onDemand);
51 }
52 
53 
54 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
55 
57 {}
58 
59 
60 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
61 
63 {
64  if (!all())
65  {
66  return cellZone_.regenerate();
67  }
68 
69  return false;
70 }
71 
72 
74 {
75  if (!all())
76  {
77  cellZone_.movePoints();
78  }
79 }
80 
81 
83 {
84  if (!all())
85  {
86  cellZone_.topoChange(map);
87  }
88 }
89 
90 
92 {
93  if (!all())
94  {
95  cellZone_.mapMesh(map);
96  }
97 }
98 
99 
101 {
102  if (!all())
103  {
104  cellZone_.distribute(map);
105  }
106 }
107 
108 
110 (
111  const dictionary& dict,
112  const bool defaultIsAll,
113  const bool onDemand
114 )
115 {
116  if (dict.found("cellZone"))
117  {
118  if (!dict.isDict("cellZone"))
119  {
120  if (dict.lookup<word>("cellZone") == "all")
121  {
122  all_ = true;
123  return true;
124  }
125  }
126 
127  all_ = false;
128 
129  cellZone_.read
130  (
131  "cellZone",
133  mesh_,
134  dict,
135  onDemand
136  );
137  }
138  else if (dict.found("points"))
139  {
140  // For backward compatibility
141 
143  << "points is deprecated, use cellZone instead." << nl
144  << " For backward compatibility the points entry "
145  "is automatically converted into a cellZone generated "
146  "using the containsPoints zoneGenerator."
147  << endl;
148 
149  all_ = false;
150 
151  cellZone_.set
152  (
154  (
155  new zoneGenerators::containsPoints("points", mesh_, dict)
156  )
157  );
158  }
159  else if (dict.found("select"))
160  {
161  const word selection(dict.lookup("select"));
162 
164  << "select " << selection
165  << " is deprecated, use cellZone instead."
166  << endl;
167 
168  if (selection == "all")
169  {
170  all_ = true;
171  }
172  }
173  else if (defaultIsAll)
174  {
175  all_ = true;
176  }
177  else
178  {
180  << "cellZone not specified"
181  << exit(FatalIOError);
182  }
183 
184  return true;
185 }
186 
187 
188 // ************************************************************************* //
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:669
bool isDict(const word &) const
Check if entry is a sub-dictionary.
Definition: dictionary.C:732
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:468
void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
void movePoints()
Update for mesh motion.
void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
bool read(const dictionary &dict, const bool defaultIsAll=false, const bool onDemand=false)
Read coefficients dictionary.
generatedCellZone(const polyMesh &mesh)
Construct from mesh selecting all cells.
bool regenerate()
Regenerate the cellZone if the regenerate switch is set true.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for handling words, derived from string.
Definition: word.H:63
A zoneGenerator which selects the cells containing the given points.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
IOerror FatalIOError
static const char nl
Definition: Ostream.H:297
dictionary dict