Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::coordinateSystems
29
30Description
31 A centralized collection of named coordinate systems.
32
33Note
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
57SourceFiles
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
72namespace Foam
73{
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
91public:
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
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,
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
215template<>
216struct is_globalIOobject<coordinateSystems> : std::true_type {};
217
218
219// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220
221} // End namespace Foam
222
223// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224
225#endif
226
227// ************************************************************************* //
bool found
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
const word & name() const noexcept
Return the object name.
Definition IOobjectI.H:205
A simple container for options an IOstream can normally have.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
constexpr PtrList() noexcept
Definition PtrListI.H:29
Base class for coordinate system specification, the default coordinate system type is cartesian .
A centralized collection of named coordinate systems.
labelList findIndices(const wordRe &key) const
Identical to the indices() method (AUG-2018).
labelList indices(const wordRe &key) const
Find and return indices for all matches.
const coordinateSystem * cfind(const word &name) const
Return pointer to named coordinateSystem or nullptr on error.
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc=true) const
Write using stream options.
static const coordinateSystems & New(const objectRegistry &obr)
Return previously registered or read construct from "constant".
wordList toc() const
Identical to names().
bool writeData(Ostream &os) const
Write data.
const coordinateSystem & lookup(const word &name) const
Return reference to named coordinateSystem or FatalErrror.
void operator=(const coordinateSystems &)=delete
No copy assignment.
coordinateSystems(const coordinateSystems &)=delete
No copy construct.
TypeNameNoDebug("coordinateSystems")
Declare type-name, virtual type (without debug switch).
const coordinateSystem * lookupPtr(const word &name) const
Deprecated(2020-03) find named coordinateSystem or nullptr.
wordList names() const
A list of the coordinate-system names.
label findIndex(const wordRe &key) const
Find and return index for the first match, return -1 if not found.
Registry of regIOobjects.
regIOobject(const IOobject &io, const bool isTimeObject=false)
Construct from IOobject. The optional flag adds special handling if the object is the top-level regIO...
Definition regIOobject.C:43
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition wordRe.H:81
A List of wordRe with additional matching capabilities.
Definition wordRes.H:56
A class for handling words, derived from Foam::string.
Definition word.H:66
OBJstream os(runTime.globalPath()/outputName)
const auto & io
auto & name
Namespace for OpenFOAM.
List< word > wordList
List of word.
Definition fileName.H:60
List< label > labelList
A List of labels.
Definition List.H:62
labelList findIndices(const ListType &input, typename ListType::const_reference val, label start=0)
Linear search to find all occurrences of given element.
#define FOAM_DEPRECATED_FOR(since, replacement)
Definition stdFoam.H:43
Trait for specifying global vs. local IOobject file types.
Definition IOobject.H:175