Random blocking method in OpenFOAM through codedFixedValue

@Runmin ZHAO  September 11, 2023

This boundary condition is suitable for diffuser modeling in indoor simulations.

inlet
    {
        type            codedFixedValue;
        value           uniform (0 0 0);
        
        redirectType    rampedFixedValue;

        codeInclude
        #{
            #include "fvCFD.H"
            #include "Random.H"
        #};

        codeOptions
        #{
            -I$(LIB_SRC)/finiteVolume/lnInclude
        #};
        
        code 
        #{

            
            vector n(1, 0, 0);  // Flow Direction
            scalar U0 = 1.2;    // Velocity magnitude
            
            const vectorField& c = patch().Cf();
            vectorField u = c*0;     //Initialize vector of size = size c
            
            labelList faceLabels = identity(c.size());

            shuffle(faceLabels);  // Randomize the face order


            forAll(faceLabels, i)
            {
              label facei = faceLabels[i];

              if (i % 5 == 0)
              {
                u[facei] = U0*n; 
              }
            }



              operator==( u );
                  
        #};
    }

Add a New Comment