[SCM] Gerris Flow Solver branch, upstream, updated. b3aa46814a06c9cb2912790b23916ffb44f1f203
Stephane Popinet
popinet at users.sf.net
Fri May 15 02:53:21 UTC 2009
The following commit has been merged in the upstream branch:
commit 47142e4bfe403fe4669ae4c5d8fb08123f80e48a
Author: Stephane Popinet <popinet at users.sf.net>
Date: Thu Oct 19 13:34:35 2006 +1000
Bug fix for GfsEventStop
EventStop was using a temporary variable to store the previous timestep values.
This variable was not initialised when adapting the mesh (temporary variables
are not initialised by default).
This has been fixed by using a "real" variable instead but with a NULL name.
This meant allowing variables with a NULL name i.e. hidden permanent variables.
darcs-hash:20061019033435-d4795-cd2ddd1597590c693a42937fca1d575986a8f4d0.gz
diff --git a/src/domain.c b/src/domain.c
index 961481c..8f1f41e 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -2436,7 +2436,6 @@ GfsVariable * gfs_domain_add_variable (GfsDomain * domain,
GfsVariable * v;
g_return_val_if_fail (domain != NULL, NULL);
- g_return_val_if_fail (name != NULL, NULL);
if ((v = gfs_variable_new (gfs_variable_class (), domain, name, description)) == NULL)
return NULL;
diff --git a/src/event.c b/src/event.c
index 4634a34..330e772 100644
--- a/src/event.c
+++ b/src/event.c
@@ -1322,7 +1322,7 @@ static void gfs_event_stop_read (GtsObject ** o, GtsFile * fp)
return;
}
s->max = atof (fp->token->str);
- s->oldv = gfs_temporary_variable (domain);
+ s->oldv = gfs_domain_add_variable (domain, NULL, NULL);
s->oldv->fine_coarse = s->v->fine_coarse;
s->oldv->coarse_fine = s->v->coarse_fine;
@@ -1338,8 +1338,6 @@ static void gfs_event_stop_read (GtsObject ** o, GtsFile * fp)
gts_file_error (fp, "`%s' is a reserved keyword", fp->token->str);
return;
}
- s->diff->fine_coarse = s->v->fine_coarse;
- s->diff->coarse_fine = s->v->coarse_fine;
}
gts_file_next_token (fp);
}
@@ -1362,36 +1360,31 @@ static void copy (FttCell * cell, GfsEventStop * s)
GFS_VARIABLE (cell, s->oldv->i) = GFS_VARIABLE (cell, s->v->i);
}
-static void copy_diff (FttCell * cell, GfsEventStop * s)
-{
- GFS_VARIABLE (cell, s->diff->i) = GFS_VARIABLE (cell, s->oldv->i);
-}
-
static gboolean gfs_event_stop_event (GfsEvent * event, GfsSimulation * sim)
{
if ((* GFS_EVENT_CLASS (GTS_OBJECT_CLASS (gfs_event_stop_class ())->parent_class)->event)
(event, sim)) {
+ GfsDomain * domain = GFS_DOMAIN (sim);
GfsEventStop * s = GFS_EVENT_STOP (event);
if (s->last >= 0.) {
GfsNorm n;
- gfs_domain_cell_traverse (GFS_DOMAIN (sim),
+ gfs_domain_cell_traverse (domain,
FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1,
(FttCellTraverseFunc) diff, s);
- if (s->diff) {
- gfs_domain_cell_traverse (GFS_DOMAIN (sim),
- FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1,
- (FttCellTraverseFunc) copy_diff, s);
- gfs_domain_copy_bc (GFS_DOMAIN (sim), FTT_TRAVERSE_LEAFS, -1, s->v, s->diff);
- }
- n = gfs_domain_norm_variable (GFS_DOMAIN (sim), s->oldv, FTT_TRAVERSE_LEAFS, -1);
+ n = gfs_domain_norm_variable (domain, s->oldv, FTT_TRAVERSE_LEAFS, -1);
if (n.infty <= s->max)
sim->time.end = sim->time.t;
+ if (s->diff) {
+ gfs_variables_swap (s->diff, s->oldv);
+ gfs_domain_bc (domain, FTT_TRAVERSE_LEAFS, -1, s->diff);
+ }
}
- gfs_domain_cell_traverse (GFS_DOMAIN (sim),
+ gfs_domain_cell_traverse (domain,
FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1,
(FttCellTraverseFunc) copy, s);
+ gfs_domain_copy_bc (domain, FTT_TRAVERSE_LEAFS, -1, s->v, s->oldv);
s->last = sim->time.t;
return TRUE;
}
diff --git a/src/output.c b/src/output.c
index 48b8d31..327a3d4 100644
--- a/src/output.c
+++ b/src/output.c
@@ -1184,7 +1184,8 @@ static gboolean gfs_output_location_event (GfsEvent * event,
fputs ("# 1:T 2:X 3:Y 4:Z", fp);
while (i) {
- fprintf (fp, " %d:%s", nv++, GFS_VARIABLE1 (i->data)->name);
+ if (GFS_VARIABLE1 (i->data)->name)
+ fprintf (fp, " %d:%s", nv++, GFS_VARIABLE1 (i->data)->name);
i = i->next;
}
fputc ('\n', fp);
@@ -1198,7 +1199,8 @@ static gboolean gfs_output_location_event (GfsEvent * event,
fprintf (fp, "%g %g %g %g", sim->time.t, p.x, p.y, p.z);
while (i) {
- fprintf (fp, " %g", gfs_interpolate (cell, p, i->data));
+ if (GFS_VARIABLE1 (i->data)->name)
+ fprintf (fp, " %g", gfs_interpolate (cell, p, i->data));
i = i->next;
}
fputc ('\n', fp);
@@ -1264,7 +1266,8 @@ static void write_text (FttCell * cell, GfsOutputSimulation * output)
gfs_cell_cm (cell, &p);
fprintf (fp, "%g %g %g", p.x, p.y, p.z);
while (i) {
- fprintf (fp, " %g", GFS_VARIABLE (cell, GFS_VARIABLE1 (i->data)->i));
+ if (GFS_VARIABLE1 (i->data)->name)
+ fprintf (fp, " %g", GFS_VARIABLE (cell, GFS_VARIABLE1 (i->data)->i));
i = i->next;
}
fputc ('\n', fp);
@@ -1293,7 +1296,8 @@ static gboolean output_simulation_event (GfsEvent * event, GfsSimulation * sim)
fputs ("# 1:X 2:Y: 3:Z", fp);
while (i) {
- fprintf (fp, " %d:%s", nv++, GFS_VARIABLE1 (i->data)->name);
+ if (GFS_VARIABLE1 (i->data)->name)
+ fprintf (fp, " %d:%s", nv++, GFS_VARIABLE1 (i->data)->name);
i = i->next;
}
fputc ('\n', fp);
@@ -1385,8 +1389,15 @@ static void output_simulation_read (GtsObject ** o, GtsFile * fp)
output->var = vars;
g_free (variables);
}
- else if (output->var == NULL)
- output->var = g_slist_copy (domain->variables);
+ else if (output->var == NULL) {
+ GSList * i = domain->variables;
+
+ while (i) {
+ if (GFS_VARIABLE1 (i->data)->name)
+ output->var = g_slist_append (output->var, i->data);
+ i = i->next;
+ }
+ }
if (format != NULL) {
if (!strcmp (format, "gfs"))
diff --git a/src/utils.c b/src/utils.c
index d324ff5..d943a20 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -420,7 +420,8 @@ static void function_read (GtsObject ** o, GtsFile * fp)
, fin);
i = domain->variables;
while (i) {
- if (find_identifier (f->expr->str, GFS_VARIABLE1 (i->data)->name))
+ if (GFS_VARIABLE1 (i->data)->name &&
+ find_identifier (f->expr->str, GFS_VARIABLE1 (i->data)->name))
lv = g_slist_prepend (lv, i->data);
i = i->next;
}
diff --git a/src/variable.c b/src/variable.c
index de9b9a9..8f00bb0 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -168,7 +168,7 @@ GfsVariable * gfs_variable_from_name (GSList * i,
{
g_return_val_if_fail (name != NULL, NULL);
- while (i && strcmp (name, GFS_VARIABLE1 (i->data)->name))
+ while (i && (!GFS_VARIABLE1 (i->data)->name || strcmp (name, GFS_VARIABLE1 (i->data)->name)))
i = i->next;
return i ? GFS_VARIABLE1 (i->data) : NULL;
}
--
Gerris Flow Solver
More information about the debian-science-commits
mailing list