From d76687285a032e25cbd258035321cb8d6d8e0330 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 25 Jan 2019 16:16:17 +0100 Subject: mg2d: factor out the boundary condition-related API --- mg2d_boundary.h | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 mg2d_boundary.h (limited to 'mg2d_boundary.h') diff --git a/mg2d_boundary.h b/mg2d_boundary.h new file mode 100644 index 0000000..4a7dcee --- /dev/null +++ b/mg2d_boundary.h @@ -0,0 +1,97 @@ +/* + * Boundary condition declaration. + * Copyright 2018 Anton Khirnov + * + * 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 3 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, see . + */ + +#ifndef MG2D_BOUNDARY_H +#define MG2D_BOUNDARY_H + +#include + +typedef struct MG2DBoundaryInternal MG2DBoundaryInternal; + +/** + * Type of the boundary condition on a given boundary. + */ +enum MG2DBCType { + /** + * The value of the unknown function is fixed on the boundary. + */ + MG2D_BC_TYPE_FIXVAL, + /** + * The normal derivative of the unkown function is fixed on the boundary. + * + * TODO: the only supported value of the derivative is currently zero, i.e. + * periodic boundary conditions. + */ + MG2D_BC_TYPE_FIXDIFF, +}; + +/** + * Location of the boundary. + */ +enum MG2DBoundaryLoc { + /** + * coord0 lower + */ + MG2D_BOUNDARY_0L, + /** + * coord0 upper + */ + MG2D_BOUNDARY_0U, + /** + * coord1 lower + */ + MG2D_BOUNDARY_1L, + /** + * coord1 upper + */ + MG2D_BOUNDARY_1U, +}; + +/** + * Boundary condition definition. + */ +typedef struct MG2DBoundary { + /** + * Type of the boundary condition. + */ + enum MG2DBCType type; + /** + * For type = MG2D_BC_TYPE_FIXVAL: + * Values of the unknown function on the boundary. + * The number of boundary layers is equal to fd_stencil. + * The first boundary layer has the number of points equal to the + * corresponding domain_size. Each subsequent boundary layer has one + * more boundary point at each end of the domain. + * + * Ignored otherwise. + */ + double *val; + /** + * Number of elements between rows in val. I.e. if val[0] is the first + * boundary point, then val[val_stride - 1] is the first boundary point in + * the second row and so on. + */ + size_t val_stride; + + /** + * Private data, not to be touched by callers. + */ + MG2DBoundaryInternal *priv; +} MG2DBoundary; + +#endif // MG2D_BOUNDARY_H -- cgit v1.2.3