FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

findFields.H

Go to the documentation of this file.
00001 // check the final time directory for the following:
00002 
00003 // 1. volume fields
00004 HashTable<word> volumeFields;
00005 
00006 // 2. the fields for each cloud:
00007 HashTable< HashTable<word> > cloudFields;
00008 
00009 if (timeDirs.size())
00010 {
00011     IOobjectList objs(mesh, timeDirs[timeDirs.size()-1].name());
00012 
00013     forAllConstIter(IOobjectList, objs, fieldIter)
00014     {
00015         const IOobject& obj = *fieldIter();
00016         const word& fieldName = obj.name();
00017         const word& fieldType = obj.headerClassName();
00018 
00019         if (fieldName.size() > 2 && fieldName(fieldName.size()-2, 2) == "_0")
00020         {
00021             // ignore _0 fields
00022         }
00023         else if (volFieldTypes.found(fieldType))
00024         {
00025             // simply ignore types that we don't handle
00026             volumeFields.insert(fieldName, fieldType);
00027         }
00028     }
00029 
00030 
00031     //
00032     // now check for lagrangian/<cloudName>
00033     //
00034     fileNameList cloudDirs = readDir
00035     (
00036         runTime.path()
00037       / timeDirs[timeDirs.size()-1].name()
00038       / regionPrefix
00039       / cloud::prefix,
00040         fileName::DIRECTORY
00041     );
00042 
00043     forAll(cloudDirs, cloudI)
00044     {
00045         const word& cloudName = cloudDirs[cloudI];
00046 
00047         // Create a new hash table for each cloud
00048         cloudFields.insert(cloudName, HashTable<word>());
00049 
00050         // Identify the new cloud within the hash table
00051         HashTable<HashTable<word> >::iterator cloudIter =
00052             cloudFields.find(cloudName);
00053 
00054         IOobjectList objs
00055         (
00056             mesh,
00057             timeDirs[timeDirs.size()-1].name(),
00058             cloud::prefix/cloudName
00059         );
00060 
00061         bool hasPositions = false;
00062         forAllConstIter(IOobjectList, objs, fieldIter)
00063         {
00064             const IOobject obj = *fieldIter();
00065             const word& fieldName = obj.name();
00066             const word& fieldType = obj.headerClassName();
00067 
00068             if (fieldName == "positions")
00069             {
00070                 hasPositions = true;
00071             }
00072             else if (cloudFieldTypes.found(fieldType))
00073             {
00074                 // simply ignore types that we don't handle
00075                 cloudIter().insert(fieldName, fieldType);
00076             }
00077         }
00078 
00079         // drop this cloud if it has no positions or is otherwise empty
00080         if (!hasPositions || cloudIter().empty())
00081         {
00082             Info<< "removing cloud " << cloudName << endl;
00083             cloudFields.erase(cloudIter);
00084         }
00085     }
00086 
00087     //
00088     // verify that the variable is present for all times
00089     //
00090     for (label i=0; volumeFields.size() && i < timeDirs.size(); ++i)
00091     {
00092         IOobjectList objs(mesh, timeDirs[i].name());
00093 
00094         forAllIter(HashTable<word>, volumeFields, fieldIter)
00095         {
00096             const word& fieldName = fieldIter.key();
00097 
00098             if (!objs.found(fieldName))
00099             {
00100                 volumeFields.erase(fieldIter);
00101             }
00102         }
00103     }
00104 }
00105 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines