Forward compatibility: flex
[foam-extend-3.2.git] / applications / utilities / parallelProcessing / decomposePar / tetPointFieldDecomposerDecomposeFields.C
blob44e1381a417f53b2a9b7c98fba7edf2f15defe69
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 "tetPointFieldDecomposer.H"
27 #include "processorTetPolyPatchFields.H"
28 #include "globalTetPolyPatchFields.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 namespace Foam
35 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
37 template<class Type>
38 tmp<GeometricField<Type, tetPolyPatchField, tetPointMesh> >
39 tetPointFieldDecomposer::decomposeField
41     const GeometricField<Type, tetPolyPatchField, tetPointMesh>& field
42 ) const
44     // Create and map the internal field values
45     Field<Type> internalField(field.internalField(), directAddressing());
47     // Create and map the patch field values
48     PtrList<tetPolyPatchField<Type> > patchFields
49     (
50         boundaryAddressing_.size() + 1
51     );
53     forAll (boundaryAddressing_, patchI)
54     {
55         if (boundaryAddressing_[patchI] >= 0)
56         {
57             patchFields.set
58             (
59                 patchI,
60                 tetPolyPatchField<Type>::New
61                 (
62                     field.boundaryField()
63                         [boundaryAddressing_[patchI]],
64                     processorMesh_.boundary()[patchI],
65                     DimensionedField<Type, tetPointMesh>::null(),
66                     *patchFieldDecompPtrs_[patchI]
67                 )
68             );
69         }
70         else
71         {
72             patchFields.set
73             (
74                 patchI,
75                 new ProcessorPointPatchField
76                 <
77                     tetPolyPatchField,
78                     tetPointMesh,
79                     tetPolyPatch,
80                     processorTetPolyPatch,
81                     tetFemMatrix,
82                     Type
83                 >
84                 (
85                     processorMesh_.boundary()[patchI],
86                     DimensionedField<Type, tetPointMesh>::null()
87                 )
88             );
89         }
90     }
92     // Add the global patch by hand.  This needs to be present on
93     // all processors
94     patchFields.set
95     (
96         patchFields.size() - 1,
97         new GlobalPointPatchField
98         <
99             tetPolyPatchField,
100             tetPointMesh,
101             tetPolyPatch,
102             globalTetPolyPatch,
103             tetFemMatrix,
104             Type
105         >
106         (
107             processorMesh_.boundary().globalPatch(),
108             DimensionedField<Type, tetPointMesh>::null()
109         )
110     );
112     // Create the field for the processor
113     return tmp<GeometricField<Type, tetPolyPatchField, tetPointMesh> >
114     (
115         new GeometricField<Type, tetPolyPatchField, tetPointMesh>
116         (
117             IOobject
118             (
119                 field.name(),
120                 processorMesh_().time().timeName(),
121                 processorMesh_(),
122                 IOobject::NO_READ,
123                 IOobject::NO_WRITE
124             ),
125             processorMesh_,
126             field.dimensions(),
127             internalField,
128             patchFields
129         )
130     );
134 template<class Type>
135 tmp<GeometricField<Type, elementPatchField, elementMesh> >
136 tetPointFieldDecomposer::decomposeField
138     const GeometricField<Type, elementPatchField, elementMesh>& field
139 ) const
141     // Create and map the internal field values
142     Field<Type> internalField(field.internalField(), cellAddressing_);
144     // Create and map the patch field values
145     PtrList<elementPatchField<Type> > patchFields
146     (
147         boundaryAddressing_.size() + 1
148     );
150     forAll (boundaryAddressing_, patchI)
151     {
152         if (boundaryAddressing_[patchI] >= 0)
153         {
154             patchFields.set
155             (
156                 patchI,
157                 elementPatchField<Type>::New
158                 (
159                     field.boundaryField()
160                         [boundaryAddressing_[patchI]],
161                     processorMesh_.boundary()[patchI],
162                     DimensionedField<Type, elementMesh>::null(),
163                     *patchFieldDecompPtrs_[patchI]
164                 )
165             );
166         }
167         else
168         {
169             patchFields.set
170             (
171                 patchI,
172                 new ProcessorPointPatchField
173                 <
174                     elementPatchField,
175                     elementMesh,
176                     tetPolyPatch,
177                     processorTetPolyPatch,
178                     DummyMatrix,
179                     Type
180                 >
181                 (
182                     processorMesh_.boundary()[patchI],
183                     DimensionedField<Type, elementMesh>::null()
184                 )
185             );
186         }
187     }
189     // Add the global patch by hand.  This needs to be present on
190     // all processors
191     patchFields.set
192     (
193         patchFields.size() - 1,
194         new GlobalPointPatchField
195         <
196             elementPatchField,
197             elementMesh,
198             tetPolyPatch,
199             globalTetPolyPatch,
200             DummyMatrix,
201             Type
202         >
203         (
204             processorMesh_.boundary().globalPatch(),
205             DimensionedField<Type, elementMesh>::null()
206         )
207     );
209     // Create the field for the processor
210     return tmp<GeometricField<Type, elementPatchField, elementMesh> >
211     (
212         new GeometricField<Type, elementPatchField, elementMesh>
213         (
214             IOobject
215             (
216                 field.name(),
217                 processorMesh_().time().timeName(),
218                 processorMesh_(),
219                 IOobject::NO_READ,
220                 IOobject::NO_WRITE
221             ),
222             processorMesh_,
223             field.dimensions(),
224             internalField,
225             patchFields
226         )
227     );
231 template<class GeoField>
232 void tetPointFieldDecomposer::decomposeFields
234     const PtrList<GeoField>& fields
235 ) const
237     forAll (fields, fieldI)
238     {
239         decomposeField(fields[fieldI])().write();
240     }
244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 } // End namespace Foam
248 // ************************************************************************* //