Forward compatibility: flex
[foam-extend-3.2.git] / applications / utilities / parallelProcessing / decomposePar / pointFieldDecomposerDecomposeFields.C
blob5a5a103679c00487af0db4eea232faf84a4a0e4e
1 /*---------------------------------------------------------------------------*\
2   =========                 |
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 -------------------------------------------------------------------------------
8 License
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 "pointFieldDecomposer.H"
27 #include "processorPointPatchFields.H"
28 #include "globalPointPatchFields.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 namespace Foam
35 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
37 template<class Type>
38 tmp<GeometricField<Type, pointPatchField, pointMesh> >
39 pointFieldDecomposer::decomposeField
41     const GeometricField<Type, pointPatchField, pointMesh>& field
42 ) const
44     // Create and map the internal field values
45     Field<Type> internalField(field.internalField(), pointAddressing_);
47     // Create a list of pointers for the patchFields including one extra
48     // for the global patch
49     PtrList<pointPatchField<Type> > patchFields
50     (
51         boundaryAddressing_.size() + 1
52     );
54     // Create and map the patch field values
55     forAll (boundaryAddressing_, patchi)
56     {
57         if (patchFieldDecomposerPtrs_[patchi])
58         {
59             patchFields.set
60             (
61                 patchi,
62                 pointPatchField<Type>::New
63                 (
64                     field.boundaryField()[boundaryAddressing_[patchi]],
65                     procMesh_.boundary()[patchi],
66                     DimensionedField<Type, pointMesh>::null(),
67                     *patchFieldDecomposerPtrs_[patchi]
68                 )
69             );
70         }
71         else
72         {
73             patchFields.set
74             (
75                 patchi,
76                 new ProcessorPointPatchField
77                 <
78                     pointPatchField,
79                     pointMesh,
80                     pointPatch,
81                     processorPointPatch,
82                     DummyMatrix,
83                     Type
84                 >
85                 (
86                     procMesh_.boundary()[patchi],
87                     DimensionedField<Type, pointMesh>::null()
88                 )
89             );
90         }
91     }
93     // Add the global patch
94     patchFields.set
95     (
96         boundaryAddressing_.size(),
97         new GlobalPointPatchField
98         <
99             pointPatchField,
100             pointMesh,
101             pointPatch,
102             globalPointPatch,
103             DummyMatrix,
104             Type
105         >
106         (
107             procMesh_.boundary().globalPatch(),
108             DimensionedField<Type, pointMesh>::null()
109         )
110     );
112     // Create the field for the processor
113     return tmp<GeometricField<Type, pointPatchField, pointMesh> >
114     (
115         new GeometricField<Type, pointPatchField, pointMesh>
116         (
117             IOobject
118             (
119                 field.name(),
120                 procMesh_().time().timeName(),
121                 procMesh_(),
122                 IOobject::NO_READ,
123                 IOobject::NO_WRITE
124             ),
125             procMesh_,
126             field.dimensions(),
127             internalField,
128             patchFields
129         )
130     );
134 template<class GeoField>
135 void pointFieldDecomposer::decomposeFields
137     const PtrList<GeoField>& fields
138 ) const
140     forAll (fields, fieldI)
141     {
142         decomposeField(fields[fieldI])().write();
143     }
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 } // End namespace Foam
151 // ************************************************************************* //