aboutsummaryrefslogtreecommitdiff
path: root/mg2d.h
diff options
context:
space:
mode:
Diffstat (limited to 'mg2d.h')
-rw-r--r--mg2d.h68
1 files changed, 63 insertions, 5 deletions
diff --git a/mg2d.h b/mg2d.h
index 47d709e..2f593bc 100644
--- a/mg2d.h
+++ b/mg2d.h
@@ -29,6 +29,68 @@
typedef struct MG2DInternal MG2DInternal;
+/**
+ * Flags for diff coeffs boundary specifications.
+ */
+enum MG2DDCFlag {
+ /**
+ * The coefficients have a discontinuity at the boundary, i.e.
+ * C(x, y) = C0(x, y) + D(x, y),
+ * where C is the resulting value used for the solve, C0 is continuous
+ * everywhere, and D is zero everywhere except along the boundary. D is
+ * assumed to be continuous along the boundary.
+ *
+ * The values of D should be stored in MG2DDCBoundarySpec.val
+ */
+ MG2D_DC_FLAG_DISCONT = (1 << 0),
+ /**
+ * The coefficients have a first order pole at the boundary, i.e.
+ * C(x, y) ยท (x_i - x_i^0) (1)
+ * is continuous, where C is the actual value of the coefficient, x_i is the
+ * coordinate which is constant along the boundary and x_i^0 is the value of
+ * that coordinate along the boundary.
+ *
+ * The value of (1) along the boundary should be stored in
+ * MG2DDCBoundarySpec.val.
+ */
+ MG2D_DC_FLAG_POLE = (1 << 1),
+};
+
+/**
+ * Specification of the behaviour of differential equation coefficients on a
+ * boundary.
+ */
+typedef struct MG2DDCBoundarySpec {
+ /**
+ * A combination of MG2DDCFlag
+ */
+ int flags;
+ /**
+ * Value determined by flags. Need not be filled if the flags are zero.
+ */
+ double *val;
+} MG2DDCBoundarySpec;
+
+/**
+ * Specification of a single coefficient of the PDE.
+ */
+typedef struct MG2DDiffCoeffs {
+ /**
+ * Values of the coefficient at the grid points. Values corresponding to
+ * successive x locations are contiguous in memory.
+ */
+ double *data;
+ /**
+ * Number of elements between successive y locations in data.
+ */
+ ptrdiff_t stride;
+
+ /**
+ * Behaviour of the coefficient on the boundaries.
+ */
+ MG2DDCBoundarySpec boundaries[4];
+} MG2DDiffCoeffs;
+
typedef struct MG2DContext {
/**
* Solver private data, not to be accessed in any way by the caller.
@@ -127,11 +189,7 @@ typedef struct MG2DContext {
* Allocated by the solver in mg2d_solver_alloc(), owned by the solver.
* Must be filled by the caller before solving.
*/
- double *diff_coeffs[MG2D_DIFF_COEFF_NB];
- /**
- * Distance between neighbouring gridpoints along coord1.
- */
- ptrdiff_t diff_coeffs_stride;
+ MG2DDiffCoeffs *diff_coeffs[MG2D_DIFF_COEFF_NB];
/**
* Number of threads to use for processing.