How to calculate laplacian of a scalar in cfx?
Hi all:
I am trying to calculate a laplacian of a scalar (for example, temperature) to be used in a source term. The CFX manual shows how to get value of gradient through user fortran, but not laplacian. Has anyone done this calculation before? Thanks. Jun |
Quote:
Thanks. |
Quote:
Thanks. |
In CFX V12 you should be able to get the gradients in CEL rather than fortran. Not sure if you are going to be able to get the Laplacian from that, I have never tried. Give it a go and see if it works. Otherwise I would discuss with CFX support, there probably is a way and it might not be documented.
|
USER_GETVAR is the function can be used to get the gradient of a variable. But I can not find the explanation of the meaning of "gradient" of a vector variable.
I tried to use USER_GETVAR with option "gradient" on a vector variable, say "phase.velocity.gradient", USER_GETVAR did not give error message and there were outputs. But I dont know the meaning of the outputs and dont know how to use them. I am waiting the response from ANSYS support team, but hope somebody here can help. One other option of the USER_GETVAR function is "curl", which is easy to understand for a vector variable. |
Finally, I have figured out one way.
First, three scalar additional variables are defined to represent x, y, z gradient of Temprerature. Then, selected components from the gradients of those three additional varialbes are combined to get the laplacian of the temperature. Hope it will be helpful for others. Or please let me know there is any problem. Jun |
As I said, you don't need fortran to do this. In V12 you can get gradients from CEL.
It sounds like you have no idea about gradients of vector fields - I recommend you do some reading into gradients of vector fields before proceeding or you will be wasting your time. |
Quote:
Thank you for your input. Could you explain more how to use cel to get the gradient? I am using v12 and the CEL #2 example in the HELP shows how to define a cel function to call a UDF, in which USER_GETVAR is called to get the gradient of a variable. Can you do it in a simpler way? About gradient, I have done enough reading I think. My understanding is that gradient operator is a vector. So when the gradient of a vector variable is called, there are only two possible ways: one is divergence of the vector variable, the other one is curl of the vector variable. Laplacian of a scalar variable, is the divergence of the gradient of that scalar variable and the laplacian is a scalar. Is there any thing wrong? |
Try Temperature.Gradient_x. I think that should do it - all discussed in the CFX documentation.
|
Quote:
Temperature.Gradient_x.Gradient_x is unrecognised name. You know what, I tried Temperature.Laplacian, and there is no error message, so maybe it is defined already in the system. But it is not very comfortable, just to assume Laplacian is indeed calculated. I think it can be tested. Thank you, Glenn, for all these discussion. |
Quote:
Temperature.Laplacian does not work. Solver quits after a bunch of message: ##,MASSOU_CALVAR,VEL ## is number from 1 to several hundreds. |
Sorry, yes, you are right - the built in functions will not do second order derivatives like this. Maybe you will need fortran after all.
|
You can use “USER_GETVAR” to get the Laplacian by User Fortran in CFX14.0. But laplacian is not available in CFX of lower edition ;)
|
Quote:
UPDATE: Segmentation violation error was due to some other reason. Actually when I try to get variable laplacian USER_GETVAR sets CRESLT = OPER. Anyone knows what does OPER mean? |
Unfortunately, I came across the same problem with you, so I gave up. I think it's a terrible bug in CFX.
Quote:
|
You will probably have to talk to ANSYS support to get this working. And if it is a bug you definitely should report it so it can be fixed for the next version.
|
By the way, CRESLT = OPER means that there is some wrong with your operater. I think that there is no other possibility for this error except the inner bug!
Quote:
|
I know this's old post, but I have some obvious idea. Let Phi be our scalar field. To calculate laplacian we create two additional variables gradPhi (vector) and laplPhi (scalar). Then we set components of gradPhi to be Phi.Gradient X, Phi.Gradient Y, Phi.Gradient Z and laplPhi = gradPhi_x.Gradient X + gradPhi_y.Gradient Y + gradPhi_z.Gradient Z.
|
You can also try the Laplacian operation, ie.
Temperature.Laplacian or Velocity u.Laplacian |
Quote:
|
If you look in the <install_directory>/CFX/etc/VARIABLES file, you may find a list of VARIABLE OPERATOR.
Among those listed are: Gradient Time Derivative Curl Laplacian Magnitude Give it a try (notice the warning under development) |
Quote:
|
All times are GMT -4. The time now is 17:35. |