IjkFieldI.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) 2019-2020 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class Type>
32 :
33  Field<Type>(),
34  ijk_()
35 {}
36 
37 
38 template<class Type>
40 :
41  Field<Type>(field),
42  ijk_(field.ijk())
43 {}
44 
45 
46 template<class Type>
48 :
49  Field<Type>(std::move(field)),
50  ijk_(field.ijk())
51 {}
52 
53 
54 template<class Type>
56 :
57  Field<Type>(cmptProduct(ijk)),
58  ijk_(ijk)
59 {}
60 
61 
62 template<class Type>
64 (
65  const labelVector& ijk,
66  const Type& val
67 )
68 :
69  Field<Type>(cmptProduct(ijk), val),
70  ijk_(ijk)
71 {}
72 
73 
74 template<class Type>
76 (
77  const labelVector& ijk,
79 )
80 :
81  Field<Type>(cmptProduct(ijk), Foam::zero{}),
82  ijk_(ijk)
83 {}
84 
85 
86 template<class Type>
88 (
89  const labelVector& ijk,
90  const UList<Type>& list
91 )
92 :
93  Field<Type>(list),
94  ijk_(ijk)
95 {
96  if (ijk_.size() != Field<Type>::size())
97  {
98  #ifdef FULLDEBUG
100  << "Resizing field to match i-j-k sizing " << sizes()
101  << nl << nl;
102  #endif
103 
105  }
106 }
107 
108 
109 template<class Type>
111 (
112  const labelVector& ijk,
113  Field<Type>&& field
114 )
115 :
116  Field<Type>(std::move(field)),
117  ijk_(ijk)
118 {
119  if (ijk_.size() != Field<Type>::size())
120  {
121  #ifdef FULLDEBUG
123  << "Resizing field to match i-j-k sizing " << sizes()
124  << nl << nl;
125  #endif
126 
127  Field<Type>::resize(ijk_.size(), Foam::zero{});
128  }
129 }
130 
131 
132 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
133 
134 template<class Type>
135 inline Foam::label Foam::IjkField<Type>::size
136 (
137  const vector::components cmpt
138 ) const
139 {
140  return ijk_.size(cmpt);
141 }
142 
143 
144 template<class Type>
145 inline void Foam::IjkField<Type>::clear()
146 {
147  ijk_.clear();
149 }
150 
151 
152 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
153 
154 template<class Type>
155 inline const Type& Foam::IjkField<Type>::operator()
156 (
157  const label i,
158  const label j,
159  const label k
160 ) const
161 {
162  return Field<Type>::operator[](ijk_.index(i, j, k));
163 }
164 
165 
166 template<class Type>
167 inline Type& Foam::IjkField<Type>::operator()
168 (
169  const label i,
170  const label j,
171  const label k
172 )
173 {
174  return Field<Type>::operator[](ijk_.index(i, j, k));
175 }
176 
177 
178 template<class Type>
179 inline const Type& Foam::IjkField<Type>::operator()
180 (
181  const labelVector& ijk
182 ) const
183 {
184  return Field<Type>::operator[](ijk_.index(ijk));
185 }
186 
187 
188 template<class Type>
189 inline Type& Foam::IjkField<Type>::operator()
190 (
191  const labelVector& ijk
192 )
193 {
194  return Field<Type>::operator[](ijk_.index(ijk));
195 }
196 
197 
198 template<class Type>
200 {
201  if (this != &rhs)
202  {
203  sizes() = rhs.sizes();
204 
207  rhs.clear();
208  }
209 }
210 
211 
212 template<class Type>
213 inline void Foam::IjkField<Type>::operator=(const Type& val)
214 {
216 }
217 
218 
219 template<class Type>
221 {
223 }
224 
225 
226 // ************************************************************************* //
void operator=(const IjkField< Type > &rhs)
Copy assignment.
Definition: IjkField.C:117
void clear()
Clear dimensions and field.
Definition: IjkFieldI.H:138
rDeltaTY field()
Cmpt cmptProduct(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
Definition: VectorSpaceI.H:542
patchWriters resize(patchIds.size())
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
label k
Boltzmann constant.
friend Ostream & operator(Ostream &, const Field< Type > &)
Generic templated field type.
Definition: Field.H:63
Generic templated field type with i-j-k addressing.
Definition: IjkField.H:49
label size() const noexcept
The number of elements in the container.
Definition: UList.H:702
#define WarningInFunction
Report a warning using Foam::Warning.
surface1 clear()
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
components
Component labeling enumeration.
Definition: Vector.H:83
Vector< label > labelVector
Vector of labels.
Definition: labelVector.H:47
IjkField()
Construct zero-sized.
Definition: IjkFieldI.H:24
A non-counting (dummy) refCount.
Definition: refCount.H:55
Namespace for OpenFOAM.