SubField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "SubField.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class Type>
32 (
33  const SubList<Type>& list
34 )
35 :
36  SubList<Type>(list)
37 {}
38 
39 
40 template<class Type>
42 (
43  const UList<Type>& list
44 )
45 :
46  SubList<Type>(list, list.size())
47 {}
48 
49 
50 template<class Type>
52 (
53  const UList<Type>& list,
54  const label subSize
55 )
56 :
57  SubList<Type>(list, subSize)
58 {}
59 
60 
61 template<class Type>
63 (
64  const UList<Type>& list,
65  const label subSize,
66  const label startIndex
67 )
68 :
69  SubList<Type>(list, subSize, startIndex)
70 {}
71 
72 
73 template<class Type>
75 (
76  const SubField<Type>& sfield
77 )
78 :
79  tmp<SubField<Type>>::refCount(),
80  SubList<Type>(sfield)
81 {}
82 
83 
84 template<class Type>
86 (
87  SubField<Type>& sfield,
88  bool reuse
89 )
90 :
91  tmp<SubField<Type>>::refCount(),
92  SubList<Type>(sfield)
93 {}
94 
95 
96 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
97 
98 template<class Type>
101 (
102  const direction d
103 ) const
104 {
105  return (reinterpret_cast<const Field<Type>&>(*this)).component(d);
106 }
107 
108 
109 template<class Type>
111 {
112  return (reinterpret_cast<const Field<Type>&>(*this)).T();
113 }
114 
115 
116 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
117 
118 template<class Type>
120 {
122 }
123 
124 
125 template<class Type>
127 {
129 }
130 
131 
132 template<class Type>
134 {
136 }
137 
138 
139 template<class Type>
140 inline void Foam::SubField<Type>::operator=(const Type& rhs)
141 {
143 }
144 
145 
146 template<class Type>
148 {
150 }
151 
152 
153 #define COMPUTED_ASSIGNMENT(TYPE, op) \
154  \
155 template<class Type> \
156 void Foam::SubField<Type>::operator op(const UList<TYPE>& f) \
157 { \
158  TFOR_ALL_F_OP_F(Type, *this, op, TYPE, f) \
159 } \
160  \
161 template<class Type> \
162 void Foam::SubField<Type>::operator op(const tmp<Field<TYPE>>& tf) \
163 { \
164  operator op(tf()); \
165  tf.clear(); \
166 } \
167  \
168 template<class Type> \
169 void Foam::SubField<Type>::operator op(const TYPE& t) \
170 { \
171  TFOR_ALL_F_OP_S(Type, *this, op, TYPE, t) \
172 }
173 
178 
179 #undef COMPUTED_ASSIGNMENT
180 
181 
182 template<class Type>
183 template<class Form, Foam::direction Ncmpts>
185 (
187 )
188 {
189  forAll(rhs, i)
190  {
191  this->operator[](i) = rhs[i];
192  }
193 }
194 
195 
196 // ************************************************************************* //
#define COMPUTED_ASSIGNMENT(TYPE, op)
Definition: SubField.C:153
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
Pre-declare SubField and related Field type.
Definition: Field.H:83
Pre-declare related SubField type.
Definition: SubField.H:63
void operator=(const SubField< Type > &)
Definition: SubField.C:119
tmp< Field< Type > > T() const
Return the field transpose (only defined for second rank tensors)
Definition: SubField.C:110
SubField(const SubList< Type > &)
Construct from a SubList.
Definition: SubField.C:32
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
Definition: SubField.C:101
void operator=(const SubList< T > &)
Assignment of all entries to the given sub-list.
Definition: SubListI.H:100
Templated vector space.
Definition: VectorSpace.H:85
Reference counter for various OpenFOAM components.
Definition: refCount.H:50
A class for managing temporary objects.
Definition: tmp.H:55
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:50
static const zero Zero
Definition: zero.H:97
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
uint8_t direction
Definition: direction.H:45