00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "processorMeshes.H"
00027 #include <OpenFOAM/Time.H>
00028 #include <OpenFOAM/primitiveMesh.H>
00029
00030
00031
00032 void Foam::processorMeshes::read()
00033 {
00034 forAll (databases_, procI)
00035 {
00036 meshes_.set
00037 (
00038 procI,
00039 new fvMesh
00040 (
00041 IOobject
00042 (
00043 meshName_,
00044 databases_[procI].timeName(),
00045 databases_[procI]
00046 )
00047 )
00048 );
00049
00050 pointProcAddressing_.set
00051 (
00052 procI,
00053 new labelIOList
00054 (
00055 IOobject
00056 (
00057 "pointProcAddressing",
00058 meshes_[procI].facesInstance(),
00059 meshes_[procI].meshSubDir,
00060 meshes_[procI],
00061 IOobject::MUST_READ,
00062 IOobject::NO_WRITE
00063 )
00064 )
00065 );
00066
00067 faceProcAddressing_.set
00068 (
00069 procI,
00070 new labelIOList
00071 (
00072 IOobject
00073 (
00074 "faceProcAddressing",
00075 meshes_[procI].facesInstance(),
00076 meshes_[procI].meshSubDir,
00077 meshes_[procI],
00078 IOobject::MUST_READ,
00079 IOobject::NO_WRITE
00080 )
00081 )
00082 );
00083
00084 cellProcAddressing_.set
00085 (
00086 procI,
00087 new labelIOList
00088 (
00089 IOobject
00090 (
00091 "cellProcAddressing",
00092 meshes_[procI].facesInstance(),
00093 meshes_[procI].meshSubDir,
00094 meshes_[procI],
00095 IOobject::MUST_READ,
00096 IOobject::NO_WRITE
00097 )
00098 )
00099 );
00100
00101 boundaryProcAddressing_.set
00102 (
00103 procI,
00104 new labelIOList
00105 (
00106 IOobject
00107 (
00108 "boundaryProcAddressing",
00109 meshes_[procI].facesInstance(),
00110 meshes_[procI].meshSubDir,
00111 meshes_[procI],
00112 IOobject::MUST_READ,
00113 IOobject::NO_WRITE
00114 )
00115 )
00116 );
00117 }
00118 }
00119
00120
00121
00122
00123 Foam::processorMeshes::processorMeshes
00124 (
00125 PtrList<Time>& databases,
00126 const word& meshName
00127 )
00128 :
00129 databases_(databases),
00130 meshName_(meshName),
00131 meshes_(databases.size()),
00132 pointProcAddressing_(databases.size()),
00133 faceProcAddressing_(databases.size()),
00134 cellProcAddressing_(databases.size()),
00135 boundaryProcAddressing_(databases.size())
00136 {
00137 read();
00138 }
00139
00140
00141
00142
00143 Foam::fvMesh::readUpdateState Foam::processorMeshes::readUpdate()
00144 {
00145 fvMesh::readUpdateState stat = fvMesh::UNCHANGED;
00146
00147 forAll (databases_, procI)
00148 {
00149
00150 fvMesh::readUpdateState procStat = meshes_[procI].readUpdate();
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163 if (stat == fvMesh::UNCHANGED)
00164 {
00165 stat = procStat;
00166 }
00167 else
00168 {
00169 if (stat != procStat)
00170 {
00171 FatalErrorIn("processorMeshes::readUpdate()")
00172 << "Processor " << procI
00173 << " has a different polyMesh at time "
00174 << databases_[procI].timeName()
00175 << " compared to any previous processors." << nl
00176 << "Please check time " << databases_[procI].timeName()
00177 << " directories on all processors for consistent"
00178 << " mesh files."
00179 << exit(FatalError);
00180 }
00181 }
00182 }
00183
00184 if
00185 (
00186 stat == fvMesh::TOPO_CHANGE
00187 || stat == fvMesh::TOPO_PATCH_CHANGE
00188 )
00189 {
00190
00191 read();
00192 }
00193 return stat;
00194 }
00195
00196
00197 void Foam::processorMeshes::reconstructPoints(fvMesh& mesh)
00198 {
00199
00200 PtrList<pointIOField> procsPoints(meshes_.size());
00201
00202 forAll (meshes_, procI)
00203 {
00204 procsPoints.set
00205 (
00206 procI,
00207 new pointIOField
00208 (
00209 IOobject
00210 (
00211 "points",
00212 meshes_[procI].time().timeName(),
00213 polyMesh::meshSubDir,
00214 meshes_[procI],
00215 IOobject::MUST_READ,
00216 IOobject::NO_WRITE
00217 )
00218 )
00219 );
00220 }
00221
00222
00223 vectorField newPoints(mesh.nPoints());
00224
00225 forAll (meshes_, procI)
00226 {
00227 const vectorField& procPoints = procsPoints[procI];
00228
00229
00230
00231 const labelList& pointProcAddressingI = pointProcAddressing_[procI];
00232
00233 if (pointProcAddressingI.size() != procPoints.size())
00234 {
00235 FatalErrorIn("processorMeshes")
00236 << "problem :"
00237 << " pointProcAddressingI:" << pointProcAddressingI.size()
00238 << " procPoints:" << procPoints.size()
00239 << abort(FatalError);
00240 }
00241
00242 forAll(pointProcAddressingI, pointI)
00243 {
00244 newPoints[pointProcAddressingI[pointI]] = procPoints[pointI];
00245 }
00246 }
00247
00248 mesh.movePoints(newPoints);
00249 mesh.write();
00250 }
00251
00252
00253