CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Udf: Define_grid_motion file (https://www.cfd-online.com/Forums/fluent-udf/165582-udf-define_grid_motion-file.html)

silvi January 20, 2016 17:51

Udf: Define_grid_motion file
 
Hi,
I'm trying to use the define_grid_motion macro. I want to update the mesh every time steps with my file txt but during the simulation my nodal coordinates don't update as the udf isn't reading the file.

this is my UDF

Code:

#include "udf.h"
#include "stdlib.h"
#include "stdio.h"
#include<string.h>
#include "dynamesh_tools.h"
DEFINE_GRID_MOTION(remesh,domain,dt,time,dtime)
{
        FILE *fd;       
        Thread *tf = DT_THREAD(dt);
        face_t f;
        Node *v;         
        real NV_VEC(vetcoord);
        int n,i,time_step;
        char nomefile[14]=“nodi_”, numero_file[5], estensione_file[5]=".txt";
 
        time_step=N_TIME+1;
        Message("time_step:%d\n", time_step);
 
        sprintf(numero_file, "%d", time_step);
        strcat(nomefile, numero_file);
        strcat(nomefile, estensione_file);
        fd=fopen(nomefile, "r");
 
        i=0;
    if( fd==NULL )
        {
    perror("Errore in apertura del file");
    exit(1);
        }
       
        SET_DEFORMING_THREAD_FLAG(THREAD_T0(tf));


        begin_f_loop(f,tf)       
        {
                f_node_loop(f,tf,n)
            {                       
                        v = F_NODE(f,tf,n);
                                               
            if (NODE_POS_NEED_UPDATE (v))
            {
                            NODE_POS_UPDATED(v);
                                fscanf(fd, "%g %g %g", &vetcoord[0], &vetcoord[1], &vetcoord[2]);                               
                                NV_V(NODE_COORD(v), +=, vetcoord);
                                i++;
                                /*Message("coordinate:ID: %d %g %g %g \n",i,NODE_X(v), NODE_Z(v), NODE_Y(v));  */           
                        }

                }
        }
        end_f_loop(f,tf);       

        fclose(fd);
}

and my file is a txt file written in matlab with dlmwrite with tab as delimiter. I didn't write nodes ids.
thank you

vaidot January 21, 2016 01:02

I had a similar problem but I could not solve it!


All times are GMT -4. The time now is 21:02.