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

}
Ejemplo n.º 2
0
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();
        }
    }
}
Ejemplo n.º 3
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;
            }
        }
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();
        }
    }
Ejemplo n.º 5
0
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;
    }
}
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);
    }
}
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();
}
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)";
            }
        }
    }
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_);
    }
}
Ejemplo n.º 10
0
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;
}
Ejemplo n.º 11
0
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;
    }
}
Ejemplo n.º 12
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.º 13
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.º 14
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;
    }
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";
    }
}
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.º 17
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.º 18
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.º 19
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);
            }
        }
Ejemplo n.º 20
0
void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
{
    bool writeResults = !args.optionFound("noWrite");

    IOobject kheader
    (
        "k",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ
    );

    if (kheader.headerOk())
    {
        Info<< "    Reading k" << endl;
        volScalarField k(kheader, mesh);

        Info<< "    Calculating uprime" << endl;
        volScalarField uprime
        (
            IOobject
            (
                "uprime",
                runTime.timeName(),
                mesh,
                IOobject::NO_READ
            ),
            sqrt((2.0/3.0)*k)
        );

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

        if (writeResults)
        {
            uprime.write();
        }
    }
    else
    {
        Info<< "    No k" << endl;
    }

    Info<< "\nEnd\n" << endl;
}
Ejemplo n.º 21
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 enstrophy" << endl;
        volScalarField enstrophy
        (
            IOobject
            (
                "enstrophy",
                runTime.timeName(),
                mesh,
                IOobject::NO_READ
            ),
            0.5*magSqr(fvc::curl(U))
        );

        Info<< "enstrophy(U) max/min : "
            << max(enstrophy).value() << " "
            << min(enstrophy).value() << endl;

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

    Info<< "\nEnd\n" << endl;
}
Ejemplo n.º 22
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;
        }
    }
Ejemplo n.º 23
0
void Foam::calcTypes::interpolate::calc
(
    const argList& args,
    const Time& runTime,
    const fvMesh& mesh
)
{
    #ifdef FOAM_DEV
        const word& fieldName = args.additionalArgs()[1];
    #else
        const word fieldName = args[2];
    #endif

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

    // Check field exists
    if (fieldHeader.headerOk())
    {
        bool processed = false;

        writeInterpolateField<scalar>(fieldHeader, mesh, processed);
        writeInterpolateField<vector>(fieldHeader, mesh, processed);
        writeInterpolateField<sphericalTensor>(fieldHeader, mesh, processed);
        writeInterpolateField<symmTensor>(fieldHeader, mesh, processed);
        writeInterpolateField<tensor>(fieldHeader, mesh, processed);

        if (!processed)
        {
            FatalError
                << "Unable to process " << fieldName << nl
                << "No call to interpolate for fields of type "
                << fieldHeader.headerClassName() << nl << nl
                << exit(FatalError);
        }
    }
    else
    {
        Info<< "    No " << fieldName << endl;
    }
}
Ejemplo n.º 24
0
void calcCompressibleYPlus
(
    const fvMesh& mesh,
    const Time& runTime,
    const volVectorField& U,
    volScalarField& yPlus
)
{
    IOobject rhoHeader
    (
        "rho",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ,
        IOobject::NO_WRITE
    );

    if (!rhoHeader.headerOk())
    {
        Info<< "    no rho field" << endl;
        return;
    }

    Info<< "Reading field rho\n" << endl;
    volScalarField rho(rhoHeader, mesh);

    #include "compressibleCreatePhi.H"

    autoPtr<fluidThermo> pThermo(fluidThermo::New(mesh));
    fluidThermo& thermo = pThermo();

    autoPtr<compressible::turbulenceModel> turbulenceModel
    (
        compressible::turbulenceModel::New
        (
            rho,
            U,
            phi,
            thermo
        )
    );

    calcYPlus(turbulenceModel, mesh, U, yPlus);
}
Ejemplo n.º 25
0
void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
{
    IOobject Uheader
    (
        "U",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ
    );

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

        volTensorField gradU = fvc::grad(U);
        volScalarField magD = mag(symm(gradU));
        volScalarField magOmega = mag(skew(gradU));
        dimensionedScalar smallMagD("smallMagD", magD.dimensions(), SMALL);

        Info<< "    Calculating flowType" << endl;

        volScalarField flowType
        (
            IOobject
            (
                "flowType",
                runTime.timeName(),
                mesh,
                IOobject::NO_READ
            ),
            (magD - magOmega)/(magD + magOmega + smallMagD)
        );

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

    Info<< "\nEnd\n" << endl;
}
void Foam::calcTypes::domainIntegrate::calc
(
    const argList& args,
    const Time& runTime,
    const fvMesh& mesh
)
{
    const word& fieldName = args.additionalArgs()[1];

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

    // Check field exists
    if (fieldHeader.headerOk())
    {
        bool processed = false;

        calcDomainIntegrate<scalar>(fieldHeader, mesh, processed);
        calcDomainIntegrate<vector>(fieldHeader, mesh, processed);
        calcDomainIntegrate<sphericalTensor>(fieldHeader, mesh, processed);
        calcDomainIntegrate<symmTensor>(fieldHeader, mesh, processed);
        calcDomainIntegrate<tensor>(fieldHeader, mesh, processed);

        if (!processed)
        {
            FatalError
                << "Unable to process " << fieldName << nl
                << "No call to mag for fields of type "
                << fieldHeader.headerClassName() << nl << nl
                << exit(FatalError);
        }
    }
    else
    {
        Info<< "    No " << fieldName << endl;
    }
}
Ejemplo n.º 27
0
void Foam::calcTypes::components::calc
(
    const argList& args,
    const Time& runTime,
    const fvMesh& mesh
)
{
    const word fieldName = args[2];

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

    // Check field exists
    if (fieldHeader.headerOk())
    {
        bool processed = false;

        writeComponentFields<vector>(fieldHeader, mesh, processed);
        writeComponentFields<sphericalTensor>(fieldHeader, mesh, processed);
        writeComponentFields<symmTensor>(fieldHeader, mesh, processed);
        writeComponentFields<tensor>(fieldHeader, mesh, processed);

        if (!processed)
        {
            FatalError
                << "Unable to process " << fieldName << nl
                << "No call to components for fields of type "
                << fieldHeader.headerClassName() << nl << nl
                << exit(FatalError);
        }
    }
    else
    {
        Info<< "    No " << fieldName << endl;
    }
}
Ejemplo n.º 28
0
bool loadFieldFunction(
    fvMesh &mesh,
    const word &fName,
    SLPtrList<FieldType> &fieldList
) {
    const Time &runTime=mesh.time();

    IOobject f
        (
            fName,
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        );
    f.headerOk();
    word className=f.headerClassName();

    if(className==FieldType::typeName) {
        Info << "Reading field " << fName << " of type "
            << FieldType::typeName << endl;
        fieldList.append(
            new FieldType
            (
                IOobject
                (
                    fName,
                    runTime.timeName(),
                    mesh,
                    IOobject::MUST_READ,
                    IOobject::AUTO_WRITE
                ),
                mesh
            )
        );
        return true;
    } else {
        return false;
    }
}
Ejemplo n.º 29
0
void Foam::calcTypes::div::calc
(
    const argList& args,
    const Time& runTime,
    const fvMesh& mesh
)
{
    const word fieldName = args[2];

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

    // Check field exists
    if (fieldHeader.headerOk())
    {
        bool processed = false;

        writeDivField<surfaceScalarField>(fieldHeader, mesh, processed);
        writeDivField<volVectorField>(fieldHeader, mesh, processed);

        if (!processed)
        {
                FatalError
                    << "Unable to process " << fieldName << nl
                    << "No call to div for fields of type "
                    << fieldHeader.headerClassName() << nl << nl
                    << exit(FatalError);
        }
    }
    else
    {
        Info<< "    No " << fieldName << endl;
    }
}
Ejemplo n.º 30
0
void Foam::InjectionModel<CloudType>::readProps()
{
    IOobject propsDictHeader
    (
        "injectionProperties",
        owner_.db().time().timeName(),
        "uniform"/cloud::prefix/owner_.name(),
        owner_.db(),
        IOobject::MUST_READ,
        IOobject::NO_WRITE,
        false
    );

    if (propsDictHeader.headerOk())
    {
        const IOdictionary propsDict(propsDictHeader);

        propsDict.readIfPresent("massInjected", massInjected_);
        propsDict.readIfPresent("nInjections", nInjections_);
        propsDict.readIfPresent("parcelsAddedTotal", parcelsAddedTotal_);
        propsDict.readIfPresent("timeStep0", timeStep0_);
    }
}