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

How to include C standard libraries into interpreted UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 11, 2019, 12:58
Default How to include C standard libraries into interpreted UDF
  #1
New Member
 
Daniel
Join Date: Apr 2018
Posts: 24
Rep Power: 8
dsaen is on a distinguished road
I'm trying to add the math.h library to my simple UDF:

Code:
#include "udf.h"
#include "math.h"

DEFINE_PROFILE(squarewave, thread, pos) {
	
	face_t f;
	real A;
	real tm1= 1;
	real tm2 = 1;
	real t = CURRENT_TIME;
	
	begin_f_loop(f, thread) {
		A = fmod(t, tm1+ tm2);
                A = round(A*10000)/10000;
		
		if (A == 0) {
			F_PROFILE(f, thread, pos) = 100;
		}
		if (A == tm1) {
			F_PROFILE(f, thread, pos) = 0;
		}
	}
	end_f_loop(f, thread)
}

However, I'm getting the errors:

Code:
math.h: No such file or directory
line 13: fmod: undeclared variable
I'm assuming I'm adding the math.h library wrongly. How should I correctly add this library?

Thanks
dsaen is offline   Reply With Quote

Old   October 21, 2019, 08:42
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
compile your code, not interpret

best regards
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   November 11, 2019, 09:53
Default
  #3
Member
 
Abhinand
Join Date: Jun 2016
Posts: 75
Rep Power: 10
Abhinand is on a distinguished road
If, I am not mistaken, the udf.h library has the files to import all the standard libraries a normal c function takes, like I/O or math functions.
So it is best to not add any of the standard files and just stick with udf.h.

It will work correctly on both interpretation and compilation

-Abhinand
Abhinand is offline   Reply With Quote

Old   November 12, 2019, 08:07
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Regardless of your issue: compile, don't interpret. Ansys should remove the option to interpret, it is in almost every aspect inferior to compiling.
pakk is offline   Reply With Quote

Reply


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] difficulties installing swak4foam newbie29 OpenFOAM Community Contributions 120 October 21, 2022 05:01
SimpleFoam cannot open include file Marija OpenFOAM Running, Solving & CFD 1 October 28, 2020 11:35
UDF interpreted Error ctmagic Fluent UDF and Scheme Programming 4 May 14, 2018 23:26
OpenFoam install script Error during paraFoam installation SePe OpenFOAM Installation 10 June 19, 2010 16:15
Problem about interpreted UDF Earng FLUENT 5 April 8, 2004 12:07


All times are GMT -4. The time now is 17:40.