In this post, several ways of setting time dependent BCs are provided.
The case simulated is based on 1st cavity tutorial.
In 0/U, the moving wall velocity was set as:
boundaryField
{
movingWall
{
type fixedValue;
value uniform (1 0 0); //Velocity of 1m/s in x direction
}
fixedWall
..
..
}//<-------------------------------1st method
The case simulated is based on 1st cavity tutorial.
In 0/U, the moving wall velocity was set as:
boundaryField
{
movingWall
{
type fixedValue;
value uniform (1 0 0); //Velocity of 1m/s in x direction
}
fixedWall
..
..
}//<-------------------------------1st method
Now, let's see the other ways of setting the same const. BC using uniformFixedValue and groovyBC
boundaryField
{
movingWall
{
type uniformFixedValue;
uniformValue constant (1 0 0); //Velocity of 1m/s in x direction
}
fixedWall
..
..
} //<-------------------------------2nd method
boundaryField
{
movingWall
{
type groovyBC;
valueExpression "vector(1, 0, 0)"; //Velocity of 1m/s in x direction
}
fixedWall
..
..
} //<-------------------------------3rd method
While, before groovyBC is used, below commands must be added to system/controlDict.
libs (
"libOpenFOAM.so" //---->mandatory if problem met with paraFoam
"libgroovyBC.so" //--->groovyBC dynamic library.
);
----------------------------------------------------------------------------------------------------------------------------------------------
boundaryField
{
movingWall
{
type uniformFixedValue;
uniformValue constant (1 0 0); //Velocity of 1m/s in x direction
}
fixedWall
..
..
} //<-------------------------------2nd method
boundaryField
{
movingWall
{
type groovyBC;
valueExpression "vector(1, 0, 0)"; //Velocity of 1m/s in x direction
}
fixedWall
..
..
} //<-------------------------------3rd method
While, before groovyBC is used, below commands must be added to system/controlDict.
libs (
"libOpenFOAM.so" //---->mandatory if problem met with paraFoam
"libgroovyBC.so" //--->groovyBC dynamic library.
);
----------------------------------------------------------------------------------------------------------------------------------------------
Now, let's set a simple time dependent BC.
we want:
t=0.0 Ux=1m/s
t=0.001 Ux=-1m/s
t=0.002 Ux=1m/s
t=0.003 Ux=-1m/s
t=0.004 Ux=1m/s
t>0.004 Ux=1m/s (same as t=0.004)
Rewrite 0/U as below:
boundaryField
{
movingWall
{
type uniformFixedValue;
uniformValue table
(
(0.0 (1 0 0))
(0.01 (-1 0 0))
(0.02 (1 0 0))
(0.03 (-1 0 0))
(0.04 (1 0 0))
);
outOfBounds clamp; //velocity after t = 0.04s is set to 1m/s also
//clamp is default for outOfBounds, can be neglected.
}
fixedWall
..
..
} //<-------------------------------1st method
we want:
t=0.0 Ux=1m/s
t=0.001 Ux=-1m/s
t=0.002 Ux=1m/s
t=0.003 Ux=-1m/s
t=0.004 Ux=1m/s
t>0.004 Ux=1m/s (same as t=0.004)
Rewrite 0/U as below:
boundaryField
{
movingWall
{
type uniformFixedValue;
uniformValue table
(
(0.0 (1 0 0))
(0.01 (-1 0 0))
(0.02 (1 0 0))
(0.03 (-1 0 0))
(0.04 (1 0 0))
);
outOfBounds clamp; //velocity after t = 0.04s is set to 1m/s also
//clamp is default for outOfBounds, can be neglected.
}
fixedWall
..
..
} //<-------------------------------1st method
Second method: create a file called values.txt in case file, so you have:
values.txt 0 system constant
In value.txt, type in:
(
(0.0 (1 0 0))
(0.01 (-1 0 0))
(0.02 (1 0 0))
(0.03 (-1 0 0))
(0.04 (1 0 0))
)
----------------------------------------------------------------------------------------------------------------------------------------------
boundaryField
{
movingWall
{
type uniformFixedValue;
uniformValue tableFile;
uniformValueCoeffs
{
filename "values.txt";
}
outOfBounds clamp; //velocity after t = 0.04s is set to 1m/s also
//clamp is default for outOfBounds, can be neglected.
}
fixedWall
..
..
} //<-------------------------------2nd method
values.txt 0 system constant
In value.txt, type in:
(
(0.0 (1 0 0))
(0.01 (-1 0 0))
(0.02 (1 0 0))
(0.03 (-1 0 0))
(0.04 (1 0 0))
)
----------------------------------------------------------------------------------------------------------------------------------------------
boundaryField
{
movingWall
{
type uniformFixedValue;
uniformValue tableFile;
uniformValueCoeffs
{
filename "values.txt";
}
outOfBounds clamp; //velocity after t = 0.04s is set to 1m/s also
//clamp is default for outOfBounds, can be neglected.
}
fixedWall
..
..
} //<-------------------------------2nd method