1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "SlicedGeometricField.H"
29 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * * //
34 template<class> class PatchField,
35 template<class> class SlicedPatchField,
38 Foam::tmp<Foam::FieldField<PatchField, Type> >
39 Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
43 const Field<Type>& completeField,
44 const bool preserveCouples
47 tmp<FieldField<PatchField, Type> > tbf
49 new FieldField<PatchField, Type>(mesh.boundary().size())
52 FieldField<PatchField, Type>& bf = tbf();
54 forAll (mesh.boundary(), patchi)
56 if (preserveCouples && mesh.boundary()[patchi].coupled())
58 // For coupled patched construct the correct patch field type
64 mesh.boundary()[patchi].type(),
65 mesh.boundary()[patchi],
70 // Initialize the values on the coupled patch to those of the slice
71 // of the given field.
72 // Note: these will usually be over-ridden by the boundary field
73 // evaluation e.g. in the case of processor and cyclic patches.
74 bf[patchi] = SlicedPatchField<Type>
76 mesh.boundary()[patchi],
77 DimensionedField<Type, GeoMesh>::null(),
86 new SlicedPatchField<Type>
88 mesh.boundary()[patchi],
89 DimensionedField<Type, GeoMesh>::null(),
100 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
105 template<class> class PatchField,
106 template<class> class SlicedPatchField,
109 Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
110 DimensionedInternalField::DimensionedInternalField
114 const dimensionSet& ds,
115 const Field<Type>& iField
118 DimensionedField<Type, GeoMesh>
126 // Set the internalField to the slice of the complete field
127 UList<Type>::operator=
129 typename Field<Type>::subField(iField, GeoMesh::size(mesh))
137 template<class> class PatchField,
138 template<class> class SlicedPatchField,
141 Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
146 const dimensionSet& ds,
147 const Field<Type>& completeField,
148 const bool preserveCouples
151 GeometricField<Type, PatchField, GeoMesh>
157 slicedBoundaryField(mesh, completeField, preserveCouples)
160 // Set the internalField to the slice of the complete field
161 UList<Type>::operator=
163 typename Field<Type>::subField(completeField, GeoMesh::size(mesh))
166 correctBoundaryConditions();
173 template<class> class PatchField,
174 template<class> class SlicedPatchField,
177 Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
182 const dimensionSet& ds,
183 const Field<Type>& completeIField,
184 const Field<Type>& completeBField,
185 const bool preserveCouples
188 GeometricField<Type, PatchField, GeoMesh>
194 slicedBoundaryField(mesh, completeBField, preserveCouples)
197 // Set the internalField to the slice of the complete field
198 UList<Type>::operator=
200 typename Field<Type>::subField(completeIField, GeoMesh::size(mesh))
203 correctBoundaryConditions();
207 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
212 template<class> class PatchField,
213 template<class> class SlicedPatchField,
216 Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
217 ~SlicedGeometricField()
219 // Set the internalField storage pointer to NULL before its destruction
220 // to protect the field it a slice of.
221 UList<Type>::operator=(UList<Type>(NULL, 0));
228 template<class> class PatchField,
229 template<class> class SlicedPatchField,
232 Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
233 DimensionedInternalField::~DimensionedInternalField()
235 // Set the internalField storage pointer to NULL before its destruction
236 // to protect the field it a slice of.
237 UList<Type>::operator=(UList<Type>(NULL, 0));
241 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
246 template<class> class PatchField,
247 template<class> class SlicedPatchField,
250 void Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
251 correctBoundaryConditions()
253 GeometricField<Type, PatchField, GeoMesh>::correctBoundaryConditions();
257 // ************************************************************************* //