1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "processorMeshes.H"
28 #include "primitiveMesh.H"
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 void Foam::processorMeshes::read()
34 forAll (databases_, procI)
44 databases_[procI].timeName(),
50 pointProcAddressing_.set
57 "pointProcAddressing",
58 meshes_[procI].facesInstance(),
59 meshes_[procI].meshSubDir,
67 faceProcAddressing_.set
75 meshes_[procI].facesInstance(),
76 meshes_[procI].meshSubDir,
84 cellProcAddressing_.set
92 meshes_[procI].facesInstance(),
93 meshes_[procI].meshSubDir,
101 boundaryProcAddressing_.set
108 "boundaryProcAddressing",
109 meshes_[procI].facesInstance(),
110 meshes_[procI].meshSubDir,
121 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
123 Foam::processorMeshes::processorMeshes
125 PtrList<Time>& databases,
129 databases_(databases),
131 meshes_(databases.size()),
132 pointProcAddressing_(databases.size()),
133 faceProcAddressing_(databases.size()),
134 cellProcAddressing_(databases.size()),
135 boundaryProcAddressing_(databases.size())
141 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
143 Foam::fvMesh::readUpdateState Foam::processorMeshes::readUpdate()
145 fvMesh::readUpdateState stat = fvMesh::UNCHANGED;
147 forAll (databases_, procI)
149 // Check if any new meshes need to be read.
150 fvMesh::readUpdateState procStat = meshes_[procI].readUpdate();
153 if (procStat != fvMesh::UNCHANGED)
155 Info<< "Processor " << procI
156 << " at time " << databases_[procI].timeName()
157 << " detected mesh change " << procStat
162 // Combine into overall mesh change status
163 if (stat == fvMesh::UNCHANGED)
169 if (stat != procStat)
171 FatalErrorIn("processorMeshes::readUpdate()")
172 << "Processor " << procI
173 << " has a different polyMesh at time "
174 << databases_[procI].timeName()
175 << " compared to any previous processors." << nl
176 << "Please check time " << databases_[procI].timeName()
177 << " directories on all processors for consistent"
186 stat == fvMesh::TOPO_CHANGE
187 || stat == fvMesh::TOPO_PATCH_CHANGE
190 // Reread all meshes and addresssing
197 void Foam::processorMeshes::reconstructPoints(fvMesh& mesh)
199 // Read the field for all the processors
200 PtrList<pointIOField> procsPoints(meshes_.size());
202 forAll (meshes_, procI)
212 meshes_[procI].time().timeName(),
213 polyMesh::meshSubDir,
222 // Create the new points
223 vectorField newPoints(mesh.nPoints());
225 forAll (meshes_, procI)
227 const vectorField& procPoints = procsPoints[procI];
229 // Set the cell values in the reconstructed field
231 const labelList& pointProcAddressingI = pointProcAddressing_[procI];
233 if (pointProcAddressingI.size() != procPoints.size())
235 FatalErrorIn("processorMeshes")
237 << " pointProcAddressingI:" << pointProcAddressingI.size()
238 << " procPoints:" << procPoints.size()
239 << abort(FatalError);
242 forAll(pointProcAddressingI, pointI)
244 newPoints[pointProcAddressingI[pointI]] = procPoints[pointI];
248 mesh.movePoints(newPoints);
253 // ************************************************************************* //