CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [swak4Foam] groovyBC and access to alpha field of other patch (https://www.cfd-online.com/Forums/openfoam-community-contributions/140597-groovybc-access-alpha-field-other-patch.html)

Tobi August 19, 2014 04:31

groovyBC and access to alpha field of other patch
 
Hi all,

I want to get access from alpha field from patch1 to use it in patch2.

The problem is that my alpha field does not exist?
Code:

type    groovyBC;
variables "alphaFromPatch1{patch1}=alpha.liquid;";
valueExpression "alphaFromPatch1";

Additionally I tried with:
  • alpha
  • alpha1
  • alpha2
  • alpha.liquid
  • alpha.air


But always I get an error that this variable does not exist or is of wrong type.
Does anyone have some idea?

Additionall question:

Is it possible to get velocity field U from patch1 and use it for patch2 not in an averaged value?

gschaider August 21, 2014 19:05

Quote:

Originally Posted by Tobi (Post 506572)
Hi all,

I want to get access from alpha field from patch1 to use it in patch2.

The problem is that my alpha field does not exist?
Code:

type    groovyBC;
variables "alphaFromPatch1{patch1}=alpha.liquid;";
valueExpression "alphaFromPatch1";

Additionally I tried with:
  • alpha
  • alpha1
  • alpha2
  • alpha.liquid
  • alpha.air


But always I get an error that this variable does not exist or is of wrong type.
Does anyone have some idea?

alpha.liquid won't help at all. swak does not consider the dot to be a valid part of a field name (it is a bit like C++ here) because it needs it to access components. To access fields with "illegal" characters in the name "aliases" have been added to swak some time ago (have a look at the forum, the README or the incomplete reference guide).

To find out under which name this field is known you'd have to consult the sources. Or there is a function object listRegisteredObjects that lists all objects currently registered in the registry. One of these objects should be your alpha

Quote:

Originally Posted by Tobi (Post 506572)
Additionall question:

Is it possible to get velocity field U from patch1 and use it for patch2 not in an averaged value?

Only if the patches are declared as mapped in the boundary-file

Tobi September 1, 2014 16:09

Dear Bernhard,

if I use mapped patch type I also get a interpolated velocity field:

Code:

smoothSolver:  Solving for alpha.liquid, Initial residual = 0, Final residual = 0, No Iterations 0
Phase-1 volume fraction = 0.088941  Min(alpha1) = 0  Max(alpha1) = 1
MULES: Correcting alpha.liquid
MULES: Correcting alpha.liquid
Phase-1 volume fraction = 0.088941  Min(alpha1) = 0  Max(alpha1) = 1
swak4Foam: Setting default mesh
swak4Foam: Allocating new repository for sampledGlobalVariables
DILUPBiCG:  Solving for Ux, Initial residual = 1, Final residual = 4.41011e-06, No Iterations 3
DILUPBiCG:  Solving for Uy, Initial residual = 1, Final residual = 5.89124e-06, No Iterations 3
GAMG:  Solving for p_rgh, Initial residual = 1, Final residual = 0.00848398, No Iterations 5
--> FOAM Warning :
    From function ExpressionResult::getUniformInternal(const label size,bool noWarn)
    in file ExpressionResult/ExpressionResultI.H at line 332
    The minimum value (-0.325913 -0.0248373 0) and the maximum (0.135614 1.34743 0) differ. I will use the average (-0.0315278 0.429949 0)
time step continuity errors : sum local = 1.2011e-06, global = -7.49768e-07, cumulative = -7.49768e-07
GAMG:  Solving for p_rgh, Initial residual = 0.00236714, Final residual = 7.34319e-09, No Iterations 31
--> FOAM Warning :
    From function ExpressionResult::getUniformInternal(const label size,bool noWarn)
    in file ExpressionResult/ExpressionResultI.H at line 332
    The minimum value (-0.135501 0.000179205 0) and the maximum (0.101674 0.436928 0) differ. I will use the average (-0.0170261 0.171489 0)
time step continuity errors : sum local = 4.0578e-11, global = 3.5819e-11, cumulative = -7.49732e-07
DILUPBiCG:  Solving for epsilon, Initial residual = 0.0161811, Final residual = 1.53934e-06, No Iterations 2
DILUPBiCG:  Solving for k, Initial residual = 1, Final residual = 2.04556e-06, No Iterations 3
ExecutionTime = 0.36 s  ClockTime = 1 s

The BC is like that:
Code:

    internalFacesForGroovyBC_master
    {
        type            groovyBC;
        value          uniform (0 0 0);
        variables      "x1=5;y1=6;x2=30;y2=0;function1=(y2-y1)/(x2-x1)*(time()-x1)+y1;x3=35;y3=0;x4=60;y4=4;function2=(y4-y3)/(x4-x3)*(time()-x3)+y3;";
        valueExpression "vector(0,0,0)";
        gradientExpression "vector(0,0,0)";
        fractionExpression "(time() < 5) ? 0 : 1";
    }
    internalFacesForGroovyBC_slave
    {
        type            groovyBC;
        variables      "velo{internalFacesForGroovyBC_master}=U;";
        valueExpression "velo";
        value          uniform (0 0 0);
    }

Do you have some hints?

gschaider September 1, 2014 16:55

Quote:

Originally Posted by Tobi (Post 508720)
Dear Bernhard,

if I use mapped patch type I also get a interpolated velocity field:

Code:

smoothSolver:  Solving for alpha.liquid, Initial residual = 0, Final residual = 0, No Iterations 0
Phase-1 volume fraction = 0.088941  Min(alpha1) = 0  Max(alpha1) = 1
MULES: Correcting alpha.liquid
MULES: Correcting alpha.liquid
Phase-1 volume fraction = 0.088941  Min(alpha1) = 0  Max(alpha1) = 1
swak4Foam: Setting default mesh
swak4Foam: Allocating new repository for sampledGlobalVariables
DILUPBiCG:  Solving for Ux, Initial residual = 1, Final residual = 4.41011e-06, No Iterations 3
DILUPBiCG:  Solving for Uy, Initial residual = 1, Final residual = 5.89124e-06, No Iterations 3
GAMG:  Solving for p_rgh, Initial residual = 1, Final residual = 0.00848398, No Iterations 5
--> FOAM Warning :
    From function ExpressionResult::getUniformInternal(const label size,bool noWarn)
    in file ExpressionResult/ExpressionResultI.H at line 332
    The minimum value (-0.325913 -0.0248373 0) and the maximum (0.135614 1.34743 0) differ. I will use the average (-0.0315278 0.429949 0)
time step continuity errors : sum local = 1.2011e-06, global = -7.49768e-07, cumulative = -7.49768e-07
GAMG:  Solving for p_rgh, Initial residual = 0.00236714, Final residual = 7.34319e-09, No Iterations 31
--> FOAM Warning :
    From function ExpressionResult::getUniformInternal(const label size,bool noWarn)
    in file ExpressionResult/ExpressionResultI.H at line 332
    The minimum value (-0.135501 0.000179205 0) and the maximum (0.101674 0.436928 0) differ. I will use the average (-0.0170261 0.171489 0)
time step continuity errors : sum local = 4.0578e-11, global = 3.5819e-11, cumulative = -7.49732e-07
DILUPBiCG:  Solving for epsilon, Initial residual = 0.0161811, Final residual = 1.53934e-06, No Iterations 2
DILUPBiCG:  Solving for k, Initial residual = 1, Final residual = 2.04556e-06, No Iterations 3
ExecutionTime = 0.36 s  ClockTime = 1 s

The BC is like that:
Code:

    internalFacesForGroovyBC_master
    {
        type            groovyBC;
        value          uniform (0 0 0);
        variables      "x1=5;y1=6;x2=30;y2=0;function1=(y2-y1)/(x2-x1)*(time()-x1)+y1;x3=35;y3=0;x4=60;y4=4;function2=(y4-y3)/(x4-x3)*(time()-x3)+y3;";
        valueExpression "vector(0,0,0)";
        gradientExpression "vector(0,0,0)";
        fractionExpression "(time() < 5) ? 0 : 1";
    }
    internalFacesForGroovyBC_slave
    {
        type            groovyBC;
        variables      "velo{internalFacesForGroovyBC_master}=U;";
        valueExpression "velo";
        value          uniform (0 0 0);
    }

Do you have some hints?

Use mapped(U) instead of the remote patch syntax. There are 2 or three examples in Examples/test (the cases with "mapped" in the name)

Tobi September 2, 2014 04:04

Hi Bernhard,

many thanks to you. Mapping the velocity field U is working without problems now. I think it knows which patch to map out of the boundary file (sampleRegion or coupleGroup). I will have a look at your mentioned "aliases" to get the alpha field for the further step now.

Thank you again.


All times are GMT -4. The time now is 05:37.