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

reconstructLagrangianFields.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 "IOField.H"
00028 #include "Time.H"
00029 
00030 // * * * * * * * * * * * * * * * Global Functions  * * * * * * * * * * * * * //
00031 
00032 template<class Type>
00033 Foam::tmp<Foam::IOField<Type> > Foam::reconstructLagrangianField
00034 (
00035     const word& cloudName,
00036     const polyMesh& mesh,
00037     const PtrList<fvMesh>& meshes,
00038     const word& fieldName
00039 )
00040 {
00041     // Construct empty field on mesh
00042     tmp<IOField<Type> > tfield
00043     (
00044         new IOField<Type>
00045         (
00046             IOobject
00047             (
00048                 fieldName,
00049                 mesh.time().timeName(),
00050                 cloud::prefix/cloudName,
00051                 mesh,
00052                 IOobject::NO_READ,
00053                 IOobject::NO_WRITE
00054             ),
00055             Field<Type>(0)
00056         )
00057     );
00058     Field<Type>& field = tfield();
00059 
00060     forAll(meshes, i)
00061     {
00062         // Check object on local mesh
00063         IOobject localIOobject
00064         (
00065             fieldName,
00066             meshes[i].time().timeName(),
00067             cloud::prefix/cloudName,
00068             meshes[i],
00069             IOobject::MUST_READ,
00070             IOobject::NO_WRITE
00071         );
00072 
00073         if (localIOobject.headerOk())
00074         {
00075             IOField<Type> fieldi(localIOobject);
00076 
00077             label offset = field.size();
00078             field.setSize(offset + fieldi.size());
00079 
00080             forAll(fieldi, j)
00081             {
00082                 field[offset + j] = fieldi[j];
00083             }
00084         }
00085     }
00086 
00087     return tfield;
00088 }
00089 
00090 
00091 template<class Type>
00092 void Foam::reconstructLagrangianFields
00093 (
00094     const word& cloudName,
00095     const polyMesh& mesh,
00096     const PtrList<fvMesh>& meshes,
00097     const IOobjectList& objects
00098 )
00099 {
00100     word fieldClassName(IOField<Type>::typeName);
00101 
00102     IOobjectList fields = objects.lookupClass(fieldClassName);
00103 
00104     if (fields.size())
00105     {
00106         Info<< "    Reconstructing lagrangian "
00107             << fieldClassName << "s\n" << endl;
00108 
00109         forAllIter(IOobjectList, fields, fieldIter)
00110         {
00111             Info<< "        " << fieldIter()->name() << endl;
00112             reconstructLagrangianField<Type>
00113             (
00114                 cloudName,
00115                 mesh,
00116                 meshes,
00117                 fieldIter()->name()
00118             )().write();
00119         }
00120 
00121         Info<< endl;
00122     }
00123 }
00124 
00125 
00126 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd