|
[Sponsors] |
Problem accessing material properties in UDF for Multiphase Multispecies |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 4, 2013, 06:42 |
Problem accessing material properties in UDF for Multiphase Multispecies
|
#1 |
New Member
Tom Tranter
Join Date: Mar 2013
Location: Leeds, UK
Posts: 21
Rep Power: 13 |
Hi,
I am simulating a fuel cell and have written a series of UDFs which work for a single phase gas-mixture. Now I am trying to simulate multiphase with an additional liquid water phase and I have a problem with accessing the material properties in order to populate a series of integers that I use later in other UDFs. The UDF is an EXECUTE_ON_LOADING so I am not passed any threads to start with and I'm sure it's a problem with getting the right thread for the gas_mixture phase. Please could anyone suggest how to correctly work through the domain and thread structure. Thanks in advance Tom Here is the UDF: /* Species Variables */ int i_H2 = 99; int i_O2 = 99; int i_H2O = 99; int i_N2 = 99; char hydrogen[2] = "h2"; char water[3] = "h2o"; char oxygen[2] = "o2"; char nitrogen[2] = "n2"; DEFINE_EXECUTE_ON_LOADING(record_species, libname) { int i; char *spe_name; Domain *d=NULL; Material *mix_mat=NULL, *sp; d=Get_Domain(1); mix_mat= mixture_material(d); mixture_species_loop(mix_mat,sp,i) { spe_name=MIXTURE_SPECIE_NAME(mix_mat,i); if(strcmp(spe_name,hydrogen)==0) i_H2 = i; else if(strcmp(spe_name,oxygen)==0) i_O2 = i; else if(strcmp(spe_name,water)==0) i_H2O = i; else if(strcmp(spe_name,nitrogen)==0) i_N2 = i; else Message("Unidentified Species in List, %s\n",spe_name); } Message("H2: %d O2: %d H2O: %d N2: %d\n",i_H2,i_O2,i_H2O,i_N2); } |
|
December 4, 2013, 06:50 |
|
#2 |
New Member
Tom Tranter
Join Date: Mar 2013
Location: Leeds, UK
Posts: 21
Rep Power: 13 |
Sorry I forgot to include a section of code at the top of the UDF in case anyone thinks that may be the problem
#include "udf.h" #include <stdio.h> #include <conio.h> #include <stdlib.h> #include "materials.h" #include "string.h" Thanks |
|
December 4, 2013, 07:10 |
|
#3 |
New Member
Tom Tranter
Join Date: Mar 2013
Location: Leeds, UK
Posts: 21
Rep Power: 13 |
I have now figured it out. the UDF manual had the answer after all - although it was quite difficult to find (excuses excuses)...
The correct code is below if anyone reading back finds this post DEFINE_EXECUTE_ON_LOADING(record_species, libname) { int i; int phase_domain_index = 0; char *spe_name; Domain *d=NULL,*sub_d=NULL; Material *mix_mat=NULL, *sp, *gas_phase; if(NULL == (d=Get_Domain(1))) Error("NULL pointer assignment on domain!\n"); if(NULL == (sub_d=DOMAIN_SUB_DOMAIN(d,phase_domain_index))) Error("NULL pointer assignment on subdomain!\n"); if(NULL == (mix_mat= mixture_material(sub_d))) Error("NULL pointer assignment on mixture!\n"); //mix_mat= mixture_material(d); mixture_species_loop(mix_mat,sp,i) { spe_name=MIXTURE_SPECIE_NAME(mix_mat,i); if(strcmp(spe_name,hydrogen)==0) i_H2 = i; else if(strcmp(spe_name,oxygen)==0) i_O2 = i; else if(strcmp(spe_name,water)==0) i_H2O = i; else if(strcmp(spe_name,nitrogen)==0) i_N2 = i; else Message("Unidentified Species in List, %s\n",spe_name); } Message("H2: %d O2: %d H2O: %d N2: %d\n",i_H2,i_O2,i_H2O,i_N2); } |
|
January 17, 2021, 08:11 |
|
#4 | |
New Member
Qi-Zhao-Lu
Join Date: Jan 2021
Posts: 2
Rep Power: 0 |
Quote:
anyway thanks for you anwser.@pmtgt |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Material Properties in COMSOL for different domains with different physics | TryMyBest | COMSOL | 0 | March 5, 2013 09:23 |
Problem in using UDF in parallel computing | Yogini | Fluent UDF and Scheme Programming | 0 | January 22, 2013 09:23 |
Fluent is not accepting Modification in Material properties | er.mkumar | FLUENT | 0 | September 1, 2012 15:24 |
Urgent problem - orthotropic material in ICEM | Luk | CFX | 6 | August 30, 2006 09:06 |
parallel UDF problem | kerem | FLUENT | 2 | June 20, 2006 07:56 |