FreeFOAM The Cross-Platform CFD Toolkit
pointFieldReconstructorReconstructFields.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 
28 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
29 
30 template<class Type>
32 Foam::pointFieldReconstructor::reconstructField(const IOobject& fieldIoObject)
33 {
34  // Read the field for all the processors
35  PtrList<GeometricField<Type, pointPatchField, pointMesh> > procFields
36  (
37  procMeshes_.size()
38  );
39 
40  forAll (procMeshes_, proci)
41  {
42  procFields.set
43  (
44  proci,
45  new GeometricField<Type, pointPatchField, pointMesh>
46  (
47  IOobject
48  (
49  fieldIoObject.name(),
50  procMeshes_[proci]().time().timeName(),
51  procMeshes_[proci](),
54  ),
55  procMeshes_[proci]
56  )
57  );
58  }
59 
60 
61  // Create the internalField
62  Field<Type> internalField(mesh_.size());
63 
64  // Create the patch fields
65  PtrList<pointPatchField<Type> > patchFields(mesh_.boundary().size());
66 
67 
68  forAll (procMeshes_, proci)
69  {
70  const GeometricField<Type, pointPatchField, pointMesh>&
71  procField = procFields[proci];
72 
73  // Get processor-to-global addressing for use in rmap
74  const labelList& procToGlobalAddr = pointProcAddressing_[proci];
75 
76  // Set the cell values in the reconstructed field
77  internalField.rmap
78  (
79  procField.internalField(),
80  procToGlobalAddr
81  );
82 
83  // Set the boundary patch values in the reconstructed field
84  forAll(boundaryProcAddressing_[proci], patchi)
85  {
86  // Get patch index of the original patch
87  const label curBPatch = boundaryProcAddressing_[proci][patchi];
88 
89  // check if the boundary patch is not a processor patch
90  if (curBPatch >= 0)
91  {
92  if (!patchFields(curBPatch))
93  {
94  patchFields.set(
95  curBPatch,
96  pointPatchField<Type>::New
97  (
98  procField.boundaryField()[patchi],
99  mesh_.boundary()[curBPatch],
101  pointPatchFieldReconstructor
102  (
103  mesh_.boundary()[curBPatch].size()
104  )
105  )
106  );
107  }
108 
109  patchFields[curBPatch].rmap
110  (
111  procField.boundaryField()[patchi],
112  patchPointAddressing_[proci][patchi]
113  );
114  }
115  }
116  }
117 
118  // Construct and write the field
119  // setting the internalField and patchFields
120  return tmp<GeometricField<Type, pointPatchField, pointMesh> >
121  (
122  new GeometricField<Type, pointPatchField, pointMesh>
123  (
124  IOobject
125  (
126  fieldIoObject.name(),
127  mesh_().time().timeName(),
128  mesh_(),
131  ),
132  mesh_,
133  procFields[0].dimensions(),
134  internalField,
135  patchFields
136  )
137  );
138 }
139 
140 
141 // Reconstruct and write all point fields
142 template<class Type>
144 (
145  const IOobjectList& objects
146 )
147 {
148  word fieldClassName
149  (
151  );
152 
153  IOobjectList fields = objects.lookupClass(fieldClassName);
154 
155  if (fields.size())
156  {
157  Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
158 
159  for
160  (
161  IOobjectList::iterator fieldIter = fields.begin();
162  fieldIter != fields.end();
163  ++fieldIter
164  )
165  {
166  Info<< " " << fieldIter()->name() << endl;
167 
168  reconstructField<Type>(*fieldIter())().write();
169  }
170 
171  Info<< endl;
172  }
173 }
174 
175 
176 // ************************ vim: set sw=4 sts=4 et: ************************ //