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-2021 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 coordinateSystems_H
63 #define 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 "coordinateSystems" or older "IOPtrList<coordinateSystem>"
87  void readFromStream(const bool valid = true);
88 
89  //- Attempt read if MUST_READ.., or READ_IF_PRESENT and has header
90  // \return False if no read should have been attempted
91  bool readObject(const IOobject& io);
92 
93 
94  //- No copy construct
95  coordinateSystems(const coordinateSystems&) = delete;
96 
97  //- No copy assignment
98  void operator=(const coordinateSystems&) = delete;
99 
100 
101 public:
102 
103  //- Declare type-name, virtual type (without debug switch)
104  TypeNameNoDebug("coordinateSystems");
105 
106 
107  // Constructors
108 
109  //- Read construct from IOobject
110  explicit coordinateSystems(const IOobject& io);
111 
112  //- Construct from IOobject and PtrList content
114  (
115  const IOobject& io,
116  const PtrList<coordinateSystem>& content
117  );
118 
119  //- Construct from IOobject and transferring PtrList content
121  (
122  const IOobject& io,
123  PtrList<coordinateSystem>&& content
124  );
125 
126 
127  // Selectors
128 
129  //- Return previously registered or read construct from "constant"
130  static const coordinateSystems& New(const objectRegistry& obr);
131 
132 
133  // Member Functions
134 
135  //- Find and return indices for all matches
136  // A no-op (returns empty list) for an empty key
137  labelList indices(const wordRe& key) const;
138 
139  //- Find and return indices for all matches
140  // A no-op (returns empty list) for an empty matcher
141  labelList indices(const wordRes& matcher) const;
142 
143  //- Find and return index for the first match, return -1 if not found
144  // A no-op (returns -1) for an empty key
145  label findIndex(const wordRe& key) const;
146 
147  //- Find and return index for the first match, return -1 if not found
148  // A no-op (returns -1) for an empty matcher
149  label findIndex(const wordRes& matcher) const;
150 
151  //- Search if given key exists
152  bool found(const wordRe& key) const;
153 
154  //- Return pointer to named coordinateSystem or nullptr on error
155  const coordinateSystem* cfind(const word& name) const;
156 
157  //- Return reference to named coordinateSystem or FatalErrror
158  const coordinateSystem& lookup(const word& name) const;
159 
160  //- A list of the coordinate-system names
161  wordList names() const;
162 
163  //- A list of the coordinate-system names satisfying the input matcher
164  wordList names(const wordRe& key) const;
165 
166  //- A list of the coordinate-system names satisfying the input matcher
167  wordList names(const wordRes& matcher) const;
168 
169  //- Identical to names()
170  inline wordList toc() const
171  {
172  return names();
173  }
174 
175 
176  // IO
177 
178  //- Write data
179  bool writeData(Ostream& os) const;
180 
181  //- Write using stream options
182  virtual bool writeObject
183  (
184  IOstreamOption streamOpt,
185  const bool valid = true
186  ) const;
187 
188 
189  // Housekeeping
190 
191  //- Identical to the indices() method (AUG-2018)
192  FOAM_DEPRECATED_FOR(2018-08, "indices() method")
193  labelList findIndices(const wordRe& key) const
194  {
195  return this->indices(key);
196  }
197 
198  //- Deprecated(2020-03) find named coordinateSystem or nullptr
199  //
200  // \deprecated(2020-03) - use cfind() method
201  FOAM_DEPRECATED_FOR(2020-03, "cfind() method")
202  const coordinateSystem* lookupPtr(const word& name) const
203  {
204  return this->cfind(name);
205  }
206 };
207 
208 
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 
211 } // End namespace Foam
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 #endif
216 
217 // ************************************************************************* //
regIOobject.H
wordRes.H
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::coordinateSystems::findIndices
labelList findIndices(const wordRe &key) const
Identical to the indices() method (AUG-2018)
Definition: coordinateSystems.H:192
Foam::coordinateSystems::found
bool found(const wordRe &key) const
Search if given key exists.
Definition: coordinateSystems.C:225
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::coordinateSystems::indices
labelList indices(const wordRe &key) const
Find and return indices for all matches.
Definition: coordinateSystems.C:185
Foam::glTF::key
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Definition: foamGltfBase.H:108
Foam::wordRe
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:80
coordinateSystem.H
Foam::coordinateSystems::lookup
const coordinateSystem & lookup(const word &name) const
Return reference to named coordinateSystem or FatalErrror.
Definition: coordinateSystems.C:256
Foam::coordinateSystems::TypeNameNoDebug
TypeNameNoDebug("coordinateSystems")
Declare type-name, virtual type (without debug switch)
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::IOstreamOption
The IOstreamOption is a simple container for options an IOstream can normally have.
Definition: IOstreamOption.H:63
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
Foam::coordinateSystems::writeData
bool writeData(Ostream &os) const
Write data.
Definition: coordinateSystems.C:299
Foam::coordinateSystems
A centralized collection of named coordinate systems.
Definition: coordinateSystems.H:78
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::coordinateSystems::writeObject
virtual bool writeObject(IOstreamOption streamOpt, const bool valid=true) const
Write using stream options.
Definition: coordinateSystems.C:318
Foam::coordinateSystems::lookupPtr
const coordinateSystem * lookupPtr(const word &name) const
Deprecated(2020-03) find named coordinateSystem or nullptr.
Definition: coordinateSystems.H:201
Foam::IOobject::name
const word & name() const noexcept
Return name.
Definition: IOobjectI.H:65
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:73
Foam::coordinateSystems::toc
wordList toc() const
Identical to names()
Definition: coordinateSystems.H:169
Foam::List< label >
Foam::coordinateSystems::names
wordList names() const
A list of the coordinate-system names.
Definition: coordinateSystems.C:273
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
Foam::FOAM_DEPRECATED_FOR
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
Definition: NamedEnum.H:69
PtrList.H
Foam::coordinateSystems::cfind
const coordinateSystem * cfind(const word &name) const
Return pointer to named coordinateSystem or nullptr on error.
Definition: coordinateSystems.C:232
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::coordinateSystems::New
static const coordinateSystems & New(const objectRegistry &obr)
Return previously registered or read construct from "constant".
Definition: coordinateSystems.C:152
Foam::coordinateSystem
Base class for coordinate system specification, the default coordinate system type is cartesian .
Definition: coordinateSystem.H:132
Foam::coordinateSystems::findIndex
label findIndex(const wordRe &key) const
Find and return index for the first match, return -1 if not found.
Definition: coordinateSystems.C:205