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

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