1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
28 Gets the indices of (source)particles that have been appended to the
29 target cloud and maps the lagrangian fields accordingly.
31 \*---------------------------------------------------------------------------*/
33 #ifndef MapLagrangianFields_H
34 #define MapLagrangianFields_H
37 #include "GeometricField.H"
38 #include "meshToMesh.H"
39 #include "IOobjectList.H"
40 #include "CompactIOField.H"
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 //- Gets the indices of (source)particles that have been appended to the
48 // target cloud and maps the lagrangian fields accordingly.
50 void MapLagrangianFields
52 const string& cloudName,
53 const IOobjectList& objects,
54 const meshToMesh& meshToMeshInterp,
55 const labelList& addParticles
58 const fvMesh& meshTarget = meshToMeshInterp.toMesh();
61 IOobjectList fields = objects.lookupClass(IOField<Type>::typeName);
63 forAllIter(IOobjectList, fields, fieldIter)
65 Info<< " mapping lagrangian field "
66 << fieldIter()->name() << endl;
68 // Read field (does not need mesh)
69 IOField<Type> fieldSource(*fieldIter());
72 IOField<Type> fieldTarget
77 meshTarget.time().timeName(),
78 cloud::prefix/cloudName,
87 forAll(addParticles, i)
89 fieldTarget[i] = fieldSource[addParticles[i]];
98 IOobjectList fieldFields =
99 objects.lookupClass(IOField<Field<Type> >::typeName);
101 forAllIter(IOobjectList, fieldFields, fieldIter)
103 Info<< " mapping lagrangian fieldField "
104 << fieldIter()->name() << endl;
106 // Read field (does not need mesh)
107 IOField<Field<Type> > fieldSource(*fieldIter());
109 // Map - use CompactIOField to automatically write in
110 // compact form for binary format.
111 CompactIOField<Field<Type>, Type> fieldTarget
116 meshTarget.time().timeName(),
117 cloud::prefix/cloudName,
126 forAll(addParticles, i)
128 fieldTarget[i] = fieldSource[addParticles[i]];
137 IOobjectList fieldFields =
138 objects.lookupClass(CompactIOField<Field<Type>, Type>::typeName);
140 forAllIter(IOobjectList, fieldFields, fieldIter)
142 Info<< " mapping lagrangian fieldField "
143 << fieldIter()->name() << endl;
145 // Read field (does not need mesh)
146 CompactIOField<Field<Type>, Type> fieldSource(*fieldIter());
149 CompactIOField<Field<Type>, Type> fieldTarget
154 meshTarget.time().timeName(),
155 cloud::prefix/cloudName,
164 forAll(addParticles, i)
166 fieldTarget[i] = fieldSource[addParticles[i]];
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 } // End namespace Foam
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 // ************************************************************************* //