initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / applications / utilities / parallelProcessing / decomposePar / pointFieldDecomposerDecomposeFields.C
blob4e8e6b29a3f4176d12b85fa1171eb5979648f924
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
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<Type>
78                 (
79                     procMesh_.boundary()[patchi],
80                     DimensionedField<Type, pointMesh>::null()
81                 )
82             );
83         }
84     }
86     // Add the global patch
87     patchFields.set
88     (
89         boundaryAddressing_.size(),
90         new globalPointPatchField<Type>
91         (
92             procMesh_.boundary().globalPatch(),
93             DimensionedField<Type, pointMesh>::null()
94         )
95     );
97     // Create the field for the processor
98     return tmp<GeometricField<Type, pointPatchField, pointMesh> >
99     (
100         new GeometricField<Type, pointPatchField, pointMesh>
101         (
102             IOobject
103             (
104                 field.name(),
105                 procMesh_().time().timeName(),
106                 procMesh_(),
107                 IOobject::NO_READ,
108                 IOobject::NO_WRITE
109             ),
110             procMesh_,
111             field.dimensions(),
112             internalField,
113             patchFields
114         )
115     );
119 template<class GeoField>
120 void pointFieldDecomposer::decomposeFields
122     const PtrList<GeoField>& fields
123 ) const
125     forAll (fields, fieldI)
126     {
127         decomposeField(fields[fieldI])().write();
128     }
132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 } // End namespace Foam
136 // ************************************************************************* //