CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   ParaView (https://www.cfd-online.com/Forums/paraview/)
-   -   [OpenFOAM] python calculator - laplacian(U) calculation (https://www.cfd-online.com/Forums/paraview/237323-python-calculator-laplacian-u-calculation.html)

rol97 July 12, 2021 12:54

python calculator - laplacian(U) calculation
 
Hi everyone,
I am currently trying to evaluate through python calculator the laplacian of U, however such function only takes as input scalars. I wanted thus to write something similar to
Code:

laplacian(U_X)
however I cannot make it work, and I get this error message.
Code:

  File "/opt/paraviewopenfoam56/lib/python2.7/site-packages/paraview/calculator.py", line 192, in execute
    retVal = compute(inputs, expression, ns=variables)
  File "/opt/paraviewopenfoam56/lib/python2.7/site-packages/paraview/calculator.py", line 140, in compute
    retVal = eval(expression, globals(), mylocals)
  File "<string>", line 1, in <module>
NameError: name 'U_X' is not defined

Do you have any suggestion on how to evaluate such term?
Thanks in advance.

rol97 July 14, 2021 04:11

Nevermind, I figured it out, it is probably basic knowledge but I will explain anyway.
The syntax to extract the single component from the vector and evaluate the laplacian is

Code:

laplacian(U[:,0])


All times are GMT -4. The time now is 23:33.