FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "pointFieldReconstructor.H"
00027 
00028 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00029 
00030 template<class Type>
00031 Foam::tmp<Foam::GeometricField<Type, Foam::pointPatchField, Foam::pointMesh> >
00032 Foam::pointFieldReconstructor::reconstructField(const IOobject& fieldIoObject)
00033 {
00034     // Read the field for all the processors
00035     PtrList<GeometricField<Type, pointPatchField, pointMesh> > procFields
00036     (
00037         procMeshes_.size()
00038     );
00039 
00040     forAll (procMeshes_, proci)
00041     {
00042         procFields.set
00043         (
00044             proci,
00045             new GeometricField<Type, pointPatchField, pointMesh>
00046             (
00047                 IOobject
00048                 (
00049                     fieldIoObject.name(),
00050                     procMeshes_[proci]().time().timeName(),
00051                     procMeshes_[proci](),
00052                     IOobject::MUST_READ,
00053                     IOobject::NO_WRITE
00054                 ),
00055                 procMeshes_[proci]
00056             )
00057         );
00058     }
00059 
00060 
00061     // Create the internalField
00062     Field<Type> internalField(mesh_.size());
00063 
00064     // Create the patch fields
00065     PtrList<pointPatchField<Type> > patchFields(mesh_.boundary().size());
00066 
00067 
00068     forAll (procMeshes_, proci)
00069     {
00070         const GeometricField<Type, pointPatchField, pointMesh>&
00071             procField = procFields[proci];
00072 
00073         // Get processor-to-global addressing for use in rmap
00074         const labelList& procToGlobalAddr = pointProcAddressing_[proci];
00075 
00076         // Set the cell values in the reconstructed field
00077         internalField.rmap
00078         (
00079             procField.internalField(),
00080             procToGlobalAddr
00081         );
00082 
00083         // Set the boundary patch values in the reconstructed field
00084         forAll(boundaryProcAddressing_[proci], patchi)
00085         {
00086             // Get patch index of the original patch
00087             const label curBPatch = boundaryProcAddressing_[proci][patchi];
00088 
00089             // check if the boundary patch is not a processor patch
00090             if (curBPatch >= 0)
00091             {
00092                 if (!patchFields(curBPatch))
00093                 {
00094                     patchFields.set(
00095                         curBPatch,
00096                         pointPatchField<Type>::New
00097                         (
00098                             procField.boundaryField()[patchi],
00099                             mesh_.boundary()[curBPatch],
00100                             DimensionedField<Type, pointMesh>::null(),
00101                             pointPatchFieldReconstructor
00102                             (
00103                                 mesh_.boundary()[curBPatch].size()
00104                             )
00105                         )
00106                     );
00107                 }
00108 
00109                 patchFields[curBPatch].rmap
00110                 (
00111                     procField.boundaryField()[patchi],
00112                     patchPointAddressing_[proci][patchi]
00113                 );
00114             }
00115         }
00116     }
00117 
00118     // Construct and write the field
00119     // setting the internalField and patchFields
00120     return tmp<GeometricField<Type, pointPatchField, pointMesh> >
00121     (
00122         new GeometricField<Type, pointPatchField, pointMesh>
00123         (
00124             IOobject
00125             (
00126                 fieldIoObject.name(),
00127                 mesh_().time().timeName(),
00128                 mesh_(),
00129                 IOobject::NO_READ,
00130                 IOobject::NO_WRITE
00131             ),
00132             mesh_,
00133             procFields[0].dimensions(),
00134             internalField,
00135             patchFields
00136         )
00137     );
00138 }
00139 
00140 
00141 // Reconstruct and write all point fields
00142 template<class Type>
00143 void Foam::pointFieldReconstructor::reconstructFields
00144 (
00145     const IOobjectList& objects
00146 )
00147 {
00148     word fieldClassName
00149     (
00150         GeometricField<Type, pointPatchField, pointMesh>::typeName
00151     );
00152 
00153     IOobjectList fields = objects.lookupClass(fieldClassName);
00154 
00155     if (fields.size())
00156     {
00157         Info<< "    Reconstructing " << fieldClassName << "s\n" << endl;
00158 
00159         for
00160         (
00161             IOobjectList::iterator fieldIter = fields.begin();
00162             fieldIter != fields.end();
00163             ++fieldIter
00164         )
00165         {
00166             Info<< "        " << fieldIter()->name() << endl;
00167 
00168             reconstructField<Type>(*fieldIter())().write();
00169         }
00170 
00171         Info<< endl;
00172     }
00173 }
00174 
00175 
00176 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines