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

Writing DO intensity into file with parallel architecture using UDF

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 16, 2022, 04:59
Default Writing DO intensity into file with parallel architecture using UDF
  #1
New Member
 
Kuljeet Singh
Join Date: Aug 2022
Posts: 20
Rep Power: 3
Kuljeet is on a distinguished road
hi
i am using this UDF to write DO intensity into a file. the case is square cavity with wall at 0K and CO2 at 1000K inside). When i am writing for individual face, i am getting right values its not happening for the whole wall, i am using a coarse grid just to check that. can anyone look into it. I think the problem is with parallel architecture i.e., have 1 host and 1 node process.

-K

Link for case file, UDF and generated files for both case.
"https://drive.google.com/file/d/1dItCD05Y9APaoA-AWt6RsqSvFhg5YUMd/view?usp=share_link"
Kuljeet is offline   Reply With Quote

Old   December 16, 2022, 07:20
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
share your code, explain problems
__________________
best regards


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

Old   December 17, 2022, 04:40
Default UDF to write Intensity. i have shared with above google drive link.
  #3
New Member
 
Kuljeet Singh
Join Date: Aug 2022
Posts: 20
Rep Power: 3
Kuljeet is on a distinguished road
#include "udf.h"
# define FLUID_ID 2
DEFINE_ON_DEMAND(intensity_to_file)
{
/* Different variables are needed on different nodes */
#if !RP_HOST
Domain *domain=Get_Domain(1);
Thread *thread;
face_t f;
cell_t c;
int k;
#else
int i;
#endif
#if !RP_NODE
FILE *fp = NULL;
char filename[]="intensity12.txt";
#endif
int size; /* data passing variables */
real *array;
int pe;
#if !RP_HOST
thread=Lookup_Thread(domain,8); // bottom wall id =8;
#endif
#if !RP_NODE
if ((fp = fopen(filename, "w"))==NULL)
Message("\n Warning: Unable to open %s for writing\n",filename);
else
Message("\nWriting intensity to %s...",filename);
#endif
/* UDF Now does 2 different things depending on NODE or HOST */
#if RP_NODE
/* Each Node loads up its data passing array */
size=THREAD_N_ELEMENTS_INT(thread)*4*1*1;
array = (real *)malloc(size * sizeof(real));

//for (int l=0;l<10;l++)/////////////////////////////////writing
//{
begin_f_loop_int(f,thread) //f is from 0 to 9

for(k=0;k<4;k++) ////////////k is no of angualr discritised grid points = phi*theta*4(2D case)
{
array[k*(l+1)]= C_DO_I(l,thread,k);
Message("%f\n",array[k*(l+1)]);
//printf("%lf",array[k]);
//array[k]= F_DO_I(9,thread,k);
}

end_f_loop_int(f,thread)

/* Set pe to destination node */
/* If on node_0 send data to host */
/* Else send to node_0 because */
/* compute nodes connect to node_0 & node_0 to host */

pe = (I_AM_NODE_ZERO_P) ? node_host : node_zero;
PRF_CSEND_INT(pe, &size, 1, myid);
PRF_CSEND_REAL(pe, array, size, myid);
free(array);/* free array on nodes after data sent */
/* node_0 now collect data sent by other compute nodes */
/* and sends it straight on to the host */
if (I_AM_NODE_ZERO_P)
compute_node_loop_not_zero (pe)
{
PRF_CRECV_INT(pe, &size, 1, pe);
array = (real *)malloc(size * sizeof(real));
PRF_CRECV_REAL(pe, array, size, pe);
PRF_CSEND_INT(node_host, &size, 1, myid);
PRF_CSEND_REAL(node_host, array, size, myid);
free((char *)array);
}
#endif /* RP_NODE */
#if RP_HOST
compute_node_loop (pe) /* only acts as a counter in this loop */
{
/* Receive data sent by each node and write it out to the file */
PRF_CRECV_INT(node_zero, &size, 1, node_zero);
array = (real *)malloc(size * sizeof(real));
PRF_CRECV_REAL(node_zero, array, size, node_zero);

//for (i=0; i<8; i++)
for (i=0; i<size; i++)
fprintf(fp, "%g\n", array[i]);
free(array);
}
#endif /* RP_HOST */
#if !RP_NODE
fclose(fp);
Message("Done\n");
#endif
}
Kuljeet is offline   Reply With Quote

Old   December 26, 2022, 03:06
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
try this code, compile
Code:
#include "udf.h"
# define FLUID_ID 2

DEFINE_ON_DEMAND(intensity_to_file)
{
/* Different variables are needed on different nodes */
Domain *domain;
Thread *thread;
face_t f;
cell_t c;
int i,k;
FILE *fp = NULL;
char filename[]="intensity12.txt";
int size; /* data passing variables */
real *array;
domain=Get_Domain(1);
thread=Lookup_Thread(domain,8); // bottom wall id =8;
#if !RP_NODE
if ((fp = fopen(filename, "w"))==NULL)
Message("\n Warning: Unable to open %s for writing\n",filename);
else
Message("\nWriting intensity to %s...",filename);
#endif

#if RP_NODE
size=THREAD_N_ELEMENTS_INT(thread)*4*1*1;
array = (real *)malloc(size * sizeof(real));

begin_f_loop_int(f,thread) /*f is from 0 to 9*/
{
	for(k=0;k<4;k++) /*k is no of angualr discritised grid points = phi*theta*4(2D case)*/
	{
	array[k*(f+1)]= C_DO_I(f,thread,k);
	Message0("%f\n",array[k*(f+1)]);
	}
}
end_f_loop_int(f,thread)
#endif
node_to_host_int_1(size);
node_to_host_real(array,size);

#if !RP_NODE
for (i=0; i<size; i++)
fprintf(fp, "%g\n", array[i]);
free(array);
fclose(fp);
#endif
Message0("Done\n");
}
Kuljeet likes this.
__________________
best regards


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

Old   December 26, 2022, 03:42
Default showing error
  #5
New Member
 
Kuljeet Singh
Join Date: Aug 2022
Posts: 20
Rep Power: 3
Kuljeet is on a distinguished road
Thanks for replying, but this code is not compiling. It is showing error mentioned below. I think we cant write to a file without using parallel architect.

ERROR: The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64).
The system cannot find the file specified

-K
Kuljeet is offline   Reply With Quote

Old   December 26, 2022, 05:02
Default
  #6
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
press build, not load
__________________
best regards


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

Old   December 26, 2022, 05:07
Default
  #7
New Member
 
Kuljeet Singh
Join Date: Aug 2022
Posts: 20
Rep Power: 3
Kuljeet is on a distinguished road
But how will i execute it. If i just load code, it is not showing in "execute on demand". So its not writing into anything.
Kuljeet is offline   Reply With Quote

Old   December 27, 2022, 02:07
Default
  #8
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
google "how to compile code in fluent"
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ 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
[Other] Contribution a new utility: refine wall layer mesh based on yPlus field lakeat OpenFOAM Community Contributions 58 December 23, 2021 02:36
OpenFoam "Permission denied" and "command not found" problems. iyidaniel@yahoo.co.uk OpenFOAM Running, Solving & CFD 11 January 2, 2018 06:47
[foam-extend.org] problem when installing foam-extend-1.6 Thomas pan OpenFOAM Installation 7 September 9, 2015 21:53
centOS 5.6 : paraFoam not working yossi OpenFOAM Installation 2 October 9, 2013 01:41
DxFoam reader update hjasak OpenFOAM Post-Processing 69 April 24, 2008 01:24


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