BUGFIX: Illegal use of uninitialised value (backport)
[foam-extend-3.2.git] / applications / utilities / parallelProcessing / decomposeSets / processorMeshes.C
blob1c51b10aef208c8b972303e2465ef71de685bd90
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "processorMeshes.H"
28 #include "Time.H"
29 #include "primitiveMesh.H"
31 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
33 void Foam::processorMeshes::readMeshes()
35     forAll (databases_, procI)
36     {
37         meshes_.set
38         (
39             procI,
40             new fvMesh
41             (
42                 IOobject
43                 (
44                     meshName_,
45                     databases_[procI].timeName(),
46                     databases_[procI]
47                 )
48             )
49         );
50     }
54 void Foam::processorMeshes::readAddressing()
56     forAll (databases_, procI)
57     {
58         pointProcAddressing_.set
59         (
60             procI,
61             new labelIOList
62             (
63                 IOobject
64                 (
65                     "pointProcAddressing",
66                     meshes_[procI].facesInstance(),
67                     meshes_[procI].meshSubDir,
68                     meshes_[procI],
69                     IOobject::MUST_READ,
70                     IOobject::NO_WRITE
71                 )
72             )
73         );
75         faceProcAddressing_.set
76         (
77             procI,
78             new labelIOList
79             (
80                 IOobject
81                 (
82                     "faceProcAddressing",
83                     meshes_[procI].facesInstance(),
84                     meshes_[procI].meshSubDir,
85                     meshes_[procI],
86                     IOobject::MUST_READ,
87                     IOobject::NO_WRITE
88                 )
89             )
90         );
92         cellProcAddressing_.set
93         (
94             procI,
95             new labelIOList
96             (
97                 IOobject
98                 (
99                     "cellProcAddressing",
100                     meshes_[procI].facesInstance(),
101                     meshes_[procI].meshSubDir,
102                     meshes_[procI],
103                     IOobject::MUST_READ,
104                     IOobject::NO_WRITE
105                 )
106             )
107         );
109         boundaryProcAddressing_.set
110         (
111             procI,
112             new labelIOList
113             (
114                 IOobject
115                 (
116                     "boundaryProcAddressing",
117                     meshes_[procI].facesInstance(),
118                     meshes_[procI].meshSubDir,
119                     meshes_[procI],
120                     IOobject::MUST_READ,
121                     IOobject::NO_WRITE
122                 )
123             )
124         );
125     }
129 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
131 Foam::processorMeshes::processorMeshes
133     PtrList<Time>& databases,
134     const word& meshName
137     databases_(databases),
138     meshName_(meshName),
139     meshes_(databases.size()),
140     pointProcAddressing_(databases.size()),
141     faceProcAddressing_(databases.size()),
142     cellProcAddressing_(databases.size()),
143     boundaryProcAddressing_(databases.size())
145     readMeshes();
146     readAddressing();
150 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
152 Foam::polyMesh::readUpdateState Foam::processorMeshes::readUpdate()
154     polyMesh::readUpdateState stat = polyMesh::UNCHANGED;
156     forAll (databases_, procI)
157     {
158         // Check if any new meshes need to be read.
159         polyMesh::readUpdateState procStat = meshes_[procI].readUpdate();
161         // Combine into overall mesh change status
162         if (stat == polyMesh::UNCHANGED)
163         {
164             stat = procStat;
165         }
166         else
167         {
168             if (stat != procStat)
169             {
170                 FatalErrorIn("processorMeshes::readUpdate()")
171                     << "Processor " << procI
172                     << " has a different polyMesh at time "
173                     << databases_[procI].timeName()
174                     << " compared to any previous processors." << nl
175                     << "Please check time " << databases_[procI].timeName()
176                     << " directories on all processors for consistent"
177                     << " mesh files."
178                     << exit(FatalError);
179             }
180         }
181     }
183     // Reading of meshes removed: readUpdate will do this
184     if
185     (
186         stat == polyMesh::TOPO_CHANGE
187      || stat == polyMesh::TOPO_PATCH_CHANGE
188     )
189     {
190         // Reread addressing; meshes are already updated with readUpdate.
191         readAddressing();
192     }
194     return stat;
198 void Foam::processorMeshes::reconstructPoints(fvMesh& mesh)
200     // Create the new points
201     vectorField newPoints(mesh.nPoints());
203     forAll (meshes_, procI)
204     {
205         const vectorField& procPoints = meshes_[procI].allPoints();
207         // Set the cell values in the reconstructed field
209         const labelList& pointProcAddressingI = pointProcAddressing_[procI];
211         if (pointProcAddressingI.size() != procPoints.size())
212         {
213             FatalErrorIn("processorMeshes")
214                 << "problem :"
215                 << " pointProcAddressingI:" << pointProcAddressingI.size()
216                 << " procPoints:" << procPoints.size()
217                 << abort(FatalError);
218         }
220         // Only live points carry reconstruction data.  Reconsider
221         // HJ, 6/Sep/2009
222         for (label pointI = 0; pointI < meshes_[procI].nPoints(); pointI++)
223 //         forAll(pointProcAddressingI, pointI)
224         {
225             newPoints[pointProcAddressingI[pointI]] = procPoints[pointI];
226         }
227     }
229     mesh.movePoints(newPoints);
230     mesh.write();
234 // ************************************************************************* //