Forward compatibility: flex
[foam-extend-3.2.git] / applications / utilities / parallelProcessing / reconstructParMesh / processorMeshesReconstructor.C
blob801200a9c4a24d160ec6a230f72a2cd082ac4267
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 "processorMeshesReconstructor.H"
28 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
30 void Foam::processorMeshesReconstructor::readMeshes()
32     forAll (databases_, procI)
33     {
34         Info<< "Reading mesh for processor " << procI << endl;
35         meshes_.set
36         (
37             procI,
38             new fvMesh
39             (
40                 IOobject
41                 (
42                     meshName_,
43                     databases_[procI].timeName(),
44                     databases_[procI]
45                 )
46             )
47         );
48     }
50     // Clear reconstruction maps: new mesh
51     clearMaps();
55 void Foam::processorMeshesReconstructor::clearMaps()
57     pointProcAddressing_.clear();
58     faceProcAddressing_.clear();
59     cellProcAddressing_.clear();
60     boundaryProcAddressing_.clear();
64 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
67 Foam::processorMeshesReconstructor::processorMeshesReconstructor
69     PtrList<Time>& databases,
70     const word& meshName
73     databases_(databases),
74     meshName_(meshName),
75     meshes_(databases.size()),
76     pointProcAddressing_(),
77     faceProcAddressing_(),
78     cellProcAddressing_(),
79     boundaryProcAddressing_()
81     readMeshes();
85 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
87 Foam::polyMesh::readUpdateState
88 Foam::processorMeshesReconstructor::readUpdate()
90     polyMesh::readUpdateState stat = polyMesh::UNCHANGED;
92     forAll (databases_, procI)
93     {
94         // Check if any new meshes need to be read.
95         polyMesh::readUpdateState procStat = meshes_[procI].readUpdate();
97         // Combine into overall mesh change status
98         if (stat == polyMesh::UNCHANGED)
99         {
100             stat = procStat;
101         }
102         else
103         {
104             if (stat != procStat)
105             {
106                 FatalErrorIn("processorMeshesReconstructor::readUpdate()")
107                     << "Processor " << procI
108                     << " has a different polyMesh at time "
109                     << databases_[procI].timeName()
110                     << " compared to any previous processors." << nl
111                     << "Please check time " << databases_[procI].timeName()
112                     << " directories on all processors for consistent"
113                     << " mesh files."
114                     << exit(FatalError);
115             }
116         }
117     }
119     if
120     (
121         stat == polyMesh::TOPO_CHANGE
122      || stat == polyMesh::TOPO_PATCH_CHANGE
123     )
124     {
125         // Reconstruction maps have changed: clear
126         Info<< "Mesh changed: clear reconstruction maps" << endl;
127         clearMaps();
128     }
130     return stat;
134 const Foam::PtrList<Foam::labelIOList>&
135 Foam::processorMeshesReconstructor::pointProcAddressing() const
137     if (pointProcAddressing_.empty())
138     {
139         FatalErrorIn
140         (
141             "const PtrList<labelIOList>& "
142             "processorMeshesReconstructor::pointProcAddressing() const"
143         )   << "Mesh is not reconstructed"
144             << abort(FatalError);
145     }
147     return pointProcAddressing_;
151 const Foam::PtrList<Foam::labelIOList>&
152 Foam::processorMeshesReconstructor::faceProcAddressing() const
154     if (faceProcAddressing_.empty())
155     {
156         FatalErrorIn
157         (
158             "const PtrList<labelIOList>& "
159             "processorMeshesReconstructor::faceProcAddressing() const"
160         )   << "Mesh is not reconstructed"
161             << abort(FatalError);
162     }
164     return faceProcAddressing_;
168 const Foam::PtrList<Foam::labelIOList>&
169 Foam::processorMeshesReconstructor::cellProcAddressing() const
171     if (cellProcAddressing_.empty())
172     {
173         FatalErrorIn
174         (
175             "const PtrList<labelIOList>& "
176             "processorMeshesReconstructor::cellProcAddressing() const"
177         )   << "Mesh is not reconstructed"
178             << abort(FatalError);
179     }
181     return cellProcAddressing_;
185 const Foam::PtrList<Foam::labelIOList>&
186 Foam::processorMeshesReconstructor::boundaryProcAddressing() const
188     if (boundaryProcAddressing_.empty())
189     {
190         FatalErrorIn
191         (
192             "const PtrList<labelIOList>& "
193             "processorMeshesReconstructor::boundaryProcAddressing() const"
194         )   << "Mesh is not reconstructed"
195             << abort(FatalError);
196     }
198     return boundaryProcAddressing_;
202 // ************************************************************************* //