|
[Sponsors] |
February 12, 2002, 15:36 |
defining UDS scalar
|
#1 |
Guest
Posts: n/a
|
hi all,
can anyone please tell me if there is some other way(other than using enum) by which i can define the user defined scalar. i want to know this because if i define them as enumerated variables their range is that of integer values and hence my calculations are going crazy. any help will be greatly appreciated. thank you, sivakumar |
|
February 12, 2002, 19:42 |
Re: defining UDS scalar
|
#2 |
Guest
Posts: n/a
|
What!!!!!
Just use an integer to point to the index of the uds. Ie uds 0 is stored in C_UDSI(cell,thread,0). The kth one is stored in C_UDSI(cell,thread,k) where k is an integer. The actual value of C_UDSI will be a real - not an integer!!!!! Greg ps in the udf manual they use an enum definition to define the index - this is a programmers choice, but the actual indexes are just integers. In some of my code I use simple calcs on the index to determine the right location, ie C_UDSI(cell,thread,UDS_BASE_IDX+i) where UDS_BASE_IDX and i are integers etc. |
|
February 12, 2002, 19:52 |
Re: defining UDS scalar
|
#3 |
Guest
Posts: n/a
|
By the way what I like to do in my code is abstract the Fluent variables one additional level. So for a uds for volume fraction say, I would define
#define UDS_VOF 0 #define UDS_TEMP 1 #define CELL_UDS_VOF(c,t) C_UDSI(c,t,UDS_VOF) #define CELL_UDS_TEMP(c,t) C_UDSI(c,t,UDS_TEMP) the good bit about this is that you can change the location of the uds (each run-time) and not change your code at all. This is in fact the way Fluent define their variables - just look in the mem.h etc header files. Most of the time, I actually would declare int UDS_VOF, UDS_TEMP; and then initialise these variables in a DEFINE_INIT and/or DEFINE_ADJUST etc piece of code. Similarly one can redfine CELL_FLUID_U(c,t) as C_U(c,t). etc... Now its possible to redefine your fluid velocity by changing the macro definition and not your code etc. This doesn't slow down your code either, since the pre-processor does the substitutions before compilation. Now for the examples I've mentioned this doesn't really make a huge difference, but for complex code its the only way to do it. In one of my models I solve over 10 uds's and have over 50 udm's - and they get defined dynamically by a secondary input file that is read by my code - a sort of case file for my models. Greg |
|
March 12, 2002, 07:42 |
Re: defining UDS scalar
|
#4 |
Guest
Posts: n/a
|
Hi Greg,
Quite a good idea with respect to making the code easier to read. But what do you mean by saying that it can make things easier by being able to "change the location of the uds (each run-time) and not change your code at all"? By "location" I assume you mean the index number your scalar is assigned to. I understand that it would make it easier to swap around the index numbers between scalars, but why would you want to do this? The only case that I can think of is if you reduce the number of scalars by taking out index numbers that are mid-range. Also, how can you change the "location" at each run-time, wouldn't you have to recompile the UDF first? They might be silly questions but the reason I ask is that I want to take full advantage of this method. cheers, Matthew. |
|
March 12, 2002, 20:53 |
Re: defining UDS scalar
|
#5 |
Guest
Posts: n/a
|
Hi Matthew,
well, what I've done is to extend Fluent to handle a secondary phases with species, etc etc. In this case I read a text file which defines the phases and species in the model - in a sense it is like a secondary case file. Then using this file I allocate uds's to solve various eqns by using an index. Thus in the code I have something like, #define CELL_PHASE_SP(c,t,p,i) C_UDSI(c,t,Index[p][i]) thus the actual location of the ith species of the pth phase can change from run to run, and there's no need to recompile the udfs. My case, is ratehr extreme, since I'm adding substantial capabilities that extend Fluent quite a lot. One day I expect they will have some of these features - say in Fluent 6.5! But in some cases, I use hybrid models/methods which are required for my problem and won't be in any standard CFD code. Really, the only use for this is to make your code more modular, more readable and thus easier to maintain. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Preventing negative scalar (UDS) values?? | Matthew Brannock | FLUENT | 5 | September 1, 2020 12:32 |
Perfect sink for an UDS scalar concentration | Peter023 | FLUENT | 8 | June 28, 2018 11:48 |
dieselFoam problem!! trying to introduce a new heat transfer model | vivek070176 | OpenFOAM Programming & Development | 10 | December 23, 2014 23:48 |
Defining UDS at interface, Boundary Zone Walls Sliding Mesh | jalarron | Fluent UDF and Scheme Programming | 0 | June 23, 2010 04:58 |
UDS for positive scalar | Jun | FLUENT | 3 | August 26, 2003 17:26 |