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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "lagrangianFieldDecomposer.H"
27 #include "IOobjectList.H"
29 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32 void Foam::lagrangianFieldDecomposer::readFields
35 const IOobjectList& lagrangianObjects,
36 PtrList<PtrList<IOField<Type> > >& lagrangianFields
39 // Search list of objects for lagrangian fields
40 IOobjectList lagrangianTypeObjects
42 lagrangianObjects.lookupClass(IOField<Type>::typeName)
48 new PtrList<IOField<Type> >
50 lagrangianTypeObjects.size()
54 label lagrangianFieldi = 0;
55 forAllIter(IOobjectList, lagrangianTypeObjects, iter)
57 lagrangianFields[cloudI].set
60 new IOField<Type>(*iter())
67 void Foam::lagrangianFieldDecomposer::readFieldFields
70 const IOobjectList& lagrangianObjects,
71 PtrList<PtrList<CompactIOField<Field<Type>, Type> > >& lagrangianFields
74 // Search list of objects for lagrangian fields
75 IOobjectList lagrangianTypeObjectsA
77 lagrangianObjects.lookupClass(IOField<Field<Type> >::typeName)
80 IOobjectList lagrangianTypeObjectsB
82 lagrangianObjects.lookupClass
84 CompactIOField<Field<Type>,
92 new PtrList<CompactIOField<Field<Type>, Type> >
94 lagrangianTypeObjectsA.size() + lagrangianTypeObjectsB.size()
98 label lagrangianFieldi = 0;
100 forAllIter(IOobjectList, lagrangianTypeObjectsA, iter)
102 lagrangianFields[cloudI].set
105 new CompactIOField<Field<Type>, Type>(*iter())
109 forAllIter(IOobjectList, lagrangianTypeObjectsB, iter)
111 lagrangianFields[cloudI].set
114 new CompactIOField<Field<Type>, Type>(*iter())
121 Foam::tmp<Foam::IOField<Type> >
122 Foam::lagrangianFieldDecomposer::decomposeField
124 const word& cloudName,
125 const IOField<Type>& field
128 // Create and map the internal field values
129 Field<Type> procField(field, particleIndices_);
131 // Create the field for the processor
132 return tmp<IOField<Type> >
139 procMesh_.time().timeName(),
140 cloud::prefix/cloudName,
152 Foam::tmp<Foam::CompactIOField<Foam::Field<Type>, Type> >
153 Foam::lagrangianFieldDecomposer::decomposeFieldField
155 const word& cloudName,
156 const CompactIOField<Field<Type>, Type>& field
159 // Create and map the internal field values
160 Field<Field<Type> > procField(field, particleIndices_);
162 // Create the field for the processor
163 return tmp<CompactIOField<Field<Type>, Type> >
165 new CompactIOField<Field<Type>, Type>
170 procMesh_.time().timeName(),
171 cloud::prefix/cloudName,
182 template<class GeoField>
183 void Foam::lagrangianFieldDecomposer::decomposeFields
185 const word& cloudName,
186 const PtrList<GeoField>& fields
189 if (particleIndices_.size())
191 forAll(fields, fieldI)
193 decomposeField(cloudName, fields[fieldI])().write();
199 template<class GeoField>
200 void Foam::lagrangianFieldDecomposer::decomposeFieldFields
202 const word& cloudName,
203 const PtrList<GeoField>& fields
206 if (particleIndices_.size())
208 forAll(fields, fieldI)
210 decomposeFieldField(cloudName, fields[fieldI])().write();
216 // ************************************************************************* //