SlicedDimensionedField.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) 2022 OpenFOAM Foundation
9  Copyright (C) 2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 Class
28  Foam::SlicedDimensionedField
29 
30 Description
31  Specialisation of DimensionedField that holds a slice of a given
32  field so that it acts as a DimensionedField.
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef Foam_SlicedDimensionedField_H
37 #define Foam_SlicedDimensionedField_H
38 
39 #include "DimensionedField.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class SlicedDimensionedField Declaration
48 \*---------------------------------------------------------------------------*/
49 
50 template<class Type, class GeoMesh>
52 :
53  public DimensionedField<Type, GeoMesh>
54 {
55 public:
56 
57  // Public Typedefs
58 
59  //- Type of mesh on which this SlicedDimensionedField is instantiated
60  typedef typename GeoMesh::Mesh Mesh;
61 
62 
63  // Constructors
64 
65  //- Construct from components and field to slice
67  (
68  const IOobject& io,
69  const Mesh& mesh,
70  const dimensionSet& dims,
71  const Field<Type>& iField
72  )
73  :
74  DimensionedField<Type, GeoMesh>(io, mesh, dims, Field<Type>())
75  {
76  // Set internalField to the slice of the complete field
78  (
79  SubList<Type>(iField, GeoMesh::size(mesh))
80  );
81  }
82 
83 
84  //- Destructor
86  {
87  // Set internalField to nullptr to avoid deletion of underlying field
88  UList<Type>::shallowCopy(nullptr);
89  }
90 };
91 
92 
93 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
94 
95 } // End namespace Foam
96 
97 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
98 
99 #endif
100 
101 // ************************************************************************* //
Specialisation of DimensionedField that holds a slice of a given field so that it acts as a Dimension...
SlicedDimensionedField(const IOobject &io, const Mesh &mesh, const dimensionSet &dims, const Field< Type > &iField)
Construct from components and field to slice.
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Definition: dimensionSet.H:105
Generic templated field type.
Definition: Field.H:62
Foam::volMesh ::Mesh Mesh
The mesh type for the DimensionedField.
const Mesh & mesh() const noexcept
Return mesh.
MESH Mesh
Definition: GeoMesh.H:58
GeoMesh::Mesh Mesh
Type of mesh on which this SlicedDimensionedField is instantiated.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
void shallowCopy(T *__restrict__ ptr, const label len) noexcept
Copy the pointer and size.
Definition: UListI.H:309
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition: GeoMesh.H:42
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:180
Namespace for OpenFOAM.