1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "fvFieldDecomposer.H"
27 #include "processorFvPatchField.H"
28 #include "processorFvsPatchField.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
38 tmp<GeometricField<Type, fvPatchField, volMesh> >
39 fvFieldDecomposer::decomposeField
41 const GeometricField<Type, fvPatchField, volMesh>& field
44 // Create and map the internal field values
45 Field<Type> internalField(field.internalField(), cellAddressing_);
47 // Create and map the patch field values
48 PtrList<fvPatchField<Type> > patchFields(boundaryAddressing_.size());
50 forAll (boundaryAddressing_, patchi)
52 if (boundaryAddressing_[patchi] >= 0)
57 fvPatchField<Type>::New
59 field.boundaryField()[boundaryAddressing_[patchi]],
60 procMesh_.boundary()[patchi],
61 DimensionedField<Type, volMesh>::null(),
62 *patchFieldDecomposerPtrs_[patchi]
71 new processorFvPatchField<Type>
73 procMesh_.boundary()[patchi],
74 DimensionedField<Type, volMesh>::null(),
77 field.internalField(),
78 *processorVolPatchFieldDecomposerPtrs_[patchi]
85 // Create the field for the processor
86 return tmp<GeometricField<Type, fvPatchField, volMesh> >
88 new GeometricField<Type, fvPatchField, volMesh>
93 procMesh_.time().timeName(),
108 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
109 fvFieldDecomposer::decomposeField
111 const GeometricField<Type, fvsPatchField, surfaceMesh>& field
119 procMesh_.nInternalFaces()
127 // Create and map the internal field values
128 Field<Type> internalField
130 field.internalField(),
134 // Problem with addressing when a processor patch picks up both internal
135 // faces and faces from cyclic boundaries. This is a bit of a hack, but
136 // I cannot find a better solution without making the internal storage
137 // mechanism for surfaceFields correspond to the one of faces in polyMesh
138 // (i.e. using slices)
139 Field<Type> allFaceField(field.mesh().nFaces());
141 forAll (field.internalField(), i)
143 allFaceField[i] = field.internalField()[i];
146 forAll (field.boundaryField(), patchi)
148 const Field<Type> & p = field.boundaryField()[patchi];
150 const label patchStart = field.mesh().boundaryMesh()[patchi].start();
154 allFaceField[patchStart + i] = p[i];
158 // Create and map the patch field values
159 PtrList<fvsPatchField<Type> > patchFields(boundaryAddressing_.size());
161 forAll (boundaryAddressing_, patchi)
163 if (boundaryAddressing_[patchi] >= 0)
168 fvsPatchField<Type>::New
170 field.boundaryField()[boundaryAddressing_[patchi]],
171 procMesh_.boundary()[patchi],
172 DimensionedField<Type, surfaceMesh>::null(),
173 *patchFieldDecomposerPtrs_[patchi]
182 new processorFvsPatchField<Type>
184 procMesh_.boundary()[patchi],
185 DimensionedField<Type, surfaceMesh>::null(),
189 *processorSurfacePatchFieldDecomposerPtrs_[patchi]
196 // Create the field for the processor
197 return tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
199 new GeometricField<Type, fvsPatchField, surfaceMesh>
204 procMesh_.time().timeName(),
218 template<class GeoField>
219 void fvFieldDecomposer::decomposeFields
221 const PtrList<GeoField>& fields
224 forAll (fields, fieldI)
226 decomposeField(fields[fieldI])().write();
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 } // End namespace Foam
235 // ************************************************************************* //