1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
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
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 "tetPointFieldReconstructor.H"
29 #include "tetPolyPatchFields.H"
30 #include "tetFemMatrices.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
40 tmp<GeometricField<Type, tetPolyPatchField, tetPointMesh> >
41 tetPointFieldReconstructor::reconstructTetPointField
43 const IOobject& fieldIoObject
46 // Read the field for all the processors
47 PtrList<GeometricField<Type, tetPolyPatchField, tetPointMesh> > procFields
52 forAll (procMeshes_, procI)
57 new GeometricField<Type, tetPolyPatchField, tetPointMesh>
62 procMeshes_[procI]().time().timeName(),
73 // Create the internalField
74 Field<Type> internalField(mesh_.nPoints());
76 // Create the patch fields
77 PtrList<tetPolyPatchField<Type> > patchFields(mesh_.boundary().size());
80 forAll (procMeshes_, procI)
82 const GeometricField<Type, tetPolyPatchField, tetPointMesh>&
83 procField = procFields[procI];
85 // Get processor-to-global addressing for use in rmap
86 labelList procToGlobalAddr = procAddressing(procI);
88 // Set the cell values in the reconstructed field
91 procField.internalField(),
95 // Set the boundary patch values in the reconstructed field
96 forAll(boundaryProcAddressing_[procI], patchI)
98 // Get patch index of the original patch
99 const label curBPatch = boundaryProcAddressing_[procI][patchI];
101 // check if the boundary patch is not a processor patch
104 if (!patchFields(curBPatch))
109 tetPolyPatchField<Type>::New
111 procField.boundaryField()[patchI],
112 mesh_.boundary()[curBPatch],
113 DimensionedField<Type, tetPointMesh>::null(),
114 tetPolyPatchFieldReconstructor
116 mesh_.boundary()[curBPatch].size(),
117 procField.boundaryField()[patchI].size()
123 // If the field stores values, do the rmap
124 if (patchFields[curBPatch].storesFieldData())
126 patchFields[curBPatch].rmap
128 procField.boundaryField()[patchI],
141 // Now construct and write the field
142 // setting the internalField and patchFields
143 return tmp<GeometricField<Type, tetPolyPatchField, tetPointMesh> >
145 new GeometricField<Type, tetPolyPatchField, tetPointMesh>
149 fieldIoObject.name(),
150 mesh_().time().timeName(),
156 procFields[0].dimensions(),
165 tmp<GeometricField<Type, elementPatchField, elementMesh> >
166 tetPointFieldReconstructor::reconstructElementField
168 const IOobject& fieldIoObject
171 // Read the field for all the processors
172 PtrList<GeometricField<Type, elementPatchField, elementMesh> > procFields
177 forAll (procMeshes_, procI)
182 new GeometricField<Type, elementPatchField, elementMesh>
186 fieldIoObject.name(),
187 procMeshes_[procI]().time().timeName(),
188 procMeshes_[procI](),
198 // Create the internalField
199 Field<Type> internalField(mesh_.nCells());
201 // Create the patch fields
202 PtrList<elementPatchField<Type> > patchFields(mesh_.boundary().size());
205 forAll (procMeshes_, procI)
207 const GeometricField<Type, elementPatchField, elementMesh>&
208 procField = procFields[procI];
210 // Set the cell values in the reconstructed field
213 procField.internalField(),
214 cellProcAddressing_[procI]
217 // Set the boundary patch values in the reconstructed field
218 forAll(boundaryProcAddressing_[procI], patchI)
220 // Get patch index of the original patch
221 const label curBPatch = boundaryProcAddressing_[procI][patchI];
223 // Get addressing slice for this patch
224 const labelList::subList cp =
225 procMeshes_[procI]().boundaryMesh()[patchI].patchSlice
227 faceProcAddressing_[procI]
230 // check if the boundary patch is not a processor patch
233 if (!patchFields(curBPatch))
238 elementPatchField<Type>::New
240 procField.boundaryField()[patchI],
241 mesh_.boundary()[curBPatch],
242 DimensionedField<Type, elementMesh>::null(),
243 tetPolyPatchFieldReconstructor
245 mesh_.boundary()[curBPatch].size(),
246 procField.boundaryField()[patchI].size()
252 // If the field stores values, do the rmap
253 if (patchFields[curBPatch].storesFieldData())
255 const label curPatchStart =
256 mesh_().boundaryMesh()[curBPatch].start();
258 labelList reverseAddressing(cp.size());
262 // Subtract one to take into account offsets for
264 reverseAddressing[faceI] = cp[faceI] - 1
268 patchFields[curBPatch].rmap
270 procField.boundaryField()[patchI],
278 // Now construct and write the field
279 // setting the internalField and patchFields
280 return tmp<GeometricField<Type, elementPatchField, elementMesh> >
282 new GeometricField<Type, elementPatchField, elementMesh>
286 fieldIoObject.name(),
287 mesh_().time().timeName(),
293 procFields[0].dimensions(),
302 void tetPointFieldReconstructor::reconstructTetPointFields
304 const IOobjectList& objects
309 GeometricField<Type, tetPolyPatchField, tetPointMesh>::typeName
312 IOobjectList fields = objects.lookupClass(fieldClassName);
316 Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
320 IOobjectList::iterator fieldIter = fields.begin();
321 fieldIter != fields.end();
325 Info<< " " << fieldIter()->name() << endl;
327 reconstructTetPointField<Type>(*fieldIter())().write();
336 void tetPointFieldReconstructor::reconstructElementFields
338 const IOobjectList& objects
343 GeometricField<Type, elementPatchField, elementMesh>::typeName
346 IOobjectList fields = objects.lookupClass(fieldClassName);
350 Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
354 IOobjectList::iterator fieldIter = fields.begin();
355 fieldIter != fields.end();
359 Info<< " " << fieldIter()->name() << endl;
361 reconstructElementField<Type>(*fieldIter())().write();
369 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
371 } // End namespace Foam
373 // ************************************************************************* //