|
[Sponsors] |
Indefinite hold when executing DEFINE_ON_DEMAND |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 19, 2020, 00:16 |
Indefinite hold when executing DEFINE_ON_DEMAND
|
#1 |
New Member
Hosea Chan
Join Date: Nov 2018
Posts: 4
Rep Power: 8 |
Dear forum users,
I am currently writing a code that sums the volume for 4 cell zones at the before the initialization, which the values will be used in 4 subsequent DEFINE_SOURCE macros. Specifically, I need to apply an x-momentum force that is dependent on the average velocity at the upstream face of the cell zone and apply the force evenly to the fluid body within the cell zone. Here is the portion of the code I have written for the volume sum: Code:
#include "udf.h" #define cell_zones 4 real total_volume[cell_zones]; real Ux[cell_zones]; int id_a[cell_zones] = {28,33,37,40}; /* get zone id of channel-in later, need input */ int id_v[cell_zones] = {9,10,11,12}; /* get zone id of channel volume later, need input */ DEFINE_ON_DEMAND(initialize) { #if !RP_HOST Domain* d; int i; d = Get_Domain(1); for (i=0; i<4 ; i++) { Message0("Begin loop %d\n",i); cell_t c; Thread* t2 = Lookup_Thread(d,id_v[i]); begin_c_loop(c, t2) { total_volume[i] += C_VOLUME(c,t2); } end_c_loop(c, t2) Message0("End loop %d\n",i); #if RP_NODE total_volume[i] = PRF_GRSUM1(total_volume[i]); #endif node_to_host_real_1(total_volume[i]); Message0("total_volume of zone %d: %12.4e\n", i,total_volume[i]); } #if RP_NODE #endif /* RP_NODE */ #endif /* !RP_HOST */ } Best regards, Hosea Chan Last edited by Hosea_Chan; November 19, 2020 at 03:03. |
|
November 19, 2020, 05:13 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
#include "udf.h"
#define cell_zones 4 real total_volume[cell_zones]; real Ux[cell_zones]; int id_a[cell_zones] = {28,33,37,40}; /* get zone id of channel-in later, need input */ int id_v[cell_zones] = {9,10,11,12}; /* get zone id of channel volume later, need input */ DEFINE_ON_DEMAND(initialize) { #if !RP_HOST Domain* d; int i; d = Get_Domain(1); for (i=0; i<4 ; i++) { Message0("Begin loop %d\n",i); cell_t c; Thread* t2 = Lookup_Thread(d,id_v[i]); begin_c_loop(c, t2) { total_volume[i] += C_VOLUME(c,t2); } end_c_loop(c, t2) Message0("End loop %d\n",i); #if RP_NODE total_volume[i] = PRF_GRSUM1(total_volume[i]); #endif Message0("total_volume of zone %d: %12.4e\n", i,total_volume[i]); } #endif /* !RP_HOST */ }
__________________
best regards ****************************** press LIKE if this message was helpful |
|
November 19, 2020, 05:23 |
|
#3 |
New Member
Hosea Chan
Join Date: Nov 2018
Posts: 4
Rep Power: 8 |
Dear Alex,
Thank you so much! The code works! So it seems like it is the line of node_to_host_real1(total_volume[i]); is holding up the macro. As I have defined total_volume as a global variable, do I need to transfer it back to the host so that the variable can be used in the subsequent macros? Thanks! Best regards, Hosea |
|
November 19, 2020, 21:55 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
usually, you want to return values to host in cases:
1. you want to read/write from/to file 2. you want to transfer values to cortex (to use in scheme code for instance) so most likely you don't need to transfer. But if you are going to transfer, read how to make it for arrays Ansys Fluent Customization manual
__________________
best regards ****************************** press LIKE if this message was helpful |
|
November 20, 2020, 08:09 |
|
#5 |
New Member
Hosea Chan
Join Date: Nov 2018
Posts: 4
Rep Power: 8 |
Dear Alex,
Thank you very much for your clear explanation! This is a great help over the manual text! Best regards, Hosea |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Does Stokes hypothesis still hold for compressible flow? | TurbJet | Main CFD Forum | 6 | February 20, 2018 03:46 |
"epsAvg_0", "epsMax_0" and "epsMin_0" after executing foamLog | KeiJun | OpenFOAM Running, Solving & CFD | 0 | October 20, 2015 11:35 |
Force fluent to hold only last timestep | ansys_matt | FLUENT | 3 | August 24, 2014 23:07 |
Hold up in a closed vessel | Pascale Fonteijn | CFX | 4 | June 9, 2003 13:27 |