예제 #1
0
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
noConvectionScheme<Type>::interpolate
(
    const surfaceScalarField&,
    const GeometricField<Type, fvPatchField, volMesh>& vf
) const
{
    return tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
    (
        new GeometricField<Type, fvsPatchField, surfaceMesh>
        (
            IOobject
            (
                "interpolate("+vf.name()+')',
                vf.instance(),
                vf.db()
            ),
            vf.mesh(),
            dimensioned<Type>
            (
                "0",
                vf.dimensions(),
                pTraits<Type>::zero
            )
        )
    );
}
const tmp<surfaceScalarField> interpolWeights(GeometricField<type, fvPatchField, volMesh>& vf, const word& name){

    //vf.boundaryField().updateCoeffs();
    const objectRegistry& db = vf.db();

    //const volVectorField& u = db.lookupObject<volVectorField>("vc");
    const volVectorField& u = db.lookupObject<volVectorField>("u");
    //const volVectorField& u = db.lookupObject<volVectorField>("s");

    surfaceScalarField phi
    (
        IOobject
        (
            "phi",
            vf.time().timeName(),
            vf.mesh(),
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        linearInterpolate(u) & vf.mesh().Sf()
    );

    tmp<surfaceInterpolationScheme<type> > tinterpScheme;
    tinterpScheme = fvc::scheme<type>(phi, vf.mesh().schemesDict().interpolationScheme(name));

    const surfaceInterpolationScheme<type>& interpolationScheme = tinterpScheme();

    tmp<surfaceScalarField> tweights = interpolationScheme.weights(vf);

    //Info << "weights[15]:" << tweights()[15] << endl;

    return tweights;

}
예제 #3
0
tmp<GeometricField<Type, PatchField, GeoMesh> > transform
(
    const GeometricField<tensor, PatchField, GeoMesh>& trf,
    const GeometricField<Type, PatchField, GeoMesh>& tf
)
{
    tmp<GeometricField<Type, PatchField, GeoMesh> > tranf
    (
        new GeometricField<Type, PatchField, GeoMesh>
        (
            IOobject
            (
                "transform(" + trf.name() + ',' + tf.name() + ')',
                tf.instance(),
                tf.db(),
                IOobject::NO_READ,
                IOobject::NO_WRITE
            ),
            tf.mesh(),
            tf.dimensions()
        )
    );

    transform(tranf(), trf, tf);

    return tranf;
}
예제 #4
0
inline tmp<volScalarField> rhoMagSqr<Type>::operator()
(
    const GeometricField<Type, fvPatchField, volMesh>& phi
) const
{
    const volScalarField& rho =
        phi.db().objectRegistry::template lookupObject<volScalarField>("rho");
    return Foam::magSqr(phi/rho);
}
예제 #5
0
tmp<GeometricField<Type, faePatchField, edgeMesh> >
correctedLnGrad<Type>::correction
(
    const GeometricField<Type, faPatchField, areaMesh>& vf
) const
{
    const faMesh& mesh = this->mesh();

    // construct GeometricField<Type, faePatchField, edgeMesh>
    tmp<GeometricField<Type, faePatchField, edgeMesh> > tssf
    (
        new GeometricField<Type, faePatchField, edgeMesh>
        (
            IOobject
            (
                "lnGradCorr("+vf.name()+')',
                vf.instance(),
                vf.db()
            ),
            mesh,
            vf.dimensions()*mesh.deltaCoeffs().dimensions()
        )
    );
    GeometricField<Type, faePatchField, edgeMesh>& ssf = tssf();

    for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++)
    {
        ssf.replace
        (
            cmpt,
            mesh.correctionVectors()
          & linearEdgeInterpolation
            <
                typename 
                outerProduct<vector, typename pTraits<Type>::cmptType>::type
            >(mesh).interpolate
            (
                gradScheme<typename pTraits<Type>::cmptType>::New
                (
                    mesh,
                    mesh.gradScheme(ssf.name())
                )()
//                 gaussGrad<typename pTraits<Type>::cmptType>(mesh)
               .grad(vf.component(cmpt))
            )
        );
    }

    return tssf;
}
tmp<tetFemMatrix<Type> > tetFem::laplacianTrace
(
    GeometricField<Type, tetPolyPatchField, tetPointMesh>& vf
)
{
    elementScalarField Gamma
    (
        IOobject
        (
            "1",
            vf.instance(),
            vf.db(),
            IOobject::NO_READ
        ),
        vf.mesh(),
        dimensionedScalar("1", dimless, 1.0)
    );

    return tetFem::laplacianTrace(Gamma, vf);
}
예제 #7
0
tmp<GeometricField<Type, faePatchField, edgeMesh> >
lnGradScheme<Type>::lnGrad
(
    const GeometricField<Type, faPatchField, areaMesh>& vf,
    const tmp<edgeScalarField>& tdeltaCoeffs,
    const word& lnGradName
)
{
    const faMesh& mesh = vf.mesh();

    // construct GeometricField<Type, faePatchField, edgeMesh>
    tmp<GeometricField<Type, faePatchField, edgeMesh> > tssf
    (
        new GeometricField<Type, faePatchField, edgeMesh>
        (
            IOobject
            (
                lnGradName + vf.name() + ')',
                vf.instance(),
                vf.db(),
                IOobject::NO_READ,
                IOobject::NO_WRITE
            ),
            mesh,
            vf.dimensions()*tdeltaCoeffs().dimensions()
        )
    );
    GeometricField<Type, faePatchField, edgeMesh>& ssf = tssf();

    // set reference to difference factors array
    const scalarField& deltaCoeffs = tdeltaCoeffs().internalField();

    // owner/neighbour addressing
    const unallocLabelList& owner = mesh.owner();
    const unallocLabelList& neighbour = mesh.neighbour();

    forAll(owner, faceI)
    {
        ssf[faceI] =
            deltaCoeffs[faceI]*(vf[neighbour[faceI]] - vf[owner[faceI]]);
    }
tmp<faMatrix<Type> >
laplacian
(
    GeometricField<Type, faPatchField, areaMesh>& vf
)
{
    edgeScalarField Gamma
    (
        IOobject
        (
            "gamma",
            vf.time().constant(),
            vf.db(),
            IOobject::NO_READ
        ),
        vf.mesh(),
        dimensionedScalar("1", dimless, 1.0)
    );

    return fam::laplacian(Gamma, vf);
}
tmp<tetFemMatrix<Type> > tetFem::laplacianTrace
(
    const dimensionedScalar& gamma,
    GeometricField<Type, tetPolyPatchField, tetPointMesh>& vf
)
{
    elementScalarField Gamma
    (
        IOobject
        (
            gamma.name(),
            vf.instance(),
            vf.db(),
            IOobject::NO_READ
        ),
        vf.mesh(),
        gamma
    );

    return tetFem::laplacianTrace(Gamma, vf);
}
tmp<faMatrix<Type> >
laplacian
(
    const dimensionedScalar& gamma,
    GeometricField<Type, faPatchField, areaMesh>& vf
)
{
    edgeScalarField Gamma
    (
        IOobject
        (
            gamma.name(),
            vf.instance(),
            vf.db(),
            IOobject::NO_READ
        ),
        vf.mesh(),
        gamma
    );

    return fam::laplacian(Gamma, vf);
}
예제 #11
0
Foam::tmp<Foam::SlicedGeometricField
<
    Type,
    Foam::fvPatchField,
    Foam::slicedFvPatchField,
    Foam::volMesh
>>
Foam::isoSurface::adaptPatchFields
(
    const GeometricField<Type, fvPatchField, volMesh>& fld
) const
{
    typedef SlicedGeometricField
    <
        Type,
        fvPatchField,
        slicedFvPatchField,
        volMesh
    > FieldType;

    tmp<FieldType> tsliceFld
    (
        new FieldType
        (
            IOobject
            (
                fld.name(),
                fld.instance(),
                fld.db(),
                IOobject::NO_READ,
                IOobject::NO_WRITE,
                false
            ),
            fld,        // internal field
            true        // preserveCouples
        )
    );
    FieldType& sliceFld = tsliceFld.ref();

    const fvMesh& mesh = fld.mesh();

    const polyBoundaryMesh& patches = mesh.boundaryMesh();

    forAll(patches, patchI)
    {
        const polyPatch& pp = patches[patchI];

        if
        (
            isA<emptyPolyPatch>(pp)
         && pp.size() != sliceFld.boundaryField()[patchI].size()
        )
        {
            // Clear old value. Cannot resize it since is a slice.
            sliceFld.boundaryField().set(patchI, NULL);

            // Set new value we can change
            sliceFld.boundaryField().set
            (
                patchI,
                new calculatedFvPatchField<Type>
                (
                    mesh.boundary()[patchI],
                    sliceFld
                )
            );

            // Note: cannot use patchInternalField since uses emptyFvPatch::size
            // Do our own internalField instead.
            const labelUList& faceCells =
                mesh.boundary()[patchI].patch().faceCells();

            Field<Type>& pfld = sliceFld.boundaryField()[patchI];
            pfld.setSize(faceCells.size());
            forAll(faceCells, i)
            {
                pfld[i] = sliceFld[faceCells[i]];
            }
        }
        else if (isA<cyclicPolyPatch>(pp))
예제 #12
0
Foam::tmp<Foam::surfaceScalarField>
Foam::PhiScheme<Type, PhiLimiter>::limiter
(
    const GeometricField<Type, fvPatchField, volMesh>& phi
) const
{
    const fvMesh& mesh = this->mesh();

    tmp<surfaceScalarField> tLimiter
    (
        new surfaceScalarField
        (
            IOobject
            (
                "PhiLimiter",
                mesh.time().timeName(),
                mesh
            ),
            mesh,
            dimless
        )
    );
    surfaceScalarField& Limiter = tLimiter();

    const surfaceScalarField& CDweights = mesh.surfaceInterpolation::weights();

    const surfaceVectorField& Sf = mesh.Sf();
    const surfaceScalarField& magSf = mesh.magSf();

    const labelUList& owner = mesh.owner();
    const labelUList& neighbour = mesh.neighbour();

    tmp<surfaceScalarField> tUflux = this->faceFlux_;

    if (this->faceFlux_.dimensions() == dimDensity*dimVelocity*dimArea)
    {
        const volScalarField& rho =
            phi.db().objectRegistry::template lookupObject<volScalarField>
            ("rho");

        tUflux = this->faceFlux_/fvc::interpolate(rho);
    }
    else if (this->faceFlux_.dimensions() != dimVelocity*dimArea)
    {
        FatalErrorInFunction
            << "dimensions of faceFlux are not correct"
            << exit(FatalError);
    }

    const surfaceScalarField& Uflux = tUflux();

    scalarField& pLimiter = Limiter.internalField();

    forAll(pLimiter, face)
    {
        pLimiter[face] = PhiLimiter::limiter
        (
            CDweights[face],
            Uflux[face],
            phi[owner[face]],
            phi[neighbour[face]],
            Sf[face],
            magSf[face]
        );
    }
tmp
<
    GeometricField
    <
        typename outerProduct<vector, Type>::type,
        tetPolyPatchField,
        tetPointMesh
    >
> 
tetFec::grad
(
    const GeometricField<Type, tetPolyPatchField, tetPointMesh>& psi
)
{
    typedef typename outerProduct<vector, Type>::type GradType;

    const tetPolyMesh& tetMesh = psi.mesh();

    tmp<GeometricField<GradType, tetPolyPatchField, tetPointMesh> > tFemGrad
    (
        new GeometricField<GradType, tetPolyPatchField, tetPointMesh>
        (
            IOobject
            (
                "grad("+psi.name()+')',
                psi.instance(),
                psi.db(),
                IOobject::NO_READ,
                IOobject::NO_WRITE
            ),
            tetMesh,
            dimensioned<GradType>
            (
                "zero",
                psi.dimensions()/dimLength,
                pTraits<GradType>::zero
            )
        )
    );

    GeometricField<GradType, tetPolyPatchField, tetPointMesh>& femGrad = 
        tFemGrad();

    pointField points = tetMesh.points();
    cellShapeList tetCellShapes = tetMesh.tetCells();

    scalarField weights (points.size(), 0.0);

    forAll (tetCellShapes, tetI)
    {
        cellShape& curShape = tetCellShapes[tetI];

        tetPointRef curTetrahedron
        (
            points[curShape[0]],
            points[curShape[1]],
            points[curShape[2]],
            points[curShape[3]]
        );

        GradType tetGrad = 
          - (1.0/3.0)*
            (
                curTetrahedron.Sa()*psi.internalField()[curShape[0]]
              + curTetrahedron.Sb()*psi.internalField()[curShape[1]]
              + curTetrahedron.Sc()*psi.internalField()[curShape[2]]
              + curTetrahedron.Sd()*psi.internalField()[curShape[3]]
            )/curTetrahedron.mag();

        forAll (curShape, pointI)
        {
            scalar weight = 
                curTetrahedron.mag()/
                mag
                (
                    points[curShape[pointI]]
                  - curShape.centre(points)
                );

            femGrad.internalField()[curShape[pointI]] += weight*tetGrad;

            weights[curShape[pointI]] += weight;
        }