OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

pointFieldReconstructorReconstructFields.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "pointFieldReconstructor.H"
00028 
00029 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00030 
00031 template<class Type>
00032 Foam::tmp<Foam::GeometricField<Type, Foam::pointPatchField, Foam::pointMesh> >
00033 Foam::pointFieldReconstructor::reconstructField(const IOobject& fieldIoObject)
00034 {
00035     // Read the field for all the processors
00036     PtrList<GeometricField<Type, pointPatchField, pointMesh> > procFields
00037     (
00038         procMeshes_.size()
00039     );
00040 
00041     forAll (procMeshes_, proci)
00042     {
00043         procFields.set
00044         (
00045             proci,
00046             new GeometricField<Type, pointPatchField, pointMesh>
00047             (
00048                 IOobject
00049                 (
00050                     fieldIoObject.name(),
00051                     procMeshes_[proci]().time().timeName(),
00052                     procMeshes_[proci](),
00053                     IOobject::MUST_READ,
00054                     IOobject::NO_WRITE
00055                 ),
00056                 procMeshes_[proci]
00057             )
00058         );
00059     }
00060 
00061 
00062     // Create the internalField
00063     Field<Type> internalField(mesh_.size());
00064 
00065     // Create the patch fields
00066     PtrList<pointPatchField<Type> > patchFields(mesh_.boundary().size());
00067 
00068 
00069     forAll (procMeshes_, proci)
00070     {
00071         const GeometricField<Type, pointPatchField, pointMesh>&
00072             procField = procFields[proci];
00073 
00074         // Get processor-to-global addressing for use in rmap
00075         const labelList& procToGlobalAddr = pointProcAddressing_[proci];
00076 
00077         // Set the cell values in the reconstructed field
00078         internalField.rmap
00079         (
00080             procField.internalField(),
00081             procToGlobalAddr
00082         );
00083 
00084         // Set the boundary patch values in the reconstructed field
00085         forAll(boundaryProcAddressing_[proci], patchi)
00086         {
00087             // Get patch index of the original patch
00088             const label curBPatch = boundaryProcAddressing_[proci][patchi];
00089 
00090             // check if the boundary patch is not a processor patch
00091             if (curBPatch >= 0)
00092             {
00093                 if (!patchFields(curBPatch))
00094                 {
00095                     patchFields.set(
00096                         curBPatch,
00097                         pointPatchField<Type>::New
00098                         (
00099                             procField.boundaryField()[patchi],
00100                             mesh_.boundary()[curBPatch],
00101                             DimensionedField<Type, pointMesh>::null(),
00102                             pointPatchFieldReconstructor
00103                             (
00104                                 mesh_.boundary()[curBPatch].size()
00105                             )
00106                         )
00107                     );
00108                 }
00109 
00110                 patchFields[curBPatch].rmap
00111                 (
00112                     procField.boundaryField()[patchi],
00113                     patchPointAddressing_[proci][patchi]
00114                 );
00115             }
00116         }
00117     }
00118 
00119     // Construct and write the field
00120     // setting the internalField and patchFields
00121     return tmp<GeometricField<Type, pointPatchField, pointMesh> >
00122     (
00123         new GeometricField<Type, pointPatchField, pointMesh>
00124         (
00125             IOobject
00126             (
00127                 fieldIoObject.name(),
00128                 mesh_().time().timeName(),
00129                 mesh_(),
00130                 IOobject::NO_READ,
00131                 IOobject::NO_WRITE
00132             ),
00133             mesh_,
00134             procFields[0].dimensions(),
00135             internalField,
00136             patchFields
00137         )
00138     );
00139 }
00140 
00141 
00142 // Reconstruct and write all point fields
00143 template<class Type>
00144 void Foam::pointFieldReconstructor::reconstructFields
00145 (
00146     const IOobjectList& objects
00147 )
00148 {
00149     word fieldClassName
00150     (
00151         GeometricField<Type, pointPatchField, pointMesh>::typeName
00152     );
00153 
00154     IOobjectList fields = objects.lookupClass(fieldClassName);
00155 
00156     if (fields.size())
00157     {
00158         Info<< "    Reconstructing " << fieldClassName << "s\n" << endl;
00159 
00160         for
00161         (
00162             IOobjectList::iterator fieldIter = fields.begin();
00163             fieldIter != fields.end();
00164             ++fieldIter
00165         )
00166         {
00167             Info<< "        " << fieldIter()->name() << endl;
00168 
00169             reconstructField<Type>(*fieldIter())().write();
00170         }
00171 
00172         Info<< endl;
00173     }
00174 }
00175 
00176 
00177 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd