Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / applications / utilities / parallelProcessing / decomposeSets / processorMeshes.C
blob170b81d6079db99a236f3df194dab235673c49c9
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "processorMeshes.H"
27 #include "foamTime.H"
28 #include "primitiveMesh.H"
30 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
32 void Foam::processorMeshes::readMeshes()
34     forAll (databases_, procI)
35     {
36         meshes_.set
37         (
38             procI,
39             new fvMesh
40             (
41                 IOobject
42                 (
43                     meshName_,
44                     databases_[procI].timeName(),
45                     databases_[procI]
46                 )
47             )
48         );
49     }
53 void Foam::processorMeshes::readAddressing()
55     forAll (databases_, procI)
56     {
57         pointProcAddressing_.set
58         (
59             procI,
60             new labelIOList
61             (
62                 IOobject
63                 (
64                     "pointProcAddressing",
65                     meshes_[procI].facesInstance(),
66                     meshes_[procI].meshSubDir,
67                     meshes_[procI],
68                     IOobject::MUST_READ,
69                     IOobject::NO_WRITE
70                 )
71             )
72         );
74         faceProcAddressing_.set
75         (
76             procI,
77             new labelIOList
78             (
79                 IOobject
80                 (
81                     "faceProcAddressing",
82                     meshes_[procI].facesInstance(),
83                     meshes_[procI].meshSubDir,
84                     meshes_[procI],
85                     IOobject::MUST_READ,
86                     IOobject::NO_WRITE
87                 )
88             )
89         );
91         cellProcAddressing_.set
92         (
93             procI,
94             new labelIOList
95             (
96                 IOobject
97                 (
98                     "cellProcAddressing",
99                     meshes_[procI].facesInstance(),
100                     meshes_[procI].meshSubDir,
101                     meshes_[procI],
102                     IOobject::MUST_READ,
103                     IOobject::NO_WRITE
104                 )
105             )
106         );
108         boundaryProcAddressing_.set
109         (
110             procI,
111             new labelIOList
112             (
113                 IOobject
114                 (
115                     "boundaryProcAddressing",
116                     meshes_[procI].facesInstance(),
117                     meshes_[procI].meshSubDir,
118                     meshes_[procI],
119                     IOobject::MUST_READ,
120                     IOobject::NO_WRITE
121                 )
122             )
123         );
124     }
128 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
130 Foam::processorMeshes::processorMeshes
132     PtrList<Time>& databases,
133     const word& meshName
136     databases_(databases),
137     meshName_(meshName),
138     meshes_(databases.size()),
139     pointProcAddressing_(databases.size()),
140     faceProcAddressing_(databases.size()),
141     cellProcAddressing_(databases.size()),
142     boundaryProcAddressing_(databases.size())
144     readMeshes();
145     readAddressing();
149 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
151 Foam::polyMesh::readUpdateState Foam::processorMeshes::readUpdate()
153     polyMesh::readUpdateState stat = polyMesh::UNCHANGED;
155     forAll (databases_, procI)
156     {
157         // Check if any new meshes need to be read.
158         polyMesh::readUpdateState procStat = meshes_[procI].readUpdate();
160         // Combine into overall mesh change status
161         if (stat == polyMesh::UNCHANGED)
162         {
163             stat = procStat;
164         }
165         else
166         {
167             if (stat != procStat)
168             {
169                 FatalErrorIn("processorMeshes::readUpdate()")
170                     << "Processor " << procI
171                     << " has a different polyMesh at time "
172                     << databases_[procI].timeName()
173                     << " compared to any previous processors." << nl
174                     << "Please check time " << databases_[procI].timeName()
175                     << " directories on all processors for consistent"
176                     << " mesh files."
177                     << exit(FatalError);
178             }
179         }
180     }
182     // Reading of meshes removed: readUpdate will do this
183     if
184     (
185         stat == polyMesh::TOPO_CHANGE
186      || stat == polyMesh::TOPO_PATCH_CHANGE
187     )
188     {
189         // Reread addressing; meshes are already updated with readUpdate.
190         readAddressing();
191     }
193     return stat;
197 void Foam::processorMeshes::reconstructPoints(fvMesh& mesh)
199     // Create the new points
200     vectorField newPoints(mesh.nPoints());
202     forAll (meshes_, procI)
203     {
204         const vectorField& procPoints = meshes_[procI].allPoints();
206         // Set the cell values in the reconstructed field
208         const labelList& pointProcAddressingI = pointProcAddressing_[procI];
210         if (pointProcAddressingI.size() != procPoints.size())
211         {
212             FatalErrorIn("processorMeshes")
213                 << "problem :"
214                 << " pointProcAddressingI:" << pointProcAddressingI.size()
215                 << " procPoints:" << procPoints.size()
216                 << abort(FatalError);
217         }
219         // Only live points carry reconstruction data.  Reconsider
220         // HJ, 6/Sep/2009
221         for (label pointI = 0; pointI < meshes_[procI].nPoints(); pointI++)
222 //         forAll(pointProcAddressingI, pointI)
223         {
224             newPoints[pointProcAddressingI[pointI]] = procPoints[pointI];
225         }
226     }
228     mesh.movePoints(newPoints);
229     mesh.write();
233 // ************************************************************************* //