All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2023 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  //- Copy constructor or reuse as specified
99  inline SubField(SubField<Type>&, bool reuse);
100 
101 
102  // Member Functions
103 
104  //- Return a null SubField
105  static inline const SubField<Type>& null();
106 
107  //- Return a component field of the field
108  inline tmp<Field<cmptType>> component(const direction) const;
109 
110  //- Return the field transpose (only defined for second rank tensors)
111  tmp<Field<Type>> T() const;
112 
113 
114  // Member Operators
115 
116  //- Assignment via UList operator. Takes linear time.
117  inline void operator=(const SubField<Type>&);
118 
119  //- Assignment via UList operator. Takes linear time.
120  inline void operator=(const Field<Type>&);
121 
122  //- Assignment via UList operator. Takes linear time.
123  inline void operator=(const Type&);
124 
125  //- Assignment via UList operator. Takes linear time.
126  template<class Form, direction Ncmpts>
127  inline void operator=(const VectorSpace<Form, Type, Ncmpts>&);
128 
129  //- Allow cast to a const Field<Type>&
130  inline operator const Field<Type>&() const;
131 };
132 
133 
134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
135 
136 } // End namespace Foam
137 
138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139 
140 #include "SubFieldI.H"
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 #endif
145 
146 // ************************************************************************* //
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 > &)
Assignment via UList operator. Takes linear time.
Definition: SubFieldI.H:124
tmp< Field< Type > > T() const
Return the field transpose (only defined for second rank tensors)
Definition: SubFieldI.H:115
SubField(const SubList< Type > &)
Construct from a SubList.
Definition: SubFieldI.H:30
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
Definition: SubFieldI.H:106
pTraits< Type >::cmptType cmptType
Component type.
Definition: SubField.H:68
A List obtained as a section of another List.
Definition: SubList.H:56
Templated vector space.
Definition: VectorSpace.H:85
Traits class for primitives.
Definition: pTraits.H:53
Reference counter for various OpenFOAM components.
Definition: refCount.H:50
A class for managing temporary objects.
Definition: tmp.H:55
Namespace for OpenFOAM.
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