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] what does this postProcessing SWAK code do? (https://www.cfd-online.com/Forums/openfoam-community-contributions/119210-what-does-postprocessing-swak-code-do.html)

immortality June 12, 2013 07:05

what does this postProcessing SWAK code do?
 
it seems that this function keeps maximum velocity on the specified face during the run.correct till now.but what does mean its min max and average in accumulations?its maximum on the face itself and what does do accumulations after that?:confused:
Code:

n2_MaxU
    {
        type swakExpression;
        valueType surface;
        verbose false;
        surfaceName normal_Plane_MaxU_2;
        surface {
            type plane;
            basePoint      (0.0345 0.002 0);
            normalVector    (1 0 0);
            interpolate true;
        }
        variables (
            "maxU=(maxU<mag(U)) ? mag(U) : maxU;"
        );
        storedVariables (
            {
                name maxU;
                initialValue "0";
            }
        );
        expression "maxU";
        accumulations (
            average
            max
            min
        );
    }


akidess June 12, 2013 07:55

I'm guessing it returns accumulations over time.

immortality June 12, 2013 08:06

Hi
how over time?in each time step it writes three values for min,max,average,what can these values point to?

akidess June 12, 2013 08:46

Let me spell that out for you:

time = 0
maxU=1
accumulate.min = 1
accumulate.max = 1
accumulate.avg = 1

time = 1
maxU=1.2
accumulate.min = 1
accumulate.max = 1.2
accumulate.avg = 1.1

time = 2
maxU = 1.3
accumulate.min = 1
accumulate.max = 1.3
accumulate.avg = 1.1666...

Again, I'm speculating. Better go and test it on a simple case.

immortality June 12, 2013 09:43

in the last time step and when the run is over,maximum mag(U) is retained in max column at last time step value,right?and mean is the average of max over time steps,correct?

wyldckat June 16, 2013 15:24

Greetings to all!

From what I can understand from swak4Foam's file "Libraries/simpleSwakFunctionObjects/general/swakExpressionFunctionObjectTemplates.C", it only calculates for the current time snapshot.
It does not do the accumulation over time, it only does for each time.

Best regards,
Bruno

gschaider June 18, 2013 12:54

Quote:

Originally Posted by wyldckat (Post 434323)
Greetings to all!

From what I can understand from swak4Foam's file "Libraries/simpleSwakFunctionObjects/general/swakExpressionFunctionObjectTemplates.C", it only calculates for the current time snapshot.
It does not do the accumulation over time, it only does for each time.

Best regards,
Bruno

Yeah. "accumulations" means "accumulate multiple values into a single value at this time". Maybe not the best choice of wording but I don't want to change it anymore as it is in use for some years now

immortality June 18, 2013 14:23

Hi dear Bernhard
I'm so much glad that you have came back from OF conference healthy!
what a good work to make this thread live!
I had a doubt still! this function keeps the maximum of variable(here velocity) for each cell of patch,correct?
for example if we have two cells 1 and 2 and in t1 time step have U_1=50 and U_2=20 it returns max=50 and min=20 avg=35
in t2 if we have U_1=30 and U_2=60 it will return:max=60 min=50(because it replaces the values by maximum ones) and avg=55,right or not?
a part of my results so far is:
Code:

  6.576724138e-05      3.023810841      4.660142385      1.923340442
  6.577586207e-05      3.558452379      5.429211642      2.278709462
  6.578448276e-05      4.176471892      6.304751686      2.696674696
  6.579310345e-05      4.887775875      7.298027973      3.18448017
  6.580172414e-05      5.702865512      8.419087265      3.750780217
  6.581034483e-05      6.632774838      9.678346504      4.407149671
  6.581896552e-05      7.68897686      11.0864985      5.164402133
  6.582758621e-05      8.883273506      12.6540637      6.033977999
  6.58362069e-05      10.22765704      14.3912009      7.027906829
  6.584482759e-05      11.7341422      16.30750203      8.158693993
  6.585344828e-05      13.41458332      18.41178111      9.43917229
  6.586206897e-05      15.28045602      20.71186201      10.88233938
  6.587068966e-05      17.34263001      23.21436942      12.50104457
  6.587931034e-05      19.61112621      25.92452915      14.29506775
  6.588793103e-05      22.09486432      28.84598416      16.28575066
  6.589655172e-05      24.80141439      31.98063552      18.48503575
  6.590517241e-05      27.73675581      35.32851623      20.90309458
  6.59137931e-05      30.90505873      38.8888536      23.54873335
  6.592241379e-05      34.30848975      42.65677919      26.42905363
  6.593103448e-05      37.94705636      46.62624626      29.54927776
  6.593965517e-05      41.81849706      50.78933545      32.91264743
  6.594827586e-05      45.91822082      55.13623215      36.50755317
  6.595689655e-05      50.23930414      59.65534983      40.32078936
  6.596551724e-05      54.77254205      64.33349064      44.36872444
  6.597413793e-05      59.50654759      69.15603614      48.64528011
  6.598275862e-05      64.42790027      74.10716061      53.14207355
  6.599137931e-05      69.52134032      79.17006075      57.84835642
          6.6e-05      74.76999984      84.32719382      62.75117335
  6.600869565e-05      80.20191603      89.60548091      67.87935063
  6.60173913e-05      85.75282663      94.9421139      73.1108164
  6.602608696e-05      91.40296817      100.3189399      78.48735902
  6.603478261e-05      97.13125858      105.7173706      83.9897924
  6.604347826e-05      102.9163906      111.1191942      89.59813642
  6.605217391e-05      108.7371214      116.5067695      95.2918886
  6.606086957e-05      114.5725309      121.8631845      101.0501592
  6.606956522e-05      120.4022561      127.1723903      106.7702199
  6.607826087e-05      126.206697      132.4193111      112.5043561
  6.608695652e-05      131.9671935      138.4103627      118.2390955
  6.609565217e-05      137.6661694      144.3977836      123.9557032
  6.610434783e-05      143.2872485      150.292268      129.6364497
  6.611304348e-05      148.815342      156.0779472      135.1682272
  6.612173913e-05      154.2367089      161.740507      140.6211128
  6.613043478e-05      159.5389946      167.267213      145.9903693
  6.613913043e-05      164.7112456      172.6469122      151.2634484
  6.614782609e-05      169.7439077      177.8714784      156.353472
  6.615652174e-05      174.6288069      182.932907      161.2850556
  6.616521739e-05      179.3591154      187.8228902      166.0909226
  6.617391304e-05      183.9293058      192.5362442      170.7643681
  6.61826087e-05      188.3350967      197.0691534      175.1944125
  6.619130435e-05      192.5733921      201.4190821      179.4659822
        6.62e-05      196.642214      205.5846915      183.5934215
  6.620869565e-05      200.5406307      209.5657541      187.532936
  6.62173913e-05      204.2686818      213.3630685      191.245755
  6.622608696e-05      207.8272985      216.978307      194.8136342
  6.623478261e-05      211.2182183      220.4139959      198.2371744
  6.624347826e-05      214.4438916      223.6734482      201.4112024
  6.625217391e-05      217.5074044      226.760596      204.4385527
  6.626086957e-05      220.4124055      229.6799096      207.3311209
  6.626956522e-05      223.1630313      232.4363278      210.0330555
  6.627826087e-05      225.7638268      235.0351723      212.5623065
  6.628695652e-05      228.2196683      237.4820683      214.9702015
  6.629565217e-05      230.5356901      239.7828706      217.2356165
  6.630434783e-05      232.7172236      241.9435958      219.3182947
  6.631304348e-05      234.7697403      243.9703601      221.2950416
  6.632173913e-05      236.6987939      245.8693232      223.1710155
  6.633043478e-05      238.5099717      247.6466382      224.8913731
  6.633913043e-05      240.2088518      249.3081565      226.4964892
  6.634782609e-05      241.8009663      250.8598044      228.0158223
  6.635652174e-05      243.2917679      252.3075361      229.4531901
  6.636521739e-05      244.686583      253.6571569      230.7505898
  6.637391304e-05      245.990601      254.9345772      231.879339
  6.63826087e-05      247.2088662      256.1872714      232.7963199
  6.639130435e-05      248.3462512      257.3526423      233.6460212
        6.64e-05      249.4074872      258.4356584      234.4324024
  6.640869565e-05      250.3971562      259.4416092      235.1592483
  6.64173913e-05      251.3196604      260.3765835      235.8301723
  6.642608696e-05      252.1792069      261.2433737      236.4486191
  6.643478261e-05      252.9797732      262.0464402      237.0172106
  6.644347826e-05      253.7251062      262.7900116      237.5370346
  6.645217391e-05      254.418821      263.4780901      238.0107342
  6.646086957e-05      255.0643801      264.1144567      238.4419351
  6.646956522e-05      255.6650504      264.7026765      238.8340591
  6.647826087e-05      256.2239022      265.2461041      239.1902458
  6.648695652e-05        256.74382      265.7478887      239.5133489
  6.649565217e-05      257.2275082      266.210985      239.8059593
  6.650434783e-05      257.6775111      266.6381648      240.0704279
  6.651304348e-05      258.0962165      267.0334951      240.3088808
  6.652173913e-05      258.4858656      267.3982008      240.5232385
  6.653043478e-05      258.8485618      267.7343959      240.7152405
  6.653913043e-05      259.1862746      268.0441803      240.8864626
  6.654782609e-05      259.5008462      268.3295163      241.0383297
  6.655652174e-05      259.7939918      268.5922346      241.1720285
  6.656521739e-05      260.0673151      268.8340411      241.2885778
  6.657391304e-05      260.3223312      269.0565242      241.3890546
  6.65826087e-05      260.560459      269.2611618      241.4745299
  6.659130435e-05      260.7830222      269.4494068      241.5459991
        6.66e-05      260.991254      269.6227622      241.6043884
  6.660869565e-05      261.1862711      269.7824792      241.6505571
  6.66173913e-05      261.3690942      269.930237      241.6851673
  6.662608696e-05      261.5406695      270.0700214      241.7087625
  6.663478261e-05      261.7018724      270.1990608      241.7219109
  6.664347826e-05      261.853572      270.3181778      241.7254113
  6.665217391e-05        261.9967      270.4281383      241.7254113
  6.666086957e-05      262.1320002      270.5296526      241.7254113
  6.666956522e-05      262.2600933      270.6233792      241.7254113
  6.667826087e-05      262.3815451      270.7102756      241.7254113
  6.668695652e-05      262.4968702      270.7948681      241.7254113
  6.669565217e-05      262.6065501      270.8733882      241.7254113
  6.670434783e-05      262.7110474      270.946306      241.7254113
  6.671304348e-05      262.8108086      271.0140583      241.7254113
  6.672173913e-05      262.9062485      271.077007      241.7254113
  6.673043478e-05      262.9977409      271.1354885      241.7254113
  6.673913043e-05      263.0856236      271.1898384      241.7254113
  6.674782609e-05      263.1702162      271.2446477      241.7254113
  6.675652174e-05      263.2518156      271.2961382      241.7254113
  6.676521739e-05      263.3306946      271.3444203      241.7254113
  6.677391304e-05      263.4071045      271.3897401      241.7254113
  6.67826087e-05      263.4812781      271.4323217      241.7254113
  6.679130435e-05      263.5534396      271.4723715      241.7254113
        6.68e-05      263.6238032      271.5106644      241.7254113
  6.680869565e-05      263.6925601      271.5505186      241.7254113
  6.68173913e-05      263.7598806      271.5884846      241.7254113
  6.682608696e-05      263.8259196      271.6246965      241.7254113
  6.683478261e-05      263.890819      271.6592887      241.7254113
  6.684347826e-05      263.9547098      271.6923824      241.7254113
  6.685217391e-05      264.0177152      271.7240869      241.7254113
  6.686086957e-05      264.0799515      271.7545006      241.7254113
  6.686956522e-05      264.1415217      271.7844266      241.7254113
  6.687826087e-05      264.2025244      271.8163604      241.7254113
  6.688695652e-05      264.2630533      271.8472865      241.7254113
  6.689565217e-05      264.3232092      271.8772544      241.7254113
  6.690434783e-05      264.3831249      271.906294      241.7254113
  6.691304348e-05      264.442892      271.9344623      241.7254113
  6.692173913e-05      264.5025752      271.9618247      241.7254113
  6.693043478e-05      264.5622249      271.9884378      241.7254113
  6.693913043e-05      264.6218767      272.0143504      241.7254113
  6.694782609e-05      264.6815659      272.0397165      241.7254113
  6.695652174e-05      264.7413228      272.0680278      241.7254113
  6.696521739e-05      264.8011818      272.0957944      241.7254113
  6.697391304e-05      264.8611684      272.1230492      241.7254113
  6.69826087e-05      264.9213117      272.1497836      241.7254113
  6.699130435e-05      264.9816341      272.1759976      241.7254113
          6.7e-05      265.0421524      272.2017197      241.7254113
  6.700884956e-05      265.1039582      272.2274276      241.7254113
  6.701769912e-05      265.1659946      272.252685      241.7254113
  6.702654867e-05      265.2282706      272.2775087      241.7254113
  6.703539823e-05      265.2907924      272.301914      241.7254113
  6.704424779e-05      265.3535658      272.3268542      241.7254113
  6.705309735e-05      265.4165991      272.3541579      241.7254113
  6.70619469e-05      265.4799001      272.3811122      241.7254113
  6.707079646e-05      265.543475      272.4076701      241.7254113
  6.707964602e-05      265.6073317      272.4338184      241.7254113
  6.708849558e-05      265.6714839      272.4595735      241.7254113
  6.709734513e-05      265.7359441      272.484947      241.7254113
  6.710619469e-05      265.8007239      272.5099448      241.7254113


billie June 18, 2013 16:21

Code:

n2_MaxU
    {
        type swakExpression;
        valueType surface;
        verbose false;
        surfaceName normal_Plane_MaxU_2;
        surface {
            type plane;
            basePoint      (0.0345 0.002 0);
            normalVector    (1 0 0);
            interpolate true;
        }
        variables (
            "maxU=(maxU<mag(U)) ? mag(U) : maxU;"
        );
        storedVariables (
            {
                name maxU;
                initialValue "0";
            }
        );
        expression "maxU";
        accumulations (
            average
            max
            min
        );
    }

I get it like this. The expression used above is an arithmetic if Operator as used in C++. It means the same as:

Code:

if (maxU<mag(U))
    maxU = mag(U);
else
    maxU = maxU;

So the expression returns the absolute value of U "mag(U)" for each interpolated value on the surface if the absolute value of U is greater than the previous value, else it returns the previous value. From all values the average, maximum and minimum value are written out.

immortality June 19, 2013 10:02

this error occurred in my recent run:
Code:

[2] --> FOAM FATAL ERROR:
[2]  Parser Error for driver SampledSurfaceValueExpressionDriver at "1.13" :"Operands have different sizes: 0 and 120"
"(maxU<mag(U)) ? mag(U) : maxU"
^
--------------|

Context of the error:


- From dictionary: IOstream.functions.n2_MaxU
Evaluating expression "(maxU<mag(U)) ? mag(U) : maxU"
[2]
[2]
[2]    From function parsingValue
[2]    in file lnInclude/CommonValueExpressionDriverI.H at line 1081.
[2]
FOAM parallel run exiting
[2]
--------------------------------------------------------------------------
MPI_ABORT was invoked on rank 2 in communicator MPI_COMM_WORLD
with errorcode 1.

NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
You may or may not see output from other processes, depending on
exactly when Open MPI kills them.
--------------------------------------------------------------------------
--------------------------------------------------------------------------
mpirun has exited due to process rank 2 with PID 3100 on
node Ehsan-com exiting without calling "finalize". This may
have caused other processes in the application to be
terminated by signals sent by mpirun (as reported here).
--------------------------------------------------------------------------

gnuplot> set terminal png small color
                                ^
        line 0: invalid color spec, must be xRRGGBB


gnuplot> set terminal png small color
                                ^
        line 0: invalid color spec, must be xRRGGBB

Killing PID 3089
 PyFoam WARNING on line 232 of file /usr/local/lib/python2.7/dist-packages/PyFoam/Execution/FoamThread.py : Process 3089 was already dead

gnuplot> set terminal png small color
                                ^
        line 0: invalid color spec, must be xRRGGBB

what's the cause?
maybe its a bug in 0.2.4 version of Swak4Foam?it used to work in before version 0.2.3 (the same function)

immortality June 19, 2013 10:36

I commented out MaxU function and now it occurs on MaxP function too:
Code:

n2_Maxp
    {
        $n2_totalPressure;
        surfaceName normal_Plane_Maxp_2;
        variables (
            "maxp=(maxp<p) ? p : maxp;"
        );
        storedVariables (
            {
                name maxp;
                initialValue "0";
            }
        );
        expression "maxp";
    }

that :
Code:

n2_totalPressure
    {
        type swakExpression;
        valueType surface;
        verbose false;
        surfaceName normal_Plane_p0_2;
        surface {
            type plane;
            basePoint      (0.0345 0.002 0);
            normalVector    (1 0 0);
            interpolate true;
        }
      expression "sum((p+.5*rho*magSqr(U))*rho*area())/sum(rho*area())";
        accumulations (
            average
        );
        outputControlMode outputTime;//outputTime is added in 0.2.4 Swak4Foam version
        outputInterval 1;
    }

the erreo is:
Code:

Expression totalPressure_right :  average=311369.862
Expression totalTemperature_right :  average=443.1194824
Expression totalEnthalpy_right :  average=147089.613
faceSource n1_Average output:
areaAverage(sampledSurface) for p = 303975
areaAverage(sampledSurface) for T = 440
areaAverage(sampledSurface) for rho = 2.406296692
areaAverage(sampledSurface) for h = 143953.2033
areaAverage(sampledSurface) for U = (7.427461575e-15 -3.188416843e-16 0)

faceSource n2_Average output:
areaAverage(sampledSurface) for p = 303975
areaAverage(sampledSurface) for T = 440
areaAverage(sampledSurface) for rho = 2.406296692
areaAverage(sampledSurface) for h = 143953.2033
areaAverage(sampledSurface) for U = (1.028058042e-15 -7.491884247e-15 0)

[2]
[2]
[2] --> FOAM FATAL ERROR:
[2]  Parser Error for driver SampledSurfaceValueExpressionDriver at "1.8" :"Operands have different sizes: 0 and 120"
"(maxp<p) ? p : maxp"
^
---------|

Context of the error:


- From dictionary: IOstream.functions.n2_Maxp
Evaluating expression "(maxp<p) ? p : maxp"
[2]
[2]
[2]    From function parsingValue
[2]    in file lnInclude/CommonValueExpressionDriverI.H at line 1081.
[2]
FOAM parallel run exiting
[2]
--------------------------------------------------------------------------
MPI_ABORT was invoked on rank 2 in communicator MPI_COMM_WORLD
with errorcode 1.

NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
You may or may not see output from other processes, depending on
exactly when Open MPI kills them.

I have to return to older version?why its so?:confused:

wyldckat June 20, 2013 19:16

Hi Ehsan,

First, a question: did these exact function objects work with the previous version of swak4Foam?

As for the error: it looks like it is having problems with how the initialization is being done.

Actually, after investigating this further, I've figured out that this only happens when using "outputTime". This does not happen when it's "timestep". Problem is that I don't know how to fix this... or at least not yet :(


The following only worked partially:
Code:

    globalMaxPInit
    {
      type addGlobalVariable ;
      outputControl timeStep ; // required by OpenFOAM
      outputInterval 1; // required by OpenFOAM
      globalName maxp;
      globalScope myVars;
      valueType scalar;
      value 0;
    }

    n2_Maxp
    {
        type swakExpression;
        valueType surface;
        verbose true;
        globalScopes ("myVars");
        surfaceName normal_Plane_Maxp_2;
        surface {
            type plane;
            basePoint      (0.0345 0.002 0);
            normalVector    (1 0 0);
            interpolate true;
        }
        variables (
            "maxp=(maxp<p) ? p : maxp;"
        );
//        storedVariables (
//            {
//                name maxp;
//                initialValue "sasd134";
//            }
//        );
        expression "maxp";
        accumulations (
            average
        );
        outputControlMode outputTime;//outputTime is added in 0.2.4 Swak4Foam version
        outputInterval 1;
    }

I say "partially", because it doesn't seen to memorize the new value for "maxp" :( Although... now that I think about it... the accumulation is "average", therefore it's possible that although the average varies, the maximum values for each point keep increasing...

Either way, I based myself on global variables from here: http://openfoamwiki.net/images/d/da/...Leoben2011.pdf

Best regards,
Bruno

gschaider June 20, 2013 21:02

Quote:

Originally Posted by immortality (Post 434709)
Hi dear Bernhard
I'm so much glad that you have came back from OF conference healthy!
what a good work to make this thread live!
I had a doubt still! this function keeps the maximum of variable(here velocity) for each cell of patch,correct?
for example if we have two cells 1 and 2 and in t1 time step have U_1=50 and U_2=20 it returns max=50 and min=20 avg=35
in t2 if we have U_1=30 and U_2=60 it will return:max=60 min=50(because it replaces the values by maximum ones) and avg=55,right or not?
a part of my results so far is:

No. At t2 min should be 20. Everything else I'd consider a bug. These are only values for the current timestep

gschaider June 20, 2013 21:08

Quote:

Originally Posted by wyldckat (Post 435137)
Hi Ehsan,

First, a question: did these exact function objects work with the previous version of swak4Foam?

As for the error: it looks like it is having problems with how the initialization is being done.

Actually, after investigating this further, I've figured out that this only happens when using "outputTime". This does not happen when it's "timestep". Problem is that I don't know how to fix this... or at least not yet :(

Probably because the global variable is only initialized when outputControl tells it to be ... which is after the swakExpression ... which leads to the error ... which means never (is it initialized).

Bug report please and I'll try to make this more transparent for the user

The problem with the stored variable seems to be something slightly different

immortality June 21, 2013 07:13

Quote:

No. At t2 min should be 20. Everything else I'd consider a bug. These are only values for the current timestep
I don't understand it! the field is MaxU for example then we expect it keeps and writes only maximum values in each cell during the run I think and after the run ends we will have max:the maximum value a cell has reached to it during whole the run times from beginning to end.min will show minimum of maximums! and average the average of maximums in each time step.:confused: if its only in each time step whats its difference from simple mag(U) field?!

Quote:

First, a question: did these exact function objects work with the previous version of swak4Foam?
sorry,I had forgotten!I didn't use outputTime for previous version,cause I couldn't!
now what should I do?set it to timeStep again?

gschaider June 23, 2013 06:32

Quote:

Originally Posted by immortality (Post 435246)
I don't understand it! the field is MaxU for example then we expect it keeps and writes only maximum values in each cell during the run I think and after the run ends we will have max:the maximum value a cell has reached to it during whole the run times from beginning to end.min will show minimum of maximums! and average the average of maximums in each time step.:confused: if its only in each time step whats its difference from simple mag(U) field?!

I things got mixed up here because it was not clear to me when answering that you were referring to your example code. You're right. It should be the maximum over time

Quote:

Originally Posted by immortality (Post 435246)
sorry,I had forgotten!I didn't use outputTime for previous version,cause I couldn't!
now what should I do?set it to timeStep again?


immortality June 23, 2013 07:30

thanks.
then
Code:

outputControlMode outputTime;
can't be used?I didn't grasp the reason exactly still! what's wrong with memorizing globalVariables that I read its the cause?can't be resolved in this version?
I think it will be a large file that maybe hard to even open after end of run(just a guess!)

wyldckat June 23, 2013 16:23

Greetings to all!

@Bernhard: Bug report made here: https://sourceforge.net/apps/mantisb...iew.php?id=176

In additional, typo reported here: https://sourceforge.net/apps/mantisb...iew.php?id=177

Best regards,
Bruno

immortality June 23, 2013 17:34

I was using those dictionaries without any problem in previous version although was not putting
Code:

outputControlMode outputTime
or
Code:

outputControlMode timestep
but it worked.I don't remember having any trouble about them in 0.2.3 I don't like downgrading! isn't there another way to get rid of this problem in 0.2.4(of course except to deleting them!)?
If not possible yet I have to downgrade:(

wyldckat June 23, 2013 18:56

Hi Ehsan,

Using the setting:
Code:

outputControlMode timestep;
will give you the old way of how swak4Foam worked.

Best regards,
Bruno


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