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 "tetPointFieldReconstructor.H"
28 #include "tetPolyPatchFields.H"
29 #include "tetFemMatrices.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
39 tmp<GeometricField<Type, tetPolyPatchField, tetPointMesh> >
40 tetPointFieldReconstructor::reconstructTetPointField
42 const IOobject& fieldIoObject
45 // Read the field for all the processors
46 PtrList<GeometricField<Type, tetPolyPatchField, tetPointMesh> > procFields
51 forAll (procMeshes_, procI)
56 new GeometricField<Type, tetPolyPatchField, tetPointMesh>
61 procMeshes_[procI]().time().timeName(),
72 // Create the internalField
73 Field<Type> internalField(mesh_.nPoints());
75 // Create the patch fields
76 PtrList<tetPolyPatchField<Type> > patchFields(mesh_.boundary().size());
79 forAll (procMeshes_, procI)
81 const GeometricField<Type, tetPolyPatchField, tetPointMesh>&
82 procField = procFields[procI];
84 // Get processor-to-global addressing for use in rmap
85 labelList procToGlobalAddr = procAddressing(procI);
87 // Set the cell values in the reconstructed field
90 procField.internalField(),
94 // Set the boundary patch values in the reconstructed field
95 forAll(boundaryProcAddressing_[procI], patchI)
97 // Get patch index of the original patch
98 const label curBPatch = boundaryProcAddressing_[procI][patchI];
100 // check if the boundary patch is not a processor patch
103 if (!patchFields(curBPatch))
108 tetPolyPatchField<Type>::New
110 procField.boundaryField()[patchI],
111 mesh_.boundary()[curBPatch],
112 DimensionedField<Type, tetPointMesh>::null(),
113 tetPolyPatchFieldReconstructor
115 mesh_.boundary()[curBPatch].size(),
116 procField.boundaryField()[patchI].size()
122 // If the field stores values, do the rmap
123 if (patchFields[curBPatch].storesFieldData())
125 patchFields[curBPatch].rmap
127 procField.boundaryField()[patchI],
140 // Now construct and write the field
141 // setting the internalField and patchFields
142 return tmp<GeometricField<Type, tetPolyPatchField, tetPointMesh> >
144 new GeometricField<Type, tetPolyPatchField, tetPointMesh>
148 fieldIoObject.name(),
149 mesh_().time().timeName(),
155 procFields[0].dimensions(),
164 tmp<GeometricField<Type, elementPatchField, elementMesh> >
165 tetPointFieldReconstructor::reconstructElementField
167 const IOobject& fieldIoObject
170 // Read the field for all the processors
171 PtrList<GeometricField<Type, elementPatchField, elementMesh> > procFields
176 forAll (procMeshes_, procI)
181 new GeometricField<Type, elementPatchField, elementMesh>
185 fieldIoObject.name(),
186 procMeshes_[procI]().time().timeName(),
187 procMeshes_[procI](),
197 // Create the internalField
198 Field<Type> internalField(mesh_.nCells());
200 // Create the patch fields
201 PtrList<elementPatchField<Type> > patchFields(mesh_.boundary().size());
204 forAll (procMeshes_, procI)
206 const GeometricField<Type, elementPatchField, elementMesh>&
207 procField = procFields[procI];
209 // Set the cell values in the reconstructed field
212 procField.internalField(),
213 cellProcAddressing_[procI]
216 // Set the boundary patch values in the reconstructed field
217 forAll(boundaryProcAddressing_[procI], patchI)
219 // Get patch index of the original patch
220 const label curBPatch = boundaryProcAddressing_[procI][patchI];
222 // Get addressing slice for this patch
223 const labelList::subList cp =
224 procMeshes_[procI]().boundaryMesh()[patchI].patchSlice
226 faceProcAddressing_[procI]
229 // check if the boundary patch is not a processor patch
232 if (!patchFields(curBPatch))
237 elementPatchField<Type>::New
239 procField.boundaryField()[patchI],
240 mesh_.boundary()[curBPatch],
241 DimensionedField<Type, elementMesh>::null(),
242 tetPolyPatchFieldReconstructor
244 mesh_.boundary()[curBPatch].size(),
245 procField.boundaryField()[patchI].size()
251 // If the field stores values, do the rmap
252 if (patchFields[curBPatch].storesFieldData())
254 const label curPatchStart =
255 mesh_().boundaryMesh()[curBPatch].start();
257 labelList reverseAddressing(cp.size());
261 // Subtract one to take into account offsets for
263 reverseAddressing[faceI] = cp[faceI] - 1
267 patchFields[curBPatch].rmap
269 procField.boundaryField()[patchI],
277 // Now construct and write the field
278 // setting the internalField and patchFields
279 return tmp<GeometricField<Type, elementPatchField, elementMesh> >
281 new GeometricField<Type, elementPatchField, elementMesh>
285 fieldIoObject.name(),
286 mesh_().time().timeName(),
292 procFields[0].dimensions(),
301 void tetPointFieldReconstructor::reconstructTetPointFields
303 const IOobjectList& objects
308 GeometricField<Type, tetPolyPatchField, tetPointMesh>::typeName
311 IOobjectList fields = objects.lookupClass(fieldClassName);
315 Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
319 IOobjectList::iterator fieldIter = fields.begin();
320 fieldIter != fields.end();
324 Info<< " " << fieldIter()->name() << endl;
326 reconstructTetPointField<Type>(*fieldIter())().write();
335 void tetPointFieldReconstructor::reconstructElementFields
337 const IOobjectList& objects
342 GeometricField<Type, elementPatchField, elementMesh>::typeName
345 IOobjectList fields = objects.lookupClass(fieldClassName);
349 Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
353 IOobjectList::iterator fieldIter = fields.begin();
354 fieldIter != fields.end();
358 Info<< " " << fieldIter()->name() << endl;
360 reconstructElementField<Type>(*fieldIter())().write();
368 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
370 } // End namespace Foam
372 // ************************************************************************* //