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-2022 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());
24
25forAll(meshes, regioni)
26{
27 const auto& mesh = meshes[regioni];
28
29 IOobjectList objects(0);
31 if (doConvertFields)
32 {
33 objects = IOobjectList(mesh, timeDirs.last().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// ************************************************************************* //
List< wordHashSet > availableRegionObjectNames(meshes.size())
label size() const noexcept
The number of elements in the list.
Definition: UPtrListI.H:106
dynamicFvMesh & mesh
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
List< word > wordList
A List of words.
Definition: fileName.H:63
label checkData(const fvMesh &mesh, const instantList &timeDirs, wordList &objectNames)
Check if fields are good to use (available at all times)
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333