|
[Sponsors] |
March 26, 2014, 08:53 |
How to read from file?
|
#1 |
New Member
Tom
Join Date: Mar 2014
Posts: 19
Rep Power: 12 |
Hello,
I'd like to create UDF that assigns over 30 different values contained in one matrix to variable which appears in DEFINE_PROFILE function. In this example I tried to do this only for 2 different q values. I don't want to do it by hand, because I'd like to have easy possibilites to change q values which are contained in .txt file After compiling, assigning boundary conditions and performing simulation 0 heat flux values are shown on faces. #include "udf.h" #include <math.h> #include <stdio.h> float q[2]; FILE *file; DEFINE_EXECUTE_ON_LOADING(udf, libname) { int i; file = fopen("power.txt", "r"); for (i=0;i<2;i++) { fscanf(file, "%g", &q[i]); } fclose(file); } DEFINE_PROFILE(p11,ft, var) { real x[3]; real z; face_t f; real q0 = q[0]; begin_f_loop(f,ft) { F_CENTROID(x,f,ft); z = x[2]; F_PROFILE(f,ft,var)= (2/M_PI)*q0*sin(((z-0.287)/0.01)*M_PI); } end_f_loop(f,ft) } DEFINE_PROFILE(p12,ft, var) { real x[3]; real z; face_t f; real q0 = q[1]; begin_f_loop(f,ft) { F_CENTROID(x,f,ft); z = x[2]; F_PROFILE(f,ft,var)= (2/M_PI)*q0*sin(((z-0.287)/0.01)*M_PI); } end_f_loop(f,ft) } |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to calculate mass flow rate on patches and summation of that during the run? | immortality | OpenFOAM Post-Processing | 104 | February 16, 2021 09:46 |
[swak4Foam] Swak4FOAM 0.2.3 / OF2.2.x installation error | FerdiFuchs | OpenFOAM Community Contributions | 27 | April 16, 2014 16:14 |
[swak4Foam] swak4Foam-groovyBC build problem | zxj160 | OpenFOAM Community Contributions | 18 | July 30, 2013 14:14 |
friction forces icoFoam | ofslcm | OpenFOAM | 3 | April 7, 2012 11:57 |
[blockMesh] Axisymmetrical mesh | Rasmus Gjesing (Gjesing) | OpenFOAM Meshing & Mesh Conversion | 10 | April 2, 2007 15:00 |