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-2020 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>& sfield
35 )
36 :
37  SubList<Type>(sfield)
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 )
56 :
57  SubList<Type>(list, list.size())
58 {}
59 
60 
61 template<class Type>
63 (
64  const UList<Type>& list,
65  const label subSize
66 )
67 :
68  SubList<Type>(list, subSize)
69 {}
70 
71 
72 template<class Type>
74 (
75  const UList<Type>& list,
76  const label subSize,
77  const label startIndex
78 )
79 :
80  SubList<Type>(list, subSize, startIndex)
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 {}
104 
105 
106 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
107 
108 template<class Type>
110 {
111  return NullObjectRef<SubField<Type>>();
112 }
113 
114 
115 template<class Type>
118 (
119  const direction d
120 ) const
121 {
122  return (reinterpret_cast<const Field<Type>&>(*this)).component(d);
123 }
124 
125 
126 template<class Type>
128 {
129  return (reinterpret_cast<const Field<Type>&>(*this)).T();
130 }
131 
132 
133 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
134 
135 template<class Type>
137 {
138  return *reinterpret_cast<const Field<Type>*>(this);
139 }
140 
141 
142 template<class Type>
144 {
146 }
147 
148 
149 template<class Type>
151 {
153 }
154 
155 
156 template<class Type>
157 inline void Foam::SubField<Type>::operator=(const Type& val)
158 {
160 }
161 
162 
163 template<class Type>
165 {
167 }
168 
169 
170 template<class Type>
171 template<class Form, Foam::direction Ncmpts>
173 (
175 )
176 {
177  forAll(rhs, i)
178  {
179  this->operator[](i) = rhs[i];
180  }
181 }
182 
183 
184 template<class Type>
185 inline void Foam::SubField<Type>::operator+=(const Type& val)
186 {
187  for (Type& lhs : *this)
188  {
189  lhs += val;
190  }
191 }
192 
193 
194 template<class Type>
195 inline void Foam::SubField<Type>::operator-=(const Type& val)
196 {
197  for (Type& lhs : *this)
198  {
199  lhs -= val;
200  }
201 }
202 
203 
204 template<class Type>
205 inline void Foam::SubField<Type>::operator*=(const scalar& s)
206 {
207  for (Type& lhs : *this)
208  {
209  lhs *= s;
210  }
211 }
212 
213 
214 template<class Type>
215 inline void Foam::SubField<Type>::operator/=(const scalar& s)
216 {
217  for (Type& lhs : *this)
218  {
219  lhs /= s;
220  }
221 }
222 
223 
224 // ************************************************************************* //
Foam::SubField::operator/=
void operator/=(const scalar &s)
Divide each entry by value.
Definition: SubFieldI.H:215
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:53
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::SubField::null
static const SubField< Type > & null()
Return a null SubField.
Definition: SubFieldI.H:109
Foam::VectorSpace
Templated vector space.
Definition: VectorSpace.H:56
Foam::SubField
SubField is a Field obtained as a section of another Field.
Definition: Field.H:64
Foam::SubField::operator*=
void operator*=(const scalar &s)
Multiply each entry by value.
Definition: SubFieldI.H:205
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:127
Foam::SubField::component
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
Definition: SubFieldI.H:118
Foam::SubField::operator=
void operator=(const SubField< Type > &)
Copy assign via UList operator. Takes linear time.
Definition: SubFieldI.H:143
range
scalar range
Definition: LISASMDCalcMethod1.H:12
Foam::SubField::operator-=
void operator-=(const Type &val)
Subtract value from each entry.
Definition: SubFieldI.H:195
Foam::UList< Type >
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::UList::size
void size(const label n) noexcept
Override size to be inconsistent with allocated storage.
Definition: UListI.H:360
Foam::SubField::operator+=
void operator+=(const Type &val)
Add value to each entry.
Definition: SubFieldI.H:185
Foam::SubField::SubField
SubField(const SubField< Type > &sfield)
Copy construct (shallow copy)
Definition: SubFieldI.H:33
Foam::zero
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:62