Ejemplo n.º 1
0
tmp<DimensionedField<scalar, GeoMesh> > atan2
(
    const DimensionedField<scalar, GeoMesh>& dsf1,
    const DimensionedField<scalar, GeoMesh>& dsf2
)
{
    tmp<DimensionedField<scalar, GeoMesh> > tAtan2
    (
        new DimensionedField<scalar, GeoMesh>
        (
            IOobject
            (
                "atan2(" + dsf1.name() + ',' + dsf2.name() + ')',
                dsf1.instance(),
                dsf1.db()
            ),
            dsf1.mesh(),
            atan2(dsf1.dimensions(), dsf2.dimensions())
        )
    );

    atan2(tAtan2().getField(), dsf1.getField(), dsf2.getField());

    return tAtan2;
}
Foam::timeVaryingMappedTotalPressureFvPatchScalarField::
timeVaryingMappedTotalPressureFvPatchScalarField
(
    const fvPatch& p,
    const DimensionedField<scalar, volMesh>& iF,
    const dictionary& dict
)
:
    timeVaryingMappedFixedValueFvPatchScalarField(p, iF, dict),
    UName_(dict.lookupOrDefault<word>("UName", "U")),
    phiName_(dict.lookupOrDefault<word>("phiName", "phi")),
    rhoName_(dict.lookupOrDefault<word>("rhoName", "none")),
    rho_
    (
        iF.dimensions() == dimPressure/dimDensity && rhoName_ == "rho"
        ? readScalar(dict.lookup("rho"))
        : 1
    ),
    psiName_(dict.lookupOrDefault<word>("psiName", "none")),
    gamma_
    (
        iF.dimensions() == dimPressure && psiName_ != "none"
        ? readScalar(dict.lookup("gamma"))
        : 1
    )
{}
Ejemplo n.º 3
0
tmp<DimensionedField<scalar, GeoMesh> > pow
(
    const DimensionedField<scalar, GeoMesh>& dsf1,
    const DimensionedField<scalar, GeoMesh>& dsf2
)
{
    tmp<DimensionedField<scalar, GeoMesh> > tPow
    (
        new DimensionedField<scalar, GeoMesh>
        (
            IOobject
            (
                "pow(" + dsf1.name() + ',' + dsf2.name() + ')',
                dsf1.instance(),
                dsf1.db()
            ),
            dsf1.mesh(),
            pow
            (
                dsf1.dimensions(),
                dimensionedScalar("1", 1.0, dsf2.dimensions())
            )
        )
    );

    pow(tPow().getField(), dsf1.getField(), dsf2.getField());

    return tPow;
}
tmp
<
    DimensionedField
        <typename DimensionedField<Type, GeoMesh>::cmptType, GeoMesh>
>
cmptAv(const DimensionedField<Type, GeoMesh>& df)
{
    typedef typename DimensionedField<Type, GeoMesh>::cmptType cmptType;

    tmp<DimensionedField<cmptType, GeoMesh> > CmptAv
    (
        new DimensionedField<scalar, GeoMesh>
        (
            IOobject
            (
                "cmptAv(" + df.name() + ')',
                df.instance(),
                df.db()
            ),
            df.mesh(),
            df.dimensions()
        )
    );

    cmptAv(CmptAv().field(), df.field());

    return CmptAv;
}
Ejemplo n.º 5
0
tmp<DimensionedField<scalar, GeoMesh> > pow
(
    const dimensionedScalar& ds,
    const DimensionedField<scalar, GeoMesh>& dsf
)
{
    tmp<DimensionedField<scalar, GeoMesh> > tPow
    (
        new DimensionedField<scalar, GeoMesh>
        (
            IOobject
            (
                "pow(" + ds.name() + ',' + dsf.name() + ')',
                dsf.instance(),
                dsf.db()
            ),
            dsf.mesh(),
            pow(ds, dsf.dimensions())
        )
    );

    pow(tPow().getField(), ds.value(), dsf.getField());

    return tPow;
}
Ejemplo n.º 6
0
tmp<DimensionedField<scalar, GeoMesh> > pow
(
    const DimensionedField<scalar, GeoMesh>& dsf1,
    const tmp<DimensionedField<scalar, GeoMesh> >& tdsf2
)
{
    const DimensionedField<scalar, GeoMesh>& dsf2 = tdsf2();

    tmp<DimensionedField<scalar, GeoMesh> > tPow =
        reuseTmpDimensionedField<scalar, scalar, GeoMesh>::New
        (
            tdsf2,
            "pow(" + dsf1.name() + ',' + dsf2.name() + ')',
            pow
            (
                dsf1.dimensions(),
                dimensionedScalar("1", 1.0, dsf2.dimensions())
            )
        );

    pow(tPow().getField(), dsf1.getField(), dsf2.getField());

    reuseTmpDimensionedField<scalar, scalar, GeoMesh>::clear(tdsf2);

    return tPow;
}
tmp<DimensionedField<typename powProduct<Type, r>::type, GeoMesh> >
pow
(
    const DimensionedField<Type, GeoMesh>& df,
    typename powProduct<Type, r>::type
)
{
    typedef typename powProduct<Type, r>::type powProductType;

    tmp<DimensionedField<powProductType, GeoMesh> > tPow
    (
        new DimensionedField<powProductType, GeoMesh>
        (
            IOobject
            (
                "pow(" + df.name() + ',' + name(r) + ')',
                df.instance(),
                df.db()
            ),
            df.mesh(),
            pow(df.dimensions(), r)
        )
    );

    pow<Type, r, GeoMesh>(tPow().field(), df.field());

    return tPow;
}
Foam::tmp<Foam::DimensionedField<Type, Foam::volMesh>>
Foam::dimFieldDecomposer::decomposeField
(
    const DimensionedField<Type, volMesh>& field
) const
{
    // Create and map the internal field values
    Field<Type> mappedField(field, cellAddressing_);

    // Create the field for the processor
    return tmp<DimensionedField<Type, volMesh>>
    (
        new DimensionedField<Type, volMesh>
        (
            IOobject
            (
                field.name(),
                procMesh_.time().timeName(),
                procMesh_,
                IOobject::NO_READ,
                IOobject::NO_WRITE,
                false
            ),
            procMesh_,
            field.dimensions(),
            mappedField
        )
    );
}
Ejemplo n.º 9
0
Foam::tmp<Foam::fvMatrix<Type>>
Foam::fvm::SuSp
(
    const DimensionedField<scalar, volMesh>& susp,
    const GeometricField<Type, fvPatchField, volMesh>& vf
)
{
    const fvMesh& mesh = vf.mesh();

    tmp<fvMatrix<Type>> tfvm
    (
        new fvMatrix<Type>
        (
            vf,
            dimVol*susp.dimensions()*vf.dimensions()
        )
    );
    fvMatrix<Type>& fvm = tfvm.ref();

    fvm.diag() += mesh.V()*max(susp.field(), scalar(0));

    fvm.source() -= mesh.V()*min(susp.field(), scalar(0))
        *vf.primitiveField();

    return tfvm;
}
Ejemplo n.º 10
0
tmp<DimensionedField<scalar, GeoMesh> > atan2
(
    const dimensionedScalar& ds,
    const DimensionedField<scalar, GeoMesh>& dsf
)
{
    tmp<DimensionedField<scalar, GeoMesh> > tAtan2
    (
        new DimensionedField<scalar, GeoMesh>
        (
            IOobject
            (
                "atan2(" + ds.name() + ',' + dsf.name() + ')',
                dsf.instance(),
                dsf.db()
            ),
            dsf.mesh(),
            atan2(ds, dsf.dimensions())
        )
    );

    atan2(tAtan2().getField(), ds.value(), dsf.getField());

    return tAtan2;
}
Ejemplo n.º 11
0
tmp<DimensionedField<scalar, GeoMesh> > stabilise
(
    const DimensionedField<scalar, GeoMesh>& dsf,
    const dimensioned<scalar>& ds
)
{
    tmp<DimensionedField<scalar, GeoMesh> > tRes
    (
        new DimensionedField<scalar, GeoMesh>
        (
            IOobject
            (
                "stabilise(" + dsf.name() + ',' + ds.name() + ')',
                dsf.instance(),
                dsf.db()
            ),
            dsf.mesh(),
            dsf.dimensions() + ds.dimensions()
        )
    );

    stabilise(tRes().getField(), dsf.getField(), ds.value());

    return tRes;
}
Ejemplo n.º 12
0
dimensioned<Type> domainIntegrate
(
    const DimensionedField<Type, volMesh>& df
)
{
    return dimensioned<Type>
    (
        "domainIntegrate(" + df.name() + ')',
        dimVol*df.dimensions(),
        gSum(fvc::volumeIntegrate(df))
    );
}
Ejemplo n.º 13
0
void DimensionedField<Type, GeoMesh>::operator=
(
    const DimensionedField<Type, GeoMesh>& df
)
{
    // Check for assignment to self
    if (this == &df)
    {
        FatalErrorIn
        (
            "DimensionedField<Type, GeoMesh>::operator="
            "(const DimensionedField<Type, GeoMesh>&)"
        )   << "attempted assignment to self"
            << abort(FatalError);
    }

    checkField(*this, df, "=");

    dimensions_ = df.dimensions();
    Field<Type>::operator=(df);
}
tmp<volScalarField> swakPsiChemistryModelPluginFunction::wrapDimField(
        const DimensionedField<scalar,volMesh> &dimField
)
{
    tmp<volScalarField> result(
            new volScalarField(
                IOobject(
                    dimField.name(),
                    mesh().time().timeName(),
                    mesh(),
                    IOobject::NO_READ,
                    IOobject::NO_WRITE
                ),
                mesh(),
                dimensionedScalar(dimField.name(),dimField.dimensions(),0),
                "zeroGradient"
            )
    );
    result->dimensionedInternalField()=dimField;

    return result;
}
Ejemplo n.º 15
0
tmp<DimensionedField<scalar, GeoMesh> > atan2
(
    const DimensionedField<scalar, GeoMesh>& dsf1,
    const tmp<DimensionedField<scalar, GeoMesh> >& tdsf2
)
{
    const DimensionedField<scalar, GeoMesh>& dsf2 = tdsf2();

    tmp<DimensionedField<scalar, GeoMesh> > tAtan2 =
        reuseTmpDimensionedField<scalar, scalar, GeoMesh>::New
        (
            tdsf2,
            "atan2(" + dsf1.name() + ',' + dsf2.name() + ')',
            atan2(dsf1.dimensions(), dsf2.dimensions())
        );

    atan2(tAtan2().getField(), dsf1.getField(), dsf2.getField());

    reuseTmpDimensionedField<scalar, scalar, GeoMesh>::clear(tdsf2);

    return tAtan2;
}
Ejemplo n.º 16
0
Foam::tmp<Foam::fvMatrix<Type>>
Foam::fvm::Sp
(
    const DimensionedField<scalar, volMesh>& sp,
    const GeometricField<Type, fvPatchField, volMesh>& vf
)
{
    const fvMesh& mesh = vf.mesh();

    tmp<fvMatrix<Type>> tfvm
    (
        new fvMatrix<Type>
        (
            vf,
            dimVol*sp.dimensions()*vf.dimensions()
        )
    );
    fvMatrix<Type>& fvm = tfvm.ref();

    fvm.diag() += mesh.V()*sp.field();

    return tfvm;
}
Ejemplo n.º 17
0
Foam::tmp<Foam::fvMatrix<Type>>
Foam::fvm::Su
(
    const DimensionedField<Type, volMesh>& su,
    const GeometricField<Type, fvPatchField, volMesh>& vf
)
{
    const fvMesh& mesh = vf.mesh();

    tmp<fvMatrix<Type>> tfvm
    (
        new fvMatrix<Type>
        (
            vf,
            dimVol*su.dimensions()
        )
    );
    fvMatrix<Type>& fvm = tfvm.ref();

    fvm.source() -= mesh.V()*su.field();

    return tfvm;
}
tmp<DimensionedField<typename outerProduct<Type, Type>::type, GeoMesh> >
sqr(const DimensionedField<Type, GeoMesh>& df)
{
    typedef typename outerProduct<Type, Type>::type outerProductType;

    tmp<DimensionedField<outerProductType, GeoMesh> > tSqr
    (
        new DimensionedField<outerProductType, GeoMesh>
        (
            IOobject
            (
                "sqr(" + df.name() + ')',
                df.instance(),
                df.db()
            ),
            df.mesh(),
            sqr(df.dimensions())
        )
    );

    sqr(tSqr().field(), df.field());

    return tSqr;
}
tmp<DimensionedField<scalar, GeoMesh> > mag
(
    const DimensionedField<Type, GeoMesh>& df
)
{
    tmp<DimensionedField<scalar, GeoMesh> > tMag
    (
        new DimensionedField<scalar, GeoMesh>
        (
            IOobject
            (
                "mag(" + df.name() + ')',
                df.instance(),
                df.db()
            ),
            df.mesh(),
            df.dimensions()
        )
    );

    mag(tMag().field(), df.field());

    return tMag;
}
Ejemplo n.º 20
0
Foam::tmp<Foam::DimensionedField<Type, Foam::volMesh>> Foam::levelSetAverage
(
    const fvMesh& mesh,
    const scalarField& levelC,
    const scalarField& levelP,
    const DimensionedField<Type, volMesh>& positiveC,
    const DimensionedField<Type, pointMesh>& positiveP,
    const DimensionedField<Type, volMesh>& negativeC,
    const DimensionedField<Type, pointMesh>& negativeP
)
{
    tmp<DimensionedField<Type, volMesh>> tResult
    (
        new DimensionedField<Type, volMesh>
        (
            IOobject
            (
                positiveC.name() + ":levelSetAverage",
                mesh.time().timeName(),
                mesh
            ),
            mesh,
            dimensioned<Type>("0", positiveC.dimensions(), Zero)
        )
    );
    DimensionedField<Type, volMesh>& result = tResult.ref();

    forAll(result, cI)
    {
        const List<tetIndices> cellTetIs =
            polyMeshTetDecomposition::cellTetIndices(mesh, cI);

        scalar v = 0;
        Type r = Zero;

        forAll(cellTetIs, cellTetI)
        {
            const triFace triIs = cellTetIs[cellTetI].faceTriIs(mesh);

            const FixedList<point, 4>
                tet =
                {
                    mesh.cellCentres()[cI],
                    mesh.points()[triIs[0]],
                    mesh.points()[triIs[1]],
                    mesh.points()[triIs[2]]
                };
            const FixedList<scalar, 4>
                level =
                {
                    levelC[cI],
                    levelP[triIs[0]],
                    levelP[triIs[1]],
                    levelP[triIs[2]]
                };
            const cut::volumeIntegrateOp<Type>
                positive = FixedList<Type, 4>
                ({
                    positiveC[cI],
                    positiveP[triIs[0]],
                    positiveP[triIs[1]],
                    positiveP[triIs[2]]
                });
            const cut::volumeIntegrateOp<Type>
                negative = FixedList<Type, 4>
                ({
                    negativeC[cI],
                    negativeP[triIs[0]],
                    negativeP[triIs[1]],
                    negativeP[triIs[2]]
                });

            v += cut::volumeOp()(tet);

            r += tetCut(tet, level, positive, negative);
        }

        result[cI] = r/v;
    }

    return tResult;
}