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