[SCM] Gerris Flow Solver branch, upstream, updated. b3aa46814a06c9cb2912790b23916ffb44f1f203
Stephane Popinet
s.popinet at niwa.co.nz
Fri May 15 02:52:18 UTC 2009
The following commit has been merged in the upstream branch:
commit 07606863ce1dd4184f5f69111001a38406f18d19
Author: Stephane Popinet <s.popinet at niwa.co.nz>
Date: Tue Jul 12 15:58:31 2005 +1000
Changed computation of centered pressure gradients
This influences only the pressure gradient in mixed cells. It is now
computed as the surface-fraction-weighted averaged rather than just
the average. This is intuitively more consistent as this provides a
continuous interpolation when the face fractions vanish on one side of
the cell. More importantly this greatly stabilises the ocean model
near sharp headlands. It has a minimal influence on the convergence
rates of the test cases with boundaries (slightly improves the V
component and slightly degrades the U component).
darcs-hash:20050712055831-fbd8f-665862ec312d49579388363afb43c15bc2317780.gz
diff --git a/src/timestep.c b/src/timestep.c
index ee30c74..f660ccd 100644
--- a/src/timestep.c
+++ b/src/timestep.c
@@ -95,19 +95,13 @@ void gfs_multilevel_params_read (GfsMultilevelParams * par, GtsFile * fp)
gts_file_variable_error (fp, var, "nrelax", "nrelax must be non zero");
}
-static void reset_gradients (FttCell * cell, GfsVariable ** g)
+static void reset_gradients (FttCell * cell, gpointer * data)
{
+ GfsVariable ** g = data[0];
+ guint * dimension = data[1];
FttComponent c;
- for (c = 0; c < FTT_DIMENSION; c++)
- GFS_VARIABLE (cell, g[c]->i) = 0.;
-}
-
-static void reset_gradients_2D (FttCell * cell, GfsVariable ** g)
-{
- FttComponent c;
-
- for (c = 0; c < 2; c++)
+ for (c = 0; c < *dimension; c++)
GFS_VARIABLE (cell, g[c]->i) = 0.;
}
@@ -130,7 +124,6 @@ static void correct_normal_velocity (FttCellFace * face,
type = ftt_face_type (face);
c = face->d/2;
- // gfs_face_gradient_flux_centered (face, &g, GFS_P, -1);
gfs_face_weighted_gradient (face, &g, p->i, -1);
dp = (g.b - g.a*GFS_VARIABLE (face->cell, p->i))/ftt_cell_size (face->cell);
if (!FTT_FACE_DIRECT (face))
@@ -140,41 +133,47 @@ static void correct_normal_velocity (FttCellFace * face,
dp /= s->solid->s[face->d];
GFS_FACE_NORMAL_VELOCITY_LEFT (face) -= dp*(*dt);
- GFS_VARIABLE (face->cell, gv[c]->i) += dp;
-
- if (type == FTT_FINE_COARSE)
+ GFS_VARIABLE (face->cell, gv[c]->i) += dp*GFS_FACE_FRACTION_LEFT (face);
+
+ switch (type) {
+ case FTT_FINE_FINE:
+ GFS_FACE_NORMAL_VELOCITY_RIGHT (face) -= dp*(*dt);
+ GFS_VARIABLE (face->neighbor, gv[c]->i) += dp*GFS_FACE_FRACTION_RIGHT (face);
+ break;
+ case FTT_FINE_COARSE: {
/* fixme: does this work (FTT_CELLS/2?) for 2D3? */
- dp *= GFS_FACE_FRACTION_LEFT (face)/(GFS_FACE_FRACTION_RIGHT (face)*FTT_CELLS/2);
-
- GFS_FACE_NORMAL_VELOCITY_RIGHT (face) -= dp*(*dt);
- GFS_VARIABLE (face->neighbor, gv[c]->i) += dp;
+ dp *= GFS_FACE_FRACTION_LEFT (face)/(FTT_CELLS/2);
+ GFS_VARIABLE (face->neighbor, gv[c]->i) += dp;
+ GFS_FACE_NORMAL_VELOCITY_RIGHT (face) -= dp/GFS_FACE_FRACTION_RIGHT (face)*(*dt);
+ break;
+ }
+ default:
+ g_assert_not_reached ();
+ }
}
-static void scale_gradients (FttCell * cell, GfsVariable ** g)
+static void scale_gradients (FttCell * cell, gpointer * data)
{
+ GfsVariable ** g = data[0];
+ guint * dimension = data[1];
FttComponent c;
- FttCellNeighbors n;
- ftt_cell_neighbors (cell, &n);
- for (c = 0; c < FTT_DIMENSION; c++) {
- FttCell * c1 = n.c[2*c], * c2 = n.c[2*c + 1];
+ if (GFS_IS_MIXED (cell)) {
+ GfsSolidVector * s = GFS_STATE (cell)->solid;
- if (c1 && c2)
- GFS_VARIABLE (cell, g[c]->i) /= 2.;
+ for (c = 0; c < *dimension; c++)
+ GFS_VARIABLE (cell, g[c]->i) /= s->s[2*c] + s->s[2*c + 1];
}
-}
-
-static void scale_gradients_2D (FttCell * cell, GfsVariable ** g)
-{
- FttComponent c;
- FttCellNeighbors n;
-
- ftt_cell_neighbors (cell, &n);
- for (c = 0; c < 2; c++) {
- FttCell * c1 = n.c[2*c], * c2 = n.c[2*c + 1];
+ else {
+ FttCellNeighbors n;
- if (c1 && c2)
- GFS_VARIABLE (cell, g[c]->i) /= 2.;
+ ftt_cell_neighbors (cell, &n);
+ for (c = 0; c < *dimension; c++) {
+ FttCell * c1 = n.c[2*c], * c2 = n.c[2*c + 1];
+
+ if (c1 && c2)
+ GFS_VARIABLE (cell, g[c]->i) /= 2.;
+ }
}
}
@@ -207,18 +206,20 @@ void gfs_correct_normal_velocities (GfsDomain * domain,
g[c] = gfs_temporary_variable (domain);
gfs_variable_set_vector (g[c], c);
}
+ data[0] = g;
+ data[1] = &dimension;
gfs_domain_cell_traverse (domain, FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1,
- (FttCellTraverseFunc) (dimension == 2 ?
- reset_gradients_2D : reset_gradients), g);
+ (FttCellTraverseFunc) reset_gradients, data);
data[0] = p;
data[1] = g;
data[2] = &dt;
gfs_domain_face_traverse (domain, dimension == 2 ? FTT_XY : FTT_XYZ,
FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1,
(FttFaceTraverseFunc) correct_normal_velocity, data);
+ data[0] = g;
+ data[1] = &dimension;
gfs_domain_cell_traverse (domain, FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1,
- (FttCellTraverseFunc) (dimension == 2 ?
- scale_gradients_2D : scale_gradients), g);
+ (FttCellTraverseFunc) scale_gradients, data);
for (c = 0; c < dimension; c++)
gfs_domain_bc (domain, FTT_TRAVERSE_LEAFS, -1, g[c]);
}
diff --git a/test/euler/boundaries/orderU.ref b/test/euler/boundaries/orderU.ref
index 87ce87d..81ed208 100644
--- a/test/euler/boundaries/orderU.ref
+++ b/test/euler/boundaries/orderU.ref
@@ -1,2 +1,2 @@
-7 3.297e-04 1.619e-03 6.040e-02
-8 1.072e-04 8.267e-04 4.055e-02
+7 3.217e-04 1.682e-03 6.040e-02
+8 1.037e-04 7.816e-04 4.053e-02
diff --git a/test/euler/boundaries/orderV.ref b/test/euler/boundaries/orderV.ref
index 96c2bb0..c4392a1 100644
--- a/test/euler/boundaries/orderV.ref
+++ b/test/euler/boundaries/orderV.ref
@@ -1,2 +1,2 @@
-7 3.642e-04 1.321e-03 4.354e-02
-8 1.138e-04 6.115e-04 3.036e-02
+7 3.744e-04 1.437e-03 4.319e-02
+8 1.195e-04 6.574e-04 2.847e-02
diff --git a/test/euler/channel/orderU.ref b/test/euler/channel/orderU.ref
index eec5b38..f3bba2f 100644
--- a/test/euler/channel/orderU.ref
+++ b/test/euler/channel/orderU.ref
@@ -1,2 +1,2 @@
-5 9.895e-05 2.695e-04 2.653e-03
-6 4.242e-05 1.495e-04 2.599e-03
+5 1.150e-04 2.984e-04 2.635e-03
+6 5.024e-05 1.554e-04 2.528e-03
diff --git a/test/euler/channel/orderV.ref b/test/euler/channel/orderV.ref
index 5bd11a2..2752db4 100644
--- a/test/euler/channel/orderV.ref
+++ b/test/euler/channel/orderV.ref
@@ -1,2 +1,2 @@
-5 1.748e-04 5.480e-04 4.853e-03
-6 4.874e-05 1.975e-04 2.550e-03
+5 1.673e-04 5.174e-04 4.757e-03
+6 4.797e-05 1.883e-04 2.537e-03
diff --git a/test/euler/channel/orderfU.ref b/test/euler/channel/orderfU.ref
index 86cb412..e763614 100644
--- a/test/euler/channel/orderfU.ref
+++ b/test/euler/channel/orderfU.ref
@@ -1,2 +1,2 @@
-5 8.038e-05 2.217e-04 2.111e-03
-6 2.754e-05 9.518e-05 1.367e-03
+5 9.618e-05 2.559e-04 2.161e-03
+6 3.591e-05 1.093e-04 1.390e-03
diff --git a/test/euler/channel/orderfV.ref b/test/euler/channel/orderfV.ref
index 805ae91..0c3b456 100644
--- a/test/euler/channel/orderfV.ref
+++ b/test/euler/channel/orderfV.ref
@@ -1,2 +1,2 @@
-5 1.618e-04 5.312e-04 4.853e-03
-6 3.465e-05 1.516e-04 2.364e-03
+5 1.590e-04 5.143e-04 4.757e-03
+6 3.509e-05 1.476e-04 2.341e-03
--
Gerris Flow Solver
More information about the debian-science-commits
mailing list