File: findFields.H

package info (click to toggle)
openfoam 4.1%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 163,028 kB
  • ctags: 58,990
  • sloc: cpp: 830,760; sh: 10,227; ansic: 8,215; xml: 745; lex: 437; awk: 194; sed: 91; makefile: 77; python: 18
file content (105 lines) | stat: -rw-r--r-- 2,783 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// check the final time directory for the following:

// 1. volume fields
HashTable<word> volumeFields;

// 2. the fields for each cloud:
HashTable<HashTable<word>> cloudFields;

if (timeDirs.size())
{
    IOobjectList objs(mesh, timeDirs.last().name());

    forAllConstIter(IOobjectList, objs, fieldIter)
    {
        const IOobject& obj = *fieldIter();
        const word& fieldName = obj.name();
        const word& fieldType = obj.headerClassName();

        if (fieldName.size() > 2 && fieldName(fieldName.size()-2, 2) == "_0")
        {
            // ignore _0 fields
        }
        else if (volFieldTypes.found(fieldType))
        {
            // simply ignore types that we don't handle
            volumeFields.insert(fieldName, fieldType);
        }
    }


    //
    // now check for lagrangian/<cloudName>
    //
    fileNameList cloudDirs = readDir
    (
        runTime.path()
      / timeDirs.last().name()
      / regionPrefix
      / cloud::prefix,
        fileName::DIRECTORY
    );

    forAll(cloudDirs, cloudI)
    {
        const word& cloudName = cloudDirs[cloudI];

        // Create a new hash table for each cloud
        cloudFields.insert(cloudName, HashTable<word>());

        // Identify the new cloud within the hash table
        HashTable<HashTable<word>>::iterator cloudIter =
            cloudFields.find(cloudName);

        IOobjectList objs
        (
            mesh,
            timeDirs.last().name(),
            cloud::prefix/cloudName
        );

        bool hasPositions = false;
        forAllConstIter(IOobjectList, objs, fieldIter)
        {
            const IOobject obj = *fieldIter();
            const word& fieldName = obj.name();
            const word& fieldType = obj.headerClassName();

            if (fieldName == "positions")
            {
                hasPositions = true;
            }
            else if (cloudFieldTypes.found(fieldType))
            {
                // simply ignore types that we don't handle
                cloudIter().insert(fieldName, fieldType);
            }
        }

        // drop this cloud if it has no positions or is otherwise empty
        if (!hasPositions || cloudIter().empty())
        {
            Info<< "removing cloud " << cloudName << endl;
            cloudFields.erase(cloudIter);
        }
    }

    //
    // verify that the variable is present for all times
    //
    for (label i=0; volumeFields.size() && i < timeDirs.size(); ++i)
    {
        IOobjectList objs(mesh, timeDirs[i].name());

        forAllIter(HashTable<word>, volumeFields, fieldIter)
        {
            const word& fieldName = fieldIter.key();

            if (!objs.found(fieldName))
            {
                volumeFields.erase(fieldIter);
            }
        }
    }
}