1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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))
97 pointPatchField<Type>::New
99 procField.boundaryField()[patchi],
100 mesh_.boundary()[curBPatch],
101 DimensionedField<Type, pointMesh>::null(),
102 pointPatchFieldReconstructor
104 mesh_.boundary()[curBPatch].size()
110 patchFields[curBPatch].rmap
112 procField.boundaryField()[patchi],
113 patchPointAddressing_[proci][patchi]
119 // Construct and write the field
120 // setting the internalField and patchFields
121 return tmp<GeometricField<Type, pointPatchField, pointMesh> >
123 new GeometricField<Type, pointPatchField, pointMesh>
127 fieldIoObject.name(),
128 mesh_().time().timeName(),
134 procFields[0].dimensions(),
142 // Reconstruct and write all point fields
144 void Foam::pointFieldReconstructor::reconstructFields
146 const IOobjectList& objects
151 GeometricField<Type, pointPatchField, pointMesh>::typeName
154 IOobjectList fields = objects.lookupClass(fieldClassName);
158 Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
162 IOobjectList::iterator fieldIter = fields.begin();
163 fieldIter != fields.end();
167 Info<< " " << fieldIter()->name() << endl;
169 reconstructField<Type>(*fieldIter())().write();
177 // ************************************************************************* //