CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   source term that stays constant over outerCorrectors of pimple loop (https://www.cfd-online.com/Forums/openfoam/241303-source-term-stays-constant-over-outercorrectors-pimple-loop.html)

jnanabrao February 18, 2022 23:45

source term that stays constant over outerCorrectors of pimple loop
 
Dear all,


My transient compressible flow calculation requires addition of random disturbances to the boundary layers of a nozzle at a particular location. The way I tried to do it is


1) create a cellSet of the boundary cells at the location.

2) Add random momentum source terms (disturbances) of the necessary magnitude using fvOptions active only at the aforementioned cellSet.



The issue:
For reasons I can't elaborate here, I need to use a pimple solver with 5 outerCorrector loops. I would like to keep my source term constant over all the 5 correctors. Unfortunately, when I tried to do so, I realized that fvOptions is called each time the U.Eqn is solved and it modifies the disturbances at each outer corrector step. My code for fvOptions is shared below


Code:

codedSource
{
    type            vectorCodedSource;
    selectionMode  cellSet;
    cellSet        boundaryLayerForce;

    fields          (U);
    name          disturbance;

    codeInclude
    #{
    #include "Random.H"
    # include "clock.H"
    #};
   
    codeCorrect
    #{
    #};

    codeAddSup
    #{
        const Time& time = mesh().time();
        Random rng(time.value());//Random rng(clock::getTime() + pid());
        vectorField& USource = eqn.source();
     
        // Start time
        const scalar startTime = -1.0;

        if (time.value() > startTime)
        {
            const labelList& cellIDs = cells();
            // Apply the source
            forAll(cellIDs, i)
            {
                label cellI = cellIDs[i];
                vector epsilon (1, 1, 1);
                epsilon.x() = -1.0 + 2.0*(rng.scalar01());
                epsilon.y() = -1.0 + 2.0*(rng.scalar01());
                epsilon.z() = 2.0*(-1.0 + 2.0*(rng.scalar01()));
             
                USource[cellI].x() =1e-4*508*epsilon.x();
                USource[cellI].y() =1e-4*508*epsilon.y();
                USource[cellI].z() = 1e-4*508*epsilon.z();
            };
       
        }
    #};

    codeSetValue
        #{
        #};
}

        {

As you can see the disturbances are scaled a fixed order of magnitude from a scalar (1e-04*508). These are then randomly weighed with a different random number between -2 and 2 in each cell.


The constant updating of the disturbances within a time step is not what I want and it leads to immediate blow up of the calculation.



My questions:
Is it possible to use fvOptions to add source terms that stay constant at a time step over all the outer correctors? It seems possible as fvOptions can access the time value.



Do I have to modify my solver in order to add disturbances and solve with a pimple loop?


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