FreeFOAM The Cross-Platform CFD Toolkit
lagrangianFieldDecomposerDecomposeFields.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 #include <OpenFOAM/IOobjectList.H>
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 
34 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
35 
36 template<class Type>
38 (
39  const label cloudI,
40  const IOobjectList& lagrangianObjects,
41  PtrList<PtrList<IOField<Type> > >& lagrangianFields
42 )
43 {
44  // Search list of objects for lagrangian fields
45  IOobjectList lagrangianTypeObjects
46  (
47  lagrangianObjects.lookupClass(IOField<Type>::typeName)
48  );
49 
50  lagrangianFields.set
51  (
52  cloudI,
53  new PtrList<IOField<Type> >
54  (
55  lagrangianTypeObjects.size()
56  )
57  );
58 
59  label lagrangianFieldi=0;
60  forAllIter(IOobjectList, lagrangianTypeObjects, iter)
61  {
62  lagrangianFields[cloudI].set
63  (
64  lagrangianFieldi++,
65  new IOField<Type>(*iter())
66  );
67  }
68 }
69 
70 
71 template<class Type>
73 (
74  const word& cloudName,
75  const IOField<Type>& field
76 ) const
77 {
78  // Create and map the internal field values
79  Field<Type> procField(field, particleIndices_);
80 
81  // Create the field for the processor
82  return tmp<IOField<Type> >
83  (
84  new IOField<Type>
85  (
86  IOobject
87  (
88  field.name(),
89  procMesh_.time().timeName(),
91  procMesh_,
94  ),
95  procField
96  )
97  );
98 }
99 
100 
101 template<class GeoField>
103 (
104  const word& cloudName,
105  const PtrList<GeoField>& fields
106 ) const
107 {
108  if (particleIndices_.size())
109  {
110  forAll (fields, fieldI)
111  {
112  decomposeField(cloudName, fields[fieldI])().write();
113  }
114  }
115 }
116 
117 
118 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
119 
120 } // End namespace Foam
121 
122 // ************************ vim: set sw=4 sts=4 et: ************************ //