1

Previous: New boundary condition definition Up: Creating new boundary condition Next: uniformFixedValue
This is an automatically generated documentation by LaTeX2HTML utility. In case of any issue, please, contact us at info@cfdsupport.com.

codedFixedValue

  • The codedFixedValue boundary condition was introduced within the run-time code compilation framework
  • It enables to add a piece of C++ code to calculate the boundary value
  • This piece of code is loaded and executed run-time
  • Within the code you can use any functionality offered by Foam::fvMesh and Foam::Time classes
  • It is always created within the particular case
  • We are going to test it using the cavity case, let’s copy the case:
    # cp -r $FOAM_TUTORIALS /incompressible/pisoFoam/RAS/cavity $FOAM_RUN

     

  • We are going to set this boundary condition for the velocity at the movingWall patch
  • Therefore we are going to touch these lines in 0/U:
        movingWall
        {
            type            fixedValue;
            value           uniform (1 0 0);
        }
    
  • The implementation of the proposed boundary condition should look as follows:
        movingWall
        {
            type            codedFixedValue;
            value           uniform (0 0 0);
            
            redirectType    increaseToFixedValue;
            
            code 
            #{
              const scalar t = this->db().time().value();
              const scalar t0 = 5.0;
              const vector x0(1, 0, 0);
              operator==( x0 * ( 1 / (1.0 + exp(-10.0*t/t0 + 5.0) ) ) );            
            #};
        }
    
    • line 25: defines the type of boundary condition,i.e., codedFixedValue
    • line 26: compulsory initial value
    • line 28: new BC name – users choice
    • lines 30-36: implementation of new code
    • line 32: variable $ t$ holds the actual (physical) time of the simulation
    • line 33: variable $ t0$ holds the value of parameter $ t_0$ in ([*])
    • line 34: variable $ x0$ holds the value of parameter $ x_0$ in ([*])
      • this is the particular case for vector-like variable
      • a similar implementation for scalar-like variable ($ p$,$ k$,$ \omega$,$ \ldots$) would be defined in the same way as $ t0$ on the line $ 33$
    • line 35: implements the boundary condition ([*])
  • Now we can test the new boundary condition:
    # blockMesh
    # pisoFoam

     

  • We can check the values at the movingWall in paraView or by using the command:
    # pisoFoam -postProcess -func "patchAverage(U,name=movingWall)" | grep "of U = \|Time ="
  • Homework: Modify the boundary condition to get the exact value of $ x_0$ at the patch movingWall for $ t>t0$
  • The possible solution is revealed in the footnote 13.1