SlicedGeometricField.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-2020 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::SlicedGeometricField
26 
27 Description
28  Specialization of GeometricField which holds slices of given complete
29  fields in a form that they act as a GeometricField.
30 
31  The destructor is wrapped to avoid deallocation of the storage of the
32  complete fields when this is destroyed.
33 
34  SlicedGeometricField can only be instantiated with a valid form of
35  SlicedPatchField to handle the slicing and storage deallocation of the
36  boundary field.
37 
38 SourceFiles
39  SlicedGeometricField.C
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef SlicedGeometricField_H
44 #define SlicedGeometricField_H
45 
46 #include "GeometricField.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 /*---------------------------------------------------------------------------*\
54  Class SlicedGeometricField Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 template
58 <
59  class Type,
60  template<class> class PatchField,
61  template<class> class SlicedPatchField,
62  class GeoMesh
63 >
64 class SlicedGeometricField
65 :
66  public GeometricField<Type, PatchField, GeoMesh>
67 {
68 public:
69 
70  typedef typename GeoMesh::Mesh Mesh;
71  typedef typename GeoMesh::BoundaryMesh BoundaryMesh;
72 
73  class Internal;
74 
75 
76 private:
77 
78  // Private Member Functions
79 
80  //- Slice the given field and a create a PtrList of SlicedPatchField
81  // from which the boundary field is built
82  tmp<FieldField<PatchField, Type>> slicedBoundaryField
83  (
84  const Mesh& mesh,
85  const Field<Type>& completeField,
86  const bool preserveCouples,
87  const bool preserveProcessorOnly = false
88  );
89 
90  //- Slice the given field and a create a PtrList of SlicedPatchField
91  // from which the boundary field is built
92  tmp<FieldField<PatchField, Type>> slicedBoundaryField
93  (
94  const Mesh& mesh,
95  const FieldField<PatchField, Type>& bField,
96  const bool preserveCouples
97  );
98 
99 
100 public:
101 
102  // Constructors
103 
104  //- Construct from components and field to slice
106  (
107  const IOobject&,
108  const Mesh&,
109  const dimensionSet&,
110  const Field<Type>& completeField,
111  const bool preserveCouples=true
112  );
113 
114  //- Construct from components and separate fields to slice for the
115  // internal field and boundary field
117  (
118  const IOobject&,
119  const Mesh&,
120  const dimensionSet&,
121  const Field<Type>& completeIField,
122  const Field<Type>& completeBField,
123  const bool preserveCouples=true,
124  const bool preserveProcessorOnly = false
125  );
126 
127  //- Construct from GeometricField. Reuses full internal and
128  // patch fields except on couples (preserveCouples=true).
130  (
131  const IOobject&,
133  const bool preserveCouples=true
134  );
135 
136  //- Copy constructor
138  (
140  <
141  Type,
142  PatchField,
143  SlicedPatchField,
144  GeoMesh
145  >&
146  );
147 
148  //- Clone
150  clone() const;
151 
152 
153  //- Destructor
155 
156 
157  // Member Functions
158 
159  //- Splice the sliced field and return the complete field
160  tmp<Field<Type>> splice() const;
161 
162  //- Correct boundary field
164 
165 
166  // Member Operators
167 
168  //- Disallow default bitwise assignment
169  void operator=(const SlicedGeometricField&) = delete;
170 
171  //- Disallow standard assignment to GeometricField,
172  // == assignment is allowed.
173  void operator=
174  (
176  ) = delete;
177 
178  //- Disallow standard assignment to tmp<GeometricField>,
179  // == assignment is allowed.
180  void operator=
181  (
183  ) = delete;
184 };
185 
186 
187 /*---------------------------------------------------------------------------*\
188  Class SlicedGeometricField::Internal Declaration
189 \*---------------------------------------------------------------------------*/
190 
191 //- The internalField of a SlicedGeometricField
192 template
193 <
194  class Type,
195  template<class> class PatchField,
196  template<class> class SlicedPatchField,
197  class GeoMesh
198 >
199 class SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
200 Internal
201 :
202  public GeometricField<Type, PatchField, GeoMesh>::Internal
203 {
204 
205 public:
206 
207  // Constructors
208 
209  //- Construct from components and field to slice
210  Internal
211  (
212  const IOobject&,
213  const Mesh&,
214  const dimensionSet&,
215  const Field<Type>& iField
216  );
217 
218 
219  //- Destructor
220  ~Internal();
221 };
222 
223 
224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 
226 } // End namespace Foam
227 
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 
230 #ifdef NoRepository
231  #include "SlicedGeometricField.C"
232 #endif
233 
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 
236 #endif
237 
238 // ************************************************************************* //
GeoMesh::BoundaryMesh BoundaryMesh
MESH::BoundaryMesh BoundaryMesh
Definition: GeoMesh.H:62
Generic GeometricField class.
DimensionedField< Type, GeoMesh > Internal
Type of the internal field from which this GeometricField is derived.
Dimension set for the base types.
Definition: dimensionSet.H:120
Pre-declare SubField and related Field type.
Definition: Field.H:56
void operator=(const SlicedGeometricField &)=delete
Disallow default bitwise assignment.
GeoMesh::Mesh Mesh
Type of mesh on which this DimensionedField is instantiated.
const Mesh & mesh() const
Return mesh.
tmp< SlicedGeometricField< Type, PatchField, SlicedPatchField, GeoMesh > > clone() const
Clone.
void correctBoundaryConditions()
Correct boundary field.
MESH Mesh
Definition: GeoMesh.H:61
The internalField of a SlicedGeometricField.
tmp< Field< Type > > splice() const
Splice the sliced field and return the complete field.
SlicedGeometricField(const IOobject &, const Mesh &, const dimensionSet &, const Field< Type > &completeField, const bool preserveCouples=true)
Construct from components and field to slice.
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition: GeoMesh.H:46
A class for managing temporary objects.
Definition: PtrList.H:53
Specialization of GeometricField which holds slices of given complete fields in a form that they act ...
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
Namespace for OpenFOAM.