coordinateSystems.H
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-2016 OpenFOAM Foundation
9  Copyright (C) 2018-2024 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::coordinateSystems
29 
30 Description
31  A centralized collection of named coordinate systems.
32 
33 Note
34  Mixing normal constructors and the coordinateSystems::New constructor
35  may yield unexpected results.
36 
37  \verbatim
38  cat1
39  {
40  coordinateSystem
41  {
42  type indirect;
43  name _10;
44  }
45  porosity 0.781;
46  Darcy
47  {
48  d d [0 -2 0 0 0] (-1000 -1000 0.50753e+08);
49  f f [0 -1 0 0 0] (-1000 -1000 12.83);
50  }
51  }
52  \endverbatim
53 
54  For this to work correctly, the coordinateSystem constructor must be
55  supplied with an objectRegistry as well as the dictionary.
56 
57 SourceFiles
58  coordinateSystems.C
59 
60 \*---------------------------------------------------------------------------*/
61 
62 #ifndef Foam_coordinateSystems_H
63 #define Foam_coordinateSystems_H
64 
65 #include "regIOobject.H"
66 #include "PtrList.H"
67 #include "coordinateSystem.H"
68 #include "wordRes.H"
69 
70 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71 
72 namespace Foam
73 {
74 
75 /*---------------------------------------------------------------------------*\
76  Class coordinateSystems Declaration
77 \*---------------------------------------------------------------------------*/
78 
80 :
81  public regIOobject,
82  public PtrList<coordinateSystem>
83 {
84  // Private Member Functions
85 
86  //- Read if IOobject flags set.
87  //- Reads "coordinateSystems" or older "IOPtrList<coordinateSystem>"
88  // Return true if read.
89  bool readIOcontents();
90 
91 public:
92 
93  //- Declare type-name, virtual type (without debug switch)
94  TypeNameNoDebug("coordinateSystems");
95 
96 
97  // Generated Methods
98 
99  //- No copy construct
100  coordinateSystems(const coordinateSystems&) = delete;
101 
102  //- No copy assignment
103  void operator=(const coordinateSystems&) = delete;
104 
105 
106  // Constructors
107 
108  //- Read construct from IOobject
109  explicit coordinateSystems(const IOobject& io);
110 
111  //- Read construct "coordinateSystems" from "constant"
112  //- using given registry
113  explicit coordinateSystems(const objectRegistry& obr);
114 
115  //- Construct from IOobject and PtrList content
117  (
118  const IOobject& io,
119  const PtrList<coordinateSystem>& content
120  );
121 
122  //- Construct from IOobject and transferring PtrList content
124  (
125  const IOobject& io,
126  PtrList<coordinateSystem>&& content
127  );
128 
129 
130  // Selectors
131 
132  //- Return previously registered or read construct from "constant"
133  static const coordinateSystems& New(const objectRegistry& obr);
134 
135 
136  // Member Functions
137 
138  //- Find and return indices for all matches
139  // A no-op (returns empty list) for an empty key
140  labelList indices(const wordRe& key) const;
141 
142  //- Find and return indices for all matches
143  // A no-op (returns empty list) for an empty matcher
144  labelList indices(const wordRes& matcher) const;
145 
146  //- Find and return index for the first match, return -1 if not found
147  // A no-op (returns -1) for an empty key
148  label findIndex(const wordRe& key) const;
149 
150  //- Find and return index for the first match, return -1 if not found
151  // A no-op (returns -1) for an empty matcher
152  label findIndex(const wordRes& matcher) const;
153 
154  //- Search if given key exists
155  bool found(const wordRe& key) const;
156 
157  //- Return pointer to named coordinateSystem or nullptr on error
158  const coordinateSystem* cfind(const word& name) const;
159 
160  //- Return reference to named coordinateSystem or FatalErrror
161  const coordinateSystem& lookup(const word& name) const;
162 
163  //- A list of the coordinate-system names
164  wordList names() const;
165 
166  //- A list of the coordinate-system names satisfying the input matcher
167  wordList names(const wordRe& key) const;
168 
169  //- A list of the coordinate-system names satisfying the input matcher
170  wordList names(const wordRes& matcher) const;
171 
172  //- Identical to names()
173  inline wordList toc() const
174  {
175  return names();
176  }
177 
178 
179  // IO
180 
181  //- Write data
182  bool writeData(Ostream& os) const;
183 
184  //- Write using stream options
185  virtual bool writeObject
186  (
187  IOstreamOption streamOpt,
188  const bool writeOnProc = true
189  ) const;
190 
191 
192  // Housekeeping
193 
194  //- Identical to the indices() method (AUG-2018)
195  FOAM_DEPRECATED_FOR(2018-08, "indices() method")
196  labelList findIndices(const wordRe& key) const
197  {
198  return this->indices(key);
199  }
200 
201  //- Deprecated(2020-03) find named coordinateSystem or nullptr
202  //
203  // \deprecated(2020-03) - use cfind() method
204  FOAM_DEPRECATED_FOR(2020-03, "cfind() method")
205  const coordinateSystem* lookupPtr(const word& name) const
206  {
207  return this->cfind(name);
208  }
209 };
210 
211 
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 //- Global file type for coordinateSystems - same content for all ranks
215 template<>
216 struct is_globalIOobject<coordinateSystems> : std::true_type {};
217 
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 } // End namespace Foam
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 #endif
226 
227 // ************************************************************************* //
Base class for coordinate system specification, the default coordinate system type is cartesian ...
wordList names() const
A list of the coordinate-system names.
labelList findIndices(const wordRe &key) const
Identical to the indices() method (AUG-2018)
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:195
TypeNameNoDebug("coordinateSystems")
Declare type-name, virtual type (without debug switch)
A centralized collection of named coordinate systems.
Trait for specifying global vs. local IOobject file types.
Definition: IOobject.H:173
const coordinateSystem * lookupPtr(const word &name) const
Deprecated(2020-03) find named coordinateSystem or nullptr.
FOAM_DEPRECATED_FOR(2022-09, "get(), set() or test() methods") const T *operator()(const label i) const
Deprecated(2022-09) - same as get()
Definition: UPtrList.H:492
void operator=(const coordinateSystems &)=delete
No copy assignment.
A simple container for options an IOstream can normally have.
wordList toc() const
Identical to names()
label findIndex(const wordRe &key) const
Find and return index for the first match, return -1 if not found.
coordinateSystems(const coordinateSystems &)=delete
No copy construct.
A class for handling words, derived from Foam::string.
Definition: word.H:63
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:53
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings...
Definition: wordRe.H:78
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
const coordinateSystem & lookup(const word &name) const
Return reference to named coordinateSystem or FatalErrror.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Definition: foamGltfBase.H:103
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:68
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc=true) const
Write using stream options.
const coordinateSystem * cfind(const word &name) const
Return pointer to named coordinateSystem or nullptr on error.
bool found(const wordRe &key) const
Search if given key exists.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Registry of regIOobjects.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:180
static const coordinateSystems & New(const objectRegistry &obr)
Return previously registered or read construct from "constant".
bool writeData(Ostream &os) const
Write data.
labelList indices(const wordRe &key) const
Find and return indices for all matches.
Namespace for OpenFOAM.