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-2025 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 )
44 :
45  mesh_(mesh),
46  all_(true)
47 {
48  read(dict);
49 }
50 
51 
52 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
53 
55 {}
56 
57 
58 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
59 
61 {
62  if (!all())
63  {
64  cellZone_.movePoints();
65  }
66 }
67 
68 
70 {
71  if (!all())
72  {
73  cellZone_.topoChange(map);
74  }
75 }
76 
77 
79 {
80  if (!all())
81  {
82  cellZone_.mapMesh(map);
83  }
84 }
85 
86 
88 {
89  if (!all())
90  {
91  cellZone_.distribute(map);
92  }
93 }
94 
95 
97 {
98  if (dict.found("cellZone"))
99  {
100  if (!dict.isDict("cellZone"))
101  {
102  if (dict.lookup<word>("cellZone") == "all")
103  {
104  all_ = true;
105  return true;
106  }
107  }
108 
109  all_ = false;
110 
111  cellZone_.read
112  (
113  "cellZone",
115  mesh_,
116  dict
117  );
118  }
119  else if (dict.found("points"))
120  {
121  // For backward compatibility
122 
124  << "points is deprecated, use cellZone instead." << nl
125  << " For backward compatibility the points entry "
126  "is automatically converted into a cellZone generated "
127  "using the containsPoints zoneGenerator."
128  << endl;
129 
130  all_ = false;
131 
132  cellZone_.set
133  (
135  (
136  new zoneGenerators::containsPoints("points", mesh_, dict)
137  )
138  );
139  }
140  else if (dict.found("select"))
141  {
142  const word selection(dict.lookup("select"));
143 
145  << "select " << selection
146  << " is deprecated, use cellZone instead."
147  << endl;
148 
149  if (selection == "all")
150  {
151  all_ = true;
152  }
153  }
154  else
155  {
157  << "cellZone not specified"
158  << exit(FatalIOError);
159  }
160 
161  return true;
162 }
163 
164 
165 // ************************************************************************* //
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:740
bool isDict(const word &) const
Check if entry is a sub-dictionary.
Definition: dictionary.C:803
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:539
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.
bool read(const dictionary &dict)
Read coefficients dictionary.
void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
generatedCellZone(const polyMesh &mesh)
Construct from mesh selecting all cells.
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:80
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for handling words, derived from string.
Definition: word.H:62
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:258
IOerror FatalIOError
static const char nl
Definition: Ostream.H:267
dictionary dict