CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   vectorCodedSource problems (https://www.cfd-online.com/Forums/openfoam-solving/231135-vectorcodedsource-problems.html)

IC01 October 22, 2020 18:07

vectorCodedSource problems
 
Hi
I have the problem with vectorCodedSource; in fvOption file
I'm modifying incompressible/simpleFoam/rotorDisk tutorial. The target is to have either polynomial or tabular velocity in the RotatingZone. Please let me know if there is a simpler way
Right now I'm trying to put velocity in the y-direction that corresponds to the y coordinate of cell. It gives me not feasible values

Thank you


Code:

{
 

    type            vectorCodedSource;
    active          true;
    selectionMode  cellZone;
    cellZone        rotatingZone;

    fields          (U);
    name            codedSource;
    codeAddSup
    #{
        const Time& time = mesh().time();
        const scalarField& V = mesh_.V();
        vectorField& USource = eqn.source();
      // const scalarField& cellx = mesh_.C().component(0) ;
        const scalarField& celly = mesh_.C().component(1) ;
      //  const scalarField& cellz = mesh_.C().component(2) ;
     

        // Start time
        const scalar startTime = 20.0; 

        if (time.value() > startTime)

   
        forAll(celly, i)
        {
            scalar v1 = 0 ;
            scalar v2 = celly[i] ;
            scalar v3 = 0 ;


            USource[i][0] +=celly[i]; //celly[i];
        }
    #};

}


Mahmoud Abbaszadeh May 31, 2022 08:08

Quote:

Originally Posted by IC01 (Post 785807)
Hi
I have the problem with vectorCodedSource; in fvOption file
I'm modifying incompressible/simpleFoam/rotorDisk tutorial. The target is to have either polynomial or tabular velocity in the RotatingZone. Please let me know if there is a simpler way
Right now I'm trying to put velocity in the y-direction that corresponds to the y coordinate of cell. It gives me not feasible values

Thank you


Code:

{
 

    type            vectorCodedSource;
    active          true;
    selectionMode  cellZone;
    cellZone        rotatingZone;

    fields          (U);
    name            codedSource;
    codeAddSup
    #{
        const Time& time = mesh().time();
        const scalarField& V = mesh_.V();
        vectorField& USource = eqn.source();
      // const scalarField& cellx = mesh_.C().component(0) ;
        const scalarField& celly = mesh_.C().component(1) ;
      //  const scalarField& cellz = mesh_.C().component(2) ;
     

        // Start time
        const scalar startTime = 20.0; 

        if (time.value() > startTime)

   
        forAll(celly, i)
        {
            scalar v1 = 0 ;
            scalar v2 = celly[i] ;
            scalar v3 = 0 ;


            USource[i][0] +=celly[i]; //celly[i];
        }
    #};

}



Hi,

Did you manage to resolve this issue?

Haitham Osman CFD December 11, 2022 21:01

the cell volume is missed
 
I hope your issue was solved.

If NOT, I think you should multiply your equation by the cell volume. So, the equation should be like

USource[i][0] +=celly[i] *V[i]

Best wishes


All times are GMT -4. The time now is 20:48.