reconstructPar.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2015-2018 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Application
28  reconstructPar
29 
30 Group
31  grpParallelUtilities
32 
33 Description
34  Reconstructs fields of a case that is decomposed for parallel
35  execution of OpenFOAM.
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #include "argList.H"
40 #include "timeSelector.H"
41 
42 #include "fvCFD.H"
43 #include "IOobjectList.H"
44 #include "processorMeshes.H"
45 #include "regionProperties.H"
46 #include "fvFieldReconstructor.H"
49 
50 #include "faCFD.H"
51 #include "faMesh.H"
52 #include "processorFaMeshes.H"
53 #include "faFieldReconstructor.H"
54 
55 #include "cellSet.H"
56 #include "faceSet.H"
57 #include "pointSet.H"
58 
59 #include "hexRef8Data.H"
60 
61 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62 
63 bool haveAllTimes
64 (
65  const wordHashSet& masterTimeDirSet,
66  const instantList& timeDirs
67 )
68 {
69  // Loop over all times
70  for (const instant& t : timeDirs)
71  {
72  if (!masterTimeDirSet.found(t.name()))
73  {
74  return false;
75  }
76  }
77  return true;
78 }
79 
80 
81 int main(int argc, char *argv[])
82 {
83  argList::addNote
84  (
85  "Reconstruct fields of a parallel case"
86  );
87 
88  // Enable -constant ... if someone really wants it
89  // Enable -withZero to prevent accidentally trashing the initial fields
90  timeSelector::addOptions(true, true); // constant(true), zero(true)
91  argList::noParallel();
92  #include "addRegionOption.H"
93  argList::addBoolOption
94  (
95  "allRegions",
96  "Operate on all regions in regionProperties"
97  );
98  argList::addOption
99  (
100  "fields",
101  "wordRes",
102  "Specify single or multiple fields to reconstruct (all by default)."
103  " Eg, 'T' or '(p T U \"alpha.*\")'"
104  );
105  argList::addBoolOption
106  (
107  "noFields",
108  "Skip reconstructing fields"
109  );
110  argList::addOption
111  (
112  "lagrangianFields",
113  "wordRes",
114  "Specify single or multiple lagrangian fields to reconstruct"
115  " (all by default)."
116  " Eg, '(U d)'"
117  " - Positions are always included."
118  );
119  argList::addBoolOption
120  (
121  "noLagrangian",
122  "Skip reconstructing lagrangian positions and fields"
123  );
124 
125  argList::addBoolOption
126  (
127  "noSets",
128  "Skip reconstructing cellSets, faceSets, pointSets"
129  );
130  argList::addBoolOption
131  (
132  "newTimes",
133  "Only reconstruct new times (i.e. that do not exist already)"
134  );
135 
136  #include "setRootCase.H"
137  #include "createTime.H"
138 
139 
140  wordRes selectedFields;
141  args.readListIfPresent<wordRe>("fields", selectedFields);
142 
143  const bool doFields = !args.found("noFields");
144 
145  if (!doFields)
146  {
147  Info<< "Skipping reconstructing fields"
148  << nl << endl;
149  }
150 
151  wordRes selectedLagrangianFields;
152  args.readListIfPresent<wordRe>
153  (
154  "lagrangianFields", selectedLagrangianFields
155  );
156 
157  const bool doLagrangian = !args.found("noLagrangian");
158 
159  if (!doLagrangian)
160  {
161  Info<< "Skipping reconstructing lagrangian positions and fields"
162  << nl << endl;
163  }
164 
165  const bool doReconstructSets = !args.found("noSets");
166 
167  if (!doReconstructSets)
168  {
169  Info<< "Skipping reconstructing cellSets, faceSets and pointSets"
170  << nl << endl;
171  }
172 
173  const bool newTimes = args.found("newTimes");
174  const bool allRegions = args.found("allRegions");
175 
176  wordList regionNames;
177  wordList regionDirs;
178  if (allRegions)
179  {
180  regionNames = regionProperties(runTime).names();
181  regionDirs = regionNames;
182 
183  Info<< "Reconstructing all regions in regionProperties" << nl
184  << " " << flatOutput(regionNames) << nl << endl;
185  }
186  else
187  {
188  regionNames.resize(1, fvMesh::defaultRegion);
189  regionDirs.resize(1, word::null);
190 
191  if (args.readIfPresent("region", regionNames.first()))
192  {
193  regionDirs.first() = regionNames.first();
194  }
195  }
196 
197 
198  // Determine the processor count
199  label nProcs = fileHandler().nProcs(args.path(), regionDirs[0]);
200 
201  if (!nProcs)
202  {
204  << "No processor* directories found"
205  << exit(FatalError);
206  }
207 
208  // Warn fileHandler of number of processors
209  const_cast<fileOperation&>(fileHandler()).setNProcs(nProcs);
210 
211  // Create the processor databases
212  PtrList<Time> databases(nProcs);
213 
214  forAll(databases, proci)
215  {
216  databases.set
217  (
218  proci,
219  new Time
220  (
221  Time::controlDictName,
222  args.rootPath(),
223  args.caseName()/("processor" + Foam::name(proci))
224  )
225  );
226  }
227 
228  // Use the times list from the master processor
229  // and select a subset based on the command-line options
230  instantList timeDirs = timeSelector::select
231  (
232  databases[0].times(),
233  args
234  );
235 
236  // Note that we do not set the runTime time so it is still the
237  // one set through the controlDict. The -time option
238  // only affects the selected set of times from processor0.
239  // - can be illogical
240  // + any point motion handled through mesh.readUpdate
241 
242 
243  if (timeDirs.empty())
244  {
245  WarningInFunction << "No times selected";
246  exit(1);
247  }
248 
249 
250  // Get current times if -newTimes
251  instantList masterTimeDirs;
252  if (newTimes)
253  {
254  masterTimeDirs = runTime.times();
255  }
256  wordHashSet masterTimeDirSet(2*masterTimeDirs.size());
257  for (const instant& t : masterTimeDirs)
258  {
259  masterTimeDirSet.insert(t.name());
260  }
261 
262 
263  // Set all times on processor meshes equal to reconstructed mesh
264  forAll(databases, proci)
265  {
266  databases[proci].setTime(runTime);
267  }
268 
269 
270  forAll(regionNames, regioni)
271  {
272  const word& regionName = regionNames[regioni];
273  const word& regionDir = regionDirs[regioni];
274 
275  Info<< "\n\nReconstructing fields for mesh " << regionName << nl
276  << endl;
277 
278  if
279  (
280  newTimes
281  && regionNames.size() == 1
282  && regionDirs[0].empty()
283  && haveAllTimes(masterTimeDirSet, timeDirs)
284  )
285  {
286  Info<< "Skipping region " << regionName
287  << " since already have all times"
288  << endl << endl;
289  continue;
290  }
291 
292 
293  fvMesh mesh
294  (
295  IOobject
296  (
297  regionName,
298  runTime.timeName(),
299  runTime,
301  )
302  );
303 
304 
305  // Read all meshes and addressing to reconstructed mesh
306  processorMeshes procMeshes(databases, regionName);
307 
308 
309  // Check face addressing for meshes that have been decomposed
310  // with a very old foam version
311  #include "checkFaceAddressingComp.H"
312 
313  // Loop over all times
314  forAll(timeDirs, timei)
315  {
316  if (newTimes && masterTimeDirSet.found(timeDirs[timei].name()))
317  {
318  Info<< "Skipping time " << timeDirs[timei].name()
319  << endl << endl;
320  continue;
321  }
322 
323 
324  // Set time for global database
325  runTime.setTime(timeDirs[timei], timei);
326 
327  Info<< "Time = " << runTime.timeName() << endl << endl;
328 
329  // Set time for all databases
330  forAll(databases, proci)
331  {
332  databases[proci].setTime(timeDirs[timei], timei);
333  }
334 
335  // Check if any new meshes need to be read.
336  fvMesh::readUpdateState meshStat = mesh.readUpdate();
337 
338  fvMesh::readUpdateState procStat = procMeshes.readUpdate();
339 
340  if (procStat == fvMesh::POINTS_MOVED)
341  {
342  // Reconstruct the points for moving mesh cases and write
343  // them out
344  procMeshes.reconstructPoints(mesh);
345  }
346  else if (meshStat != procStat)
347  {
349  << "readUpdate for the reconstructed mesh:"
350  << meshStat << nl
351  << "readUpdate for the processor meshes :"
352  << procStat << nl
353  << "These should be equal or your addressing"
354  << " might be incorrect."
355  << " Please check your time directories for any "
356  << "mesh directories." << endl;
357  }
358 
359 
360  // Get list of objects from processor0 database
361  IOobjectList objects
362  (
363  procMeshes.meshes()[0],
364  databases[0].timeName()
365  );
366 
367  if (doFields)
368  {
369  // If there are any FV fields, reconstruct them
370  Info<< "Reconstructing FV fields" << nl << endl;
371 
372  fvFieldReconstructor reconstructor
373  (
374  mesh,
375  procMeshes.meshes(),
376  procMeshes.faceProcAddressing(),
377  procMeshes.cellProcAddressing(),
378  procMeshes.boundaryProcAddressing()
379  );
380 
381  reconstructor.reconstructFvVolumeInternalFields<scalar>
382  (
383  objects,
384  selectedFields
385  );
386  reconstructor.reconstructFvVolumeInternalFields<vector>
387  (
388  objects,
389  selectedFields
390  );
391  reconstructor.reconstructFvVolumeInternalFields<sphericalTensor>
392  (
393  objects,
394  selectedFields
395  );
396  reconstructor.reconstructFvVolumeInternalFields<symmTensor>
397  (
398  objects,
399  selectedFields
400  );
401  reconstructor.reconstructFvVolumeInternalFields<tensor>
402  (
403  objects,
404  selectedFields
405  );
406 
407  reconstructor.reconstructFvVolumeFields<scalar>
408  (
409  objects,
410  selectedFields
411  );
412  reconstructor.reconstructFvVolumeFields<vector>
413  (
414  objects,
415  selectedFields
416  );
417  reconstructor.reconstructFvVolumeFields<sphericalTensor>
418  (
419  objects,
420  selectedFields
421  );
422  reconstructor.reconstructFvVolumeFields<symmTensor>
423  (
424  objects,
425  selectedFields
426  );
427  reconstructor.reconstructFvVolumeFields<tensor>
428  (
429  objects,
430  selectedFields
431  );
432 
433  reconstructor.reconstructFvSurfaceFields<scalar>
434  (
435  objects,
436  selectedFields
437  );
438  reconstructor.reconstructFvSurfaceFields<vector>
439  (
440  objects,
441  selectedFields
442  );
443  reconstructor.reconstructFvSurfaceFields<sphericalTensor>
444  (
445  objects,
446  selectedFields
447  );
448  reconstructor.reconstructFvSurfaceFields<symmTensor>
449  (
450  objects,
451  selectedFields
452  );
453  reconstructor.reconstructFvSurfaceFields<tensor>
454  (
455  objects,
456  selectedFields
457  );
458 
459  if (reconstructor.nReconstructed() == 0)
460  {
461  Info<< "No FV fields" << nl << endl;
462  }
463  }
464 
465  if (doFields)
466  {
467  Info<< "Reconstructing point fields" << nl << endl;
468 
469  const pointMesh& pMesh = pointMesh::New(mesh);
470  PtrList<pointMesh> pMeshes(procMeshes.meshes().size());
471 
472  forAll(pMeshes, proci)
473  {
474  pMeshes.set
475  (
476  proci,
477  new pointMesh(procMeshes.meshes()[proci])
478  );
479  }
480 
481  pointFieldReconstructor reconstructor
482  (
483  pMesh,
484  pMeshes,
485  procMeshes.pointProcAddressing(),
486  procMeshes.boundaryProcAddressing()
487  );
488 
489  reconstructor.reconstructFields<scalar>
490  (
491  objects,
492  selectedFields
493  );
494  reconstructor.reconstructFields<vector>
495  (
496  objects,
497  selectedFields
498  );
499  reconstructor.reconstructFields<sphericalTensor>
500  (
501  objects,
502  selectedFields
503  );
504  reconstructor.reconstructFields<symmTensor>
505  (
506  objects,
507  selectedFields
508  );
509  reconstructor.reconstructFields<tensor>
510  (
511  objects,
512  selectedFields
513  );
514 
515  if (reconstructor.nReconstructed() == 0)
516  {
517  Info<< "No point fields" << nl << endl;
518  }
519  }
520 
521 
522  // If there are any clouds, reconstruct them.
523  // The problem is that a cloud of size zero will not get written so
524  // in pass 1 we determine the cloud names and per cloud name the
525  // fields. Note that the fields are stored as IOobjectList from
526  // the first processor that has them. They are in pass2 only used
527  // for name and type (scalar, vector etc).
528 
529  if (doLagrangian)
530  {
531  HashTable<IOobjectList> allCloudObjects;
532 
533  forAll(databases, proci)
534  {
535  fileName lagrangianDir
536  (
537  fileHandler().filePath
538  (
539  databases[proci].timePath()
540  / regionDir
541  / cloud::prefix
542  )
543  );
544 
545  fileNameList cloudDirs;
546  if (!lagrangianDir.empty())
547  {
548  cloudDirs = fileHandler().readDir
549  (
550  lagrangianDir,
551  fileName::DIRECTORY
552  );
553  }
554 
555  for (const fileName& cloudDir : cloudDirs)
556  {
557  // Check if we already have cloud objects for this
558  // cloudname
559  if (!allCloudObjects.found(cloudDir))
560  {
561  // Do local scan for valid cloud objects
562  IOobjectList localObjs
563  (
564  procMeshes.meshes()[proci],
565  databases[proci].timeName(),
566  cloud::prefix/cloudDir
567  );
568 
569  if
570  (
571  localObjs.found("coordinates")
572  || localObjs.found("positions")
573  )
574  {
575  allCloudObjects.insert(cloudDir, localObjs);
576  }
577  }
578  }
579  }
580 
581 
582  if (allCloudObjects.size())
583  {
584  lagrangianReconstructor reconstructor
585  (
586  mesh,
587  procMeshes.meshes(),
588  procMeshes.faceProcAddressing(),
589  procMeshes.cellProcAddressing()
590  );
591 
592  // Pass2: reconstruct the cloud
593  forAllConstIters(allCloudObjects, iter)
594  {
595  const word cloudName = word::validate(iter.key());
596 
597  // Objects (on arbitrary processor)
598  const IOobjectList& cloudObjs = iter.val();
599 
600  Info<< "Reconstructing lagrangian fields for cloud "
601  << cloudName << nl << endl;
602 
603  reconstructor.reconstructPositions(cloudName);
604 
605  reconstructor.reconstructFields<label>
606  (
607  cloudName,
608  cloudObjs,
609  selectedLagrangianFields
610  );
611  reconstructor.reconstructFieldFields<label>
612  (
613  cloudName,
614  cloudObjs,
615  selectedLagrangianFields
616  );
617 
618  reconstructor.reconstructFields<scalar>
619  (
620  cloudName,
621  cloudObjs,
622  selectedLagrangianFields
623  );
624  reconstructor.reconstructFieldFields<scalar>
625  (
626  cloudName,
627  cloudObjs,
628  selectedLagrangianFields
629  );
630 
631  reconstructor.reconstructFields<vector>
632  (
633  cloudName,
634  cloudObjs,
635  selectedLagrangianFields
636  );
637  reconstructor.reconstructFieldFields<vector>
638  (
639  cloudName,
640  cloudObjs,
641  selectedLagrangianFields
642  );
643 
644  reconstructor.reconstructFields<sphericalTensor>
645  (
646  cloudName,
647  cloudObjs,
648  selectedLagrangianFields
649  );
650  reconstructor.reconstructFieldFields<sphericalTensor>
651  (
652  cloudName,
653  cloudObjs,
654  selectedLagrangianFields
655  );
656 
657  reconstructor.reconstructFields<symmTensor>
658  (
659  cloudName,
660  cloudObjs,
661  selectedLagrangianFields
662  );
663  reconstructor.reconstructFieldFields<symmTensor>
664  (
665  cloudName,
666  cloudObjs,
667  selectedLagrangianFields
668  );
669 
670  reconstructor.reconstructFields<tensor>
671  (
672  cloudName,
673  cloudObjs,
674  selectedLagrangianFields
675  );
676  reconstructor.reconstructFieldFields<tensor>
677  (
678  cloudName,
679  cloudObjs,
680  selectedLagrangianFields
681  );
682  }
683  }
684  else
685  {
686  Info<< "No lagrangian fields" << nl << endl;
687  }
688  }
689 
690 
691  // If there are any FA fields, reconstruct them
692 
693  if
694  (
695  objects.lookupClass(areaScalarField::typeName).size()
696  || objects.lookupClass(areaVectorField::typeName).size()
697  || objects.lookupClass(areaSphericalTensorField::typeName).size()
698  || objects.lookupClass(areaSymmTensorField::typeName).size()
699  || objects.lookupClass(areaTensorField::typeName).size()
700  || objects.lookupClass(edgeScalarField::typeName).size()
701  )
702  {
703  Info << "Reconstructing FA fields" << nl << endl;
704 
705  faMesh aMesh(mesh);
706 
707  processorFaMeshes procFaMeshes(procMeshes.meshes());
708 
709  faFieldReconstructor reconstructor
710  (
711  aMesh,
712  procFaMeshes.meshes(),
713  procFaMeshes.edgeProcAddressing(),
714  procFaMeshes.faceProcAddressing(),
715  procFaMeshes.boundaryProcAddressing()
716  );
717 
718  reconstructor.reconstructFaAreaFields<scalar>(objects);
719  reconstructor.reconstructFaAreaFields<vector>(objects);
720  reconstructor.reconstructFaAreaFields<sphericalTensor>(objects);
721  reconstructor.reconstructFaAreaFields<symmTensor>(objects);
722  reconstructor.reconstructFaAreaFields<tensor>(objects);
723 
724  reconstructor.reconstructFaEdgeFields<scalar>(objects);
725  }
726  else
727  {
728  Info << "No FA fields" << nl << endl;
729  }
730 
731  if (doReconstructSets)
732  {
733  // Scan to find all sets
734  HashTable<label> cSetNames;
735  HashTable<label> fSetNames;
736  HashTable<label> pSetNames;
737 
738  forAll(procMeshes.meshes(), proci)
739  {
740  const fvMesh& procMesh = procMeshes.meshes()[proci];
741 
742  // Note: look at sets in current time only or between
743  // mesh and current time?. For now current time. This will
744  // miss out on sets in intermediate times that have not
745  // been reconstructed.
746  IOobjectList objects
747  (
748  procMesh,
749  databases[0].timeName(), //procMesh.facesInstance()
750  polyMesh::meshSubDir/"sets"
751  );
752 
753  IOobjectList cSets(objects.lookupClass(cellSet::typeName));
754  forAllConstIters(cSets, iter)
755  {
756  cSetNames.insert(iter.key(), cSetNames.size());
757  }
758 
759  IOobjectList fSets(objects.lookupClass(faceSet::typeName));
760  forAllConstIters(fSets, iter)
761  {
762  fSetNames.insert(iter.key(), fSetNames.size());
763  }
764  IOobjectList pSets(objects.lookupClass(pointSet::typeName));
765  forAllConstIters(pSets, iter)
766  {
767  pSetNames.insert(iter.key(), pSetNames.size());
768  }
769  }
770 
771  if (cSetNames.size() || fSetNames.size() || pSetNames.size())
772  {
773  // Construct all sets
774  PtrList<cellSet> cellSets(cSetNames.size());
775  PtrList<faceSet> faceSets(fSetNames.size());
776  PtrList<pointSet> pointSets(pSetNames.size());
777 
778  Info<< "Reconstructing sets:" << endl;
779  if (cSetNames.size())
780  {
781  Info<< " cellSets "
782  << cSetNames.sortedToc() << endl;
783  }
784  if (fSetNames.size())
785  {
786  Info<< " faceSets "
787  << fSetNames.sortedToc() << endl;
788  }
789  if (pSetNames.size())
790  {
791  Info<< " pointSets "
792  << pSetNames.sortedToc() << endl;
793  }
794 
795  // Load sets
796  forAll(procMeshes.meshes(), proci)
797  {
798  const fvMesh& procMesh = procMeshes.meshes()[proci];
799 
800  IOobjectList objects
801  (
802  procMesh,
803  databases[0].timeName(),
804  polyMesh::meshSubDir/"sets"
805  );
806 
807  // cellSets
808  const labelList& cellMap =
809  procMeshes.cellProcAddressing()[proci];
810 
811  IOobjectList cSets
812  (
813  objects.lookupClass(cellSet::typeName)
814  );
815 
816  forAllConstIters(cSets, iter)
817  {
818  // Load cellSet
819  const cellSet procSet(*iter());
820  label setI = cSetNames[iter.key()];
821  if (!cellSets.set(setI))
822  {
823  cellSets.set
824  (
825  setI,
826  new cellSet
827  (
828  mesh,
829  iter.key(),
830  procSet.size()
831  )
832  );
833  }
834  cellSet& cSet = cellSets[setI];
835  cSet.instance() = runTime.timeName();
836 
837  for (const label celli : procSet)
838  {
839  cSet.insert(cellMap[celli]);
840  }
841  }
842 
843  // faceSets
844  const labelList& faceMap =
845  procMeshes.faceProcAddressing()[proci];
846 
847  IOobjectList fSets
848  (
849  objects.lookupClass(faceSet::typeName)
850  );
851 
852  forAllConstIters(fSets, iter)
853  {
854  // Load faceSet
855  const faceSet procSet(*iter());
856  label setI = fSetNames[iter.key()];
857  if (!faceSets.set(setI))
858  {
859  faceSets.set
860  (
861  setI,
862  new faceSet
863  (
864  mesh,
865  iter.key(),
866  procSet.size()
867  )
868  );
869  }
870  faceSet& fSet = faceSets[setI];
871  fSet.instance() = runTime.timeName();
872 
873  for (const label facei : procSet)
874  {
875  fSet.insert(mag(faceMap[facei])-1);
876  }
877  }
878  // pointSets
879  const labelList& pointMap =
880  procMeshes.pointProcAddressing()[proci];
881 
882  IOobjectList pSets
883  (
884  objects.lookupClass(pointSet::typeName)
885  );
886  forAllConstIters(pSets, iter)
887  {
888  // Load pointSet
889  const pointSet propSet(*iter());
890  label setI = pSetNames[iter.key()];
891  if (!pointSets.set(setI))
892  {
893  pointSets.set
894  (
895  setI,
896  new pointSet
897  (
898  mesh,
899  iter.key(),
900  propSet.size()
901  )
902  );
903  }
904  pointSet& pSet = pointSets[setI];
905  pSet.instance() = runTime.timeName();
906 
907  for (const label pointi : propSet)
908  {
909  pSet.insert(pointMap[pointi]);
910  }
911  }
912  }
913 
914  // Write sets
915 
916  for (const auto& set : cellSets)
917  {
918  set.write();
919  }
920  for (const auto& set : faceSets)
921  {
922  set.write();
923  }
924  for (const auto& set : pointSets)
925  {
926  set.write();
927  }
928  }
929 
930 
931  // Reconstruct refinement data
932  {
933  PtrList<hexRef8Data> procData(procMeshes.meshes().size());
934 
935  forAll(procMeshes.meshes(), procI)
936  {
937  const fvMesh& procMesh = procMeshes.meshes()[procI];
938 
939  procData.set
940  (
941  procI,
942  new hexRef8Data
943  (
944  IOobject
945  (
946  "dummy",
947  procMesh.time().timeName(),
948  polyMesh::meshSubDir,
949  procMesh,
950  IOobject::READ_IF_PRESENT,
951  IOobject::NO_WRITE,
952  false
953  )
954  )
955  );
956  }
957 
958  // Combine individual parts
959 
960  const PtrList<labelIOList>& cellAddr =
961  procMeshes.cellProcAddressing();
962 
963  UPtrList<const labelList> cellMaps(cellAddr.size());
964  forAll(cellAddr, i)
965  {
966  cellMaps.set(i, &cellAddr[i]);
967  }
968 
969  const PtrList<labelIOList>& pointAddr =
970  procMeshes.pointProcAddressing();
971 
972  UPtrList<const labelList> pointMaps(pointAddr.size());
973  forAll(pointAddr, i)
974  {
975  pointMaps.set(i, &pointAddr[i]);
976  }
977 
978  UPtrList<const hexRef8Data> procRefs(procData.size());
979  forAll(procData, i)
980  {
981  procRefs.set(i, &procData[i]);
982  }
983 
984  hexRef8Data
985  (
986  IOobject
987  (
988  "dummy",
989  mesh.time().timeName(),
990  polyMesh::meshSubDir,
991  mesh,
992  IOobject::NO_READ,
993  IOobject::NO_WRITE,
994  false
995  ),
996  cellMaps,
997  pointMaps,
998  procRefs
999  ).write();
1000  }
1001  }
1002 
1003 
1004  // Reconstruct refinement data
1005  {
1006  PtrList<hexRef8Data> procData(procMeshes.meshes().size());
1007 
1008  forAll(procMeshes.meshes(), procI)
1009  {
1010  const fvMesh& procMesh = procMeshes.meshes()[procI];
1011 
1012  procData.set
1013  (
1014  procI,
1015  new hexRef8Data
1016  (
1017  IOobject
1018  (
1019  "dummy",
1020  procMesh.time().timeName(),
1021  polyMesh::meshSubDir,
1022  procMesh,
1023  IOobject::READ_IF_PRESENT,
1024  IOobject::NO_WRITE,
1025  false
1026  )
1027  )
1028  );
1029  }
1030 
1031  // Combine individual parts
1032 
1033  const PtrList<labelIOList>& cellAddr =
1034  procMeshes.cellProcAddressing();
1035 
1036  UPtrList<const labelList> cellMaps(cellAddr.size());
1037  forAll(cellAddr, i)
1038  {
1039  cellMaps.set(i, &cellAddr[i]);
1040  }
1041 
1042  const PtrList<labelIOList>& pointAddr =
1043  procMeshes.pointProcAddressing();
1044 
1045  UPtrList<const labelList> pointMaps(pointAddr.size());
1046  forAll(pointAddr, i)
1047  {
1048  pointMaps.set(i, &pointAddr[i]);
1049  }
1050 
1051  UPtrList<const hexRef8Data> procRefs(procData.size());
1052  forAll(procData, i)
1053  {
1054  procRefs.set(i, &procData[i]);
1055  }
1056 
1057  hexRef8Data
1058  (
1059  IOobject
1060  (
1061  "dummy",
1062  mesh.time().timeName(),
1063  polyMesh::meshSubDir,
1064  mesh,
1065  IOobject::NO_READ,
1066  IOobject::NO_WRITE,
1067  false
1068  ),
1069  cellMaps,
1070  pointMaps,
1071  procRefs
1072  ).write();
1073  }
1074 
1075  // If there is a "uniform" directory in the time region
1076  // directory copy from the master processor
1077  {
1078  fileName uniformDir0
1079  (
1080  fileHandler().filePath
1081  (
1082  databases[0].timePath()/regionDir/"uniform"
1083  )
1084  );
1085 
1086  if (!uniformDir0.empty() && fileHandler().isDir(uniformDir0))
1087  {
1088  fileHandler().cp(uniformDir0, runTime.timePath()/regionDir);
1089  }
1090  }
1091 
1092  // For the first region of a multi-region case additionally
1093  // copy the "uniform" directory in the time directory
1094  if (regioni == 0 && regionDir != word::null)
1095  {
1096  fileName uniformDir0
1097  (
1098  fileHandler().filePath
1099  (
1100  databases[0].timePath()/"uniform"
1101  )
1102  );
1103 
1104  if (!uniformDir0.empty() && fileHandler().isDir(uniformDir0))
1105  {
1106  fileHandler().cp(uniformDir0, runTime.timePath());
1107  }
1108  }
1109  }
1110  }
1111 
1112  Info<< "\nEnd\n" << endl;
1113 
1114  return 0;
1115 }
1116 
1117 
1118 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:71
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::sphericalTensor
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
Definition: sphericalTensor.H:54
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeTopological.C:94
cloudName
const word cloudName(propsDict.get< word >("cloud"))
faCFD.H
regionProperties.H
fvFieldReconstructor.H
lagrangianReconstructor.H
processorFaMeshes.H
validate
thermo validate(args.executable(), "h")
Foam::argList::readListIfPresent
bool readListIfPresent(const word &optName, List< T > &list) const
Definition: argListI.H:373
Foam::fileHandler
const fileOperation & fileHandler()
Get current file handler.
Definition: fileOperation.C:1170
IOobjectList.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
faMesh.H
processorMeshes.H
Foam::instantList
List< instant > instantList
List of instants.
Definition: instantList.H:44
Foam::argList::readIfPresent
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
Definition: argListI.H:302
Foam::argList::rootPath
const fileName & rootPath() const
Return root path.
Definition: argListI.H:63
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:59
aMesh
faMesh aMesh(mesh)
checkFaceAddressingComp.H
Foam::fileOperation::readDir
virtual fileNameList readDir(const fileName &, const fileName::Type=fileName::FILE, const bool filtergz=true, const bool followLink=true) const =0
Read a directory and return the entries as a string list.
regionName
Foam::word regionName
Definition: createNamedDynamicFvMesh.H:1
pointFieldReconstructor.H
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::fileOperation::nProcs
virtual label nProcs(const fileName &dir, const fileName &local="") const
Get number of processor directories/results. Used for e.g.
Definition: fileOperation.C:915
argList.H
faceSet.H
addRegionOption.H
Foam::symmTensor
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
Definition: symmTensor.H:59
timeName
word timeName
Definition: getTimeIndex.H:3
Foam::argList::path
fileName path() const
Return the full path to the (processor local) case.
Definition: argListI.H:81
Foam::FatalError
error FatalError
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
hexRef8Data.H
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:51
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::fileNameList
List< fileName > fileNameList
A List of fileNames.
Definition: fileNameList.H:58
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
setRootCase.H
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:372
Foam::nl
constexpr char nl
Definition: Ostream.H:385
forAllConstIters
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28
Foam::flatOutput
FlatOutput< Container > flatOutput(const Container &obj, label len=0)
Global flatOutput function.
Definition: FlatOutput.H:85
Foam::fileOperation::isDir
virtual bool isDir(const fileName &, const bool followLink=true) const =0
Does the name exist as a DIRECTORY in the file system?
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::HashSet::insert
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
Definition: HashSet.H:181
timeSelector.H
createTime.H
faFieldReconstructor.H
Foam::wordHashSet
HashSet< word > wordHashSet
A HashSet with word keys.
Definition: HashSet.H:407
Foam::fileOperation::cp
virtual bool cp(const fileName &src, const fileName &dst, const bool followLink=true) const =0
Copy, recursively if necessary, the source to the destination.
fvCFD.H
Foam::argList::caseName
const fileName & caseName() const
Return case name (parallel run) or global case (serial run)
Definition: argListI.H:69
cellSet.H
args
Foam::argList args(argc, argv)
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:298
Foam::tensor
Tensor< scalar > tensor
Tensor of scalars, i.e. Tensor<scalar>.
Definition: symmTensor.H:61
Foam::argList::found
bool found(const word &optName) const
Return true if the named option is found.
Definition: argListI.H:157
Foam::IOobject::MUST_READ
Definition: IOobject.H:120
pointSet.H