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 {
132 }
133 
134 
135 template<class Type>
137 {
139 }
140 
141 
142 template<class Type>
143 inline void Foam::SubField<Type>::operator=(const Type& val)
144 {
146 }
147 
148 
149 template<class Type>
151 {
153 }
154 
155 
156 template<class Type>
157 template<class Form, Foam::direction Ncmpts>
159 (
160  const VectorSpace<Form, Type, Ncmpts>& rhs
161 )
162 {
163  forAll(rhs, i)
164  {
165  this->operator[](i) = rhs[i];
166  }
167 }
168 
169 
170 template<class Type>
171 inline void Foam::SubField<Type>::operator+=(const Type& val)
172 {
173  for (Type& lhs : *this)
174  {
175  lhs += val;
176  }
177 }
178 
179 
180 template<class Type>
181 inline void Foam::SubField<Type>::operator-=(const Type& val)
182 {
183  for (Type& lhs : *this)
184  {
185  lhs -= val;
186  }
187 }
188 
189 
190 template<class Type>
191 inline void Foam::SubField<Type>::operator*=(const scalar& s)
192 {
193  for (Type& lhs : *this)
194  {
195  lhs *= s;
196  }
197 }
198 
199 
200 template<class Type>
201 inline void Foam::SubField<Type>::operator/=(const scalar& s)
202 {
203  for (Type& lhs : *this)
204  {
205  lhs /= s;
206  }
207 }
208 
209 
210 // ************************************************************************* //
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:122
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:64
void operator-=(const Type &val)
Subtract value from each entry.
Definition: SubFieldI.H:174
void operator+=(const Type &val)
Add value to each entry.
Definition: SubFieldI.H:164
scalar range
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:286
SubField() noexcept=default
Default construct, zero-sized and nullptr.
A non-owning sub-view of a List (allocated or unallocated storage).
Definition: SubList.H:46
Generic templated field type.
Definition: Field.H:63
void operator/=(const scalar &s)
Divide each entry by value.
Definition: SubFieldI.H:194
const direction noexcept
Definition: scalarImpl.H:255
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:184