DimensionedFieldListSlicer.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) 2025-2026 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::DimensionedFieldListSlicer
26 
27 Description
28  Class to provide list slices to different parts of a dimensioned field
29 
30 See also
31  Foam::FieldListSlice
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef DimensionedFieldListSlicer_H
36 #define DimensionedFieldListSlicer_H
37 
38 #include "GeometricField.H"
39 #include "FieldListSlice.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 /*---------------------------------------------------------------------------*\
46  Class DimensionedFieldListSlicer Declaration
47 \*---------------------------------------------------------------------------*/
48 
49 template<class Type>
51 {
52  // Private Data
53 
54  //- Pointers to the fields
56 
57 
58 public:
59 
60  // Constructors
61 
62  //- Construct null. Set later.
64  {}
65 
66  //- Construct from a list of dimensioned fields
67  template<class GeoMesh, template<class> class PrimitiveField>
69  (
71  geoFields
72  )
73  {
74  set(geoFields);
75  }
76 
77  //- Construct from a list of geometric fields
78  template<class GeoMesh, template<class> class PrimitiveField>
80  (
82  geoFields
83  )
84  {
85  set(geoFields);
86  }
87 
88 
89  // Member Functions
90 
91  //- Set the field pointers
92  template<class GeoMesh, template<class> class PrimitiveField>
93  inline void set
94  (
96  geoFields
97  )
98  {
99  fields_.resize(geoFields.size());
100 
101  forAll(geoFields, fieldi)
102  {
103  fields_.set(fieldi, &geoFields[fieldi].primitiveField());
104  }
105  }
106 
107  //- Set the field pointers
108  template<class GeoMesh, template<class> class PrimitiveField>
109  inline void set
110  (
112  geoFields
113  )
114  {
115  fields_.resize(geoFields.size());
116 
117  forAll(geoFields, fieldi)
118  {
119  fields_.set(fieldi, &geoFields[fieldi].primitiveField());
120  }
121  }
122 
123  //- Return a slice for an internal element
124  inline FieldListSlice<Type> slice(const label elementi) const
125  {
126  return FieldListSlice<Type>(fields_, elementi);
127  }
128 };
129 
130 
131 /*---------------------------------------------------------------------------*\
132  Class DimensionedFieldListAndSlicer Declaration
133 \*---------------------------------------------------------------------------*/
134 
135 template<class Type, class GeoMesh, template<class> class PrimitiveField=Field>
137 :
138  public PtrList<DimensionedField<Type, GeoMesh, PrimitiveField>>,
139  private DimensionedFieldListSlicer<Type>
140 {
141 public:
142 
143  // Constructors
144 
145  //- Null Constructor
147  {}
148 
149  //- Construct with size specified
151  :
152  PtrList<DimensionedField<Type, GeoMesh, PrimitiveField>>(size)
153  {}
154 
155  //- Construct from arguments
156  template<class ... Args>
158  :
159  PtrList<DimensionedField<Type, GeoMesh>>(args ...)
160  {
161  set();
162  }
163 
164 
165  // Member Functions
166 
167  //- Inherit the pointer list's set method
169 
170  //- Set the field pointers in the slicer
171  inline void set()
172  {
174  }
175 
176  //- Return a slice for an internal element
178 };
179 
180 
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 
183 } // End namespace Foam
184 
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 
187 #endif
188 
189 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
void set()
Set the field pointers in the slicer.
Class to provide list slices to different parts of a dimensioned field.
void set(const UPtrList< DimensionedField< Type, GeoMesh, PrimitiveField >> &geoFields)
Set the field pointers.
DimensionedFieldListSlicer()
Construct null. Set later.
FieldListSlice< Type > slice(const label elementi) const
Return a slice for an internal element.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Class to provide a list-like interface to a slice through a UPtrList of fields.
Pre-declare SubField and related Field type.
Definition: Field.H:83
Generic GeometricField class.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: UPtrList.H:66
bool set(const label) const
Is element set.
Definition: UPtrListI.H:87
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
void resize(const label)
Reset size of UPtrList. This can only be used to set the size.
Definition: UPtrListI.H:71
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
Foam::argList args(argc, argv)