[SCM] Gerris Flow Solver branch, upstream, updated. b3aa46814a06c9cb2912790b23916ffb44f1f203
Stephane Popinet
popinet at users.sf.net
Fri May 15 02:56:05 UTC 2009
The following commit has been merged in the upstream branch:
commit e58c4d82e9538bb592e17845a633d16c66a0df97
Author: Stephane Popinet <popinet at users.sf.net>
Date: Fri Jan 16 08:01:46 2009 +1100
New GfsBcValve BC for GfsRiver
darcs-hash:20090115210146-d4795-e4ed6dc406d28cb01b6c043b3ee1ed5bdbd254ac.gz
diff --git a/src/init.c b/src/init.c
index 443e761..c12200f 100644
--- a/src/init.c
+++ b/src/init.c
@@ -112,10 +112,11 @@ GtsObjectClass ** gfs_classes (void)
gfs_gedge_class (),
gfs_bc_dirichlet_class (),
- gfs_bc_subcritical_class (),
gfs_bc_neumann_class (),
gfs_bc_navier_class (),
gfs_bc_flather_class (),
+ gfs_bc_subcritical_class (),
+ gfs_bc_valve_class (),
gfs_boundary_class (),
gfs_boundary_inflow_constant_class (),
diff --git a/src/river.c b/src/river.c
index 76f6405..da0245a 100644
--- a/src/river.c
+++ b/src/river.c
@@ -99,6 +99,10 @@ typedef struct {
static void face_fluxes (FttCellFace * face, GfsRiver * r)
{
+ if (GFS_VALUE (face->cell, r->v1[0]) <= DRY &&
+ GFS_VALUE (face->neighbor, r->v1[0]) <= DRY)
+ return;
+
static Sym sym[4] = {
{U, 1., V, 1.},
{U, -1., V, -1.},
@@ -533,3 +537,66 @@ GfsBcClass * gfs_bc_subcritical_class (void)
return klass;
}
+
+/* GfsBcValve: Object */
+
+static void valve (FttCellFace * f, GfsBc * b)
+{
+ gdouble un = (FTT_FACE_DIRECT (f) ? - 1. : 1.)*GFS_VALUE (f->neighbor, b->v);
+ if (un > 0.) /* Valve opened (Neumann) */
+ GFS_VALUE (f->cell, b->v) =
+ GFS_VALUE (f->neighbor, b->v) +
+ gfs_function_face_value (GFS_BC_VALUE (b)->val, f)
+ *ftt_cell_size (f->cell);
+ else /* Valve closed (Dirichlet 0) */
+ GFS_VALUE (f->cell, b->v) = - GFS_VALUE (f->neighbor, b->v);
+}
+
+static void homogeneous_valve (FttCellFace * f, GfsBc * b)
+{
+ gdouble un = (FTT_FACE_DIRECT (f) ? - 1. : 1.)*GFS_VALUE (f->neighbor, b->v);
+ if (un > 0.) /* Valve opened (Neumann 0) */
+ GFS_VALUE (f->cell, b->v) = GFS_VALUE (f->neighbor, b->v);
+ else /* Valve closed (Dirichlet 0) */
+ GFS_VALUE (f->cell, b->v) = - GFS_VALUE (f->neighbor, b->v);
+}
+
+static void face_valve (FttCellFace * f, GfsBc * b)
+{
+ gdouble un = (FTT_FACE_DIRECT (f) ? - 1. : 1.)*GFS_VALUE (f->neighbor, b->v);
+ if (un > 0.) /* Valve opened (Neumann) */
+ GFS_STATE (f->cell)->f[f->d].v =
+ GFS_VALUE (f->neighbor, b->v) +
+ gfs_function_face_value (GFS_BC_VALUE (b)->val, f)
+ *ftt_cell_size (f->cell)/2.;
+ else /* Valve closed (Dirichlet 0) */
+ GFS_STATE (f->cell)->f[f->d].v = 0.;
+}
+
+static void gfs_bc_valve_init (GfsBc * object)
+{
+ object->bc = (FttFaceTraverseFunc) valve;
+ object->homogeneous_bc = (FttFaceTraverseFunc) homogeneous_valve;
+ object->face_bc = (FttFaceTraverseFunc) face_valve;
+}
+
+GfsBcClass * gfs_bc_valve_class (void)
+{
+ static GfsBcClass * klass = NULL;
+
+ if (klass == NULL) {
+ GtsObjectClassInfo gfs_bc_valve_info = {
+ "GfsBcValve",
+ sizeof (GfsBcValue),
+ sizeof (GfsBcClass),
+ (GtsObjectClassInitFunc) NULL,
+ (GtsObjectInitFunc) gfs_bc_valve_init,
+ (GtsArgSetFunc) NULL,
+ (GtsArgGetFunc) NULL
+ };
+ klass = gts_object_class_new (GTS_OBJECT_CLASS (gfs_bc_value_class ()),
+ &gfs_bc_valve_info);
+ }
+
+ return klass;
+}
diff --git a/src/river.h b/src/river.h
index 4106bdc..026baf5 100644
--- a/src/river.h
+++ b/src/river.h
@@ -1,3 +1,29 @@
+/* Gerris - The GNU Flow Solver
+ * Copyright (C) 2001-2009 National Institute of Water and Atmospheric Research
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef __RIVER_H__
+#define __RIVER_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
#include "variable.h"
/* GfsRiver: Header */
@@ -31,5 +57,16 @@ GfsSimulationClass * gfs_river_class (void);
#define GFS_IS_BC_SUBCRITICAL(obj) (gts_object_is_from_class (obj,\
gfs_bc_subcritical_class ()))
-
GfsBcClass * gfs_bc_subcritical_class (void);
+
+/* GfsBcValve: Header */
+
+#define GFS_IS_BC_VALVE(obj) (gts_object_is_from_class (obj,\
+ gfs_bc_valve_class ()))
+GfsBcClass * gfs_bc_valve_class (void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __RIVER_H__ */
--
Gerris Flow Solver
More information about the debian-science-commits
mailing list