Esempio n. 1
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);
            }
        }
Esempio n. 2
0
Foam::baseAtmosphere::baseAtmosphere
(
    const wordList& partNames,
    const fvMesh& mesh,
    const dictionary dict
)
:
    PtrList<fluidSpecie>(partNames.size())
{
    for(label ip = 0; ip < size(); ip++)
    {
        set
        (
            ip,
            new fluidSpecie
            (
                partNames[ip],
                IOobject(partNames[ip]+"VapourRho", mesh.time().timeName(), mesh,
                         IOobject::MUST_READ, IOobject::AUTO_WRITE),
                IOobject(partNames[ip]+"LiquidFrac", mesh.time().timeName(), mesh,
                         IOobject::MUST_READ, IOobject::AUTO_WRITE),
                mesh,
                dict.subDict(partNames[ip])
            )
        );
    }
}
Foam::tmp<GeoField> Foam::uniformInterpolate
(
    const IOobject& fieldIO,
    const word& fieldName,
    const wordList& times,
    const scalarField& weights,
    const objectRegistry& fieldsCache
)
{
    // Look up the first field
    const objectRegistry& time0Fields = fieldsCache.lookupObject
    <
        const objectRegistry
    >
    (
        times[0]
    );
    const GeoField& field0 = time0Fields.lookupObject
    <
        const GeoField
    >
    (
        fieldName
    );


    // Interpolate
    tmp<GeoField> tfld(new GeoField(fieldIO, weights[0]*field0));
    GeoField& fld = tfld.ref();

    for (label i = 1; i < times.size(); ++i)
    {
        const objectRegistry& timeIFields = fieldsCache.lookupObject
        <
            const objectRegistry
        >
        (
            times[i]
        );
        const GeoField& fieldI = timeIFields.lookupObject
        <
            const GeoField
        >
        (
            fieldName
        );

        fld += weights[i]*fieldI;
    }

    return tfld;
}
Esempio n. 4
0
Foam::dimensionSets::dimensionSets
(
    const HashTable<dimensionedScalar>& units,
    const wordList& unitNames
)
:
    units_(unitNames.size()),
    conversion_(unitNames.size()),
    conversionPivots_(unitNames.size()),
    valid_(false)
{
    forAll(unitNames, i)
    {
        units_.set
        (
            i,
            new dimensionedScalar
            (
                units[unitNames[i]]
            )
        );
    }
// Get patch ids of named patches
Foam::labelHashSet Foam::cellDistFuncs::getPatchIDs
(
    const wordList& patchNames
) const
{
    const polyBoundaryMesh& bMesh = mesh().boundaryMesh();

    // Construct Set of patchNames for easy checking if included
    HashSet<word> patchNamesHash(patchNames.size());

    forAll(patchNames, patchI)
    {
        patchNamesHash.insert(patchNames[patchI]);
    }
void postProcessingWaves::writeNameDict
(
    const scalar& dt,
    const wordList& names
)
{
    IOdictionary xyz
    (
        IOobject
        (
            callName_ + "_dict",
            rT_.constant(),
            addDir_,
            rT_,
            IOobject::NO_READ,
            IOobject::NO_WRITE
        )
    );

    // Adding deltaT information to the dictionary
    xyz.add("deltaT", dt, true);

    // Adding indexing to the dictionary
    labelList index( names.size(), 0 );

    forAll (index, indexi)
    {
        index[indexi] = indexi;
    }

    xyz.add("index", index, true);

    // Adding the names
    xyz.add("names", names, true);

    // Write the dictionary
    xyz.regIOobject::write();
}
Esempio n. 7
0
void Foam::preservePatchTypes
(
    const objectRegistry& obr,
    const word& meshInstance,
    const fileName& meshDir,
    const wordList& patchNames,
    PtrList<dictionary>& patchDicts,
    const word& defaultFacesName,
    word& defaultFacesType
)
{
    patchDicts.setSize(patchNames.size());

    dictionary patchDictionary;

    // Read boundary file as single dictionary
    {
        IOobject patchEntriesHeader
        (
            "boundary",
            meshInstance,
            meshDir,
            obr,
            IOobject::MUST_READ,
            IOobject::NO_WRITE,
            false
        );

        if (patchEntriesHeader.typeHeaderOk<polyBoundaryMesh>(true))
        {
            // Create a list of entries from the boundary file.
            polyBoundaryMeshEntries patchEntries(patchEntriesHeader);

            forAll(patchEntries, patchi)
            {
                patchDictionary.add(patchEntries[patchi]);
            }
        }
Esempio n. 8
0
void coupledInfo<MeshType>::setField
(
    const wordList& fieldNames,
    const dictionary& fieldDicts,
    const label internalSize,
    PtrList<GeomField>& fields
) const
{
    typedef typename GeomField::InternalField InternalField;
    typedef typename GeomField::PatchFieldType PatchFieldType;
    typedef typename GeomField::GeometricBoundaryField GeomBdyFieldType;
    typedef typename GeomField::DimensionedInternalField DimInternalField;

    // Size up the pointer list
    fields.setSize(fieldNames.size());

    // Define patch type names, assumed to be
    // common for volume and surface fields
    word emptyType(emptyPolyPatch::typeName);
    word processorType(processorPolyPatch::typeName);

    forAll(fieldNames, i)
    {
        // Create and map the patch field values
        label nPatches = subMesh().boundary().size();

        // Create field parts
        PtrList<PatchFieldType> patchFields(nPatches);

        // Read dimensions
        dimensionSet dimSet
        (
            fieldDicts.subDict(fieldNames[i]).lookup("dimensions")
        );

        // Read the internal field
        InternalField internalField
        (
            "internalField",
            fieldDicts.subDict(fieldNames[i]),
            internalSize
        );

        // Create dummy types for initial field creation
        forAll(patchFields, patchI)
        {
            if (patchI == (nPatches - 1))
            {
                // Artificially set last patch
                patchFields.set
                (
                    patchI,
                    PatchFieldType::New
                    (
                        emptyType,
                        subMesh().boundary()[patchI],
                        DimInternalField::null()
                    )
                );
            }
            else
            {
                patchFields.set
                (
                    patchI,
                    PatchFieldType::New
                    (
                        PatchFieldType::calculatedType(),
                        subMesh().boundary()[patchI],
                        DimInternalField::null()
                    )
                );
            }
        }

        // Create field with dummy patches
        fields.set
        (
            i,
            new GeomField
            (
                IOobject
                (
                    fieldNames[i],
                    subMesh().time().timeName(),
                    subMesh(),
                    IOobject::NO_READ,
                    IOobject::NO_WRITE,
                    false
                ),
                subMesh(),
                dimSet,
                internalField,
                patchFields
            )
        );

        // Set correct references for patch internal fields,
        // and fetch values from the supplied geometric field dictionaries
        GeomBdyFieldType& bf = fields[i].boundaryField();

        forAll(bf, patchI)
        {
            if (patchI == (nPatches - 1))
            {
                // Artificially set last patch
                bf.set
                (
                    patchI,
                    PatchFieldType::New
                    (
                        emptyType,
                        subMesh().boundary()[patchI],
                        fields[i].dimensionedInternalField()
                    )
                );
            }
            else
            if (isA<processorPolyPatch>(subMesh().boundary()[patchI].patch()))
            {
                bf.set
                (
                    patchI,
                    PatchFieldType::New
                    (
                        processorType,
                        subMesh().boundary()[patchI],
                        fields[i].dimensionedInternalField()
                    )
                );
            }
            else
            {
                bf.set
                (
                    patchI,
                    PatchFieldType::New
                    (
                        subMesh().boundary()[patchI],
                        fields[i].dimensionedInternalField(),
                        fieldDicts.subDict
                        (
                            fieldNames[i]
                        ).subDict("boundaryField").subDict
                        (
                            subMesh().boundary()[patchI].name()
                        )
                    )
                );
            }
        }
    }
int main(int argc, char *argv[])
{
#   include "addRegionOption.H"
    argList::validArgs.append("faceZone");
    argList::validArgs.append("patch");
    argList::validOptions.insert("additionalPatches", "(patch2 .. patchN)");
    argList::validOptions.insert("internalFacesOnly", "");
    argList::validOptions.insert("overwrite", "");

#   include "setRootCase.H"
#   include "createTime.H"
    runTime.functionObjects().off();
#   include "createNamedMesh.H"
    const word oldInstance = mesh.pointsInstance();

    const polyBoundaryMesh& patches = mesh.boundaryMesh();
    const faceZoneMesh& faceZones = mesh.faceZones();

    // Faces to baffle
    faceZoneID zoneID(args.additionalArgs()[0], faceZones);

    Info<< "Converting faces on zone " << zoneID.name()
        << " into baffles." << nl << endl;

    if (zoneID.index() == -1)
    {
        FatalErrorIn(args.executable()) << "Cannot find faceZone "
            << zoneID.name() << endl
            << "Valid zones are " << faceZones.names()
            << exit(FatalError);
    }

    const faceZone& fZone = faceZones[zoneID.index()];

    Info<< "Found " << returnReduce(fZone.size(), sumOp<label>())
        << " faces on zone " << zoneID.name() << nl << endl;

    // Make sure patches and zoneFaces are synchronised across couples
    patches.checkParallelSync(true);
    fZone.checkParallelSync(true);

    // Patches to put baffles into
    DynamicList<label> newPatches(1);

    word patchName(args.additionalArgs()[1]);
    newPatches.append(findPatchID(mesh, patchName));
    Info<< "Using patch " << patchName
        << " at index " << newPatches[0] << endl;


    // Additional patches
    if (args.optionFound("additionalPatches"))
    {
        const wordList patchNames
        (
            args.optionLookup("additionalPatches")()
        );

        newPatches.reserve(patchNames.size() + 1);
        forAll(patchNames, i)
        {
            newPatches.append(findPatchID(mesh, patchNames[i]));
            Info<< "Using additional patch " << patchNames[i]
                << " at index " << newPatches[newPatches.size()-1] << endl;
        }
    }