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] on run time object (https://www.cfd-online.com/Forums/openfoam-community-contributions/145364-run-time-object.html)

hchen December 3, 2014 14:36

on run time object
 
Hi,

I want to extract the sum of a vector field in a cell zone at every time step. The cell zone is already set up in the mesh.

The vector field is something like:
(a & U + mag(U) * b & U) * cellVolume
where a and b are 3*3 tensor and & means the inner product.
So the final result is supposed to be a vector.

It seems that swak4foam can do that but I never use it before. I am trying to find some information and any helps are appreciated!

Best regards
Hao

gschaider December 3, 2014 16:55

Quote:

Originally Posted by hchen (Post 522356)
Hi,

I want to extract the sum of a vector field in a cell zone at every time step. The cell zone is already set up in the mesh.

The vector field is something like:
(a & U + mag(U) * b & U) * cellVolume
where a and b are 3*3 tensor and & means the inner product.
So the final result is supposed to be a vector.

It seems that swak4foam can do that but I never use it before. I am trying to find some information and any helps are appreciated!

Best regards
Hao

When you google "swak4Foam" the first page you get is this page on which a number of information is linked https://openfoamwiki.net/index.php/C...er_information

The basic training from the 9th Workshop is probably currently the best introduction (and it even has an example with a cellset if I remember it correctly)

hchen December 4, 2014 05:40

Hi Bernhard:

Thanks for your information. So swak4foam can do that right?

I am trying to learn it and also pyFoam.

When I install Pyfoam and use pyFoamPlotRunner, it shows some error so it did not plot the residuals:

Code:

gnuplot> set terminal x11
                      ^
        line 0: unknown or ambiguous terminal type; type just 'set terminal' for a list


gnuplot> set terminal x11

gnuplot> set terminal x11 noraise
                                            ^
 ^
                line 0: line 0: unknown or ambiguous terminal type; type just 'set terminal' for a list

unknown or ambiguous terminal type; type just 'set terminal' for a list


gnuplot> set terminal x11 noraise
                      ^
        line 0: unknown or ambiguous terminal type; type just 'set terminal' for a list


gnuplot> set terminal x11
                      ^
        line 0: unknown or ambiguous terminal type; type just 'set terminal' for a list


gnuplot> set terminal x11 noraise
                      ^
        line 0: unknown or ambiguous terminal type; type just 'set terminal' for a list

 PyFoam WARNING on line 142 of file /usr/local/lib/python2.7/dist-packages/PyFoam/LogAnalysis/GeneralLineAnalyzer.py : Problem doing timelines could not convert string to float: 
 PyFoam WARNING on line 142 of file /usr/local/lib/python2.7/dist-packages/PyFoam/LogAnalysis/GeneralLineAnalyzer.py : Problem doing timelines could not convert string to float: 
 PyFoam WARNING on line 142 of file /usr/local/lib/python2.7/dist-packages/PyFoam/LogAnalysis/GeneralLineAnalyzer.py : Problem doing timelines could not convert string to float:

Maybe it is due to the version of gnuplot? I then check the pyFoamVersion:
Code:

Python version: 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2]

Python executable: /usr/bin/python

Python 2.7 is one development platform for PyFoam (along with Python 3)
PYTHONPATH is not set

Location of this utility: /usr/local/bin/pyFoamVersion.py

 PyFoam WARNING on line 192 of file /usr/local/lib/python2.7/dist-packages/PyFoam/FoamInformation.py : Basedir /home/hchen/OpenFOAM for fork openfoam does not exist or is not a directory
Version 3.1 Fork extend of the installed 1 versions:
extend-3.1 : /home/hchen/foam/foam-extend-3.1

pyFoam-Version: 0.6.4

Path where PyFoam was found (PyFoam.__path__) is ['/usr/local/lib/python2.7/dist-packages/PyFoam']

Configuration search path: [('file', '/etc/pyFoam/pyfoamrc'), ('directory', '/etc/pyFoam/pyfoamrc.d'), ('file', '/home/hchen/.pyFoam/pyfoamrc'), ('directory', '/home/hchen/.pyFoam/pyfoamrc.d')]
Configuration files (used): []

Installed libraries:
cython              :  No      Not used. Maybe will by used later to spped up parts of PyFoam
cProfile            :  Yes
docutils            :  No      Not necessary. Needed for RestructuredText to HTML conversion
Gnuplot              :  No      Not a problem. Version from ThirdParty is used
hotshot              :  Yes
ipdb                :  No      Not necessary. Only makes debugging more comfortable
IPython              :  No      Not necessary. But the interactive shell may be more comfortable
matplotlib          :  Yes      version: 1.3.1
mercurial            :  Yes      version: 2.8.2
nose                :  No      Only needed for running the unit-tests (developers only)
numpy                :  Yes      version: 1.8.2
openpyxl            :  No      Not a problem. Only used for exporting pandas-data to Excel-files (advanced)
pandas              :  No      Not a problem. Only used for handling of advanced data-handling
ply                  :  No      Not a problem. Version from ThirdParty is used
profile              :  Yes
psyco                :  No      Not a problem. Acceleration not possible
PyQt4                :  Yes      version: 4.8.6
PyQt4.Qwt5          :  No      Only an alternate plotting back-end
scipy                :  Yes      version: 0.13.3
Tkinter              :  Yes      version: $Revision: 81008 $
twisted              :  Yes      version: 13.2.0
vtk                  :  Yes      version: 5.8.0
xlwt                :  No      Not a problem. Only used for exporting pandas-data to Excel-files
xlrd                :  No      Not a problem. Only used for importing Excel-files to pandas-data

Library locations
cProfile            : /usr/lib/python2.7/cProfile.py
hotshot              : /usr/lib/python2.7/hotshot/__init__.py
matplotlib          : /usr/lib/pymodules/python2.7/matplotlib/__init__.pyc
mercurial            : /usr/lib/python2.7/dist-packages/mercurial/__init__.pyc
numpy                : /usr/lib/python2.7/dist-packages/numpy/__init__.pyc
profile              : /usr/lib/python2.7/profile.py
PyQt4                : /usr/lib/python2.7/dist-packages/PyQt4/__init__.pyc
scipy                : /usr/lib/python2.7/dist-packages/scipy/__init__.pyc
Tkinter              : /usr/lib/python2.7/lib-tk/Tkinter.py
twisted              : /usr/lib/python2.7/dist-packages/twisted/__init__.pyc
vtk                  : /usr/lib/pymodules/python2.7/vtk/__init__.pyc

Checking additional envirnoment variables

Checking for PYFOAM_DIR : Location of the PyFoam-installation. Not strictly necessary
PYFOAM_DIR missing from environment

Checking for PYFOAM_SITE_DIR : Location of non-PyFoam-disctributions script. Set and used by some Foam-distributions
PYFOAM_SITE_DIR missing from environment

I did not install PyFoam when I download foam extend so I now use a newer version of pyfoam.

Can you figure out the reason?

Best regards
Hao

Quote:

Originally Posted by gschaider (Post 522367)
When you google "swak4Foam" the first page you get is this page on which a number of information is linked https://openfoamwiki.net/index.php/C...er_information

The basic training from the 9th Workshop is probably currently the best introduction (and it even has an example with a cellset if I remember it correctly)


hchen December 4, 2014 09:06

I solved the problem, it is just because of the version of Gnuplot. I reinstall gnuplot-x11 and seems solved.

But it is a bit wired since it shows that it uses the third party of pyfoam so the gnuplot version should be correct...

Best regards
Hao

gschaider December 4, 2014 09:25

Quote:

Originally Posted by hchen (Post 522481)
I solved the problem, it is just because of the version of Gnuplot. I reinstall gnuplot-x11 and seems solved.

But it is a bit wired since it shows that it uses the third party of pyfoam so the gnuplot version should be correct...

What seems weird to ME is that some Linux toy-distributions ship gnuplot without x11-support (what DO they use for interactive plotting?)

pyFoam can only check for the existence of the Gnuplot-Python-library. It COULD check for the gnuplot-binary but checking whether the binary supports the x11-terminal would be harder

hchen December 4, 2014 10:57

Hi Bernhard:

I went through some of the presentations you gave in the workshop and thanks very much that you develop this wonderful utility!

For my case I can add these in the controlDict:

Code:

functions
(
    whichFields
    {
        type                listRegisteredObjects;
        outputControlMode    startup;
    }

    volumeForceSum
    {
        type                swakExpression;
        valueType            cellZone;
        zoneName            in;
        accumulations        (sum);
        expression          "vol()*U+mag(U)*vol()*U";
        verbose              true;
        outputControlMode    timeStep;
        outputInterval      1;
    }
);

libs
(
      "libOpenFOAM.so"
      "libsimpleSwakFunctionObjects.so"
      "libswakFunctionObjects.so"
      "libgroovyBC.so"
);

But somehow I have a questions that how can I define the tensor a and b in the controlDict?

Best regards
Hao

Quote:

Originally Posted by gschaider (Post 522486)
What seems weird to ME is that some Linux toy-distributions ship gnuplot without x11-support (what DO they use for interactive plotting?)

pyFoam can only check for the existence of the Gnuplot-Python-library. It COULD check for the gnuplot-binary but checking whether the binary supports the x11-terminal would be harder


gschaider December 4, 2014 15:39

Quote:

Originally Posted by hchen (Post 522499)
Hi Bernhard:

I went through some of the presentations you gave in the workshop and thanks very much that you develop this wonderful utility!

For my case I can add these in the controlDict:

Code:

functions
(
    whichFields
    {
        type                listRegisteredObjects;
        outputControlMode    startup;
    }

    volumeForceSum
    {
        type                swakExpression;
        valueType            cellZone;
        zoneName            in;
        accumulations        (sum);
        expression          "vol()*U+mag(U)*vol()*U";
        verbose              true;
        outputControlMode    timeStep;
        outputInterval      1;
    }
);

libs
(
      "libOpenFOAM.so"
      "libsimpleSwakFunctionObjects.so"
      "libswakFunctionObjects.so"
      "libgroovyBC.so"
);

But somehow I have a questions that how can I define the tensor a and b in the controlDict?

Best regards
Hao

Have a look at the incomplete reference guide that comes with the sources (or http://sourceforge.net/p/openfoam-ex...Reference.md): "Constants and type building"


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