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 -------------------------------------------------------------------------------
11 License
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 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class Type>
33 (
34  const SubField<Type>& fld
35 )
36 :
37  SubList<Type>(fld)
38 {}
39 
40 
41 template<class Type>
43 (
44  const SubList<Type>& list
45 )
46 :
47  SubList<Type>(list)
48 {}
49 
50 
51 template<class Type>
53 (
54  const UList<Type>& list
55 ) noexcept
56 :
57  SubList<Type>(list)
58 {}
59 
60 
61 template<class Type>
63 (
64  const UList<Type>& list,
65  const label len
66 )
67 :
68  SubList<Type>(list, len)
69 {}
70 
71 
72 template<class Type>
74 (
75  const UList<Type>& list,
76  const label len,
77  const label start
78 )
79 :
80  SubList<Type>(list, len, start)
81 {}
82 
83 
84 template<class Type>
86 (
87  const UList<Type>& list,
88  const labelRange& range
89 )
90 :
91  SubList<Type>(list, range)
92 {}
93 
94 
95 template<class Type>
97 (
98  const labelRange& range,
99  const UList<Type>& list
100 )
101 :
102  SubList<Type>(range, list)
103 {}
105 
106 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
107 
108 template<class Type>
111 (
112  const direction d
113 ) const
114 {
115  return (reinterpret_cast<const Field<Type>&>(*this)).component(d);
116 }
117 
118 
119 template<class Type>
121 {
122  return (reinterpret_cast<const Field<Type>&>(*this)).T();
123 }
124 
125 
126 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
127 
128 template<class Type>
130 {
131  return *reinterpret_cast<const Field<Type>*>(this);
132 }
133 
134 
135 template<class Type>
137 {
139 }
140 
141 
142 template<class Type>
144 {
146 }
147 
148 
149 template<class Type>
150 inline void Foam::SubField<Type>::operator=(const Type& val)
151 {
153 }
154 
155 
156 template<class Type>
158 {
160 }
161 
162 
163 template<class Type>
164 template<class Form, Foam::direction Ncmpts>
166 (
167  const VectorSpace<Form, Type, Ncmpts>& rhs
168 )
169 {
170  forAll(rhs, i)
171  {
172  this->operator[](i) = rhs[i];
173  }
174 }
175 
176 
177 template<class Type>
178 inline void Foam::SubField<Type>::operator+=(const Type& val)
179 {
180  for (Type& lhs : *this)
181  {
182  lhs += val;
183  }
184 }
185 
186 
187 template<class Type>
188 inline void Foam::SubField<Type>::operator-=(const Type& val)
189 {
190  for (Type& lhs : *this)
191  {
192  lhs -= val;
193  }
194 }
195 
196 
197 template<class Type>
198 inline void Foam::SubField<Type>::operator*=(const scalar& s)
199 {
200  for (Type& lhs : *this)
201  {
202  lhs *= s;
203  }
204 }
205 
206 
207 template<class Type>
208 inline void Foam::SubField<Type>::operator/=(const scalar& s)
209 {
210  for (Type& lhs : *this)
211  {
212  lhs /= s;
213  }
214 }
215 
216 
217 // ************************************************************************* //
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
Definition: SubFieldI.H:104
uint8_t direction
Definition: direction.H:46
tmp< Field< Type > > T() const
Return the field transpose (only defined for second rank tensors)
Definition: SubFieldI.H:113
A range or interval of labels defined by a start and a size.
Definition: labelRange.H:52
void operator=(const SubField< Type > &)
Copy assign via UList operator. Takes linear time.
Definition: SubFieldI.H:129
SubField is a Field obtained as a section of another Field, without its own allocation. SubField is derived from a SubList rather than a List.
Definition: Field.H:63
void operator-=(const Type &val)
Subtract value from each entry.
Definition: SubFieldI.H:181
void operator+=(const Type &val)
Add value to each entry.
Definition: SubFieldI.H:171
scalar range
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
SubField() noexcept=default
Default construct, zero-sized and nullptr.
A List obtained as a section of another List.
Definition: SubList.H:50
Generic templated field type.
Definition: Field.H:62
void operator/=(const scalar &s)
Divide each entry by value.
Definition: SubFieldI.H:201
const direction noexcept
Definition: Scalar.H:258
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;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
A class for managing temporary objects.
Definition: HashPtrTable.H:50
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))
void operator*=(const scalar &s)
Multiply each entry by value.
Definition: SubFieldI.H:191