Hi all,
I have advanced on the coding of the new type of source (I have named it SourceAdvection) devoted to add a migration mechanism of species (Tracers) as an extra advection superposed to the regular velocity one. At the moment I have focused in the part of the vof advection (i.e. SourceAdvection applied to VariableVOFConcentrations) with promising results (see figure). However the code has something defective: If the SourceAdvection is applied to more than one tracer I got a segmentation fault when I try to destroy an array of GfsVariables. I am desperated stuck on this. Let me describe what I do:
The SourceAdvection has the folllowing form:
struct _GfsSourceAdvection {
/*< private >*/
GfsSourceScalar parent;
/*< public >*/
GfsFunction * intensity;
GfsVariable * e[FTT_DIMENSION];
GfsVariable * vc[FTT_DIMENSION]; /* center values of the migration velocity */
GfsVariable * vn[FTT_NEIGHBORS]; /* face values of the migration velocity */
};
The extra-migration velocity center values, vc, and face values, vn, at mid time step are calculated inside of a source_advection_event ().
Once I have available these values I have modified the gfs_tracer_vof_advection() in the following form:
1.- for each j->data concentration tracer:
a) I create two array of variables vcenter[FTT_DIMENSION] and vfaces[FTT_NEIGHBORS] by means of the gfs_temporary_variable (domain).
b) Sum up all existing migration velocities provided by the SourceAdvections into the above variables arrays.
c) since GFS_VARIABLE_TRACER (j->data)->advection.u and GFS_VARIABLE_TRACER (j->data)->advection.g are free hung up there the velocity arrays:
GFS_VARIABLE_TRACER (j->data)->advection.u = vcenter
GFS_VARIABLE_TRACER (j->data)->advection.g = vfaces
This is the point where I have more doubts. It is correct what I do in 1.c?
2.- for each j->data concentration tracer:
a) Compute extra fluxdue to migration using the already calculated values stored at
GFS_VARIABLE_TRACER (j->data)->advection.u
GFS_VARIABLE_TRACER (j->data)->advection.g
3.- for each j->data concentration tracer let destroy and restore:
for (c...)
if(GFS_VARIABLE_TRACER (j->data)->advection.u[c])
gts_object_destroy .. ;
GFS_VARIABLE_TRACER (j->data)->advection.u = NULL;
for (d...)
if(GFS_VARIABLE_TRACER (j->data)->advection.g[d])
gts_object_destroy .. ;
GFS_VARIABLE_TRACER (j->data)->advection.d = NULL;
It is here where the the program fails. Before going further I want to solve it, maybe I am missing something obvious.
I would appreciate any help on the issue.
Cheers
Jose