SlicedGeometricField.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) 2011-2017,2022 OpenFOAM Foundation
9  Copyright (C) 2023 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::SlicedGeometricField
29 
30 Description
31  Specialization of GeometricField which holds slices of given complete
32  fields in a form that they act as a GeometricField.
33 
34  The destructor is wrapped to avoid deallocation of the storage of the
35  complete fields when this is destroyed.
36 
37  SlicedGeometricField can only be instantiated with a valid form of
38  SlicedPatchField to handle the slicing and storage deallocation of the
39  boundary field.
40 
41 SourceFiles
42  SlicedGeometricField.C
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef Foam_SlicedGeometricField_H
47 #define Foam_SlicedGeometricField_H
48 
49 #include "GeometricField.H"
50 #include "SlicedDimensionedField.H"
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 namespace Foam
55 {
56 
57 /*---------------------------------------------------------------------------*\
58  Class SlicedGeometricField Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 template
62 <
63  class Type,
64  template<class> class PatchField,
65  template<class> class SlicedPatchField,
66  class GeoMesh
67 >
68 class SlicedGeometricField
69 :
70  public GeometricField<Type, PatchField, GeoMesh>
71 {
72 public:
73 
74  // Public Typedefs
75 
76  typedef typename GeoMesh::Mesh Mesh;
78 
79  //- The internal field slice for this SlicedGeometricField
81 
82 
83 private:
84 
85  // Private Member Functions
86 
87  //- Return true if field size is too small to be the complete field
88  //- (ie, it must be boundary field addressing)
89  static bool
90  isBoundaryAddressing(const Mesh& mesh, const label fieldSize);
91 
92  //- Slice the given field and a create a PtrList of SlicedPatchField
93  // from which the boundary field is built
95  makeBoundary
96  (
97  const Mesh& mesh,
98  const Field<Type>& completeOrBoundaryField,
99  const bool preserveCouples,
100  const bool preserveProcessorOnly = false,
101  const bool isBoundaryOnly = false
102  ) const;
103 
104  //- Slice the given field and a create a PtrList of SlicedPatchField
105  // from which the boundary field is built
107  makeBoundary
108  (
109  const Mesh& mesh,
110  const FieldField<PatchField, Type>& bField,
111  const bool preserveCouples
112  ) const;
113 
114  // Note - copy construct allowed
115 
116  //- No copy assignment
117  void operator=(const SlicedGeometricField&) = delete;
118 
119  //- No copy assignment from GeometricField,
120  // == assignment is allowed.
121  void operator=
122  (
124  ) = delete;
125 
126  //- No copy assignment from tmp<GeometricField>,
127  // == assignment is allowed.
128  void operator=
129  (
131  ) = delete;
132 
133 
134 public:
135 
136  // Constructors
137 
138  //- Construct from components and field to slice
140  (
141  const IOobject&,
142  const Mesh&,
143  const dimensionSet& dims,
144  const Field<Type>& completeField,
145  const bool preserveCouples = true
146  );
147 
148  //- Construct from components and separate fields to slice for the
149  //- internal field and boundary field
151  (
152  const IOobject&,
153  const Mesh&,
154  const dimensionSet& dims,
155  const Field<Type>& completeIField,
156  const Field<Type>& completeBField,
157  const bool preserveCouples = true,
158  const bool preserveProcessorOnly = false
159  );
160 
161  //- Construct from GeometricField. Reuses full internal and
162  //- patch fields except on couples (preserveCouples=true).
164  (
165  const IOobject&,
167  const bool preserveCouples = true
168  );
169 
170  //- Copy construct
172  (
174  <
175  Type,
176  PatchField,
177  SlicedPatchField,
178  GeoMesh
179  >&
180  );
181 
182  //- Clone
184  clone() const;
185 
186 
187  //- Destructor
189 
190 
191  // Member Functions
192 
193  //- Correct boundary field
195 };
196 
197 
198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 
200 } // End namespace Foam
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 #ifdef NoRepository
205  #include "SlicedGeometricField.C"
206 #endif
207 
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 
210 #endif
211 
212 // ************************************************************************* //
GeoMesh::BoundaryMesh BoundaryMesh
Specialisation of DimensionedField that holds a slice of a given field so that it acts as a Dimension...
SlicedGeometricField(const IOobject &, const Mesh &, const dimensionSet &dims, const Field< Type > &completeField, const bool preserveCouples=true)
Construct from components and field to slice.
MESH::BoundaryMesh BoundaryMesh
Definition: GeoMesh.H:59
Generic GeometricField class.
Definition: areaFieldsFwd.H:50
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
GeoMesh::Mesh Mesh
Type of mesh on which this DimensionedField is instantiated.
const Mesh & mesh() const noexcept
Return mesh.
tmp< SlicedGeometricField< Type, PatchField, SlicedPatchField, GeoMesh > > clone() const
Clone.
void correctBoundaryConditions()
Correct boundary field.
MESH Mesh
Definition: GeoMesh.H:58
SlicedDimensionedField< Type, GeoMesh > Internal
The internal field slice for this SlicedGeometricField.
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition: GeoMesh.H:42
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Specialization of GeometricField which holds slices of given complete fields in a form that they act ...
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:171
Namespace for OpenFOAM.