Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
10License
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
30template<class Type>
33 Field<Type>(),
34 ijk_()
35{}
36
37
38template<class Type>
41 Field<Type>(field),
42 ijk_(field.ijk())
43{}
44
45
46template<class Type>
49 Field<Type>(std::move(field)),
50 ijk_(field.ijk())
51{}
52
53
54template<class Type>
57 Field<Type>(cmptProduct(ijk)),
58 ijk_(ijk)
59{}
60
61
62template<class Type>
64(
65 const labelVector& ijk,
66 const Type& val
67)
69 Field<Type>(cmptProduct(ijk), val),
70 ijk_(ijk)
71{}
72
73
74template<class Type>
76(
77 const labelVector& ijk,
79)
81 Field<Type>(cmptProduct(ijk), Foam::zero{}),
82 ijk_(ijk)
83{}
84
85
86template<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
99 WarningInFunction
100 << "Resizing field to match i-j-k sizing " << sizes()
101 << nl << nl;
102 #endif
104 Field<Type>::resize(ijk_.size(), Foam::zero{});
105 }
106}
107
108
109template<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
122 WarningInFunction
123 << "Resizing field to match i-j-k sizing " << sizes()
124 << nl << nl;
125 #endif
126
127 Field<Type>::resize(ijk_.size(), Foam::zero{});
129}
130
131
132// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
133
134template<class Type>
135inline Foam::label Foam::IjkField<Type>::size
136(
137 const vector::components cmpt
138) const
139{
140 return ijk_.size(cmpt);
141}
142
143
144template<class Type>
145inline void Foam::IjkField<Type>::clear()
147 ijk_.clear();
149}
150
151
152// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
153
154template<class Type>
155inline 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}
165
166template<class Type>
168(
169 const label i,
170 const label j,
171 const label k
173{
174 return Field<Type>::operator[](ijk_.index(i, j, k));
175}
176
177
178template<class Type>
179inline 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
188template<class Type>
190(
191 const labelVector& ijk
193{
194 return Field<Type>::operator[](ijk_.index(ijk));
195}
196
197
198template<class Type>
200{
201 if (this != &rhs)
202 {
203 sizes() = rhs.sizes();
204
207 rhs.clear();
208 }
209}
210
211
212template<class Type>
213inline void Foam::IjkField<Type>::operator=(const Type& val)
214{
216}
217
218
219template<class Type>
221{
223}
224
225
226// ************************************************************************* //
label k
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
void operator=(const Field< Type > &)
Copy assignment.
Definition Field.C:781
constexpr Field() noexcept
Default construct.
Definition FieldI.H:24
Generic templated field type with i-j-k addressing.
Definition IjkField.H:52
IjkField()
Construct zero-sized.
Definition IjkFieldI.H:24
const ijkAddressing & ijk() const noexcept
Return i,j,k addressing.
Definition IjkField.H:113
const labelVector & sizes() const noexcept
Return i,j,k addressing sizes.
Definition IjkField.H:123
label size(const vector::components cmpt) const
The addressing dimension in the given direction.
Definition IjkFieldI.H:129
void operator=(const IjkField< Type > &rhs)
Copy assignment.
Definition IjkField.C:117
void clear()
Clear dimensions and field.
Definition IjkFieldI.H:138
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
Definition List.C:347
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
void size(const label n)
Definition UList.H:118
Type & operator[](const label i)
Definition UListI.H:363
label size() const noexcept
Return the total i*j*k size.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition zero.H:58
rDeltaTY field()
Namespace for OpenFOAM.
Vector< label > labelVector
Vector of labels.
Definition labelVector.H:47
Cmpt cmptProduct(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
A non-counting (dummy) refCount.
Definition refCount.H:55