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
00027 #include "fvFieldReconstructor.H"
00028 #include "Time.H"
00029 #include "PtrList.H"
00030 #include "fvPatchFields.H"
00031 #include "emptyFvPatch.H"
00032 #include "emptyFvPatchField.H"
00033 #include "emptyFvsPatchField.H"
00034
00035
00036
00037 template<class Type>
00038 Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
00039 Foam::fvFieldReconstructor::reconstructFvVolumeField
00040 (
00041 const IOobject& fieldIoObject
00042 )
00043 {
00044
00045 PtrList<GeometricField<Type, fvPatchField, volMesh> > procFields
00046 (
00047 procMeshes_.size()
00048 );
00049
00050 forAll (procMeshes_, procI)
00051 {
00052 procFields.set
00053 (
00054 procI,
00055 new GeometricField<Type, fvPatchField, volMesh>
00056 (
00057 IOobject
00058 (
00059 fieldIoObject.name(),
00060 procMeshes_[procI].time().timeName(),
00061 procMeshes_[procI],
00062 IOobject::MUST_READ,
00063 IOobject::NO_WRITE
00064 ),
00065 procMeshes_[procI]
00066 )
00067 );
00068 }
00069
00070
00071
00072 Field<Type> internalField(mesh_.nCells());
00073
00074
00075 PtrList<fvPatchField<Type> > patchFields(mesh_.boundary().size());
00076
00077
00078 forAll (procMeshes_, procI)
00079 {
00080 const GeometricField<Type, fvPatchField, volMesh>& procField =
00081 procFields[procI];
00082
00083
00084 internalField.rmap
00085 (
00086 procField.internalField(),
00087 cellProcAddressing_[procI]
00088 );
00089
00090
00091 forAll(boundaryProcAddressing_[procI], patchI)
00092 {
00093
00094 const label curBPatch = boundaryProcAddressing_[procI][patchI];
00095
00096
00097 const labelList::subList cp =
00098 procMeshes_[procI].boundary()[patchI].patchSlice
00099 (
00100 faceProcAddressing_[procI]
00101 );
00102
00103
00104 if (curBPatch >= 0)
00105 {
00106
00107
00108 if (!patchFields(curBPatch))
00109 {
00110 patchFields.set
00111 (
00112 curBPatch,
00113 fvPatchField<Type>::New
00114 (
00115 procField.boundaryField()[patchI],
00116 mesh_.boundary()[curBPatch],
00117 DimensionedField<Type, volMesh>::null(),
00118 fvPatchFieldReconstructor
00119 (
00120 mesh_.boundary()[curBPatch].size()
00121 )
00122 )
00123 );
00124 }
00125
00126 const label curPatchStart =
00127 mesh_.boundaryMesh()[curBPatch].start();
00128
00129 labelList reverseAddressing(cp.size());
00130
00131 forAll(cp, faceI)
00132 {
00133
00134
00135 reverseAddressing[faceI] = cp[faceI] - 1 - curPatchStart;
00136 }
00137
00138 patchFields[curBPatch].rmap
00139 (
00140 procField.boundaryField()[patchI],
00141 reverseAddressing
00142 );
00143 }
00144 else
00145 {
00146 const Field<Type>& curProcPatch =
00147 procField.boundaryField()[patchI];
00148
00149
00150
00151 forAll(cp, faceI)
00152 {
00153
00154
00155 label curF = cp[faceI] - 1;
00156
00157
00158 if (curF >= mesh_.nInternalFaces())
00159 {
00160 label curBPatch = mesh_.boundaryMesh().whichPatch(curF);
00161
00162 if (!patchFields(curBPatch))
00163 {
00164 patchFields.set
00165 (
00166 curBPatch,
00167 fvPatchField<Type>::New
00168 (
00169 mesh_.boundary()[curBPatch].type(),
00170 mesh_.boundary()[curBPatch],
00171 DimensionedField<Type, volMesh>::null()
00172 )
00173 );
00174 }
00175
00176
00177 label curPatchFace =
00178 mesh_.boundaryMesh()
00179 [curBPatch].whichFace(curF);
00180
00181 patchFields[curBPatch][curPatchFace] =
00182 curProcPatch[faceI];
00183 }
00184 }
00185 }
00186 }
00187 }
00188
00189 forAll(mesh_.boundary(), patchI)
00190 {
00191
00192 if
00193 (
00194 typeid(mesh_.boundary()[patchI]) == typeid(emptyFvPatch)
00195 && !patchFields(patchI)
00196 )
00197 {
00198 patchFields.set
00199 (
00200 patchI,
00201 fvPatchField<Type>::New
00202 (
00203 emptyFvPatchField<Type>::typeName,
00204 mesh_.boundary()[patchI],
00205 DimensionedField<Type, volMesh>::null()
00206 )
00207 );
00208 }
00209 }
00210
00211
00212
00213
00214 return tmp<GeometricField<Type, fvPatchField, volMesh> >
00215 (
00216 new GeometricField<Type, fvPatchField, volMesh>
00217 (
00218 IOobject
00219 (
00220 fieldIoObject.name(),
00221 mesh_.time().timeName(),
00222 mesh_,
00223 IOobject::NO_READ,
00224 IOobject::NO_WRITE
00225 ),
00226 mesh_,
00227 procFields[0].dimensions(),
00228 internalField,
00229 patchFields
00230 )
00231 );
00232 }
00233
00234
00235 template<class Type>
00236 Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> >
00237 Foam::fvFieldReconstructor::reconstructFvSurfaceField
00238 (
00239 const IOobject& fieldIoObject
00240 )
00241 {
00242
00243 PtrList<GeometricField<Type, fvsPatchField, surfaceMesh> > procFields
00244 (
00245 procMeshes_.size()
00246 );
00247
00248 forAll (procMeshes_, procI)
00249 {
00250 procFields.set
00251 (
00252 procI,
00253 new GeometricField<Type, fvsPatchField, surfaceMesh>
00254 (
00255 IOobject
00256 (
00257 fieldIoObject.name(),
00258 procMeshes_[procI].time().timeName(),
00259 procMeshes_[procI],
00260 IOobject::MUST_READ,
00261 IOobject::NO_WRITE
00262 ),
00263 procMeshes_[procI]
00264 )
00265 );
00266 }
00267
00268
00269
00270 Field<Type> internalField(mesh_.nInternalFaces());
00271
00272
00273 PtrList<fvsPatchField<Type> > patchFields(mesh_.boundary().size());
00274
00275
00276 forAll (procMeshes_, procI)
00277 {
00278 const GeometricField<Type, fvsPatchField, surfaceMesh>& procField =
00279 procFields[procI];
00280
00281
00282
00283
00284
00285
00286 {
00287 labelList curAddr(faceProcAddressing_[procI]);
00288
00289 forAll (curAddr, addrI)
00290 {
00291 curAddr[addrI] -= 1;
00292 }
00293
00294 internalField.rmap
00295 (
00296 procField.internalField(),
00297 curAddr
00298 );
00299 }
00300
00301
00302 forAll(boundaryProcAddressing_[procI], patchI)
00303 {
00304
00305 const label curBPatch = boundaryProcAddressing_[procI][patchI];
00306
00307
00308 const labelList::subList cp =
00309 procMeshes_[procI].boundary()[patchI].patchSlice
00310 (
00311 faceProcAddressing_[procI]
00312 );
00313
00314
00315 if (curBPatch >= 0)
00316 {
00317
00318
00319 if (!patchFields(curBPatch))
00320 {
00321 patchFields.set
00322 (
00323 curBPatch,
00324 fvsPatchField<Type>::New
00325 (
00326 procField.boundaryField()[patchI],
00327 mesh_.boundary()[curBPatch],
00328 DimensionedField<Type, surfaceMesh>::null(),
00329 fvPatchFieldReconstructor
00330 (
00331 mesh_.boundary()[curBPatch].size()
00332 )
00333 )
00334 );
00335 }
00336
00337 const label curPatchStart =
00338 mesh_.boundaryMesh()[curBPatch].start();
00339
00340 labelList reverseAddressing(cp.size());
00341
00342 forAll(cp, faceI)
00343 {
00344
00345
00346 reverseAddressing[faceI] = cp[faceI] - 1 - curPatchStart;
00347 }
00348
00349 patchFields[curBPatch].rmap
00350 (
00351 procField.boundaryField()[patchI],
00352 reverseAddressing
00353 );
00354 }
00355 else
00356 {
00357 const Field<Type>& curProcPatch =
00358 procField.boundaryField()[patchI];
00359
00360
00361
00362 forAll(cp, faceI)
00363 {
00364 label curF = cp[faceI] - 1;
00365
00366
00367 if (curF >= 0)
00368 {
00369
00370 if (curF >= mesh_.nInternalFaces())
00371 {
00372 label curBPatch =
00373 mesh_.boundaryMesh().whichPatch(curF);
00374
00375 if (!patchFields(curBPatch))
00376 {
00377 patchFields.set
00378 (
00379 curBPatch,
00380 fvsPatchField<Type>::New
00381 (
00382 mesh_.boundary()[curBPatch].type(),
00383 mesh_.boundary()[curBPatch],
00384 DimensionedField<Type, surfaceMesh>
00385 ::null()
00386 )
00387 );
00388 }
00389
00390
00391 label curPatchFace =
00392 mesh_.boundaryMesh()
00393 [curBPatch].whichFace(curF);
00394
00395 patchFields[curBPatch][curPatchFace] =
00396 curProcPatch[faceI];
00397 }
00398 else
00399 {
00400
00401 internalField[curF] = curProcPatch[faceI];
00402 }
00403 }
00404 }
00405 }
00406 }
00407 }
00408
00409 forAll(mesh_.boundary(), patchI)
00410 {
00411
00412 if
00413 (
00414 typeid(mesh_.boundary()[patchI]) == typeid(emptyFvPatch)
00415 && !patchFields(patchI)
00416 )
00417 {
00418 patchFields.set
00419 (
00420 patchI,
00421 fvsPatchField<Type>::New
00422 (
00423 emptyFvsPatchField<Type>::typeName,
00424 mesh_.boundary()[patchI],
00425 DimensionedField<Type, surfaceMesh>::null()
00426 )
00427 );
00428 }
00429 }
00430
00431
00432
00433
00434 return tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
00435 (
00436 new GeometricField<Type, fvsPatchField, surfaceMesh>
00437 (
00438 IOobject
00439 (
00440 fieldIoObject.name(),
00441 mesh_.time().timeName(),
00442 mesh_,
00443 IOobject::NO_READ,
00444 IOobject::NO_WRITE
00445 ),
00446 mesh_,
00447 procFields[0].dimensions(),
00448 internalField,
00449 patchFields
00450 )
00451 );
00452 }
00453
00454
00455
00456 template<class Type>
00457 void Foam::fvFieldReconstructor::reconstructFvVolumeFields
00458 (
00459 const IOobjectList& objects,
00460 const HashSet<word>& selectedFields
00461 )
00462 {
00463 const word& fieldClassName =
00464 GeometricField<Type, fvPatchField, volMesh>::typeName;
00465
00466 IOobjectList fields = objects.lookupClass(fieldClassName);
00467
00468 if (fields.size())
00469 {
00470 Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
00471
00472 forAllConstIter(IOobjectList, fields, fieldIter)
00473 {
00474 if
00475 (
00476 !selectedFields.size()
00477 || selectedFields.found(fieldIter()->name())
00478 )
00479 {
00480 Info<< " " << fieldIter()->name() << endl;
00481
00482 reconstructFvVolumeField<Type>(*fieldIter())().write();
00483 }
00484 }
00485 Info<< endl;
00486 }
00487 }
00488
00489
00490 template<class Type>
00491 void Foam::fvFieldReconstructor::reconstructFvSurfaceFields
00492 (
00493 const IOobjectList& objects,
00494 const HashSet<word>& selectedFields
00495 )
00496 {
00497 const word& fieldClassName =
00498 GeometricField<Type, fvsPatchField, surfaceMesh>::typeName;
00499
00500 IOobjectList fields = objects.lookupClass(fieldClassName);
00501
00502 if (fields.size())
00503 {
00504 Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
00505
00506 forAllConstIter(IOobjectList, fields, fieldIter)
00507 {
00508 if
00509 (
00510 !selectedFields.size()
00511 || selectedFields.found(fieldIter()->name())
00512 )
00513 {
00514 Info<< " " << fieldIter()->name() << endl;
00515
00516 reconstructFvSurfaceField<Type>(*fieldIter())().write();
00517 }
00518 }
00519 Info<< endl;
00520 }
00521 }
00522
00523
00524