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/)
-   -   external variable in codedFixedValue boundary condition (https://www.cfd-online.com/Forums/openfoam-solving/242750-external-variable-codedfixedvalue-boundary-condition.html)

claudio_it May 9, 2022 12:24

external variable in codedFixedValue boundary condition
 
Hi,
I'd like to read an external variable (i.e. defined in another dictionary) within a boundary condition of the kind codedFixedValue.
The snippet is more or less like this:

Code:

#include "$FOAM_CASE/include/initialConditions"

dimensions      [0 1 -1 0 0 0 0];

internalField  uniform ($Uref 0 0);

boundaryField
{
    inlet
    {
   
        //
   
        type            codedFixedValue;
        value          uniform (1 0 0);
       
        name            parabolicVelocity;
       

         
        code
        #{
       
            const vectorField& Cf = patch().Cf();
            vectorField& field = *this;
           
            const scalar Umax = 1.5*$Uref;
           
            forAll(Cf, faceI)
            {
                const scalar y =Cf[faceI][1];
               
                field[faceI] = vector(4*Umax/(pow(H,2))*(H-y)*y, 0, 0);
            }
        #};

The variable Uref is defined in the file initialConditions. It is correctly read to initialize the internal field. But up to now, I'm not able to read it within the code. What is the correct way to access that variable?

Thank you
Claudio


All times are GMT -4. The time now is 07:53.