CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Strange behaviour - custom boundary condition runs many times in 1 timestep (https://www.cfd-online.com/Forums/openfoam-programming-development/241909-strange-behaviour-custom-boundary-condition-runs-many-times-1-timestep.html)

quarkz March 26, 2022 20:34

Strange behaviour - custom boundary condition runs many times in 1 timestep
 
Hi,

I tried to create a boundary incoming U boundary condition to change its value at each timestep. I tried using codedFixedValue and now also high lvl programming.

I tried to print some variables such as U, time for debugging purpose but I realised somethings strange - the U velocity is changed twice in 1 timestep when running simpleFoam. Moreover, if pimpleFoam is used, it runs even more -> twice within each pimpleFoam iteration.

My code is

Code:

inlet
    {
                type            codedFixedValue;
                value          $internalField;
                name    u_6dof_change;
                code
                #{
               
                        scalar cur_incoming_vel;
                       
                       
                        const fvPatch& boundaryPatch = patch();
                        vectorField& field = *this;
               
                        forAll(boundaryPatch, faceI) {
                               
                                field[faceI] =  field[faceI] + vector(1., 0,0);
         
                                cur_incoming_vel = field[faceI].component(vector::X);
                               
                        }
         
                        Info << "current incoming velocity = " << cur_incoming_vel << endl;
                 
                       
          #};

From simpleFoam

Code:

Starting time loop

Time = 0.0001

current incoming velocity = 2
smoothSolver:  Solving for Ux, Initial residual = 1, Final residual = 6.81739e-09, No Iterations 18
smoothSolver:  Solving for Uy, Initial residual = 1, Final residual = 7.71109e-09, No Iterations 16
GAMG:  Solving for p, Initial residual = 1, Final residual = 0.00713548, No Iterations 11
time step continuity errors : sum local = 2.62419e-08, global = -1.09807e-09, cumulative = -1.09807e-09
current incoming velocity = 3
current incoming velocity = 4
ExecutionTime = 0.14 s  ClockTime = 0 s

Time = 0.0002

smoothSolver:  Solving for Ux, Initial residual = 0.478384, Final residual = 3.57783e-09, No Iterations 18
smoothSolver:  Solving for Uy, Initial residual = 0.37882, Final residual = 9.38104e-09, No Iterations 16
GAMG:  Solving for p, Initial residual = 0.104267, Final residual = 0.0010176, No Iterations 10
time step continuity errors : sum local = 1.40033e-07, global = -2.25939e-08, cumulative = -2.3692e-08
current incoming velocity = 5
current incoming velocity = 6
ExecutionTime = 0.17 s  ClockTime = 0 s

Time = 0.0003

Why is this so? I only want it to run once per time step. How can I prevent this from happening?

quarkz May 19, 2022 00:44

Hi,

I finally realised why this is happening. It turns that that it is due to:

Code:

moveMeshOuterCorrectors yes
in the fvSolution file.

When this is specified, this will update the mesh every single outer iteration of the PIMPLE loop (with iterative marching enabled). For moving bodies, you can use the option moveMeshOuterCorrectors yes to gain more stability. This is reported in : http://www.wolfdynamics.com/training...s_2021_OF8.pdf


All times are GMT -4. The time now is 15:31.