CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   CFX (https://www.cfd-online.com/Forums/cfx/)
-   -   How to calculate laplacian of a scalar in cfx? (https://www.cfd-online.com/Forums/cfx/80641-how-calculate-laplacian-scalar-cfx.html)

Jun October 1, 2010 12:55

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

Jun October 3, 2010 14:28

Quote:

Originally Posted by Jun (Post 277444)
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

Anybody? Please help with an answer or a potential place to get an answer. Any information?

Thanks.

Jun October 3, 2010 21:45

Quote:

Originally Posted by Jun (Post 277444)
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

Anybody? Please help with an answer or a potential place to get an answer. Any information?

Thanks.

ghorrocks October 4, 2010 18:10

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.

Jun October 5, 2010 10:07

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.

Jun October 5, 2010 13:50

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

ghorrocks October 5, 2010 20:14

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.

Jun October 5, 2010 20:32

Quote:

Originally Posted by ghorrocks (Post 277995)
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.

Hi Glenn:

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?

ghorrocks October 5, 2010 20:39

Try Temperature.Gradient_x. I think that should do it - all discussed in the CFX documentation.

Jun October 5, 2010 20:51

Quote:

Originally Posted by ghorrocks (Post 278001)
Try Temperature.Gradient_x. I think that should do it - all discussed in the CFX documentation.

But laplacian is needed, which is some kind of second gradient of the gradient of a scalar variable.

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.

Jun October 5, 2010 21:17

Quote:

Originally Posted by Jun (Post 278002)
But laplacian is needed, which is some kind of second gradient of the gradient of a scalar variable.

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.

Update.

Temperature.Laplacian does not work. Solver quits after a bunch of message: ##,MASSOU_CALVAR,VEL

## is number from 1 to several hundreds.

ghorrocks October 6, 2010 06:13

Sorry, yes, you are right - the built in functions will not do second order derivatives like this. Maybe you will need fortran after all.

hustxinxin June 20, 2013 22:21

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 ;)

Antanas October 17, 2013 07:54

Quote:

Originally Posted by hustxinxin (Post 435174)
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 ;)

But how? I tried to get it in fortran subroutine but solver raise error "Segmentation violation" when USER_GETVAR is called. Name of the variable for which I call USER_GETVAR is "Fluid 1.Electric Potential.Laplacian".

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?

hustxinxin October 24, 2013 17:16

Unfortunately, I came across the same problem with you, so I gave up. I think it's a terrible bug in CFX.

Quote:

Originally Posted by Antanas (Post 457453)
But how? I tried to get it in fortran subroutine but solver raise error "Segmentation violation" when USER_GETVAR is called. Name of the variable for which I call USER_GETVAR is "Fluid 1.Electric Potential.Laplacian".

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?


ghorrocks October 24, 2013 17:18

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.

hustxinxin October 24, 2013 17:21

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:

Originally Posted by Antanas (Post 457453)
But how? I tried to get it in fortran subroutine but solver raise error "Segmentation violation" when USER_GETVAR is called. Name of the variable for which I call USER_GETVAR is "Fluid 1.Electric Potential.Laplacian".

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?


Antanas March 2, 2018 04:30

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.

Opaque March 2, 2018 07:30

You can also try the Laplacian operation, ie.

Temperature.Laplacian

or

Velocity u.Laplacian

Antanas March 2, 2018 08:07

Quote:

Originally Posted by Opaque (Post 683526)
You can also try the Laplacian operation, ie.

Temperature.Laplacian

or

Velocity u.Laplacian

Is it already working?


All times are GMT -4. The time now is 16:19.