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

MapLagrangianFields.H

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 InNamespace
00026     Foam
00027 
00028 Description
00029     Gets the indices of (source)particles that have been appended to the
00030     target cloud and maps the lagrangian fields accordingly.
00031 
00032 \*---------------------------------------------------------------------------*/
00033 
00034 #ifndef MapLagrangianFields_H
00035 #define MapLagrangianFields_H
00036 
00037 #include "cloud.H"
00038 #include "GeometricField.H"
00039 #include "meshToMesh.H"
00040 #include "IOobjectList.H"
00041 
00042 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00043 
00044 namespace Foam
00045 {
00046 
00047 //- Gets the indices of (source)particles that have been appended to the
00048 //  target cloud and maps the lagrangian fields accordingly.
00049 template<class Type>
00050 void MapLagrangianFields
00051 (
00052     const string& cloudName,
00053     const IOobjectList& objects,
00054     const meshToMesh& meshToMeshInterp,
00055     const labelList& addParticles
00056 )
00057 {
00058     const fvMesh& meshTarget = meshToMeshInterp.toMesh();
00059 
00060     IOobjectList fields = objects.lookupClass(IOField<Type>::typeName);
00061 
00062     forAllIter(IOobjectList, fields, fieldIter)
00063     {
00064         Info<< "    mapping lagrangian field " << fieldIter()->name() << endl;
00065 
00066         // Read field (does not need mesh)
00067         IOField<Type> fieldSource(*fieldIter());
00068 
00069         // Map
00070         IOField<Type> fieldTarget
00071         (
00072             IOobject
00073             (
00074                 fieldIter()->name(),
00075                 meshTarget.time().timeName(),
00076                 cloud::prefix/cloudName,
00077                 meshTarget,
00078                 IOobject::NO_READ,
00079                 IOobject::NO_WRITE,
00080                 false
00081             ),
00082             addParticles.size()
00083         );
00084         forAll(addParticles, i)
00085         {
00086             fieldTarget[i] = fieldSource[addParticles[i]];
00087         }
00088 
00089         // Write field
00090         fieldTarget.write();
00091     }
00092 }
00093 
00094 
00095 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00096 
00097 } // End namespace Foam
00098 
00099 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00100 
00101 #endif
00102 
00103 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd