Пример #1
0
Foam::cloud::cloud(const objectRegistry& obr, const word& cloudName)
:
    objectRegistry
    (
        IOobject
        (
            (cloudName.size() ? cloudName : defaultName),
            obr.time().timeName(),
            prefix,
            obr,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        )
    )
{
    if (isA<polyMesh>(obr))
    {
        if (debug)
        {
            Pout<< "cloud: Initialising polyMesh nGeometricD" << endl;
        }

        // initialise mesh dimensions - needed for parallel runs
        // due to lazy evaluation of valid mesh dimensions
        const polyMesh& mesh = dynamic_cast<const polyMesh&>(obr);
        const_cast<polyMesh&>(mesh).nGeometricD();
    }
}
Foam::solution::solution(const objectRegistry& obr, const fileName& dictName)
:
    IOdictionary
    (
        IOobject
        (
            dictName,
            obr.time().system(),
            obr,
            IOobject::READ_IF_PRESENT,  // Allow default dictionary creation
            IOobject::NO_WRITE
        )
    ),
    relaxationFactors_
    (
        ITstream("relaxationFactors", tokenList())()
    ),
    defaultRelaxationFactor_(0),
    solvers_(ITstream("solvers", tokenList())())
{
    if (!headerOk())
    {
        if (debug)
        {
            InfoIn
            (
                "Foam::solution::solution(const objectRegistry& obr, "
                "const fileName& dictName)"
            )   << "Solution dictionary not found.  Adding default entries"
                << endl;
        }
    }

    read();
}
Пример #3
0
Foam::functionObjects::regionFunctionObject::regionFunctionObject
(
    const word& name,
    const objectRegistry& obr,
    const dictionary& dict
)
:
    functionObject(name),
    time_(obr.time()),
    obr_(obr)
{}
Пример #4
0
Foam::IOobjectList::IOobjectList
(
    const objectRegistry& db,
    const fileName& instance,
    const fileName& local,
    IOobject::readOption r,
    IOobject::writeOption w,
    bool registerObject
)
:
    HashPtrTable<IOobject>()
{
    word newInstance = instance;

    if (!isDir(db.path(instance)))
    {
        newInstance = db.time().findInstancePath(instant(instance));

        if (newInstance.empty())
        {
            return;
        }
    }

    // Create a list of file names in this directory
    fileNameList ObjectNames =
        readDir(db.path(newInstance, db.dbDir()/local), fileName::FILE);

    forAll(ObjectNames, i)
    {
        IOobject* objectPtr = new IOobject
        (
            ObjectNames[i],
            newInstance,
            local,
            db,
            r,
            w,
            registerObject
        );

        if (objectPtr->headerOk())
        {
            insert(ObjectNames[i], objectPtr);
        }
        else
        {
            delete objectPtr;
        }
    }
Foam::cloud::cloud(const objectRegistry& obr, const word& cloudName)
:
    objectRegistry
    (
        IOobject
        (
            ( cloudName.size() ? cloudName : defaultName ),
            obr.time().timeName(),
            prefix,
            obr,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        )
    )
{}
Пример #6
0
Foam::data::data(const objectRegistry& obr)
:
    IOdictionary
    (
        IOobject
        (
            "data",
            obr.time().system(),
            obr,
            IOobject::NO_READ,
            IOobject::NO_WRITE
        )
    ),
    prevTimeIndex_(0)
{
    set("solverPerformance", dictionary());
}
Пример #7
0
Foam::IOobjectList::IOobjectList
(
    const objectRegistry& db,
    const fileName& instance,
    const fileName& local
)
:
    HashPtrTable<IOobject>()
{
    word newInstance = instance;

    if (!isDir(db.path(instance)))
    {
        newInstance = db.time().findInstancePath(instant(instance));

        if (newInstance.empty())
        {
            return;
        }
    }

    // Create list file names in directory
    fileNameList ObjectNames =
        readDir(db.path(newInstance, db.dbDir()/local), fileName::FILE);

    forAll(ObjectNames, i)
    {
        IOobject* objectPtr = new IOobject
        (
            ObjectNames[i],
            newInstance,
            local,
            db,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        );

        if (objectPtr->headerOk())
        {
            insert(ObjectNames[i], objectPtr);
        }
        else
        {
            delete objectPtr;
        }
    }
Пример #8
0
faSchemes::faSchemes(const objectRegistry& obr)
    :
    IOdictionary
    (
       IOobject
       (
           "faSchemes",
           obr.time().system(),
           obr,
//             IOobject::MUST_READ,
           IOobject::READ_IF_PRESENT,  // Allow default dictionary creation
           IOobject::NO_WRITE
       )
    ),
    ddtSchemes_(ITstream("ddtSchemes", tokenList())()),
    defaultDdtScheme_("default", tokenList()),
    d2dt2Schemes_(ITstream("d2dt2Schemes", tokenList())()),
    defaultD2dt2Scheme_("default", tokenList()),
    interpolationSchemes_(ITstream("interpolationSchemes", tokenList())()),
    defaultInterpolationScheme_("default", tokenList()),
    divSchemes_(ITstream("divSchemes", tokenList())()),
    defaultDivScheme_("default", tokenList()),
    gradSchemes_(ITstream("gradSchemes", tokenList())()),
    defaultGradScheme_("default", tokenList()),
    lnGradSchemes_(ITstream("lnGradSchemes", tokenList())()),
    defaultLnGradScheme_("default", tokenList()),
    laplacianSchemes_(ITstream("laplacianSchemes", tokenList())()),
    defaultLaplacianScheme_("default", tokenList()),
    fluxRequired_(ITstream("fluxRequired", tokenList())())
{
    if (!headerOk())
    {
        if (debug)
        {
            InfoIn
            (
                "faSchemes::faSchemes(const objectRegistry& obr)"
            )   << "faSchemes dictionary not found.  Creating default."
                << endl;
        }
    }

    read();
}
Пример #9
0
Foam::surfaceRegistry::surfaceRegistry
(
    const objectRegistry& obr,
    const word& surfName
)
:
    objectRegistry
    (
        IOobject
        (
            ( surfName.size() ? surfName : defaultName ),
            obr.time().timeName(),
            prefix,
            obr,
            IOobject::NO_READ,
            IOobject::NO_WRITE
        )
    )
{}
Foam::IOOutputFilter<OutputFilter>::IOOutputFilter
(
    const word& outputFilterName,
    const objectRegistry& obr,
    const fileName& dictName,
    const IOobject::readOption rOpt,
    const bool readFromFiles
)
:
    IOdictionary
    (
        IOobject
        (
            dictName,
            obr.time().system(),
            obr,
            rOpt,
            IOobject::NO_WRITE
        )
    ),
    OutputFilter(outputFilterName, obr, *this, readFromFiles)
{}
Пример #11
0
Foam::solution::solution(const objectRegistry& obr, const fileName& dictName)
:
    IOdictionary
    (
        IOobject
        (
            dictName,
            obr.time().system(),
            obr,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    ),
    relaxationFactors_
    (
        ITstream("relaxationFactors",
        tokenList())()
    ),
    defaultRelaxationFactor_(0),
    solvers_(ITstream("solvers", tokenList())())
{
    read();
}
label TimeClone::copyObjects(const objectRegistry &src,objectRegistry &dst)
{
    Dbug << "Copying stuff from " << src.name() << " to " << dst.name() << endl;
    Dbug << "t=" << src.time().timeName() << endl;
    Dbug << "Dst AUTO_WRITE: " << (dst.writeOpt()==IOobject::AUTO_WRITE) << endl;

    label cnt=0;

    forAllConstIter(objectRegistry,src,it) {
	const word &name=it.key();
        const regIOobject &obj=*(*it);

        Dbug << name << " is class " << obj.headerClassName() << endl;

        if(isA<objectRegistry>(obj)) {
            Dbug << name << " is objectRegistry. Creating new and cloning" << endl;
            const objectRegistry &orig=dynamicCast<const objectRegistry>(obj);
            if(&src==&orig) {
                Dbug << name << "==" << src.name() << " -> Skipping" << endl;
            } else {
                word dbName=orig.name();
                if(dbName==polyMesh::defaultRegion) {
                    dbName="";
                }
                autoPtr<objectRegistry> newSubp(
                    new objectRegistry(
                        IOobject(
                            dbName,
                            src.time().timeName(),
                            src.local(),
                            dst
                        )
                    )
                );
                objectRegistry &newSub=newSubp();
                Dbug << "AUTO_WRITE: " << (newSub.writeOpt()==IOobject::AUTO_WRITE) << endl;
                Dbug << "old path: " << obj.objectPath() << endl;
                Dbug << "new Path: " << newSub.objectPath() << endl;
                Dbug << "Created registry owned by parent: " << newSub.ownedByRegistry() << endl;
                cnt+=copyObjects(orig,newSub);
                dst.store(newSubp.ptr());
                Dbug << "New registry owned by parent: " << newSub.ownedByRegistry() << endl;
            }
        } else if(obj.writeOpt()==IOobject::AUTO_WRITE) {
            Dbug << name << " set to AUTO_WRITE. Creating copy" << endl;
            autoPtr<regIOobject> newObjP;

            // work around because there is no virtual clone method in IObobject

#define tryClone(Type)                                                  \
            if(!newObjP.valid() && isA<Type>(obj)) {                    \
                newObjP.set(                                            \
                    new Type(                                           \
                        IOobject(                                       \
                            obj.name(),                                 \
                            src.time().timeName(),                      \
                            obj.local(),               \
                            dst                                         \
                        ),                                              \
                        dynamicCast<const Type>(obj)));                 \
            }

            tryClone(volScalarField);
            tryClone(volVectorField);
            tryClone(volTensorField);
            tryClone(volSymmTensorField);
            tryClone(volSphericalTensorField);

            tryClone(surfaceScalarField);
            tryClone(surfaceVectorField);
            tryClone(surfaceTensorField);
            tryClone(surfaceSymmTensorField);
            tryClone(surfaceSphericalTensorField);

            tryClone(pointScalarField);
            tryClone(pointVectorField);
            tryClone(pointTensorField);
            tryClone(pointSymmTensorField);
            tryClone(pointSphericalTensorField);

            tryClone(diagTensorIOField);
            tryClone(labelIOField);
            tryClone(pointIOField);
            tryClone(scalarIOField);
            tryClone(sphericalTensorIOField);
            tryClone(symmTensorIOField);
            tryClone(tensorIOField);
            tryClone(vector2DIOField);
            tryClone(vectorIOField);
            //            tryClone(polyBoundaryMesh);

#undef tryClone

            if(newObjP.valid()) {
                regIOobject &newObj=dynamicCast<regIOobject&>(newObjP());
                Dbug << "Adding " << name << " to registry " << dst.name()
                    << " Class: " << newObj.headerClassName() << endl;
                Dbug << "Owned by old Registry: " << newObj.ownedByRegistry() << endl;
                Dbug << "AUTO_WRITE: " << (newObj.writeOpt()==IOobject::AUTO_WRITE) << endl;
                Dbug << "Old Path: " << obj.objectPath() << endl;
                Dbug << "New Path: " << newObj.objectPath() << endl;
                Dbug << "Local: " << obj.local() << " -> " << newObj.local() << endl;
                newObj.writeOpt()=IOobject::AUTO_WRITE;
                regIOobject *ptr=static_cast<regIOobject*>(newObjP.ptr());
                dst.store(ptr);
                Dbug << "Owned by new Registry: " << newObj.ownedByRegistry() << endl;
                cnt++;
            } else {
                Dbug << "No fitting type found for " << name << endl;
            }
        } else {
            Dbug << name << " not copied" << endl;
        }
    }

    Dbug << "Copying to " << dst.name() << " ended " << cnt << endl;
    Dbug << dst.names() << endl;

    return cnt;
}
Foam::fileNameList
Foam::fileOperations::autoParallelFileOperation::readObjects
(
    const objectRegistry& db,
    const fileName& instance,
    const fileName& local,
    word& newInstance
) const
{
    fileNameList objects;

    if (!Pstream::parRun())
    {
        objects = uncollatedFileOperation::readObjects
        (
            db,
            instance,
            local,
            newInstance
        );
    }
    else
    {
        // tbd: lagrangian. dbDir="", local = "lagrangian/KinematicCloud"
        fileName path
        (
            filePath
            (
                db.rootPath()
               /db.time().globalCaseName()
               /instance
               /db.dbDir()
               /local
            )
        );

        if (Foam::isDir(path))
        {
            newInstance = instance;
            objects = Foam::readDir(path, fileType::file);

            if (debug)
            {
                Pout<< indent
                    << "autoParallelFileOperation::readObjects :"
                    << " Returning parent directory searching:"
                    << endl << indent
                    << "    path     :" << path << endl << indent
                    << "    objects  :" << objects << endl << endl;
            }

            return objects;
        }
        else
        {
            objects = uncollatedFileOperation::readObjects
            (
                db,
                instance,
                local,
                newInstance
            );
        }
    }

    if (debug)
    {
        Pout<< indent
            << "autoParallelFileOperation::readObjects :"
            << " Returning from directory searching:" << endl << indent
            << "    path     :" << db.path(instance, db.dbDir()/local)
            << endl << indent
            << "    objects  :" << objects << endl << indent
            << "    newInst  :" << newInstance << endl << endl;
    }
    return objects;
}
Пример #14
0
Foam::fvSchemes::fvSchemes(const objectRegistry& obr)
:
    IOdictionary
    (
        IOobject
        (
            "fvSchemes",
            obr.time().system(),
            obr,
            (
                obr.readOpt() == IOobject::MUST_READ
             || obr.readOpt() == IOobject::READ_IF_PRESENT
              ? IOobject::MUST_READ_IF_MODIFIED
              : obr.readOpt()
            ),
            IOobject::NO_WRITE
        )
    ),
    ddtSchemes_
    (
        ITstream
        (
            objectPath() + ".ddtSchemes",
            tokenList()
        )()
    ),
    defaultDdtScheme_
    (
        ddtSchemes_.name() + ".default",
        tokenList()
    ),
    d2dt2Schemes_
    (
        ITstream
        (
            objectPath() + ".d2dt2Schemes",
            tokenList()
        )()
    ),
    defaultD2dt2Scheme_
    (
        d2dt2Schemes_.name() + ".default",
        tokenList()
    ),
    interpolationSchemes_
    (
        ITstream
        (
            objectPath() + ".interpolationSchemes",
            tokenList()
        )()
    ),
    defaultInterpolationScheme_
    (
        interpolationSchemes_.name() + ".default",
        tokenList()
    ),
    divSchemes_
    (
        ITstream
        (
            objectPath() + ".divSchemes",
            tokenList()
        )()
    ),
    defaultDivScheme_
    (
        divSchemes_.name() + ".default",
        tokenList()
    ),
    gradSchemes_
    (
        ITstream
        (
            objectPath() + ".gradSchemes",
            tokenList()
        )()
    ),
    defaultGradScheme_
    (
        gradSchemes_.name() + ".default",
        tokenList()
    ),
    snGradSchemes_
    (
        ITstream
        (
            objectPath() + ".snGradSchemes",
            tokenList()
        )()
    ),
    defaultSnGradScheme_
    (
        snGradSchemes_.name() + ".default",
        tokenList()
    ),
    laplacianSchemes_
    (
        ITstream
        (
            objectPath() + ".laplacianSchemes",
            tokenList()
        )()
    ),
    defaultLaplacianScheme_
    (
        laplacianSchemes_.name() + ".default",
        tokenList()
    ),
    fluxRequired_
    (
        ITstream
        (
            objectPath() + ".fluxRequired",
            tokenList()
        )()
    ),
    defaultFluxRequired_(false),
    steady_(false)
{
    if
    (
        readOpt() == IOobject::MUST_READ
     || readOpt() == IOobject::MUST_READ_IF_MODIFIED
     || (readOpt() == IOobject::READ_IF_PRESENT && headerOk())
    )
    {
        read(schemesDict());
    }
}
Пример #15
0
Foam::fvSchemes::fvSchemes(const objectRegistry& obr)
    :
    IOdictionary
    (
       IOobject
       (
           "fvSchemes",
           obr.time().system(),
           obr,
           (
               obr.readOpt() == IOobject::MUST_READ
               ? IOobject::MUST_READ_IF_MODIFIED
               : obr.readOpt()
           ),
           IOobject::NO_WRITE
       )
    ),
    ddtSchemes_
    (
       ITstream
       (
           objectPath() + "::ddtSchemes",
           tokenList()
       )()
    ),
    defaultDdtScheme_
    (
       ddtSchemes_.name() + "::default",
       tokenList()
    ),
    d2dt2Schemes_
    (
       ITstream
       (
           objectPath() + "::d2dt2Schemes",
           tokenList()
       )()
    ),
    defaultD2dt2Scheme_
    (
       d2dt2Schemes_.name() + "::default",
       tokenList()
    ),
    interpolationSchemes_
    (
       ITstream
       (
           objectPath() + "::interpolationSchemes",
           tokenList()
       )()
    ),
    defaultInterpolationScheme_
    (
       interpolationSchemes_.name() + "::default",
       tokenList()
    ),
    divSchemes_
    (
       ITstream
       (
           objectPath() + "::divSchemes",
           tokenList()
       )()
    ),
    defaultDivScheme_
    (
       divSchemes_.name() + "::default",
       tokenList()
    ),
    gradSchemes_
    (
       ITstream
       (
           objectPath() + "::gradSchemes",
           tokenList()
       )()
    ),
    defaultGradScheme_
    (
       gradSchemes_.name() + "::default",
       tokenList()
    ),
    snGradSchemes_
    (
       ITstream
       (
           objectPath() + "::snGradSchemes",
           tokenList()
       )()
    ),
    defaultSnGradScheme_
    (
       snGradSchemes_.name() + "::default",
       tokenList()
    ),
    laplacianSchemes_
    (
       ITstream
       (
           objectPath() + "::laplacianSchemes",
           tokenList()
       )()
    ),
    defaultLaplacianScheme_
    (
       laplacianSchemes_.name() + "::default",
       tokenList()
    ),
    fluxRequired_
    (
       ITstream
       (
           objectPath() + "::fluxRequired",
           tokenList()
       )()
    ),
    defaultFluxRequired_(false)
{
    // persistent settings across reads is incorrect
    clear();

    if
    (
        readOpt() == IOobject::MUST_READ
        || readOpt() == IOobject::MUST_READ_IF_MODIFIED
    )
    {
        read(schemesDict());
    }
}
Пример #16
0
Foam::fvSchemes::fvSchemes(const objectRegistry& obr)
:
    IOdictionary
    (
        IOobject
        (
            "fvSchemes",
            obr.time().system(),
            obr,
//             IOobject::MUST_READ,
            IOobject::READ_IF_PRESENT,  // Allow default dictionary creation
            IOobject::NO_WRITE
        )
    ),
    ddtSchemes_
    (
        ITstream
        (
            objectPath() + "::ddtSchemes",
            tokenList()
        )()
    ),
    defaultDdtScheme_
    (
        ddtSchemes_.name() + "::default",
        tokenList()
    ),
    d2dt2Schemes_
    (
        ITstream
        (
            objectPath() + "::d2dt2Schemes",
            tokenList()
        )()
    ),
    defaultD2dt2Scheme_
    (
        d2dt2Schemes_.name() + "::default",
        tokenList()
    ),
    interpolationSchemes_
    (
        ITstream
        (
            objectPath() + "::interpolationSchemes",
            tokenList()
        )()
    ),
    defaultInterpolationScheme_
    (
        interpolationSchemes_.name() + "::default",
        tokenList()
    ),
    divSchemes_
    (
        ITstream
        (
            objectPath() + "::divSchemes",
            tokenList()
        )()
    ),
    defaultDivScheme_
    (
        divSchemes_.name() + "::default",
        tokenList()
    ),
    gradSchemes_
    (
        ITstream
        (
            objectPath() + "::gradSchemes",
            tokenList()
        )()
    ),
    defaultGradScheme_
    (
        gradSchemes_.name() + "::default",
        tokenList()
    ),
    snGradSchemes_
    (
        ITstream
        (
            objectPath() + "::snGradSchemes",
            tokenList()
        )()
    ),
    defaultSnGradScheme_
    (
        snGradSchemes_.name() + "::default",
        tokenList()
    ),
    laplacianSchemes_
    (
        ITstream
        (
            objectPath() + "::laplacianSchemes",
            tokenList()
        )()
    ),
    defaultLaplacianScheme_
    (
        laplacianSchemes_.name() + "::default",
        tokenList()
    ),
    fluxRequired_
    (
        ITstream
        (
            objectPath() + "::fluxRequired",
            tokenList()
        )()
    ),
    defaultFluxRequired_(false),
    cacheFields_
    (
        ITstream
        (
            objectPath() + "::cacheFields",
            tokenList()
        )()
    )
{
    if (!headerOk())
    {
        if (debug)
        {
            InfoIn
            (
                "fvSchemes::fvSchemes(const objectRegistry& obr)"
            )   << "fvSchemes dictionary not found.  Creating default."
                << endl;
        }

        regIOobject::write();
    }

    read();
}