当前位置: 首页>>代码示例>>C++>>正文


C++ IOobject::headerOk方法代码示例

本文整理汇总了C++中IOobject::headerOk方法的典型用法代码示例。如果您正苦于以下问题:C++ IOobject::headerOk方法的具体用法?C++ IOobject::headerOk怎么用?C++ IOobject::headerOk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IOobject的用法示例。


在下文中一共展示了IOobject::headerOk方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: calc

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;
    }

}
开发者ID:CFMS,项目名称:foam-extend-foam-extend-3.2,代码行数:53,代码来源:ibContinuityError.C

示例2: createDummyFvMeshFiles

void createDummyFvMeshFiles(const polyMesh& mesh, const word& regionName)
{
    // Create dummy system/fv*
    {
        IOobject io
        (
            "fvSchemes",
            mesh.time().system(),
            regionName,
            mesh,
            IOobject::NO_READ,
            IOobject::NO_WRITE,
            false
        );

        Info<< "Testing:" << io.objectPath() << endl;

        if (!io.headerOk())
        {
            Info<< "Writing dummy " << regionName/io.name() << endl;
            dictionary dummyDict;
            dictionary divDict;
            dummyDict.add("divSchemes", divDict);
            dictionary gradDict;
            dummyDict.add("gradSchemes", gradDict);
            dictionary laplDict;
            dummyDict.add("laplacianSchemes", laplDict);

            IOdictionary(io, dummyDict).regIOobject::write();
        }
    }
    {
        IOobject io
        (
            "fvSolution",
            mesh.time().system(),
            regionName,
            mesh,
            IOobject::NO_READ,
            IOobject::NO_WRITE,
            false
        );

        if (!io.headerOk())
        {
            Info<< "Writing dummy " << regionName/io.name() << endl;
            dictionary dummyDict;
            IOdictionary(io, dummyDict).regIOobject::write();
        }
    }
}
开发者ID:iYohey,项目名称:OpenFOAM-dev,代码行数:51,代码来源:extrudeMesh.C

示例3: forAll

    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;
            }
        }
开发者ID:Brzous,项目名称:WindFOAM,代码行数:31,代码来源:dsmcFieldsCalc.C

示例4: zones

Foam::wordList Foam::vtkPV4Foam::readZoneNames(const word& zoneType)
{
    wordList zoneNames;

    // mesh not loaded - read from file
    IOobject ioObj
    (
        zoneType,
        dbPtr_().findInstance
        (
            meshDir_,
            zoneType,
            IOobject::READ_IF_PRESENT
        ),
        meshDir_,
        dbPtr_(),
        IOobject::READ_IF_PRESENT,
        IOobject::NO_WRITE,
        false
    );

    if (ioObj.headerOk())
    {
        zonesEntries zones(ioObj);

        zoneNames.setSize(zones.size());
        forAll(zones, zoneI)
        {
            zoneNames[zoneI] = zones[zoneI].keyword();
        }
    }
开发者ID:GoldenMan123,项目名称:openfoam-extend-foam-extend-3.1,代码行数:31,代码来源:vtkPV4FoamUpdateInfo.C

示例5:

Foam::IOobject Foam::fv::IOoptionList::createIOobject
(
    const fvMesh& mesh
) const
{
    IOobject io
    (
        "fvOptions",
        mesh.time().system(),
        mesh,
        IOobject::MUST_READ,
        IOobject::NO_WRITE
    );

    if (io.headerOk())
    {
        Info<< "Creating fintite volume options from " << io.name() << nl
            << endl;

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

        io.readOpt() = IOobject::NO_READ;
        return io;
    }
}
开发者ID:ADGlassby,项目名称:OpenFOAM-2.2.x,代码行数:30,代码来源:fvIOoptionList.C

示例6: writeScalarMultValues

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);
    }
}
开发者ID:TsukasaHori,项目名称:openfoam-extend-foam-extend-3.1,代码行数:26,代码来源:scalarMult.C

示例7: dict

void replaceBoundaryType
(
    const fvMesh& mesh,
    const word& fieldName,
    const word& boundaryType,
    const string& boundaryValue
)
{
    IOobject header
    (
        fieldName,
        mesh.time().timeName(),
        mesh,
        IOobject::MUST_READ,
        IOobject::NO_WRITE
    );

    if (!header.headerOk())
    {
        return;
    }

    Info<< "Updating boundary types for field " << header.name() << endl;

    const word oldTypeName = IOdictionary::typeName;
    const_cast<word&>(IOdictionary::typeName) = word::null;

    IOdictionary dict(header);

    const_cast<word&>(IOdictionary::typeName) = oldTypeName;
    const_cast<word&>(dict.type()) = dict.headerClassName();

    // Make a backup of the old file
    if (mvBak(dict.objectPath(), "old"))
    {
        Info<< "    Backup original file to "
            << (dict.objectPath() + ".old") << endl;
    }

    // Loop through boundary patches and update
    const polyBoundaryMesh& bMesh = mesh.boundaryMesh();
    dictionary& boundaryDict = dict.subDict("boundaryField");
    forAll(bMesh, patchI)
    {
        if (isA<wallPolyPatch>(bMesh[patchI]))
        {
            word patchName = bMesh[patchI].name();
            dictionary& oldPatch = boundaryDict.subDict(patchName);

            dictionary newPatch(dictionary::null);
            newPatch.add("type", boundaryType);
            newPatch.add("value", ("uniform " + boundaryValue).c_str());

            oldPatch = newPatch;
        }
    }

    Info<< "    writing updated " << dict.name() << nl << endl;
    dict.regIOobject::write();
}
开发者ID:000861,项目名称:OpenFOAM-2.1.x,代码行数:60,代码来源:applyWallFunctionBoundaryConditions.C

示例8: fieldTypes

bool Foam::sampledSurfaceElevation::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)";
            }
        }
    }
开发者ID:dyj19901127,项目名称:waves2Foam,代码行数:29,代码来源:sampledSurfaceElevation.C

示例9: propsDict

void Foam::StandardWallInteraction<CloudType>::readProps()
{
    if (!this->owner().solution().transient())
    {
        return;
    }

    IOobject propsDictHeader
    (
        "standardWallInteractionProperties",
        this->owner().db().time().timeName(),
        "uniform"/cloud::prefix/this->owner().name(),
        this->owner().db(),
        IOobject::MUST_READ_IF_MODIFIED,
        IOobject::NO_WRITE,
        false
    );

    if (propsDictHeader.headerOk())
    {
        const IOdictionary propsDict(propsDictHeader);
        propsDict.readIfPresent("nEscape", nEscape0_);
        propsDict.readIfPresent("massEscape", massEscape0_);
        propsDict.readIfPresent("nStick", nStick0_);
        propsDict.readIfPresent("massStick", massStick0_);
    }
}
开发者ID:AmaneShino,项目名称:OpenFOAM-2.0.x,代码行数:27,代码来源:StandardWallInteraction.C

示例10: main

int main(int argc, char *argv[])
{
    argList::validArgs.append("scaling factor");

#   include "setRootCase.H"

    const scalar scaleFactor = args.argRead<scalar>(1);

#   include "createTime.H"
#   include "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;
}
开发者ID:AmaneShino,项目名称:OpenFOAM-2.0.x,代码行数:60,代码来源:deformedGeom.C

示例11:

Foam::IOobject Foam::IOMRFZoneList::createIOobject
(
    const fvMesh& mesh
) const
{
    IOobject io
    (
        "MRFProperties",
        mesh.time().constant(),
        mesh,
        IOobject::MUST_READ,
        IOobject::NO_WRITE
    );

    if (io.headerOk())
    {
        Info<< "Creating MRF zone list from " << io.name() << endl;

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

        io.readOpt() = IOobject::NO_READ;
        return io;
    }
}
开发者ID:mattijsjanssens,项目名称:OpenFOAM-dev,代码行数:29,代码来源:IOMRFZoneList.C

示例12: calc

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;
}
开发者ID:Cescfangs,项目名称:OpenFOAM-1.7.x,代码行数:59,代码来源:vorticity.C

示例13: main

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;
    }
开发者ID:lento234,项目名称:OF-2.3.x,代码行数:59,代码来源:fieldIntegrate.C

示例14: main

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;
    }
开发者ID:endJunction,项目名称:flowStats,代码行数:58,代码来源:tauwRMS.C

示例15: dataType

word postProcessingWaves::dataType()
{
    std::stringstream ss;
    ss << callName_ << "_0";

    IOobject fileHeader
    (
        ss.str(),
        rT_.constant(),
        addDir_,
        rT_,
        IOobject::MUST_READ
    );

    // The inquiry to fileHeader.headerOk() is needed to update
    // headerClassName() from IOobject. This is weird but not looked into.
#if OFPLUSBRANCH == 1
    #if OFVERSION<1606
        if (!fileHeader.headerOk())
        {
        }
    #else
        // Dummy question to read in the class name
        fileHeader.typeHeaderOk<volScalarField>(false);
    #endif
#else
    if (!fileHeader.headerOk())
    {
    }
#endif

    if (fileHeader.headerClassName() == "scalarField")
    {
        return "scalar";
    }
    else if (fileHeader.headerClassName() == "vectorField")
    {
        return "vector";
    }
    else
    {
        return "unknown";
    }
}
开发者ID:Unofficial-Extend-Project-Mirror,项目名称:openfoam-extend-Breeder1.6-other-waves2Foam,代码行数:44,代码来源:postProcessingWaves.C


注:本文中的IOobject::headerOk方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。