BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / OpenFOAM / fields / GeometricFields / SlicedGeometricField / SlicedGeometricField.C
blob43d14a57405600060bb8f59618ba725851be44f1
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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.
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.
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "SlicedGeometricField.H"
28 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * * //
30 template
32     class Type,
33     template<class> class PatchField,
34     template<class> class SlicedPatchField,
35     class GeoMesh
37 Foam::tmp<Foam::FieldField<PatchField, Type> >
38 Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
39 slicedBoundaryField
41     const Mesh& mesh,
42     const Field<Type>& completeField,
43     const bool preserveCouples
46     tmp<FieldField<PatchField, Type> > tbf
47     (
48         new FieldField<PatchField, Type>(mesh.boundary().size())
49     );
51     FieldField<PatchField, Type>& bf = tbf();
53     forAll(mesh.boundary(), patchi)
54     {
55         if (preserveCouples && mesh.boundary()[patchi].coupled())
56         {
57             // For coupled patched construct the correct patch field type
58             bf.set
59             (
60                 patchi,
61                 PatchField<Type>::New
62                 (
63                     mesh.boundary()[patchi].type(),
64                     mesh.boundary()[patchi],
65                     *this
66                 )
67             );
69             // Initialize the values on the coupled patch to those of the slice
70             // of the given field.
71             // Note: these will usually be over-ridden by the boundary field
72             // evaluation e.g. in the case of processor and cyclic patches.
73             bf[patchi] = SlicedPatchField<Type>
74             (
75                 mesh.boundary()[patchi],
76                 DimensionedField<Type, GeoMesh>::null(),
77                 completeField
78             );
79         }
80         else
81         {
82             bf.set
83             (
84                 patchi,
85                 new SlicedPatchField<Type>
86                 (
87                     mesh.boundary()[patchi],
88                     DimensionedField<Type, GeoMesh>::null(),
89                     completeField
90                 )
91             );
92         }
93     }
95     return tbf;
99 template
101     class Type,
102     template<class> class PatchField,
103     template<class> class SlicedPatchField,
104     class GeoMesh
106 Foam::tmp<Foam::FieldField<PatchField, Type> >
107 Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
108 slicedBoundaryField
110     const Mesh& mesh,
111     const FieldField<PatchField, Type>& bField,
112     const bool preserveCouples
115     tmp<FieldField<PatchField, Type> > tbf
116     (
117         new FieldField<PatchField, Type>(mesh.boundary().size())
118     );
120     FieldField<PatchField, Type>& bf = tbf();
122     forAll(mesh.boundary(), patchi)
123     {
124         if (preserveCouples && mesh.boundary()[patchi].coupled())
125         {
126             // For coupled patched construct the correct patch field type
127             bf.set
128             (
129                 patchi,
130                 PatchField<Type>::New
131                 (
132                     mesh.boundary()[patchi].type(),
133                     mesh.boundary()[patchi],
134                     *this
135                 )
136             );
138             // Assign field
139             bf[patchi] == bField[patchi];
140         }
141         else
142         {
143             // Create unallocated copy of patch field
144             bf.set
145             (
146                 patchi,
147                 new SlicedPatchField<Type>
148                 (
149                     mesh.boundary()[patchi],
150                     DimensionedField<Type, GeoMesh>::null()
151                 )
152             );
153             bf[patchi].UList<Type>::operator=(bField[patchi]);
154         }
155     }
157     return tbf;
161 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
163 template
165     class Type,
166     template<class> class PatchField,
167     template<class> class SlicedPatchField,
168     class GeoMesh
170 Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
171 DimensionedInternalField::DimensionedInternalField
173     const IOobject& io,
174     const Mesh& mesh,
175     const dimensionSet& ds,
176     const Field<Type>& iField
179     DimensionedField<Type, GeoMesh>
180     (
181         io,
182         mesh,
183         ds,
184         Field<Type>()
185     )
187     // Set the internalField to the slice of the complete field
188     UList<Type>::operator=
189     (
190         typename Field<Type>::subField(iField, GeoMesh::size(mesh))
191     );
195 template
197     class Type,
198     template<class> class PatchField,
199     template<class> class SlicedPatchField,
200     class GeoMesh
202 Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
203 SlicedGeometricField
205     const IOobject& io,
206     const Mesh& mesh,
207     const dimensionSet& ds,
208     const Field<Type>& completeField,
209     const bool preserveCouples
212     GeometricField<Type, PatchField, GeoMesh>
213     (
214         io,
215         mesh,
216         ds,
217         Field<Type>(),
218         slicedBoundaryField(mesh, completeField, preserveCouples)
219     )
221     // Set the internalField to the slice of the complete field
222     UList<Type>::operator=
223     (
224         typename Field<Type>::subField(completeField, GeoMesh::size(mesh))
225     );
227     correctBoundaryConditions();
231 template
233     class Type,
234     template<class> class PatchField,
235     template<class> class SlicedPatchField,
236     class GeoMesh
238 Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
239 SlicedGeometricField
241     const IOobject& io,
242     const Mesh& mesh,
243     const dimensionSet& ds,
244     const Field<Type>& completeIField,
245     const Field<Type>& completeBField,
246     const bool preserveCouples
249     GeometricField<Type, PatchField, GeoMesh>
250     (
251         io,
252         mesh,
253         ds,
254         Field<Type>(),
255         slicedBoundaryField(mesh, completeBField, preserveCouples)
256     )
258     // Set the internalField to the slice of the complete field
259     UList<Type>::operator=
260     (
261         typename Field<Type>::subField(completeIField, GeoMesh::size(mesh))
262     );
264     correctBoundaryConditions();
268 template
270     class Type,
271     template<class> class PatchField,
272     template<class> class SlicedPatchField,
273     class GeoMesh
275 Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
276 SlicedGeometricField
278     const IOobject& io,
279     const GeometricField<Type, PatchField, GeoMesh>& gf,
280     const bool preserveCouples
283     GeometricField<Type, PatchField, GeoMesh>
284     (
285         io,
286         gf.mesh(),
287         gf.dimensions(),
288         Field<Type>(),
289         slicedBoundaryField(gf.mesh(), gf.boundaryField(), preserveCouples)
290     )
292     // Set the internalField to the supplied internal field
293     UList<Type>::operator=(gf.internalField());
295     correctBoundaryConditions();
299 template
301     class Type,
302     template<class> class PatchField,
303     template<class> class SlicedPatchField,
304     class GeoMesh
306 Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
307 SlicedGeometricField
309     const SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>& gf
312     GeometricField<Type, PatchField, GeoMesh>
313     (
314         gf,
315         gf.mesh(),
316         gf.dimensions(),
317         Field<Type>(),
318         slicedBoundaryField(gf.mesh(), gf.boundaryField(), true)
319     )
321     // Set the internalField to the supplied internal field
322     UList<Type>::operator=(gf.internalField());
326 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
328 template
330     class Type,
331     template<class> class PatchField,
332     template<class> class SlicedPatchField,
333     class GeoMesh
335 Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
336 ~SlicedGeometricField()
338     // Set the internalField storage pointer to NULL before its destruction
339     // to protect the field it a slice of.
340     UList<Type>::operator=(UList<Type>(NULL, 0));
344 template
346     class Type,
347     template<class> class PatchField,
348     template<class> class SlicedPatchField,
349     class GeoMesh
351 Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
352 DimensionedInternalField::~DimensionedInternalField()
354     // Set the internalField storage pointer to NULL before its destruction
355     // to protect the field it a slice of.
356     UList<Type>::operator=(UList<Type>(NULL, 0));
360 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
362 template
364     class Type,
365     template<class> class PatchField,
366     template<class> class SlicedPatchField,
367     class GeoMesh
369 void Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
370 correctBoundaryConditions()
372     GeometricField<Type, PatchField, GeoMesh>::correctBoundaryConditions();
376 // ************************************************************************* //