CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Incorrect argument type in User Defined Scalar

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 5, 2018, 10:46
Default Incorrect argument type in User Defined Scalar
  #1
New Member
 
Vassili BRIODEAU
Join Date: Mar 2018
Posts: 3
Rep Power: 8
vbriodeau is on a distinguished road
Hello everyone,

I am new to this forum. I read the guide to ask questions and the FAQ.

The issue is very simple. I have already been interpreting some UDFs, yet I now try to use User defined scalars (UDS). I wrote the following (useless) UDF and could interpret it, yet, when the calculation launches, it shows the following message:
chip-exec: energy_source: argument 3: incorrect type (32): int expected

The solver still continues.

I defined a scalar in the scalar panel as well as in the materials>source term. In the UDF, I put a 0 as the index of the scalar (I have only one), or I defined int i=0 and later UDSI(c,t,i). I don't understand why such a message appears. I got the error message in both cases

This has similarities to the following topics:
https://www.cfd-online.com/Forums/fluent-udf/67364-udf-parallel-error-chip-exec-function-not-found.html
Error: chip-exec: function "UDF" not found.

I tried once to compile it, and got an error message, yet I did not persevere in this way.

I did not introduce a memory
code for product of rho and velocity
help needed for accessing previous step values
fluentError: received a fatal signal (Segmentation fault).

Code:
#include "udf.h" /* must be at the beginning of every UDF you write */
DEFINE_SOURCE(energy_source, c, t, dS, eqn) 
{
real source; /* local variable */
/* Loop over cells in a thread to get information stored in cells. */
  begin_c_loop(c, t)
    {
     /* C_T gets cell temperature. The += will cause all of the cell 
        temperatures to be added together. */
        C_UDSI(c,t,0) +=C_T(c, t)*0,01;
    }
  end_c_loop(c, t)
return source;
}
Does anyone has an idea where it could come from?

Regards
vbriodeau is offline   Reply With Quote

Old   March 6, 2018, 03:27
Default
  #2
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 11
obscureed is on a distinguished road
Hi Vasili,

I cannot explain that error message. (You have not defined a global variable called "t", have you?)

There are some things to look at in your UDF:
(1) I would try to set up the compiler if at all possible, rather than using the interpreter. As one benefit, you might get better error messages.
(2) Currently, source is never given a value (and C does not initialize to zero by default), which will cause trouble when you actually run.
(3) "0,01" is not a valid number -- at least, not in my locale. Your compiler/interpreter might be different, but I doubt it. Try "0.01".
(4) I understand that this is only a test UDF, but it is starting on the wrong track. DEFINE_SOURCE is called for every cell (which is why you are given c and t). So, if you needed to do something for each cell's value of C_UDSI, you would only need to do it once per visit to DEFINE_SOURCE.

To test the compiler, I would start with a really minimal UDF:
Code:
#include "udf.h"
DEFINE_SOURCE(zero_source,c,t,dS,eqn)
{
  dS[eqn] = 0.0;
  return 0.0;
}
Good luck!
Ed
obscureed is offline   Reply With Quote

Old   March 6, 2018, 03:41
Default
  #3
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
I don't know if it causes the error, but what I do see is that you are using the loop wrong.
You should use DEFINE_SOURCE to tell Fluent what is the source in cell c on thread t. But what you do is tell Fluent what is the source on all cells of thread t by looping over each cell c in that thread... Effectively, you are trying to use variable c twice.

Your UDF should be much simpler:

Code:
#include "udf.h" /* must be at the beginning of every UDF you write */
DEFINE_SOURCE(energy_source, c, t, dS, eqn) 
{
   real source=0; /* local variable */
   /* C_T gets cell temperature. The += will cause all of the cell 
        temperatures to be added together. */
   C_UDSI(c,t,0) +=C_T(c, t)*0,01;
   return source;
}
By the way: I don't know if you are allowed to write to a UDS like this. I don't know your ultimate goal, but if you just want to store something, a user defined memory (UDM) is better suited.
pakk is offline   Reply With Quote

Old   March 6, 2018, 11:20
Default
  #4
New Member
 
Vassili BRIODEAU
Join Date: Mar 2018
Posts: 3
Rep Power: 8
vbriodeau is on a distinguished road
Hello pakk and obscureed,

thanks for your replies. I tried to compile and it worked (last time I tried I had a wrong header file). Yet, as i now try to interprete, it also works; I don't know what happened before.

The function you both submitted and mine also worked:
- 0,01 does not seem to be a problem, I already tried so.
- Not putting source to 0 does not seem to be a problem.

Your remarks about the use of the function seem to make sense, although I did not completely understood the explanation.
I built this tricky function because I want to sum all the temperatures over all the cells. This is quite useless, but it is just to train. At the end, this should be the sum of the absoprtion of all the cells to get a mass flow
I started with a source function because it seemed easier. That is alo why I defined a source term, which should be the sum of all the temperatures (yet I forgot the line C_UDSI=source).

A memory might indeed be used, but the code which inspires me does not use it, so I think I don't (C_UDSI_M1 would suffice to call the previous value).

hence the remark
Quote:
You should use DEFINE_SOURCE to tell Fluent what is the source in cell c on thread t. But what you do is tell Fluent what is the source on all cells of thread t by looping over each cell c in that thread... Effectively, you are trying to use variable c twice.
Did I though right? namely, I would like to understand the logic; I already read the manuel about this.
vbriodeau is offline   Reply With Quote

Old   March 6, 2018, 21:16
Default
  #5
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
As Pakk mentioned
for macros DEFINE_SOURCE you do not need to organize loop over cell/threads because this macros already has cell/threads as arguments
Code:
DEFINE_SOURCE(energy_source, c, t, dS, eqn)
on the other hand, fluent has other macros, where you may want to use cell/threads loops (DEFINE_ADJUST,DEFINE_PROFILE and so on)

so you will apply
Code:
 begin_c_loop(c, t)
    {
     /* code here */
    }
  end_c_loop(c, t)
for cell loop

best regards
AlexanderZ is offline   Reply With Quote

Old   March 19, 2018, 09:43
Default
  #6
New Member
 
Vassili BRIODEAU
Join Date: Mar 2018
Posts: 3
Rep Power: 8
vbriodeau is on a distinguished road
Thank you both for your support,

I understood now. i took this idea from a DEFINE_ADJUST macro, so it does not make sense.

I put the topic as solved.

Best regards and thank you very much
vbriodeau is offline   Reply With Quote

Reply

Tags
argument, fluent - udf, integer, uds, udsi

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Inlet patch problems martyn88 OpenFOAM Running, Solving & CFD 6 April 21, 2017 18:34
rhoPimpleFoam hardship petrus OpenFOAM Running, Solving & CFD 0 October 7, 2016 02:41
Modified pimpleFoam solver to MRFPimpleFoam solver hiuluom OpenFOAM Programming & Development 12 June 14, 2015 21:22
Possible Bug in pimpleFoam (or createPatch) (or fluent3DMeshToFoam) cfdonline2mohsen OpenFOAM 3 October 21, 2013 09:28
[swak4Foam] Air Conditioned room groovyBC Sebaj OpenFOAM Community Contributions 7 October 31, 2012 14:16


All times are GMT -4. The time now is 12:29.