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,
78  const Foam::zero
79 )
80 :
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 
104  Field<Type>::resize(ijk_.size(), Zero);
105  }
106 }
107 
108 
109 template<class Type>
111 (
112  const labelVector& ijk,
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(), Zero);
128  }
129 }
130 
131 
132 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
133 
134 template<class Type>
136 {
137  return ijk_;
138 }
139 
140 
141 template<class Type>
143 {
144  return ijk_;
145 }
146 
147 
148 template<class Type>
150 {
151  return ijk_.sizes();
152 }
153 
154 
155 template<class Type>
157 {
158  return ijk_.sizes();
159 }
160 
161 
162 template<class Type>
163 inline const Foam::label& Foam::IjkField<Type>::size
164 (
165  const vector::components cmpt
166 ) const
167 {
168  return ijk_.size(cmpt);
169 }
170 
171 
172 template<class Type>
174 {
175  ijk_.clear();
177 }
178 
179 
180 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
181 
182 template<class Type>
183 inline const Type& Foam::IjkField<Type>::operator()
184 (
185  const label i,
186  const label j,
187  const label k
188 ) const
189 {
190  return Field<Type>::operator[](ijk_.index(i, j, k));
191 }
192 
193 
194 template<class Type>
195 inline Type& Foam::IjkField<Type>::operator()
196 (
197  const label i,
198  const label j,
199  const label k
200 )
201 {
202  return Field<Type>::operator[](ijk_.index(i, j, k));
203 }
204 
205 
206 template<class Type>
207 inline const Type& Foam::IjkField<Type>::operator()
208 (
209  const labelVector& ijk
210 ) const
211 {
212  return Field<Type>::operator[](ijk_.index(ijk));
213 }
214 
215 
216 template<class Type>
217 inline Type& Foam::IjkField<Type>::operator()
218 (
219  const labelVector& ijk
220 )
221 {
222  return Field<Type>::operator[](ijk_.index(ijk));
223 }
224 
225 
226 template<class Type>
228 {
229  if (this != &rhs)
230  {
231  sizes() = rhs.sizes();
232 
234 
235  rhs.clear();
236  }
237 }
238 
239 
240 template<class Type>
241 inline void Foam::IjkField<Type>::operator=(const Type& val)
242 {
244 }
245 
246 
247 template<class Type>
249 {
251 }
252 
253 
254 // ************************************************************************* //
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::IjkField::size
const label & size(const vector::components cmpt) const
The addressing dimension in the given direction.
Definition: IjkFieldI.H:164
Foam::Field::operator
friend Ostream & operator(Ostream &, const Field< Type > &)
Foam::cmptProduct
Cmpt cmptProduct(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
Definition: VectorSpaceI.H:596
Foam::IjkField::IjkField
IjkField()
Construct zero-sized.
Definition: IjkFieldI.H:31
Foam::Vector< scalar >::components
components
Component labeling enumeration.
Definition: Vector.H:81
resize
patchWriters resize(patchIds.size())
Foam::Field
Generic templated field type.
Definition: Field.H:63
field
rDeltaTY field()
Foam::IjkField::sizes
const labelVector & sizes() const
Return i,j,k addressing sizes.
Definition: IjkFieldI.H:149
Foam::IjkField::operator=
void operator=(const IjkField< Type > &rhs)
Copy assignment.
Definition: IjkField.C:124
Foam::IjkField::clear
void clear()
Clear dimensions and field.
Definition: IjkFieldI.H:173
Foam::IjkField
Generic templated field type with i-j-k addressing.
Definition: IjkField.H:53
clear
patchWriters clear()
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::Vector< label >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::UList< Type >
k
label k
Boltzmann constant.
Definition: LISASMDCalcMethod2.H:41
Foam::ijkAddressing
A simple i-j-k (row-major order) to linear addressing.
Definition: ijkAddressing.H:51
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:328
Foam::IjkField::ijk
const ijkAddressing & ijk() const
Return i,j,k addressing.
Definition: IjkFieldI.H:135
Foam::zero
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:62