CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > CFX

Getting Variables with USER_GETVAR

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By Opaque

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 9, 2021, 07:25
Default Getting Variables with USER_GETVAR
  #1
New Member
 
Join Date: Feb 2021
Posts: 3
Rep Power: 5
Aristid is on a distinguished road
Hi everyone,

i tried to get the temperature variable via a User CEL Function by using USER_GETVAR.

However, when I call the function it doesn't return anything, even the CRESLT variable that should tell if the function call was successful is empty.

Then i simplified the routine and tried to get the pressure variable (mabye this function can't get the temperature variable?) but the same error accured.
The Code is down below.

How do i use this function properly? Is there a bug? If so, is there a workaround?





#include "cfx5ext.h"
dllexport(adt)
SUBROUTINE ADT (
& NLOC,NRET,NARG,RET,ARGS,
& CRESLT,
& CZ,DZ,IZ,LZ,RZ)

#include "MMS.h"
#include "stack_point.h"

INTEGER NLOC, NRET, NARG
CHARACTER*(*) CRESLT
REAL RET(NLOC,NRET), ARGS(NLOC,NARG)

INTEGER IZ(*)
CHARACTER CZ(*)*(1)
DOUBLE PRECISION DZ(*)
LOGICAL LZ(*)
REAL RZ(*)

__stack_point__ pT

CRESLT = 'GOOD'

CALL SET_A_0 (RET, NLOC*NRET )

CALL MESAGE ('WRITE', 'WORKS UNTIL SET_A0')

CALL USER_GETVAR ('Steelliq.pressure',CRESLT,
& pT,CZ,DZ,IZ,LZ,RZ)

IF (CRESLT .NE. 'GOOD') THEN
CALL MESAGE ('WRITE', 'GET_VAR NOT GOOD')
ENDIF

CALL MESAGE ('WRITE', CRESLT)

CALL USER_SOURCE_SUB (RET(1,1),ARGS(1,1))

END

SUBROUTINE USER_SOURCE_SUB (OUTP, INP)
REAL OUTP, INP
OUTP = 1000.0
CALL MESAGE ('WRITE', 'WORKS UNTIL USER_SOUCE')

END

Last edited by Aristid; March 9, 2021 at 09:14.
Aristid is offline   Reply With Quote

Old   March 9, 2021, 08:41
Default
  #2
Senior Member
 
Join Date: Jun 2009
Posts: 1,880
Rep Power: 33
Opaque will become famous soon enough
If I recall correctly, you can use

'Steelliq.Pressure'

or

'Steelliq.p'

but definitely NOT

'Steelliq.pressure'

What surprises me is that you are not getting CRESLT = 'NAME' as documented.
aero_head and Aristid like this.
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum.
Opaque is offline   Reply With Quote

Old   March 9, 2021, 09:52
Default
  #3
New Member
 
Join Date: Feb 2021
Posts: 3
Rep Power: 5
Aristid is on a distinguished road
Thank you very much for the quick reply!

I now corrected it to 'Steelliq.Pressure', and i also tried 'Steelliq.p',
but still the same error accurs (solver crashes and message "solvermanager.exe stopped working" appears).

Before that i also tried to get Variables via creating Additional variables
(someone suggested this in a master thesis online to avoid this "bug"),
but the call to USER_GETVAR fails every time and CRESLT is empty.


Have you used USER_GETVAR successfully?

Are there alternatives to using USER_GETVAR?

I've been stuck on this problem for over a week now and suspected this might be a bug.
Aristid is offline   Reply With Quote

Old   March 10, 2021, 21:04
Default
  #4
Senior Member
 
Join Date: Jun 2009
Posts: 1,880
Rep Power: 33
Opaque will become famous soon enough
Have you run the tutorial or documentation example using user_getvar?

Would you mind posting the basics of your usage of user_getvar?
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum.
Opaque is offline   Reply With Quote

Old   March 15, 2021, 13:04
Default
  #5
New Member
 
Join Date: Feb 2021
Posts: 3
Rep Power: 5
Aristid is on a distinguished road
Thank you very much! I have now run "User CEL Example 2" (AdVarSource), and it's running fine.

It looks like the error i experienced is caused by the time the Call to the User CEL Function is made.

Before i always tried to check the return Value of the User CEL Function via Monitor Objects but never actually used it.
Mabye if i use it somewhere the error will disappear.


My Goal is to find the Y-Coordinate of the position where Temperature has a certain Value (f.e. 2000K).

My Usage of user_getvar would be to obtain the temperature field in the entire domain (or mabye only on one surface, i don't know yet).

By usind user_get_meshdata i would obtain vertex coordinates.

Then i would find the index of the temperature value closest to 2000K and hope that the Y-Coordinate-Array has the same indexing as the Temperature Array.
Aristid is offline   Reply With Quote

Old   March 15, 2021, 17:26
Default
  #6
Senior Member
 
Join Date: Jun 2009
Posts: 1,880
Rep Power: 33
Opaque will become famous soon enough
Great!!

You are aware your goal is not a 1->1 match, there can be multiple locations for a given value of Temperature. Not even sorting the arrays you are dealing with will guarantee you a unique solution, or even a repeatable solution, i.e. the same location between calls even if the temperature at the specific location remains constant.

Let us know how we can help
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum.
Opaque is offline   Reply With Quote

Reply

Tags
cel, fortran, get variable, user_getvar


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[swak4Foam] How to define boundary condition variables by using previosly defined variables? pawlo OpenFOAM Community Contributions 8 September 13, 2020 12:37
Optimal tolerance and variables scaling settings 4513645ygq Main CFD Forum 0 July 28, 2020 09:56
SU2 violates the lower bound of the FFD design variables cfdjetman SU2 4 October 2, 2019 17:15
Some variables not loading in Tecplot nick.l.thomas Tecplot 1 October 25, 2018 18:48
PHI file structure Eugene Phoenics 9 November 2, 2001 23:00


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