Loading...
Searching...
No Matches
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// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30
31template<class Type>
33(
34 const SubField<Type>& fld
36:
37 SubList<Type>(fld)
38{}
39
40
41template<class Type>
43(
44 const SubList<Type>& list
46:
47 SubList<Type>(list)
48{}
49
50
51template<class Type>
53(
54 const UList<Type>& list
56:
57 SubList<Type>(list)
58{}
59
60
61template<class Type>
63(
64 const UList<Type>& list,
65 const label len
67:
68 SubList<Type>(list, len)
69{}
70
71
72template<class Type>
74(
75 const UList<Type>& list,
76 const label len,
77 const label start
79:
80 SubList<Type>(list, len, start)
81{}
82
83
84template<class Type>
86(
87 const UList<Type>& list,
88 const labelRange& range
90:
91 SubList<Type>(list, range)
92{}
93
94
95template<class Type>
97(
98 const labelRange& range,
99 const UList<Type>& list
100)
101:
102 SubList<Type>(range, list)
104
105
106// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
107
108template<class Type>
111(
112 const direction d
113) const
114{
115 return (reinterpret_cast<const Field<Type>&>(*this)).component(d);
116}
117
118
119template<class Type>
121{
122 return (reinterpret_cast<const Field<Type>&>(*this)).T();
123}
124
125
126// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
127
128template<class Type>
133
134
135template<class Type>
140
141
142template<class Type>
143inline void Foam::SubField<Type>::operator=(const Type& val)
144{
146}
147
149template<class Type>
154
155
156template<class Type>
157template<class Form, Foam::direction Ncmpts>
159(
161)
162{
163 forAll(rhs, i)
165 this->operator[](i) = rhs[i];
166 }
167}
168
169
170template<class Type>
171inline void Foam::SubField<Type>::operator+=(const Type& val)
172{
173 for (Type& lhs : *this)
175 lhs += val;
176 }
177}
178
179
180template<class Type>
181inline void Foam::SubField<Type>::operator-=(const Type& val)
182{
183 for (Type& lhs : *this)
185 lhs -= val;
186 }
187}
188
189
190template<class Type>
191inline void Foam::SubField<Type>::operator*=(const scalar& s)
192{
193 for (Type& lhs : *this)
195 lhs *= s;
196 }
197}
198
200template<class Type>
201inline void Foam::SubField<Type>::operator/=(const scalar& s)
202{
203 for (Type& lhs : *this)
205 lhs /= s;
206 }
207}
208
210// ************************************************************************* //
scalar range
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
SubField is a Field obtained as a section of another Field, without its own allocation....
Definition SubField.H:58
void operator*=(const scalar &s)
Multiply each entry by value.
Definition SubFieldI.H:184
void operator=(const SubField< Type > &)
Copy assign via UList operator. Takes linear time.
Definition SubFieldI.H:122
tmp< Field< Type > > T() const
Return the field transpose (only defined for second rank tensors).
Definition SubFieldI.H:113
SubField() noexcept=default
Default construct, zero-sized and nullptr.
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
Definition SubFieldI.H:104
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
void operator/=(const scalar &s)
Divide each entry by value.
Definition SubFieldI.H:194
A non-owning sub-view of a List (allocated or unallocated storage).
Definition SubList.H:61
void operator=(const SubList< T > &list)
Copy assign entries (deep copy) from given sub-list. Sizes must match!
Definition SubListI.H:211
SubList() noexcept=default
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:89
scalar & operator[](const label i)
Templated vector space.
Definition VectorSpace.H:75
A range or interval of labels defined by a start and a size.
Definition labelRange.H:66
A class for managing temporary objects.
Definition tmp.H:75
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition zero.H:58
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:49
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
const direction noexcept
Definition scalarImpl.H:265
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299