FreeFOAM The Cross-Platform CFD Toolkit
SlicedGeometricField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
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 \*---------------------------------------------------------------------------*/
25 
27 
28 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * * //
29 
30 template
31 <
32  class Type,
33  template<class> class PatchField,
34  template<class> class SlicedPatchField,
35  class GeoMesh
36 >
40 (
41  const Mesh& mesh,
42  const Field<Type>& completeField,
43  const bool preserveCouples
44 )
45 {
46  tmp<FieldField<PatchField, Type> > tbf
47  (
48  new FieldField<PatchField, Type>(mesh.boundary().size())
49  );
50 
51  FieldField<PatchField, Type>& bf = tbf();
52 
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  );
68 
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  }
94 
95  return tbf;
96 }
97 
98 
99 template
100 <
101  class Type,
102  template<class> class PatchField,
103  template<class> class SlicedPatchField,
104  class GeoMesh
105 >
109 (
110  const Mesh& mesh,
111  const FieldField<PatchField, Type>& bField,
112  const bool preserveCouples
113 )
114 {
115  tmp<FieldField<PatchField, Type> > tbf
116  (
117  new FieldField<PatchField, Type>(mesh.boundary().size())
118  );
119 
120  FieldField<PatchField, Type>& bf = tbf();
121 
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  );
137 
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  }
156 
157  return tbf;
158 }
159 
160 
161 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
162 
163 template
164 <
165  class Type,
166  template<class> class PatchField,
167  template<class> class SlicedPatchField,
168  class GeoMesh
169 >
172 (
173  const IOobject& io,
174  const Mesh& mesh,
175  const dimensionSet& ds,
176  const Field<Type>& iField
177 )
178 :
180  (
181  io,
182  mesh,
183  ds,
184  Field<Type>()
185  )
186 {
187  // Set the internalField to the slice of the complete field
189  (
190  typename Field<Type>::subField(iField, GeoMesh::size(mesh))
191  );
192 }
193 
194 
195 template
196 <
197  class Type,
198  template<class> class PatchField,
199  template<class> class SlicedPatchField,
200  class GeoMesh
201 >
204 (
205  const IOobject& io,
206  const Mesh& mesh,
207  const dimensionSet& ds,
208  const Field<Type>& completeField,
209  const bool preserveCouples
210 )
211 :
213  (
214  io,
215  mesh,
216  ds,
217  Field<Type>(),
218  slicedBoundaryField(mesh, completeField, preserveCouples)
219  )
220 {
221  // Set the internalField to the slice of the complete field
223  (
224  typename Field<Type>::subField(completeField, GeoMesh::size(mesh))
225  );
226 
228 }
229 
230 
231 template
232 <
233  class Type,
234  template<class> class PatchField,
235  template<class> class SlicedPatchField,
236  class GeoMesh
237 >
240 (
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
247 )
248 :
250  (
251  io,
252  mesh,
253  ds,
254  Field<Type>(),
255  slicedBoundaryField(mesh, completeBField, preserveCouples)
256  )
257 {
258  // Set the internalField to the slice of the complete field
260  (
261  typename Field<Type>::subField(completeIField, GeoMesh::size(mesh))
262  );
263 
265 }
266 
267 
268 template
269 <
270  class Type,
271  template<class> class PatchField,
272  template<class> class SlicedPatchField,
273  class GeoMesh
274 >
277 (
278  const IOobject& io,
280  const bool preserveCouples
281 )
282 :
284  (
285  io,
286  gf.mesh(),
287  gf.dimensions(),
288  Field<Type>(),
289  slicedBoundaryField(gf.mesh(), gf.boundaryField(), preserveCouples)
290  )
291 {
292  // Set the internalField to the supplied internal field
294 
296 }
297 
298 
299 template
300 <
301  class Type,
302  template<class> class PatchField,
303  template<class> class SlicedPatchField,
304  class GeoMesh
305 >
308 (
310 )
311 :
313  (
314  gf,
315  gf.mesh(),
316  gf.dimensions(),
317  Field<Type>(),
318  slicedBoundaryField(gf.mesh(), gf.boundaryField(), true)
319  )
320 {
321  // Set the internalField to the supplied internal field
323 }
324 
325 
326 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
327 
328 template
329 <
330  class Type,
331  template<class> class PatchField,
332  template<class> class SlicedPatchField,
333  class GeoMesh
334 >
337 {
338  // Set the internalField storage pointer to NULL before its destruction
339  // to protect the field it a slice of.
341 }
342 
343 
344 template
345 <
346  class Type,
347  template<class> class PatchField,
348  template<class> class SlicedPatchField,
349  class GeoMesh
350 >
353 {
354  // Set the internalField storage pointer to NULL before its destruction
355  // to protect the field it a slice of.
357 }
358 
359 
360 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
361 
362 template
363 <
364  class Type,
365  template<class> class PatchField,
366  template<class> class SlicedPatchField,
367  class GeoMesh
368 >
371 {
373 }
374 
375 
376 // ************************ vim: set sw=4 sts=4 et: ************************ //