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 "pointFieldReconstructor.H"
29 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32 Foam::tmp<Foam::GeometricField<Type, Foam::pointPatchField, Foam::pointMesh> >
33 Foam::pointFieldReconstructor::reconstructField(const IOobject& fieldIoObject)
35 // Read the field for all the processors
36 PtrList<GeometricField<Type, pointPatchField, pointMesh> > procFields
41 forAll (procMeshes_, proci)
46 new GeometricField<Type, pointPatchField, pointMesh>
51 procMeshes_[proci]().time().timeName(),
62 // Create the internalField
63 Field<Type> internalField(mesh_.size());
65 // Create the patch fields
66 PtrList<pointPatchField<Type> > patchFields(mesh_.boundary().size());
69 forAll (procMeshes_, proci)
71 const GeometricField<Type, pointPatchField, pointMesh>&
72 procField = procFields[proci];
74 // Get processor-to-global addressing for use in rmap
75 const labelList& procToGlobalAddr = pointProcAddressing_[proci];
77 // Set the cell values in the reconstructed field
80 procField.internalField(),
84 // Set the boundary patch values in the reconstructed field
85 forAll(boundaryProcAddressing_[proci], patchi)
87 // Get patch index of the original patch
88 const label curBPatch = boundaryProcAddressing_[proci][patchi];
90 // check if the boundary patch is not a processor patch
93 if (!patchFields(curBPatch))
98 pointPatchField<Type>::New
100 procField.boundaryField()[patchi],
101 mesh_.boundary()[curBPatch],
102 DimensionedField<Type, pointMesh>::null(),
103 pointPatchFieldReconstructor
105 mesh_.boundary()[curBPatch].size(),
106 procField.boundaryField()[patchi].size()
112 patchFields[curBPatch].rmap
114 procField.boundaryField()[patchi],
115 patchPointAddressing_[proci][patchi]
121 // Construct and write the field
122 // setting the internalField and patchFields
123 return tmp<GeometricField<Type, pointPatchField, pointMesh> >
125 new GeometricField<Type, pointPatchField, pointMesh>
129 fieldIoObject.name(),
130 mesh_().time().timeName(),
136 procFields[0].dimensions(),
144 // Reconstruct and write all point fields
146 void Foam::pointFieldReconstructor::reconstructFields
148 const IOobjectList& objects
153 GeometricField<Type, pointPatchField, pointMesh>::typeName
156 IOobjectList fields = objects.lookupClass(fieldClassName);
160 Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
164 IOobjectList::iterator fieldIter = fields.begin();
165 fieldIter != fields.end();
169 Info<< " " << fieldIter()->name() << endl;
171 reconstructField<Type>(*fieldIter())().write();
179 // ************************************************************************* //