SubField.H
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-2019 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 Class
25  Foam::SubField
26 
27 Description
28  SubField is a Field obtained as a section of another Field.
29 
30  Thus it is itself unallocated so that no storage is allocated or
31  deallocated during its use. To achieve this behaviour, SubField is
32  derived from a SubList rather than a List.
33 
34 SourceFiles
35  SubFieldI.H
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef SubField_H
40 #define SubField_H
41 
42 #include "SubList.H"
43 #include "Field.H"
44 #include "VectorSpace.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 //- Pre-declare SubField and related Field type
52 template<class Type> class Field;
53 template<class Type> class SubField;
54 
55 /*---------------------------------------------------------------------------*\
56  Class SubField Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 template<class Type>
60 class SubField
61 :
62  public tmp<SubField<Type>>::refCount,
63  public SubList<Type>
64 {
65 
66 public:
67 
68  //- Component type
69  typedef typename pTraits<Type>::cmptType cmptType;
70 
71 
72  // Constructors
73 
74  //- Construct from a SubList
75  inline SubField(const SubList<Type>&);
76 
77  //- Construct from a UList<Type>, using the entire size
78  explicit inline SubField(const UList<Type>&);
79 
80  //- Construct from a UList<Type> with a given size
81  inline SubField
82  (
83  const UList<Type>& list,
84  const label subSize
85  );
86 
87  //- Construct from a UList<Type> with a given size and start index
88  inline SubField
89  (
90  const UList<Type>& list,
91  const label subSize,
92  const label startIndex
93  );
94 
95  //- Copy constructor
96  inline SubField(const SubField<Type>&);
97 
98 
99  // Member Functions
100 
101  //- Return a null SubField
102  static inline const SubField<Type>& null();
103 
104  //- Return a component field of the field
105  inline tmp<Field<cmptType>> component(const direction) const;
106 
107  //- Return the field transpose (only defined for second rank tensors)
108  tmp<Field<Type>> T() const;
109 
110 
111  // Member Operators
112 
113  //- Assignment via UList operator. Takes linear time.
114  inline void operator=(const SubField<Type>&);
115 
116  //- Assignment via UList operator. Takes linear time.
117  inline void operator=(const Field<Type>&);
118 
119  //- Assignment via UList operator. Takes linear time.
120  template<class Form, direction Ncmpts>
121  inline void operator=(const VectorSpace<Form, Type, Ncmpts>&);
122 
123  //- Allow cast to a const Field<Type>&
124  inline operator const Field<Type>&() const;
125 };
126 
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 } // End namespace Foam
131 
132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
133 
134 #include "SubFieldI.H"
135 
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137 
138 #endif
139 
140 // ************************************************************************* //
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
Definition: SubFieldI.H:94
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
tmp< Field< Type > > T() const
Return the field transpose (only defined for second rank tensors)
Definition: SubFieldI.H:103
uint8_t direction
Definition: direction.H:45
Traits class for primitives.
Definition: pTraits.H:50
Templated vector space.
Definition: VectorSpace.H:53
void operator=(const SubField< Type > &)
Assignment via UList operator. Takes linear time.
Definition: SubFieldI.H:112
SubField(const SubList< Type > &)
Construct from a SubList.
Definition: SubFieldI.H:30
Pre-declare related SubField type.
Definition: Field.H:60
Pre-declare SubField and related Field type.
Definition: Field.H:56
pTraits< Type >::cmptType cmptType
Component type.
Definition: SubField.H:68
A class for managing temporary objects.
Definition: PtrList.H:53
static const SubField< Type > & null()
Return a null SubField.
Definition: SubFieldI.H:85
Namespace for OpenFOAM.