Foam::tmp<Foam::Field<Type> > Foam::fieldValues::faceSource::setFieldValues
(
    const word& fieldName
) const
{
    typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
    typedef GeometricField<Type, fvPatchField, volMesh> vf;

    if (source_ != stSampledSurface && obr_.foundObject<sf>(fieldName))
    {
        return filterField(obr_.lookupObject<sf>(fieldName), true);
    }
    else if (obr_.foundObject<vf>(fieldName))
    {
        if (surfacePtr_.valid())
        {
            return surfacePtr_().sample(obr_.lookupObject<vf>(fieldName));
        }
        else
        {
            return filterField(obr_.lookupObject<vf>(fieldName), true);
        }
    }

    return tmp<Field<Type> >(new Field<Type>(0));
}
예제 #2
0
Foam::tmp<Foam::Field<Type> > Foam::fieldValues::cellSource::setFieldValues
(
    const word& fieldName,
    const bool mustGet
) const
{
    typedef GeometricField<Type, fvPatchField, volMesh> vf;

    if (obr_.foundObject<vf>(fieldName))
    {
        return filterField(obr_.lookupObject<vf>(fieldName));
    }

    if (mustGet)
    {
        FatalErrorIn
        (
            "Foam::tmp<Foam::Field<Type> > "
            "Foam::fieldValues::cellSource::setFieldValues"
            "("
                "const word&, "
                "const bool"
            ") const"
        )   << "Field " << fieldName << " not found in database"
            << abort(FatalError);
    }

    return tmp<Field<Type> >(new Field<Type>(0.0));
}
예제 #3
0
void Foam::fieldValues::cellSource::initialise(const dictionary& dict)
{
    setCellZoneCells();

    if (nCells_ == 0)
    {
        WarningIn
        (
            "Foam::fieldValues::cellSource::initialise(const dictionary&)"
        )
            << type() << " " << name_ << ": "
            << sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl
            << "    Source has no cells - deactivating" << endl;

        active_ = false;
        return;
    }

    Info<< type() << " " << name_ << ":"
        << sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl
        << "    total cells  = " << nCells_ << nl
        << "    total volume = " << gSum(filterField(mesh().V()))
        << nl << endl;

    if (operation_ == opWeightedAverage)
    {
        dict.lookup("weightField") >> weightFieldName_;
        Info<< "    weight field = " << weightFieldName_;
    }
예제 #4
0
 void filterIntegerField(const std::string& keyword, std::vector<int>& output_field)
 {
     if (deck_->hasKeyword(keyword)) {
         const std::vector<int>& field = deck_->getKeyword(keyword)->getIntData();
         filterField(field, output_field);
     }
 }
예제 #5
0
void Foam::fieldValues::cellSource::write()
{
    fieldValue::write();

    if (active_)
    {
        scalar totalVolume = gSum(filterField(mesh().V()));
        if (Pstream::master())
        {
            file() << obr_.time().value() << tab << totalVolume;
        }

        forAll(fields_, i)
        {
            writeValues<scalar>(fields_[i]);
            writeValues<vector>(fields_[i]);
            writeValues<sphericalTensor>(fields_[i]);
            writeValues<symmTensor>(fields_[i]);
            writeValues<tensor>(fields_[i]);
        }

        if (Pstream::master())
        {
            file()<< endl;
        }

        if (log_)
        {
            Info<< endl;
        }
    }
예제 #6
0
 void filterDoubleField(const std::string& keyword, std::vector<double>& output_field)
 {
     if (deck_->hasKeyword(keyword)) {
         const std::vector<double>& field = deck_->getKeyword(keyword)->getRawDoubleData();
         filterField(field, output_field);
     }
 }
예제 #7
0
void Foam::fieldValues::cellSource::initialise(const dictionary& dict)
{
    setCellZoneCells();

    Info<< type() << " " << name_ << ":" << nl
        << "    total cells  = " << nCells_ << nl
        << "    total volume = " << gSum(filterField(mesh().V()))
        << nl << endl;

    if (operation_ == opWeightedAverage)
    {
        dict.lookup("weightField") >> weightFieldName_;
        if
        (
            obr().foundObject<volScalarField>(weightFieldName_)
        )
        {
            Info<< "    weight field = " << weightFieldName_;
        }
        else
        {
            FatalErrorIn("cellSource::initialise()")
                << type() << " " << name_ << ": "
                << sourceTypeNames_[source_] << "(" << sourceName_ << "):"
                << nl << "    Weight field " << weightFieldName_
                << " must be a " << volScalarField::typeName
                << nl << exit(FatalError);
        }
    }
bool Foam::fieldValues::faceSource::writeValues(const word& fieldName)
{
    const bool ok = validField<Type>(fieldName);

    if (ok)
    {
        // Get (correctly oriented) field
        Field<Type> values = combineFields(setFieldValues<Type>(fieldName)());

        // Get unoriented magSf
        scalarField magSf;

        if (surfacePtr_.valid())
        {
            magSf = combineFields(surfacePtr_().magSf());
        }
        else
        {
            magSf = combineFields(filterField(mesh().magSf(), false)());
        }

        // Get (correctly oriented) weighting field
        scalarField weightField =
            combineFields(setFieldValues<scalar>(weightFieldName_)());

        if (Pstream::master())
        {
            Type result = processValues(values, magSf, weightField);

            if (valueOutput_)
            {
                IOList<Type>
                (
                    IOobject
                    (
                        fieldName + "_" + sourceTypeNames_[source_] + "-"
                            + sourceName_,
                        obr_.time().timeName(),
                        obr_,
                        IOobject::NO_READ,
                        IOobject::NO_WRITE
                    ),
                    values
                ).write();
            }

            outputFilePtr_()<< tab << result;

            if (log_)
            {
                Info<< "    " << operationTypeNames_[operation_]
                    << "(" << sourceName_ << ") for " << fieldName
                    <<  " = " << result << endl;
            }
        }
    }

    return ok;
}
예제 #9
0
bool Foam::fieldValues::cellSource::writeValues(const word& fieldName)
{
    const bool ok = validField<Type>(fieldName);

    if (ok)
    {
        Field<Type> values(setFieldValues<Type>(fieldName));
        scalarField V(filterField(mesh().V()));
        scalarField weightField(values.size(), 1.0);

        if (weightFieldName_ != "none")
        {
            weightField = setFieldValues<scalar>(weightFieldName_, true);
        }

        // Combine onto master
        combineFields(values);
        combineFields(V);
        combineFields(weightField);

        // apply weight field
        values *= weightField;

        if (Pstream::master())
        {
            Type result = processValues(values, V, weightField);

            // add to result dictionary, over-writing any previous entry
            resultDict_.add(fieldName, result, true);

            if (valueOutput_)
            {
                IOField<Type>
                (
                    IOobject
                    (
                        fieldName + "_" + sourceTypeNames_[source_] + "-"
                            + sourceName_,
                        obr_.time().timeName(),
                        obr_,
                        IOobject::NO_READ,
                        IOobject::NO_WRITE
                    ),
                    values
                ).write();
            }


            file()<< tab << result;

            Info(log_)<< "    " << operationTypeNames_[operation_]
                << "(" << sourceName_ << ") for " << fieldName
                <<  " = " << result << endl;
        }
    }

    return ok;
}
예제 #10
0
파일: filter.cpp 프로젝트: KDE/choqok
void Filter::writeConfig()
{
    d->config->writeEntry("Text", filterText());
    d->config->writeEntry("Field", (int)filterField());
    d->config->writeEntry("Type", (int)filterType());
    d->config->writeEntry("Action", (int)filterAction());
    d->config->writeEntry("DontHideReplies", dontHideReplies());
    d->config->sync();
}
예제 #11
0
Foam::tmp<Foam::Field<Type>>
Foam::functionObjects::fieldValues::surfaceRegion::getFieldValues
(
    const word& fieldName,
    const bool mustGet,
    const bool applyOrientation
) const
{
    typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
    typedef GeometricField<Type, fvPatchField, volMesh> vf;

    if (regionType_ != stSampledSurface && obr_.foundObject<sf>(fieldName))
    {
        return filterField(obr_.lookupObject<sf>(fieldName), applyOrientation);
    }
    else if (obr_.foundObject<vf>(fieldName))
    {
        const vf& fld = obr_.lookupObject<vf>(fieldName);

        if (surfacePtr_.valid())
        {
            if (surfacePtr_().interpolate())
            {
                const interpolationCellPoint<Type> interp(fld);
                tmp<Field<Type>> tintFld(surfacePtr_().interpolate(interp));
                const Field<Type>& intFld = tintFld();

                // Average
                const faceList& faces = surfacePtr_().faces();
                tmp<Field<Type>> tavg
                (
                    new Field<Type>(faces.size(), Zero)
                );
                Field<Type>& avg = tavg.ref();

                forAll(faces, facei)
                {
                    const face& f = faces[facei];
                    forAll(f, fp)
                    {
                        avg[facei] += intFld[f[fp]];
                    }
                    avg[facei] /= f.size();
                }

                return tavg;
            }
            else
            {
                return surfacePtr_().sample(fld);
            }
        }
        else
        {
            return filterField(fld, applyOrientation);
예제 #12
0
bool Foam::functionObjects::fieldValues::volRegion::writeValues
(
    const word& fieldName
)
{
    const bool ok = validField<Type>(fieldName);

    if (ok)
    {
        Field<Type> values(setFieldValues<Type>(fieldName));
        scalarField V(filterField(mesh().V()));
        scalarField weightField(values.size(), 1.0);

        if (weightFieldName_ != "none")
        {
            weightField = setFieldValues<scalar>(weightFieldName_, true);
        }

        Type result = processValues(values, V, weightField);

        if (Pstream::master())
        {

            // Add to result dictionary, over-writing any previous entry
            resultDict_.add(fieldName, result, true);

            if (writeFields_)
            {
                IOField<Type>
                (
                    IOobject
                    (
                        fieldName + "_" + regionTypeNames_[regionType_] + "-"
                            + regionName_,
                        obr_.time().timeName(),
                        obr_,
                        IOobject::NO_READ,
                        IOobject::NO_WRITE
                    ),
                    weightField*values
                ).write();
            }


            file()<< tab << result;

            Log << "    " << operationTypeNames_[operation_]
                << "(" << regionName_ << ") of " << fieldName
                <<  " = " << result << endl;
        }
    }

    return ok;
}
Foam::tmp<Foam::Field<Type> > Foam::fieldValues::cellSource::setFieldValues
(
    const word& fieldName
) const
{
    typedef GeometricField<Type, fvPatchField, volMesh> vf;

    if (obr_.foundObject<vf>(fieldName))
    {
        return filterField(obr_.lookupObject<vf>(fieldName));
    }

    return tmp<Field<Type> >(new Field<Type>(0.0));
}
bool Foam::fieldValues::cellSource::writeValues(const word& fieldName)
{
    const bool ok = validField<Type>(fieldName);

    if (ok)
    {
        Field<Type> values = combineFields(setFieldValues<Type>(fieldName));

        scalarField V = combineFields(filterField(mesh().V()));

        scalarField weightField =
            combineFields(setFieldValues<scalar>(weightFieldName_));

        if (Pstream::master())
        {
            Type result = processValues(values, V, weightField);

            if (valueOutput_)
            {
                IOList<Type>
                (
                    IOobject
                    (
                        fieldName + "_" + sourceTypeNames_[source_] + "-"
                            + sourceName_,
                        obr_.time().timeName(),
                        obr_,
                        IOobject::NO_READ,
                        IOobject::NO_WRITE
                    ),
                    values
                ).write();
            }


            outputFilePtr_()<< tab << result;

            if (log_)
            {
                Info<< "    " << operationTypeNames_[operation_]
                    << "(" << sourceName_ << ") for " << fieldName
                    <<  " = " << result << endl;
            }
        }
    }

    return ok;
}
예제 #15
0
void Foam::fieldValues::cellSource::write()
{
    fieldValue::write();

    if (active_)
    {
        scalar totalVolume = gSum(filterField(mesh().V()));
        if (Pstream::master())
        {
            file() << obr_.time().value() << tab << totalVolume;
        }

        forAll(fields_, i)
        {
            const word& fieldName = fields_[i];
            bool processed = false;

            processed = processed || writeValues<scalar>(fieldName);
            processed = processed || writeValues<vector>(fieldName);
            processed = processed || writeValues<sphericalTensor>(fieldName);
            processed = processed || writeValues<symmTensor>(fieldName);
            processed = processed || writeValues<tensor>(fieldName);

            if (!processed)
            {
                WarningIn("void Foam::fieldValues::cellSource::write()")
                    << "Requested field " << fieldName
                    << " not found in database and not processed"
                    << endl;
            }
        }

        if (Pstream::master())
        {
            file()<< endl;
        }

        Info(log_)<< endl;
    }
}
예제 #16
0
Foam::tmp<Foam::Field<Type>>
Foam::functionObjects::fieldValues::volRegion::setFieldValues
(
    const word& fieldName,
    const bool mustGet
) const
{
    typedef GeometricField<Type, fvPatchField, volMesh> vf;

    if (obr_.foundObject<vf>(fieldName))
    {
        return filterField(obr_.lookupObject<vf>(fieldName));
    }

    if (mustGet)
    {
        FatalErrorInFunction
            << "Field " << fieldName << " not found in database"
            << abort(FatalError);
    }

    return tmp<Field<Type>>(new Field<Type>(0.0));
}