1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 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::read()
35 forAll (databases_, procI)
45 databases_[procI].timeName(),
51 pointProcAddressing_.set
58 "pointProcAddressing",
59 meshes_[procI].facesInstance(),
60 meshes_[procI].meshSubDir,
68 faceProcAddressing_.set
76 meshes_[procI].facesInstance(),
77 meshes_[procI].meshSubDir,
85 cellProcAddressing_.set
93 meshes_[procI].facesInstance(),
94 meshes_[procI].meshSubDir,
102 boundaryProcAddressing_.set
109 "boundaryProcAddressing",
110 meshes_[procI].facesInstance(),
111 meshes_[procI].meshSubDir,
122 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
124 Foam::processorMeshes::processorMeshes
126 PtrList<Time>& databases,
130 databases_(databases),
132 meshes_(databases.size()),
133 pointProcAddressing_(databases.size()),
134 faceProcAddressing_(databases.size()),
135 cellProcAddressing_(databases.size()),
136 boundaryProcAddressing_(databases.size())
142 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
144 Foam::fvMesh::readUpdateState Foam::processorMeshes::readUpdate()
146 fvMesh::readUpdateState stat = fvMesh::UNCHANGED;
148 forAll (databases_, procI)
150 // Check if any new meshes need to be read.
151 fvMesh::readUpdateState procStat = meshes_[procI].readUpdate();
154 if (procStat != fvMesh::UNCHANGED)
156 Info<< "Processor " << procI
157 << " at time " << databases_[procI].timeName()
158 << " detected mesh change " << procStat
163 // Combine into overall mesh change status
164 if (stat == fvMesh::UNCHANGED)
170 if (stat != procStat)
172 FatalErrorIn("processorMeshes::readUpdate()")
173 << "Processor " << procI
174 << " has a different polyMesh at time "
175 << databases_[procI].timeName()
176 << " compared to any previous processors." << nl
177 << "Please check time " << databases_[procI].timeName()
178 << " directories on all processors for consistent"
187 stat == fvMesh::TOPO_CHANGE
188 || stat == fvMesh::TOPO_PATCH_CHANGE
191 // Reread all meshes and addresssing
198 void Foam::processorMeshes::reconstructPoints(fvMesh& mesh)
200 // Read the field for all the processors
201 PtrList<pointIOField> procsPoints(meshes_.size());
203 forAll (meshes_, procI)
213 meshes_[procI].time().timeName(),
214 polyMesh::meshSubDir,
223 // Create the new points
224 vectorField newPoints(mesh.nPoints());
226 forAll (meshes_, procI)
228 const vectorField& procPoints = procsPoints[procI];
230 // Set the cell values in the reconstructed field
232 const labelList& pointProcAddressingI = pointProcAddressing_[procI];
234 if (pointProcAddressingI.size() != procPoints.size())
236 FatalErrorIn("processorMeshes")
238 << " pointProcAddressingI:" << pointProcAddressingI.size()
239 << " procPoints:" << procPoints.size()
240 << abort(FatalError);
243 forAll(pointProcAddressingI, pointI)
245 newPoints[pointProcAddressingI[pointI]] = procPoints[pointI];
249 mesh.movePoints(newPoints);
254 // ************************************************************************* //