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


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

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


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

示例1: writeZones

// Hack to do zones which have Lists in them. See above.
bool writeZones(const word& name, const fileName& meshDir, Time& runTime)
{
    IOobject io
    (
        name,
        runTime.timeName(),
        meshDir,
        runTime,
        IOobject::MUST_READ,
        IOobject::NO_WRITE,
        false
    );

    bool writeOk = false;

    if (io.headerOk())
    {
        Info<< "        Reading " << io.headerClassName()
            << " : " << name << endl;

        // Switch off type checking (for reading e.g. faceZones as
        // generic list of dictionaries).
        const word oldTypeName = IOPtrList<entry>::typeName;
        const_cast<word&>(IOPtrList<entry>::typeName) = word::null;

        IOPtrList<entry> meshObject(io);

        forAll(meshObject, i)
        {
            if (meshObject[i].isDict())
            {
                dictionary& d = meshObject[i].dict();

                if (d.found("faceLabels"))
                {
                    d.set("faceLabels", labelList(d.lookup("faceLabels")));
                }

                if (d.found("flipMap"))
                {
                    d.set("flipMap", boolList(d.lookup("flipMap")));
                }

                if (d.found("cellLabels"))
                {
                    d.set("cellLabels", labelList(d.lookup("cellLabels")));
                }

                if (d.found("pointLabels"))
                {
                    d.set("pointLabels", labelList(d.lookup("pointLabels")));
                }
            }
        }

        const_cast<word&>(IOPtrList<entry>::typeName) = oldTypeName;
        // Fake type back to what was in field
        const_cast<word&>(meshObject.type()) = io.headerClassName();

        Info<< "        Writing " << name << endl;

        // Force writing as ascii
        writeOk = meshObject.regIOobject::writeObject
        (
            IOstream::ASCII,
            IOstream::currentVersion,
            runTime.writeCompression()
        );
    }
开发者ID:BarisCumhur,项目名称:OpenFOAM-2.3.x,代码行数:70,代码来源:foamFormatConvert.C

示例2: if

void Foam::functionObjects::fieldCoordinateSystemTransform::transform
(
    const word& fieldName
)
{
    typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
    typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;

    if (mesh_.foundObject<VolFieldType>(fieldName))
    {
        DebugInfo
            << type() << ": Field " << fieldName << " already in database"
            << endl;

        transformField<VolFieldType>
        (
            mesh_.lookupObject<VolFieldType>(fieldName)
        );
    }
    else if (mesh_.foundObject<SurfaceFieldType>(fieldName))
    {
        DebugInfo
            << type() << ": Field " << fieldName << " already in database"
            << endl;

        transformField<SurfaceFieldType>
        (
            mesh_.lookupObject<SurfaceFieldType>(fieldName)
        );
    }
    else
    {
        IOobject fieldHeader
        (
            fieldName,
            mesh_.time().timeName(),
            mesh_,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        );

        if
        (
            fieldHeader.headerOk()
         && fieldHeader.headerClassName() == VolFieldType::typeName
        )
        {
            DebugInfo
                << type() << ": Field " << fieldName << " read from file"
                << endl;

            transformField<VolFieldType>
            (
                mesh_.lookupObject<VolFieldType>(fieldName)
            );
        }
        else if
        (
            fieldHeader.headerOk()
         && fieldHeader.headerClassName() == SurfaceFieldType::typeName
        )
        {
            DebugInfo
                << type() << ": Field " << fieldName << " read from file"
                << endl;

            transformField<SurfaceFieldType>
            (
                mesh_.lookupObject<SurfaceFieldType>(fieldName)
            );
        }
    }
}
开发者ID:EricAlex,项目名称:OpenFOAM-dev,代码行数:73,代码来源:fieldCoordinateSystemTransformTemplates.C

示例3: main

int main(int argc, char *argv[])
{
    timeSelector::addOptions();
    #include "addRegionOption.H"
    argList::validArgs.append("fieldName");
    argList::validArgs.append("patchName");
    #include "setRootCase.H"
    #include "createTime.H"
    instantList timeDirs = timeSelector::select0(runTime, args);
    #include "createNamedMesh.H"

    const word fieldName = args[1];
    const word patchName = args[2];

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

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

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

            const label patchI = mesh.boundaryMesh().findPatchID(patchName);
            if (patchI < 0)
            {
                FatalError
                    << "Unable to find patch " << patchName << nl
                    << exit(FatalError);
            }
            scalar area = gSum(mesh.magSf().boundaryField()[patchI]);

            bool done = false;
            printAverage<volScalarField>(mesh, io, area, patchI, done);
            printAverage<volVectorField>(mesh, io, area, patchI, done);
            printAverage<volSphericalTensorField>(mesh, io, area, patchI, done);
            printAverage<volSymmTensorField>(mesh, io, area, patchI, done);
            printAverage<volTensorField>(mesh, io, area, patchI, done);

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

        Info<< endl;
    }
开发者ID:BarisCumhur,项目名称:OpenFOAM-dev,代码行数:64,代码来源:patchAverage.C


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