CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Pre-Processing (https://www.cfd-online.com/Forums/openfoam-pre-processing/)
-   -   How to modify the particle patchInjection model to a position injection model? (https://www.cfd-online.com/Forums/openfoam-pre-processing/213276-how-modify-particle-patchinjection-model-position-injection-model.html)

zhangxc0223 December 20, 2018 06:55

How to modify the particle patchInjection model to a position injection model?
 
1 Attachment(s)
Sorry that I am pretty new about the C++ code in OpenFOAM. I am currently trying to simulate a particle-laden flow with the lagrangian particles injecting into the domain from a section at a certain position. The geometry of the section is as same as the inject patch, but it is 100mm away from the inject patch in the downstream domain (shown in the figure). Can it be achieved by simply modifying the codes related to “position” as below in the "patchInjection.C" file? If it is achievable, how to modify them?


Code:

    if ((time0 >= 0.0) && (time0 < duration_))
    {
        scalar nParcels = (time1 - time0)*parcelsPerSecond_;

        cachedRandom& rnd = this->owner().rndGen();

        label nParcelsToInject = floor(nParcels);

        // Inject an additional parcel with a probability based on the
        // remainder after the floor function
        if
        (
            nParcelsToInject > 0
        && (
              nParcels - scalar(nParcelsToInject)
            > rnd.globalPosition(scalar(0), scalar(1))
            )
        )
        {
            ++nParcelsToInject;
        }

        return nParcelsToInject;
    }
    else
    {
        return 0;
    }

By the way, is there any different way to achieve this kind of injection? I have tried many different ways, including the cellZoneInjection. But none of them works fine. Because I would like to perform a random and continuous particle injection during a long-time interval at this desired position.

Thank in advance and kind regards.


All times are GMT -4. The time now is 23:17.