regionSolversI.H
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) 2023 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 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
27 
29 {
30  return solvers_.size();
31 }
32 
33 
34 // * * * * * * * * * * * * * * * * Iterators * * * * * * * * * * * * * * * * //
35 
37 :
38  regionSolvers_(rs),
39  index_(0)
40 {}
41 
42 
43 inline bool Foam::regionSolvers::iterator::operator==
44 (
45  const iterator& iter
46 ) const
47 {
48  return index_ == iter.index_;
49 }
50 
51 
52 inline bool Foam::regionSolvers::iterator::operator!=
53 (
54  const iterator& iter
55 ) const
56 {
57  return !operator==(iter);
58 }
59 
60 
62 {
63  return regionSolvers_.solvers_[index_];
64 }
65 
66 
68 {
69  return regionSolvers_.solvers_[index_];
70 }
71 
72 
74 {
75  return regionSolvers_.solvers_(index_);
76 }
77 
78 
81 {
82  if (++index_ >= regionSolvers_.solvers_.size())
83  {
84  // Set index to -1 to indicate end
85  index_ = -1;
86 
87  // Reset the prefix to global space padding
88  regionSolvers_.setGlobalPrefix();
89  }
90  else
91  {
92  // Set the prefix for region corresponding to index_
93  regionSolvers_.setPrefix(index_);
94  }
95 
96  return *this;
97 }
98 
99 
102 {
103  iterator tmp(*this);
104  operator++();
105  return tmp;
106 }
107 
108 
110 {
111  // Set the prefix for region 0
112  setPrefix(0);
113 
114  // Return the iterator for region 0
115  return iterator(*this);
116 }
117 
118 
120 {
121  iterator endIter(*this);
122 
123  // Set index to -1 to indicate end
124  endIter.index_ = -1;
125 
126  return endIter;
127 }
128 
129 
130 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
131 
132 inline Foam::regionSolvers::operator PtrList<solver>&()
133 {
134  return solvers_;
135 }
136 
137 
138 // ************************************************************************* //
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
iterator(regionSolvers &)
Construct for the regionSolvers.
Class to hold the lists of region meshes and solvers.
Definition: regionSolvers.H:82
iterator begin()
Return an iterator to begin traversing the solvers.
label size() const
Return the number of region solvers.
friend class iterator
void setPrefix(const label i) const
Set the Info prefix to the space padded region name.
iterator end()
Return an iterator to end traversing the solvers.
Abstract base class for run-time selectable region solvers.
Definition: solver.H:55
A class for managing temporary objects.
Definition: tmp.H:55
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:59
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)