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 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 #ifndef coordinateSystems_H
62 #define coordinateSystems_H
63 
64 #include "regIOobject.H"
65 #include "PtrList.H"
66 #include "coordinateSystem.H"
67 #include "wordRes.H"
68 
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 
71 namespace Foam
72 {
73 
74 /*---------------------------------------------------------------------------*\
75  Class coordinateSystems Declaration
76 \*---------------------------------------------------------------------------*/
77 
79 :
80  public regIOobject,
81  public PtrList<coordinateSystem>
82 {
83  // Private Member Functions
84 
85  //- Read "coordinateSystems" or older "IOPtrList<coordinateSystem>"
86  void readFromStream(const bool valid = true);
87 
88  //- Attempt read if MUST_READ.., or READ_IF_PRESENT and has header
89  // \return False if no read should have been attempted
90  bool readObject(const IOobject& io);
91 
92 
93  //- No copy construct
94  coordinateSystems(const coordinateSystems&) = delete;
95 
96  //- No copy assignment
97  void operator=(const coordinateSystems&) = delete;
98 
99 
100 public:
101 
102  //- Runtime type information
103  TypeNameNoDebug("coordinateSystems");
104 
105 
106  // Constructors
107 
108  //- Read construct from IOobject
109  explicit coordinateSystems(const IOobject& io);
110 
111  //- Construct from IOobject and PtrList content
113  (
114  const IOobject& io,
115  const PtrList<coordinateSystem>& content
116  );
117 
118  //- Construct from IOobject and transferring PtrList content
120  (
121  const IOobject& io,
122  PtrList<coordinateSystem>&& content
123  );
124 
125 
126  // Selectors
127 
128  //- Return previously registered or read construct from "constant"
129  static const coordinateSystems& New(const objectRegistry& obr);
130 
131 
132  // Member Functions
133 
134  //- Find and return indices for all matches
135  labelList indices(const keyType& key) const;
136 
137  //- Find and return indices for all matches
138  labelList indices(const wordRes& matcher) const;
139 
140  //- Find and return index for the first match, return -1 if not found
141  label findIndex(const keyType& key) const;
142 
143  //- Find and return index for the first match, return -1 if not found
144  label findIndex(const wordRes& matcher) const;
145 
146  //- Search if given key exists
147  bool found(const keyType& key) const;
148 
149  //- Return reference to named coordinateSystem or FatalErrror
150  const coordinateSystem& lookup(const word& name) const;
151 
152  //- Return pointer to named coordinateSystem or nullptr on error
153  const coordinateSystem* lookupPtr(const word& name) const;
154 
155  //- A list of the coordinate-system names
156  wordList names() const;
157 
158  //- A list of the coordinate-system names satisfying the input matcher
159  wordList names(const keyType& key) const;
160 
161  //- A list of the coordinate-system names satisfying the input matcher
162  wordList names(const wordRe& matcher) const;
163 
164  //- A list of the coordinate-system names satisfying the input matcher
165  wordList names(const wordRes& matcher) const;
166 
167  //- Identical to names()
168  inline wordList toc() const
169  {
170  return names();
171  }
172 
173 
174  // IO
175 
176  //- Write data
177  bool writeData(Ostream& os) const;
178 
179  //- Write data
180  virtual bool writeObject
181  (
185  const bool valid = true
186  ) const;
187 
188 
189  // Housekeeping
190 
191  //- Identical to the indices() method (AUG-2018)
192  labelList findIndices(const keyType& key) const
193  {
194  return this->indices(key);
195  }
196 };
197 
198 
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 
201 } // End namespace Foam
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 #endif
206 
207 // ************************************************************************* //
regIOobject.H
wordRes.H
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::coordinateSystems::findIndex
label findIndex(const keyType &key) const
Find and return index for the first match, return -1 if not found.
Definition: coordinateSystems.C:298
Foam::IOobject::name
const word & name() const
Return name.
Definition: IOobjectI.H:46
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::coordinateSystems::indices
labelList indices(const keyType &key) const
Find and return indices for all matches.
Definition: coordinateSystems.C:271
Foam::wordRe
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:72
coordinateSystem.H
Foam::coordinateSystems::lookupPtr
const coordinateSystem * lookupPtr(const word &name) const
Return pointer to named coordinateSystem or nullptr on error.
Definition: coordinateSystems.C:333
Foam::coordinateSystems::lookup
const coordinateSystem & lookup(const word &name) const
Return reference to named coordinateSystem or FatalErrror.
Definition: coordinateSystems.C:354
Foam::coordinateSystems::TypeNameNoDebug
TypeNameNoDebug("coordinateSystems")
Runtime type information.
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::keyType
A class for handling keywords in dictionaries.
Definition: keyType.H:60
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::IOstreamOption::versionNumber
Representation of a major/minor version number.
Definition: IOstreamOption.H:79
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:65
Foam::coordinateSystems::writeData
bool writeData(Ostream &os) const
Write data.
Definition: coordinateSystems.C:426
Foam::IOstreamOption::streamFormat
streamFormat
Data format (ascii | binary)
Definition: IOstreamOption.H:64
Foam::coordinateSystems
A centralized collection of named coordinate systems.
Definition: coordinateSystems.H:77
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::coordinateSystems::findIndices
labelList findIndices(const keyType &key) const
Identical to the indices() method (AUG-2018)
Definition: coordinateSystems.H:191
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:67
Foam::coordinateSystems::toc
wordList toc() const
Identical to names()
Definition: coordinateSystems.H:167
Foam::coordinateSystems::writeObject
virtual bool writeObject(IOstream::streamFormat, IOstream::versionNumber ver, IOstream::compressionType, const bool valid=true) const
Write data.
Definition: coordinateSystems.C:445
Foam::List< label >
Foam::coordinateSystems::names
wordList names() const
A list of the coordinate-system names.
Definition: coordinateSystems.C:377
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
PtrList.H
Foam::IOstreamOption::compressionType
compressionType
Compression treatment (UNCOMPRESSED | COMPRESSED)
Definition: IOstreamOption.H:71
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:238
Foam::coordinateSystems::found
bool found(const keyType &key) const
Search if given key exists.
Definition: coordinateSystems.C:326
Foam::coordinateSystem
Base class for coordinate system specification, the default coordinate system type is cartesian .
Definition: coordinateSystem.H:122