Пример #1
0
// Construct from components
Foam::lagrangianWriter::lagrangianWriter
(
    const vtkMesh& vMesh,
    const bool binary,
    const fileName& fName,
    const word& cloudName,
    const bool dummyCloud
)
:
    vMesh_(vMesh),
    binary_(binary),
    fName_(fName),
    cloudName_(cloudName),
    os_(fName.c_str())
{
    const fvMesh& mesh = vMesh_.mesh();

    // Write header
    writeFuns::writeHeader(os_, binary_, mesh.time().caseName());
    os_ << "DATASET POLYDATA" << std::endl;

    if (dummyCloud)
    {
        nParcels_ = 0;

        os_ << "POINTS " << nParcels_ << " float" << std::endl;
    }
    else
    {
        Cloud<passiveParticle> parcels(mesh, cloudName_, false);

        nParcels_ = parcels.size();

        os_ << "POINTS " << nParcels_ << " float" << std::endl;

        DynamicList<floatScalar> partField(3*parcels.size());

        forAllConstIter(Cloud<passiveParticle>, parcels, elmnt)
        {
            writeFuns::insert(elmnt().position(), partField);
        }
        writeFuns::write(os_, binary_, partField);
    }
Пример #2
0
void stochasticDispersionRAS::disperseParcels() const
{

    const scalar cps = 0.16432;

    scalar dt = spray_.runTime().deltaT().value();
    const volScalarField& k = turbulence().k();
    //volVectorField gradk = fvc::grad(k);
    const volScalarField& epsilon = turbulence().epsilon();
    const volVectorField& U = spray_.U();

    for
    (
        spray::iterator elmnt = spray_.begin();
        elmnt != spray_.end();
        ++elmnt
    )
    {
        label celli = elmnt().cell();
        scalar UrelMag = mag(elmnt().U() - U[celli] - elmnt().Uturb());

        scalar Tturb = min
        (
            k[celli]/epsilon[celli], 
            cps*pow(k[celli], 1.5)/epsilon[celli]/(UrelMag + SMALL)
        );

        // parcel is perturbed by the turbulence
        if (dt < Tturb)
        {
            elmnt().tTurb() += dt;

            if (elmnt().tTurb() > Tturb)
            {
                elmnt().tTurb() = 0.0;
                
                scalar sigma = sqrt(2.0*k[celli]/3.0);
                vector dir = 2.0*spray_.rndGen().vector01() - vector::one;
                dir /= mag(dir) + SMALL;

                // numerical recipes... Ch. 7. Random Numbers...
                scalar x1,x2;
                scalar rsq = 10.0;
                while((rsq > 1.0) || (rsq == 0.0))
                {
                    x1 = 2.0*spray_.rndGen().scalar01() - 1.0;
                    x2 = 2.0*spray_.rndGen().scalar01() - 1.0;
                    rsq = x1*x1 + x2*x2;
                }

                scalar fac = sqrt(-2.0*log(rsq)/rsq);

                fac *= mag(x1);

                elmnt().Uturb() = sigma*fac*dir;
            }
        }
        else
        {
            elmnt().tTurb() = GREAT;
            elmnt().Uturb() = vector::zero;
        }
    }
}
void Foam::stochasticDispersionRAS::disperseParcels() const
{

    const scalar cps = 0.16432;
    const vector one(1.0, 1.0, 1.0);

    scalar dt = spray_.runTime().deltaTValue();
    const volScalarField& k = turbulence().k();
    // volVectorField gradk(fvc::grad(k));
    const volScalarField& epsilon = turbulence().epsilon();
    const volVectorField& U = spray_.U();

    forAllIter(spray, spray_, elmnt)
    {
        const label cellI = elmnt().cell();
        scalar UrelMag = mag(elmnt().U() - U[cellI] - elmnt().Uturb());

        scalar Tturb = min
                       (
                           k[cellI]/epsilon[cellI],
                           cps*pow(k[cellI], 1.5)/epsilon[cellI]/(UrelMag + SMALL)
                       );

        // parcel is perturbed by the turbulence
        if (dt < Tturb)
        {
            elmnt().tTurb() += dt;

            if (elmnt().tTurb() > Tturb)
            {
                elmnt().tTurb() = 0.0;

                scalar sigma = sqrt(2.0*k[cellI]/3.0);
                vector dir = 2.0*spray_.rndGen().sample01<vector>() - one;
                dir /= mag(dir) + SMALL;

                // numerical recipes... Ch. 7. Random Numbers...
                scalar x1,x2;
                scalar rsq = 10.0;
                while (rsq > 1.0 || rsq == 0.0)
                {
                    x1 = 2.0*spray_.rndGen().sample01<scalar>() - 1.0;
                    x2 = 2.0*spray_.rndGen().sample01<scalar>() - 1.0;
                    rsq = x1*x1 + x2*x2;
                }

                scalar fac = sqrt(-2.0*log(rsq)/rsq);

                fac *= mag(x1);

                elmnt().Uturb() = sigma*fac*dir;

            }
        }
        else
        {
            elmnt().tTurb() = GREAT;
            elmnt().Uturb() = vector::zero;
        }
    }
}
Пример #4
0
void gradientDispersionRAS::disperseParcels() const
{

    const scalar cps = 0.16432;

    scalar dt = spray_.runTime().deltaT().value();
    const volScalarField& k = turbulence().k();
    volVectorField gradk = fvc::grad(k);
    const volScalarField& epsilon = turbulence().epsilon();
    const volVectorField& U = spray_.U();

    for
    (
        spray::iterator elmnt = spray_.begin();
        elmnt != spray_.end();
        ++elmnt
    )
    {
        label celli = elmnt().cell();
        scalar UrelMag = mag(elmnt().U() - U[celli] - elmnt().Uturb());

        scalar Tturb = min
        (
            k[celli]/epsilon[celli], 
            cps*pow(k[celli], 1.5)/epsilon[celli]/(UrelMag + SMALL)
        );
        // parcel is perturbed by the turbulence
        if (dt < Tturb)
        {
            elmnt().tTurb() += dt;

            if (elmnt().tTurb() > Tturb)
            {
                elmnt().tTurb() = 0.0;

                scalar sigma = sqrt(2.0*k[celli]/3.0);
                vector dir = -gradk[celli]/(mag(gradk[celli]) + SMALL);

                // numerical recipes... Ch. 7. Random Numbers...
                scalar x1 = 0.0;
                scalar x2 = 0.0;
                scalar rsq = 10.0;
                while((rsq > 1.0) || (rsq == 0.0))
                {
                    x1 = 2.0*spray_.rndGen().scalar01() - 1.0;
                    x2 = 2.0*spray_.rndGen().scalar01() - 1.0;
                    rsq = x1*x1 + x2*x2;
                }
                
                scalar fac = sqrt(-2.0*log(rsq)/rsq);
                
                // in 2D calculations the -grad(k) is always
                // away from the axis of symmetry
                // This creates a 'hole' in the spray and to
                // prevent this we let x1 be both negative/positive
                if (spray_.twoD())
                {
                    fac *= x1;
                }
                else
                {
                    fac *= mag(x1);
                }
                
                elmnt().Uturb() = sigma*fac*dir;
            }
        }
        else
        {
            elmnt().tTurb() = GREAT;
            elmnt().Uturb() = vector::zero;
        }
    }
}