|
[Sponsors] |
February 9, 2019, 14:03 |
How to create new macro?
|
#1 |
Member
Peter Maroul
Join Date: May 2018
Posts: 52
Rep Power: 8 |
Hi all.
I saw into the previous forums a fairly strange user defined macro as follows: int neighborcell(cell_t c, Thread *t, cell_t *cn, Thread **tn, int n). This macro isn't defined in cell macros in UDF programming. That is probably defined for the first time by a user. Hereby, One question comes up to me: How can we define a new macro or function to be inserted in UDF programming? Thanks in advance for any answer! P.Maroul |
|
February 11, 2019, 02:29 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
same way as function in C language
best regards |
|
February 11, 2019, 11:37 |
|
#3 | |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Quote:
You gave an example of how to define a function. And then you ask how to define a function... You have answered your own question before you asked it! |
||
February 11, 2019, 19:54 |
|
#4 | |
Member
Peter Maroul
Join Date: May 2018
Posts: 52
Rep Power: 8 |
Quote:
Ok, but I indicated only a function title . My main question is that where and how to define or recall in macros. For example, Is it essential to define it in UDF.h or can we define it everywhere in udf macros for example in define-adjust? |
||
February 11, 2019, 20:00 |
|
#5 |
Member
Peter Maroul
Join Date: May 2018
Posts: 52
Rep Power: 8 |
||
February 11, 2019, 22:29 |
|
#6 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
You are making things complicated.
Macros are build in fluent functions, nothing else. You cant modify them (may be can, but not recommended) On the other hand, you may create file with your own function (or put these functions in your source file for each UDF). When you will compile your UDF hook this file with UDF source. Same as in C best regards |
|
February 19, 2019, 06:08 |
|
#7 |
Member
Peter Maroul
Join Date: May 2018
Posts: 52
Rep Power: 8 |
Dear Alexander
Therefor, Can I write a file (for example file name: udfexample.c) with following structure? Is it correct? Code:
int neighborcell(cell_t c, Thread *t, cell_t *cn, Thread **tn, int n) { . . /* function commands here written*/ . . } /*for example define_init*/ #include "udf.h" DEFINE_INIT(my_init_func,d) { . . . /* text commands here*/ . . . } |
|
February 19, 2019, 06:12 |
|
#8 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
#include "udf.h"
in the first line you should execute your function from one of Fluent macros. (for example from DEFINE_INIT) best regards |
|
February 19, 2019, 06:20 |
|
#9 |
Member
Peter Maroul
Join Date: May 2018
Posts: 52
Rep Power: 8 |
How is the following one?
Is it true? Code:
#include "udf.h" DEFINE_INIT(my_init_func,d) {/* function definition immediately starts after define init calling*/ int neighborcell(cell_t c, Thread *t, cell_t *cn, Thread **tn, int n) { . . /* function commands here written*/ . . }/* The end of fuction definition*/ /*First lines of define _init after function definition */ . . . /* text commands here*/ . . . } |
|
February 19, 2019, 22:34 |
|
#10 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Code:
#include "udf.h" int neighborcell(cell_t c, Thread *t, cell_t *cn, Thread **tn, int n) { . . /* function commands here written*/ . . } /*for example define_init*/ DEFINE_INIT(my_init_func,d) { . . . /* text commands here*/ // if you want execute your function: neighborcell(c, t, cn, tn, n) // of course c , t , cn ,tn, n values should be defined . . . } |
|
February 20, 2019, 06:12 |
|
#11 |
Member
Peter Maroul
Join Date: May 2018
Posts: 52
Rep Power: 8 |
Dear Alexander
Your Answers was so helpful. Thanks a lot for your kind attention. P.Maroul |
|
Tags |
new macro creation |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
OpenFoam "Permission denied" and "command not found" problems. | iyidaniel@yahoo.co.uk | OpenFOAM Running, Solving & CFD | 11 | January 2, 2018 07:47 |
[gmsh] How to create a 3D volume mesh using a existing surface mesh?! | RobertHB | Mesh Generation & Pre-Processing | 0 | July 20, 2017 09:12 |
[ICEM] how to create a 2d tri mesh with quad mesh in the boundary layer | seal2013 | ANSYS Meshing & Geometry | 3 | October 6, 2013 17:09 |
Actuator disk model | audrich | FLUENT | 0 | September 21, 2009 08:06 |
Macro Trouble -Winows Explorer Crashes with Macro | Martin Castillo | FLUENT | 1 | July 25, 2007 05:18 |