Loading...
Searching...
No Matches
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-2025 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
12
13Description
14 Check field availability for last time.
15 Done to avoid mapping 'undefined' when a field only exists as time 0.
16
17Requires
18 readFields.H (for the checkData function)
19
20\*---------------------------------------------------------------------------*/
21
22// Initially all possible objects that are available at the final time
23List<wordHashSet> availableRegionObjectNames(meshes.size());
24List<HashTable<wordHashSet>> availableFaRegionObjectNames(meshes.size());
26forAll(meshes, regioni)
28 const auto& mesh = meshes[regioni];
29
30 IOobjectList objects;
31 HashTable<IOobjectList> faObjects;
32
33 if (doConvertFields && !timeDirs.empty())
34 {
35 const word& checkTimeName = timeDirs.back().name();
36
37 // List of volume mesh objects for this instance
38 objects = IOobjectList(mesh, checkTimeName);
39
40 objects.prune_0(); // Remove restart fields
41
42 if (fieldSelector)
43 {
44 objects.filterObjects(fieldSelector);
45 }
46 if (!doPointValues)
47 {
48 // Prune point fields if disabled
49 objects.filterClasses(Foam::fieldTypes::is_point, true);
50 }
51
52
53 // The finite-area fields for this volume region and instance
54 faObjects.reserve(meshesFa[regioni].size());
55 for (const auto& areaMesh : meshesFa[regioni])
56 {
57 const word& areaName = areaMesh.name();
58
59 IOobjectList objs
60 (
61 areaMesh,
62 checkTimeName,
63 IOobjectOption::NO_REGISTER
64 );
65
66 objs.prune_0(); // Remove restart fields
67
68 if (fieldSelector)
69 {
70 objs.filterObjects(fieldSelector);
71 }
72
73 faObjects(areaName) = std::move(objs);
74 }
75 }
76
77 // Volume fields
78 if (!objects.empty())
79 {
80 wordList objectNames(objects.sortedNames());
81
82 // Check availability for all times...
83 checkData
84 (
85 mesh.thisDb(),
86 timeDirs,
87 objectNames
88 );
89
90 availableRegionObjectNames[regioni] = objectNames;
91 }
92
93 // Area fields
94 for (const auto& areaMesh : meshesFa[regioni])
95 {
96 const word& areaName = areaMesh.name();
97
98 wordList objectNames;
99
100 if (const auto iter = faObjects.cfind(areaName); iter.good())
101 {
102 objectNames = iter.val().sortedNames();
103 }
104
105 // Check availability for all times...
106 checkData
107 (
108 areaMesh,
109 timeDirs,
110 objectNames
111 );
112
113 availableFaRegionObjectNames[regioni].emplace_set
114 (
115 areaName,
116 std::move(objectNames)
117 );
118 }
119}
120
121
122// ************************************************************************* //
List< HashTable< wordHashSet > > availableFaRegionObjectNames(meshes.size())
List< wordHashSet > availableRegionObjectNames(meshes.size())
dynamicFvMesh & mesh
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
List< PtrDynList< faMesh > > meshesFa(regionNames.size())
bool is_point(const word &clsName)
Test if the class name appears to be a point field.
Definition pointFields.C:94
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299