BUGFIX: Uninitialised member variables
[foam-extend-3.2.git] / applications / utilities / parallelProcessing / decomposePar / pointFieldDecomposerDecomposeFields.C
blob722315f94b1d5e0d8dd95cea7f8c833760a8da09
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
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 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
19     for more details.
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 "pointFieldDecomposer.H"
28 #include "processorPointPatchFields.H"
29 #include "globalPointPatchFields.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 namespace Foam
36 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
38 template<class Type>
39 tmp<GeometricField<Type, pointPatchField, pointMesh> >
40 pointFieldDecomposer::decomposeField
42     const GeometricField<Type, pointPatchField, pointMesh>& field
43 ) const
45     // Create and map the internal field values
46     Field<Type> internalField(field.internalField(), pointAddressing_);
48     // Create a list of pointers for the patchFields including one extra
49     // for the global patch
50     PtrList<pointPatchField<Type> > patchFields
51     (
52         boundaryAddressing_.size() + 1
53     );
55     // Create and map the patch field values
56     forAll (boundaryAddressing_, patchi)
57     {
58         if (patchFieldDecomposerPtrs_[patchi])
59         {
60             patchFields.set
61             (
62                 patchi,
63                 pointPatchField<Type>::New
64                 (
65                     field.boundaryField()[boundaryAddressing_[patchi]],
66                     procMesh_.boundary()[patchi],
67                     DimensionedField<Type, pointMesh>::null(),
68                     *patchFieldDecomposerPtrs_[patchi]
69                 )
70             );
71         }
72         else
73         {
74             patchFields.set
75             (
76                 patchi,
77                 new ProcessorPointPatchField
78                 <
79                     pointPatchField,
80                     pointMesh,
81                     pointPatch,
82                     processorPointPatch,
83                     DummyMatrix,
84                     Type
85                 >
86                 (
87                     procMesh_.boundary()[patchi],
88                     DimensionedField<Type, pointMesh>::null()
89                 )
90             );
91         }
92     }
94     // Add the global patch
95     patchFields.set
96     (
97         boundaryAddressing_.size(),
98         new GlobalPointPatchField
99         <
100             pointPatchField,
101             pointMesh,
102             pointPatch,
103             globalPointPatch,
104             DummyMatrix,
105             Type
106         >
107         (
108             procMesh_.boundary().globalPatch(),
109             DimensionedField<Type, pointMesh>::null()
110         )
111     );
113     // Create the field for the processor
114     return tmp<GeometricField<Type, pointPatchField, pointMesh> >
115     (
116         new GeometricField<Type, pointPatchField, pointMesh>
117         (
118             IOobject
119             (
120                 field.name(),
121                 procMesh_().time().timeName(),
122                 procMesh_(),
123                 IOobject::NO_READ,
124                 IOobject::NO_WRITE
125             ),
126             procMesh_,
127             field.dimensions(),
128             internalField,
129             patchFields
130         )
131     );
135 template<class GeoField>
136 void pointFieldDecomposer::decomposeFields
138     const PtrList<GeoField>& fields
139 ) const
141     forAll (fields, fieldI)
142     {
143         decomposeField(fields[fieldI])().write();
144     }
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 } // End namespace Foam
152 // ************************************************************************* //