1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
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
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"
29 #include "primitiveMesh.H"
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33 void Foam::processorMeshes::readMeshes()
35 forAll (databases_, procI)
45 databases_[procI].timeName(),
54 void Foam::processorMeshes::readAddressing()
56 forAll (databases_, procI)
58 pointProcAddressing_.set
65 "pointProcAddressing",
66 meshes_[procI].facesInstance(),
67 meshes_[procI].meshSubDir,
75 faceProcAddressing_.set
83 meshes_[procI].facesInstance(),
84 meshes_[procI].meshSubDir,
92 cellProcAddressing_.set
100 meshes_[procI].facesInstance(),
101 meshes_[procI].meshSubDir,
109 boundaryProcAddressing_.set
116 "boundaryProcAddressing",
117 meshes_[procI].facesInstance(),
118 meshes_[procI].meshSubDir,
129 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
131 Foam::processorMeshes::processorMeshes
133 PtrList<Time>& databases,
137 databases_(databases),
139 meshes_(databases.size()),
140 pointProcAddressing_(databases.size()),
141 faceProcAddressing_(databases.size()),
142 cellProcAddressing_(databases.size()),
143 boundaryProcAddressing_(databases.size())
150 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
152 Foam::polyMesh::readUpdateState Foam::processorMeshes::readUpdate()
154 polyMesh::readUpdateState stat = polyMesh::UNCHANGED;
156 forAll (databases_, procI)
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)
168 if (stat != procStat)
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"
183 // Reading of meshes removed: readUpdate will do this
186 stat == polyMesh::TOPO_CHANGE
187 || stat == polyMesh::TOPO_PATCH_CHANGE
190 // Reread addressing; meshes are already updated with readUpdate.
198 void Foam::processorMeshes::reconstructPoints(fvMesh& mesh)
200 // Create the new points
201 vectorField newPoints(mesh.nPoints());
203 forAll (meshes_, procI)
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())
213 FatalErrorIn("processorMeshes")
215 << " pointProcAddressingI:" << pointProcAddressingI.size()
216 << " procPoints:" << procPoints.size()
217 << abort(FatalError);
220 // Only live points carry reconstruction data. Reconsider
222 for (label pointI = 0; pointI < meshes_[procI].nPoints(); pointI++)
223 // forAll(pointProcAddressingI, pointI)
225 newPoints[pointProcAddressingI[pointI]] = procPoints[pointI];
229 mesh.movePoints(newPoints);
234 // ************************************************************************* //