SubFieldI.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) 2017-2021 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
27\*---------------------------------------------------------------------------*/
28
29// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
30
31template<class Type>
33{
34 return NullObjectRef<SubField<Type>>();
35}
36
37
38// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39
40template<class Type>
42(
43 const SubField<Type>& sfield
44)
45:
46 SubList<Type>(sfield)
47{}
48
49
50template<class Type>
52(
53 const SubList<Type>& list
54)
55:
56 SubList<Type>(list)
57{}
58
59
60template<class Type>
62(
63 const UList<Type>& list
64)
65:
66 SubList<Type>(list)
67{}
68
69
70template<class Type>
72(
73 const UList<Type>& list,
74 const label subSize
75)
76:
77 SubList<Type>(list, subSize)
78{}
79
80
81template<class Type>
83(
84 const UList<Type>& list,
85 const label subSize,
86 const label startIndex
87)
88:
89 SubList<Type>(list, subSize, startIndex)
90{}
91
92
93template<class Type>
95(
96 const UList<Type>& list,
97 const labelRange& range
98)
99:
100 SubList<Type>(list, range)
101{}
102
103
104template<class Type>
106(
107 const labelRange& range,
108 const UList<Type>& list
109)
110:
111 SubList<Type>(range, list)
112{}
113
114
115// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
116
117template<class Type>
120(
121 const direction d
122) const
123{
124 return (reinterpret_cast<const Field<Type>&>(*this)).component(d);
125}
126
127
128template<class Type>
130{
131 return (reinterpret_cast<const Field<Type>&>(*this)).T();
132}
133
134
135// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
136
137template<class Type>
139{
140 return *reinterpret_cast<const Field<Type>*>(this);
141}
142
143
144template<class Type>
146{
148}
149
150
151template<class Type>
153{
155}
156
157
158template<class Type>
159inline void Foam::SubField<Type>::operator=(const Type& val)
160{
162}
163
164
165template<class Type>
167{
169}
170
171
172template<class Type>
173template<class Form, Foam::direction Ncmpts>
175(
177)
178{
179 forAll(rhs, i)
180 {
181 this->operator[](i) = rhs[i];
182 }
183}
184
185
186template<class Type>
187inline void Foam::SubField<Type>::operator+=(const Type& val)
188{
189 for (Type& lhs : *this)
190 {
191 lhs += val;
192 }
193}
194
195
196template<class Type>
197inline void Foam::SubField<Type>::operator-=(const Type& val)
198{
199 for (Type& lhs : *this)
200 {
201 lhs -= val;
202 }
203}
204
205
206template<class Type>
207inline void Foam::SubField<Type>::operator*=(const scalar& s)
208{
209 for (Type& lhs : *this)
210 {
211 lhs *= s;
212 }
213}
214
215
216template<class Type>
217inline void Foam::SubField<Type>::operator/=(const scalar& s)
218{
219 for (Type& lhs : *this)
220 {
221 lhs /= s;
222 }
223}
224
225
226// ************************************************************************* //
scalar range
Generic templated field type.
Definition: Field.H:82
SubField is a Field obtained as a section of another Field, without its own allocation....
Definition: SubField.H:62
void operator*=(const scalar &s)
Multiply each entry by value.
Definition: SubFieldI.H:207
static const SubField< Type > & null()
Return nullObject reference SubField.
Definition: SubFieldI.H:32
void operator=(const SubField< Type > &)
Copy assign via UList operator. Takes linear time.
Definition: SubFieldI.H:145
tmp< Field< Type > > T() const
Return the field transpose (only defined for second rank tensors)
Definition: SubFieldI.H:129
SubField() noexcept=default
Default construct, zero-sized and nullptr.
void operator-=(const Type &val)
Subtract value from each entry.
Definition: SubFieldI.H:197
void operator+=(const Type &val)
Add value to each entry.
Definition: SubFieldI.H:187
void operator/=(const scalar &s)
Divide each entry by value.
Definition: SubFieldI.H:217
A List obtained as a section of another List.
Definition: SubList.H:70
void operator=(const SubList< T > &list)
Copy assign entries from given sub-list. Sizes must match!
Definition: SubListI.H:132
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:94
Templated vector space.
Definition: VectorSpace.H:79
A range or interval of labels defined by a start and a size.
Definition: labelRange.H:58
A class for managing temporary objects.
Definition: tmp.H:65
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:63
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
uint8_t direction
Definition: direction.H:56
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333