checkFieldAvailability.H
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) 2021-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
12 
13 Description
14  Check field availability for last time.
15  Done to avoid mapping 'undefined' when a field only exists as time 0.
16 
17 Requires
18  readFields.H (for the checkData function)
19 
20 \*---------------------------------------------------------------------------*/
21 
22 // Initially all possible objects that are available at the final time
23 List<wordHashSet> availableRegionObjectNames(meshes.size());
24 
25 forAll(meshes, regioni)
26 {
27  const auto& mesh = meshes[regioni];
28 
29  IOobjectList objects(0);
30 
31  if (doConvertFields && !timeDirs.empty())
32  {
33  objects = IOobjectList(mesh, timeDirs.back().name());
34 
35  if (fieldSelector && !fieldSelector().empty())
36  {
37  objects.filterObjects(fieldSelector());
38  }
39 
40  if (fieldSelector && !fieldSelector().empty())
41  {
42  objects.filterObjects(fieldSelector());
43  }
44 
45  // Remove "*_0" restart fields
46  objects.prune_0();
47 
48  if (!doPointValues)
49  {
50  // Prune point fields if disabled
51  objects.filterClasses
52  (
53  [](const word& clsName)
54  {
55  return fieldTypes::point.found(clsName);
56  },
57  true // prune
58  );
59  }
60  }
61 
62  wordList objectNames(objects.sortedNames());
63 
64  // Check availability for all times...
65  checkData(mesh, timeDirs, objectNames);
66 
67  availableRegionObjectNames[regioni] = objectNames;
68 }
69 
70 
71 // ************************************************************************* //
forAll(meshes, regioni)
dynamicFvMesh & mesh
label checkData(const fvMesh &mesh, const instantList &timeDirs, wordList &objectNames)
Check if fields are good to use (available at all times)
List< wordHashSet > availableRegionObjectNames(meshes.size())
label size() const noexcept
The number of entries in the list.
Definition: UPtrListI.H:106
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
List< word > wordList
List of word.
Definition: fileName.H:59
vector point
Point is a vector.
Definition: point.H:37