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 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(mesh, timeDirs.last().name());
30 
31  if (!fieldPatterns.empty())
32  {
33  objects.filterObjects(fieldPatterns);
34  }
35 
36  // Remove "*_0" restart fields
37  objects.prune_0();
38 
39  if (!doPointValues)
40  {
41  // Prune point fields if disabled
42  objects.filterClasses
43  (
44  [](const word& clsName)
45  {
46  return fieldTypes::point.found(clsName);
47  },
48  true // prune
49  );
50  }
51 
52  wordList objectNames(objects.sortedNames());
53 
54  // Check availability for all times...
55  checkData(mesh, timeDirs, objectNames);
56 
57  availableRegionObjectNames[regioni] = objectNames;
58 }
59 
60 
61 // ************************************************************************* //
Foam::checkData
label checkData(const fvMesh &mesh, const instantList &timeDirs, wordList &objectNames)
Check if fields are good to use (available at all times)
forAll
forAll(meshes, regioni)
Definition: checkFieldAvailability.H:32
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:62
availableRegionObjectNames
List< wordHashSet > availableRegionObjectNames(meshes.size())
meshes
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::point
vector point
Point is a vector.
Definition: point.H:43