Ejemplo n.º 1
0
Foam::IOList<T>::IOList(const IOobject& io)
:
    regIOobject(io)
{
    // Temporary warning
    if (io.readOpt() == IOobject::MUST_READ_IF_MODIFIED)
    {
        WarningIn("IOList::IOList(const IOobject&)")
            << "IOList " << name()
            << " constructed with IOobject::MUST_READ_IF_MODIFIED"
            " but IOList does not support automatic rereading."
            << endl;
    }
    if
    (
        (
            io.readOpt() == IOobject::MUST_READ
         || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
        )
     || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
    )
    {
        readStream(typeName) >> *this;
        close();
    }
Foam::surfMesh::surfMesh(const IOobject& io, const word& surfName)
:
    surfaceRegistry(io.db(), (surfName.size() ? surfName : io.name())),
    Allocator
    (
        IOobject
        (
            "points",
            time().findInstance(meshDir(), "points"),
            meshSubDir,
            *this,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        ),
        IOobject
        (
            "faces",
            time().findInstance(meshDir(), "faces"),
            meshSubDir,
            *this,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        ),
        IOobject
        (
            "surfZones",
            time().findInstance(meshDir(), "surfZones"),
            meshSubDir,
            *this,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    ),
    MeshReference(this->storedIOFaces(), this->storedIOPoints())
{}
Ejemplo n.º 3
0
Foam::IOobject Foam::IOporosityModelList::createIOobject
(
    const fvMesh& mesh
) const
{
    IOobject io
    (
        "porosityProperties",
        mesh.time().constant(),
        mesh,
        IOobject::MUST_READ,
        IOobject::NO_WRITE
    );

    if (io.typeHeaderOk<IOdictionary>(true))
    {
        Info<< "Creating porosity model list from " << io.name() << nl << endl;

        io.readOpt() = IOobject::MUST_READ_IF_MODIFIED;
        return io;
    }
    else
    {
        Info<< "No porosity models present" << nl << endl;

        io.readOpt() = IOobject::NO_READ;
        return io;
    }
}
Ejemplo n.º 4
0
void printSum
(
    const fvMesh& mesh,
    const IOobject& fieldHeader,
    const label patchI,
    bool& done
)
{
    if (!done && fieldHeader.headerClassName() == FieldType::typeName)
    {
        Info<< "    Reading " << FieldType::typeName << " "
            << fieldHeader.name() << endl;

        FieldType field(fieldHeader, mesh);
        typename FieldType::value_type sumField = gSum
        (
            field.boundaryField()[patchI]
        );

        Info<< "    Integral of " << fieldHeader.name() << " over patch "
            << mesh.boundary()[patchI].name() << '[' << patchI << ']' << " = "
            << sumField << nl;

        done = true;
    }
}
Ejemplo n.º 5
0
void Foam::calcTypes::curl::writeCurlField
(
    const IOobject& header,
    const fvMesh& mesh,
    bool& processed
)
{
    typedef GeometricField<Type, fvPatchField, volMesh> fieldType;

    if (header.headerClassName() == fieldType::typeName)
    {
        Info<< "    Reading " << header.name() << endl;
        fieldType field(header, mesh);

        Info<< "    Calculating curl" << header.name() << endl;
        volVectorField curlField
        (
            IOobject
            (
                "curl" + header.name(),
                mesh.time().timeName(),
                mesh,
                IOobject::NO_READ
            ),
            Foam::fvc::curl(field)
        );
        curlField.write();

        processed = true;
    }
}
Ejemplo n.º 6
0
void Foam::calcTypes::interpolate::writeInterpolateField
(
    const IOobject& header,
    const fvMesh& mesh,
    bool& processed
)
{
    typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
    typedef GeometricField<Type, fvsPatchField, surfaceMesh> surfaceFieldType;

    if (header.headerClassName() == fieldType::typeName)
    {
        Info<< "    Reading " << header.name() << endl;
        fieldType field(header, mesh);

        Info<< "    Calculating interpolate" << header.name() << endl;
        surfaceFieldType interpolateField
        (
            IOobject
            (
                "interpolate" + header.name(),
                mesh.time().timeName(),
                mesh,
                IOobject::NO_READ
            ),
            fvc::interpolate(field)
        );
        interpolateField.write();

        processed = true;
    }
}
Ejemplo n.º 7
0
    bool addFieldsToList
    (
        const fvMesh& mesh,
        PtrList<GeometricField<Type, fvPatchField, volMesh>>& list,
        const wordList& fieldNames
    )
    {
        typedef GeometricField<Type, fvPatchField, volMesh> fieldType;

        label index = 0;
        forAll(fieldNames, i)
        {
            IOobject obj
            (
                fieldNames[i],
                mesh.time().timeName(),
                mesh,
                IOobject::MUST_READ
            );

            if (obj.headerOk() && obj.headerClassName() == fieldType::typeName)
            {
                list.set(index++, new fieldType(obj, mesh));
            }
            else
            {
                Info<< "Could not find " << fieldNames[i] << endl;

                return false;
            }
        }
Ejemplo n.º 8
0
bool Foam::sampledSets::checkFieldTypes()
{
    wordList fieldTypes(fieldNames_.size());

    // check files for a particular time
    if (loadFromFiles_)
    {
        forAll(fieldNames_, fieldi)
        {
            IOobject io
            (
                fieldNames_[fieldi],
                mesh_.time().timeName(),
                mesh_,
                IOobject::MUST_READ,
                IOobject::NO_WRITE,
                false
            );

            if (io.headerOk())
            {
                fieldTypes[fieldi] = io.headerClassName();
            }
            else
            {
                fieldTypes[fieldi] = "(notFound)";
            }
        }
    }
Ejemplo n.º 9
0
Foam::solidBodyMotionFvMesh::solidBodyMotionFvMesh(const IOobject& io)
:
    dynamicFvMesh(io),
    dynamicMeshCoeffs_
    (
        IOdictionary
        (
            IOobject
            (
                "dynamicMeshDict",
                io.time().constant(),
                *this,
                IOobject::MUST_READ,
                IOobject::NO_WRITE
            )
        ).subDict(typeName + "Coeffs")
    ),
    SBMFPtr_(solidBodyMotionFunction::New(dynamicMeshCoeffs_, io.time())),
    undisplacedPoints_
    (
        IOobject
        (
            "points",
            io.time().constant(),
            meshSubDir,
            *this,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    )
{}
void Foam::calcTypes::scalarMult::calc
(
    const argList& args,
    const Time& runTime,
    const fvMesh& mesh
)
{
    IOobject baseFieldHeader
    (
        baseFieldName_,
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ
    );

    if (baseFieldHeader.headerOk())
    {
        writeScalarMultValues(runTime, mesh, baseFieldHeader);
    }
    else
    {
        FatalErrorIn("calcTypes::scalarMult::calc")
            << "Unable to read base field: " << baseFieldName_
            << nl << exit(FatalError);
    }
}
Ejemplo n.º 11
0
int main(int argc, char *argv[])
{
    timeSelector::addOptions();
    #include "addRegionOption.H"
    argList::validArgs.append("fieldName");
    #include "setRootCase.H"
    #include "createTime.H"
    instantList timeDirs = timeSelector::select0(runTime, args);
    #include "createNamedMesh.H"

    const word fieldName = args[1];

    forAll(timeDirs, timeI)
    {
        runTime.setTime(timeDirs[timeI], timeI);
        Info<< "Time = " << runTime.timeName() << endl;

        IOobject fieldHeader
        (
            fieldName,
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ
        );

        // Check field exists
        if (fieldHeader.headerOk())
        {
            mesh.readUpdate();

            // Give fluid volume
            Info<< "    Volume of fluid = "
                << gSum(mesh.V()) << " [m3]" << endl;

            // Read field and calc integral
            bool done = false;

            printIntegrate<volScalarField>(mesh,fieldHeader,done);
            printIntegrate<volVectorField>(mesh,fieldHeader,done);
            printIntegrate<volSphericalTensorField>(mesh,fieldHeader,done);
            printIntegrate<volSymmTensorField>(mesh,fieldHeader,done);
            printIntegrate<volTensorField>(mesh,fieldHeader,done);

            if (!done)
            {
                FatalError
                    << "Only possible to integrate volFields."
                    << " Field " << fieldName << " is of type "
                    << fieldHeader.headerClassName()
                    << nl << exit(FatalError);
            }
        }
        else
        {
            Info<< "    No field " << fieldName << endl;
        }

        Info<< endl;
    }
Ejemplo n.º 12
0
int main(int argc, char *argv[])
{
    argList::validArgs.append("scaling factor");

#   include <OpenFOAM/setRootCase.H>

    scalar scaleFactor(readScalar(IStringStream(args.additionalArgs()[0])()));

#   include <OpenFOAM/createTime.H>
#   include <OpenFOAM/createMesh.H>

    volPointInterpolation pInterp(mesh);

    // Get times list
    instantList Times = runTime.times();

    pointField zeroPoints(mesh.points());

    // skip "constant" time
    for (label timeI = 1; timeI < Times.size(); ++timeI)
    {
        runTime.setTime(Times[timeI], timeI);

        Info<< "Time = " << runTime.timeName() << endl;

        IOobject Uheader
        (
            "U",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ
        );

        // Check U exists
        if (Uheader.headerOk())
        {
            Info<< "    Reading U" << endl;
            volVectorField U(Uheader, mesh);

            pointField newPoints =
                zeroPoints
              + scaleFactor*pInterp.interpolate(U)().internalField();

            mesh.polyMesh::movePoints(newPoints);

            mesh.write();
        }
        else
        {
            Info<< "    No U" << endl;
        }

        Info<< endl;
    }

    Info<< "End\n" << endl;

    return 0;
}
Ejemplo n.º 13
0
void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
{
    bool writeResults = !args.optionFound("noWrite");

    IOobject Uheader
    (
        "U",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ
    );

    if (Uheader.headerOk())
    {
        Info<< "    Reading U" << endl;
        volVectorField U(Uheader, mesh);

        Info<< "    Calculating vorticity" << endl;
        volVectorField vorticity
        (
            IOobject
            (
                "vorticity",
                runTime.timeName(),
                mesh,
                IOobject::NO_READ
            ),
            fvc::curl(U)
        );

        volScalarField magVorticity
        (
            IOobject
            (
                "magVorticity",
                runTime.timeName(),
                mesh,
                IOobject::NO_READ
            ),
            mag(vorticity)
        );

        Info<< "vorticity max/min : "
            << max(magVorticity).value() << " "
            << min(magVorticity).value() << endl;

        if (writeResults)
        {
            vorticity.write();
            magVorticity.write();
        }
    }
    else
    {
        Info<< "    No U" << endl;
    }

    Info<< "\nEnd\n" << endl;
}
Ejemplo n.º 14
0
Foam::IOdictionary::IOdictionary(const IOobject& io, const dictionary& dict)
:
    regIOobject(io)
{
    // Temporary warning
    if (debug && io.readOpt() == IOobject::MUST_READ)
    {
        WarningInFunction
            << "Dictionary " << name()
            << " constructed with IOobject::MUST_READ"
            " instead of IOobject::MUST_READ_IF_MODIFIED." << nl
            << "Use MUST_READ_IF_MODIFIED if you need automatic rereading."
            << endl;
    }

    // Everyone check or just master
    bool masterOnly =
        regIOobject::fileModificationChecking == timeStampMaster
     || regIOobject::fileModificationChecking == inotifyMaster;


    // Check if header is ok for READ_IF_PRESENT
    bool isHeaderOk = false;
    if (io.readOpt() == IOobject::READ_IF_PRESENT)
    {
        if (masterOnly)
        {
            if (Pstream::master())
            {
                isHeaderOk = headerOk();
            }
            Pstream::scatter(isHeaderOk);
        }
        else
        {
            isHeaderOk = headerOk();
        }
    }


    if
    (
        (
            io.readOpt() == IOobject::MUST_READ
         || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
        )
     || isHeaderOk
    )
    {
        readFile(masterOnly);
    }
    else
    {
        dictionary::operator=(dict);
    }

    dictionary::name() = IOobject::objectPath();
}
Ejemplo n.º 15
0
int main(int argc, char *argv[])
{
    timeSelector::addOptions();
    argList::validArgs.append("patchName");

    #include "setRootCase.H"
    #include "createTime.H"

    instantList timeDirs = timeSelector::select0(runTime, args);

    const word vecFieldName = "wallShearStress";

    #include "createMesh.H"

    runTime.setTime(timeDirs.last(), timeDirs.size()-1);

    const word patchName = args[1];

    forAll(timeDirs, timeI)
    {
        runTime.setTime(timeDirs[timeI], timeI);

        Info<< "Time = " << runTime.timeName() << endl;

        Info << "    Read vector field " << vecFieldName << endl;

        IOobject vecFieldHeader
        (
            vecFieldName,
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        );

        if (!vecFieldHeader.headerOk())
        {
            Info << "Unable to read vector field" << vecFieldName << endl;
            return EXIT_FAILURE;
        }

        const label patchI = mesh.boundaryMesh().findPatchID(patchName);
        if (patchI < 0)
        {
            FatalError << "Unable to find patch " << patchName << nl
                << exit(FatalError);
        }

        const volVectorField vectorField(vecFieldHeader, mesh);
        const scalarField magVecField = magSqr(vectorField.boundaryField()[patchI]);

        const scalar area = gSum(mesh.magSf().boundaryField()[patchI]);
        scalar meanSqr = gSum(magVecField * mesh.magSf().boundaryField()[patchI]) / area;

        Info << "    RMS(mag(" << vecFieldName << ")) = " << Foam::sqrt(meanSqr) << endl;
        Info << "    max(mag(" << vecFieldName << ")) = " << Foam::sqrt(Foam::gMax(magVecField));
        Info << endl;
    }
Foam::fileName Foam::fileOperations::masterFileOperation::processorsCasePath
(
    const IOobject& io
)
{
    return
        io.rootPath()
       /io.time().globalCaseName()
       /"processors";
}
Ejemplo n.º 17
0
Foam::autoPtr<Foam::dynamicFvMesh> Foam::dynamicFvMesh::New(const IOobject& io)
{
    // Enclose the creation of the dynamicMesh to ensure it is
    // deleted before the dynamicFvMesh is created otherwise the dictionary
    // is entered in the database twice
    IOdictionary dynamicMeshDict
    (
        IOobject
        (
            "dynamicMeshDict",
            io.time().constant(),
            io.db(),
            IOobject::MUST_READ,
            IOobject::NO_WRITE,
            false
        )
    );
    
    word dynamicFvMeshTypeName(dynamicMeshDict.lookup("dynamicFvMesh"));

    Info<< "Selecting dynamicFvMesh " << dynamicFvMeshTypeName << endl;

    dlLibraryTable::open
    (
        dynamicMeshDict,
        "dynamicFvMeshLibs",
        IOobjectConstructorTablePtr_
    );

    if (!IOobjectConstructorTablePtr_)
    {
        FatalErrorIn
        (
            "dynamicFvMesh::New(const IOobject&)"
        )   << "dynamicFvMesh table is empty"
            << exit(FatalError);
    }

    IOobjectConstructorTable::iterator cstrIter =
        IOobjectConstructorTablePtr_->find(dynamicFvMeshTypeName);

    if (cstrIter == IOobjectConstructorTablePtr_->end())
    {
        FatalErrorIn
        (
            "dynamicFvMesh::New(const IOobject&)"
        )   << "Unknown dynamicFvMesh type " << dynamicFvMeshTypeName
            << endl << endl
            << "Valid dynamicFvMesh types are :" << endl
            << IOobjectConstructorTablePtr_->sortedToc()
            << exit(FatalError);
    }

    return autoPtr<dynamicFvMesh>(cstrIter()(io));
}
Foam::autoPtr<Foam::dynamicFvMesh> Foam::dynamicFvMesh::New(const IOobject& io)
{
    // Note: - do not register the dictionary since dynamicFvMeshes themselves
    // do this.
    // - defaultRegion (region0) gets loaded from constant, other ones
    //   get loaded from constant/<regionname>. Normally we'd use
    //   polyMesh::dbDir() but we haven't got a polyMesh yet ...
    IOdictionary dict
    (
        IOobject
        (
            "dynamicMeshDict",
            io.time().constant(),
            (io.name() == polyMesh::defaultRegion ? "" : io.name()),
            io.db(),
            IOobject::MUST_READ_IF_MODIFIED,
            IOobject::NO_WRITE,
            false
        )
    );

    const word dynamicFvMeshTypeName(dict.lookup("dynamicFvMesh"));

    Info<< "Selecting dynamicFvMesh " << dynamicFvMeshTypeName << endl;

    const_cast<Time&>(io.time()).libs().open
    (
        dict,
        "dynamicFvMeshLibs",
        IOobjectConstructorTablePtr_
    );

    if (!IOobjectConstructorTablePtr_)
    {
        FatalErrorInFunction
            << "dynamicFvMesh table is empty"
            << exit(FatalError);
    }

    IOobjectConstructorTable::iterator cstrIter =
        IOobjectConstructorTablePtr_->find(dynamicFvMeshTypeName);

    if (cstrIter == IOobjectConstructorTablePtr_->end())
    {
        FatalErrorInFunction
            << "Unknown dynamicFvMesh type "
            << dynamicFvMeshTypeName << nl << nl
            << "Valid dynamicFvMesh types are :" << endl
            << IOobjectConstructorTablePtr_->sortedToc()
            << exit(FatalError);
    }

    return autoPtr<dynamicFvMesh>(cstrIter()(io));
}
void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
{
    IOobject phiHeader
    (
        "phi",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ
    );

    IOobject faceIbMaskHeader
    (
        "faceIbMask",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ
    );

    if (phiHeader.headerOk() && faceIbMaskHeader.headerOk())
    {
        Info<< "    Reading phi" << endl;
        surfaceScalarField phi(phiHeader, mesh);

        Info<< "    Reading faceIbMask" << endl;
        surfaceScalarField faceIbMask(faceIbMaskHeader, mesh);

        volScalarField contErr = fvc::div(faceIbMask*phi);

        scalar sumLocalContErr = runTime.deltaT().value()*
            mag(contErr)().weightedAverage(mesh.V()).value();

        scalar globalContErr = runTime.deltaT().value()*
            contErr.weightedAverage(mesh.V()).value();

        Info<< "IB time step continuity errors : sum local = "
            << sumLocalContErr
            << ", global = " << globalContErr
            << endl;

        volScalarField magContErr
        (
            "magContErr",
            mag(contErr)
        );
        magContErr.write();

    }
    else
    {
        Info<< "    No phi or faceIbMask" << endl;
    }

}
Foam::fileName Foam::fileOperations::masterFileOperation::processorsPath
(
    const IOobject& io,
    const word& instance
)
{
    return
        processorsCasePath(io)
       /instance
       /io.db().dbDir()
       /io.local();
}
Foam::tmp<Foam::IOField<Type>> Foam::reconstructLagrangianField
(
    const word& cloudName,
    const polyMesh& mesh,
    const PtrList<fvMesh>& meshes,
    const word& fieldName
)
{
    // Construct empty field on mesh
    tmp<IOField<Type>> tfield
    (
        new IOField<Type>
        (
            IOobject
            (
                fieldName,
                mesh.time().timeName(),
                cloud::prefix/cloudName,
                mesh,
                IOobject::NO_READ,
                IOobject::NO_WRITE
            ),
            Field<Type>(0)
        )
    );
    Field<Type>& field = tfield.ref();

    forAll(meshes, i)
    {
        // Check object on local mesh
        IOobject localIOobject
        (
            fieldName,
            meshes[i].time().timeName(),
            cloud::prefix/cloudName,
            meshes[i],
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        );

        if (localIOobject.headerOk())
        {
            IOField<Type> fieldi(localIOobject);

            label offset = field.size();
            field.setSize(offset + fieldi.size());

            forAll(fieldi, j)
            {
                field[offset + j] = fieldi[j];
            }
        }
Ejemplo n.º 22
0
int main(int argc, char *argv[])
{
    timeSelector::addOptions();

    #include "setRootCase.H"
    #include "createTime.H"

    instantList timeDirs = timeSelector::select0(runTime, args);

    const word vecFieldName = "U";

    #include "createMesh.H"

    runTime.setTime(timeDirs.last(), timeDirs.size()-1);


    forAll(timeDirs, timeI)
    {
        runTime.setTime(timeDirs[timeI], timeI);

        Info<< "Time = " << runTime.timeName() << endl;

        Info << "    Read vector field " << vecFieldName << endl;

        IOobject vecFieldHeader
        (
            vecFieldName,
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        );

        if (!vecFieldHeader.headerOk())
        {
            Info << "Unable to read vector field" << vecFieldName << endl;
            return EXIT_FAILURE;
        }

        const volVectorField vecField(vecFieldHeader, mesh);
        const volScalarField magVecField(magSqr(vecField));

        scalar volIntegral2 = 0;
        vector volIntegral(0, 0, 0);
        scalar volume = 0;

        forAll (magVecField, cellI)
        {
            volIntegral2 += magVecField[cellI]*magVecField.mesh().V()[cellI];
            volIntegral += vecField[cellI]*vecField.mesh().V()[cellI];
            volume += magVecField.mesh().V()[cellI];
        }
Ejemplo n.º 23
0
Foam::IOList<T>::IOList(const IOobject& io)
:
    regIOobject(io)
{
    if
    (
        io.readOpt() == IOobject::MUST_READ
     || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
    )
    {
        readStream(typeName) >> *this;
        close();
    }
Foam::binaryOperationSearchableSurface::binaryOperationSearchableSurface
(
    const IOobject& io,
    const dictionary& dict
)
:
    searchableSurface(io),
    aName_(dict.lookupOrDefault<word>("aName","A")),
    bName_(dict.lookupOrDefault<word>("bName","B")),
    a_(
        searchableSurface::New
        (
            word(dict.subDict("a").lookup("type")),
            IOobject(
                name()+"_"+word(dict.lookup("type"))+"_"+aName_,
                io.instance(),
                io.db(),
                io.readOpt(),
                io.writeOpt()
            ),
            dict.subDict("a")
        )
    ),
    b_(
        searchableSurface::New
        (
            word(dict.subDict("b").lookup("type")),
            IOobject(
                name()+"_"+word(dict.lookup("type"))+"_"+bName_,
                io.instance(),
                io.db(),
                io.readOpt(),
                io.writeOpt()
            ),
            dict.subDict("b")
        )
    ),
    nrARegions_(
        a().regions().size()
    ),
    nrBRegions_(
        b().regions().size()
    )
{
    if(aName_==bName_) {
        FatalErrorIn("binaryOperationSearchableSurface::binaryOperationSearchableSurface")
            << "'aName' and 'bName' have the same value " << aName_
                << " for " << name()
                << endl
                << exit(FatalError);
    }
    if(regions().size()!=size()) {
        FatalErrorIn("binaryOperationSearchableSurface::binaryOperationSearchableSurface")
            << "Number of regions " << regions().size() << " not equal to size "
                << size() << nl << "Regions: " << regions()
                << endl
                << exit(FatalError);

    }
}
Ejemplo n.º 25
0
Foam::featureEdgeMesh::featureEdgeMesh(const IOobject& io)
:
    regIOobject(io),
    edgeMesh(pointField(0), edgeList(0))
{
    if
    (
        io.readOpt() == IOobject::MUST_READ
     || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
    )
    {
        readStream(typeName) >> *this;
        close();
    }
Ejemplo n.º 26
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;
        }
    }
Ejemplo n.º 27
0
Foam::IOPtrList<T>::IOPtrList(const IOobject& io)
:
    regIOobject(io)
{
    if
    (
        io.readOpt() == IOobject::MUST_READ
     || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
    )
    {
        PtrList<T>::read(readStream(typeName), INew<T>());
        close();
    }
}
Ejemplo n.º 28
0
Foam::objectRegistry::objectRegistry
(
    const IOobject& io,
    const label nIoObjects
)
:
    regIOobject(io),
    HashTable<regIOobject*>(nIoObjects),
    time_(io.time()),
    parent_(io.db()),
    dbDir_(parent_.dbDir()/local()/name()),
    event_(1)
{
    writeOpt() = IOobject::AUTO_WRITE;
}
Ejemplo n.º 29
0
int main(int argc, char *argv[])
{
    timeSelector::addOptions();

#   include "addRegionOption.H"
#   include "setRootCase.H"
#   include "createTime.H"

    instantList timeDirs = timeSelector::select0(runTime, args);

#   include "createNamedMesh.H"

    forAll(timeDirs, timeI)
    {
        runTime.setTime(timeDirs[timeI], timeI);

        Info<< "Time = " << runTime.timeName() << nl << endl;

        const IOobjectList fieldObjs(mesh, runTime.timeName());
        const wordList objNames = fieldObjs.names();

        PtrList<volScalarField> vsf(objNames.size());
        PtrList<volVectorField> vvf(objNames.size());
        PtrList<volSphericalTensorField> vsptf(objNames.size());
        PtrList<volSymmTensorField> vsytf(objNames.size());
        PtrList<volTensorField> vtf(objNames.size());

        Info<< "Valid fields:" << endl;

        forAll(objNames, objI)
        {
            IOobject obj
            (
                objNames[objI],
                runTime.timeName(),
                mesh,
                IOobject::MUST_READ
            );

            if (obj.headerOk())
            {
                addToFieldList<scalar>(vsf, obj, objI, mesh);
                addToFieldList<vector>(vvf, obj, objI, mesh);
                addToFieldList<sphericalTensor>(vsptf, obj, objI, mesh);
                addToFieldList<symmTensor>(vsytf, obj, objI, mesh);
                addToFieldList<tensor>(vtf, obj, objI, mesh);
            }
        }
Foam::tmp<Foam::DimensionedField<Type, Foam::volMesh>>
Foam::fvFieldReconstructor::reconstructFvVolumeInternalField
(
    const IOobject& fieldIoObject
) const
{
    // Read the field for all the processors
    PtrList<DimensionedField<Type, volMesh>> procFields
    (
        procMeshes_.size()
    );

    forAll(procMeshes_, proci)
    {
        procFields.set
        (
            proci,
            new DimensionedField<Type, volMesh>
            (
                IOobject
                (
                    fieldIoObject.name(),
                    procMeshes_[proci].time().timeName(),
                    procMeshes_[proci],
                    IOobject::MUST_READ,
                    IOobject::NO_WRITE
                ),
                procMeshes_[proci]
            )
        );
    }