aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2019-01-25 15:55:47 +0100
committerAnton Khirnov <anton@khirnov.net>2019-01-25 15:55:47 +0100
commit30ca9d8f0fa8dcaab5606d03e4cdf4082db9baae (patch)
tree6c09aa45cd753e986a0050d4bd47d24a93db4962
parentbe15318094225dc75d1f3c4a7984e770d4e128ec (diff)
mg2d: split the constant definitions into their own header
This will allow sharing them with ell_relax.
-rw-r--r--mg2d.c1
-rw-r--r--mg2d.h112
-rw-r--r--mg2d_constants.h134
3 files changed, 136 insertions, 111 deletions
diff --git a/mg2d.c b/mg2d.c
index 81b1b46..76878ca 100644
--- a/mg2d.c
+++ b/mg2d.c
@@ -30,6 +30,7 @@
#include "ell_relax.h"
#include "log.h"
#include "mg2d.h"
+#include "mg2d_constants.h"
#define LEVELS_MAX 16
diff --git a/mg2d.h b/mg2d.h
index 58308fd..6b2def6 100644
--- a/mg2d.h
+++ b/mg2d.h
@@ -22,117 +22,7 @@
#include <stddef.h>
#include <stdint.h>
-enum MG2DError {
- MG2D_ERR_DIVERGE = -0xff00,
-};
-
-/**
- * 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,
-};
-
-/**
- * Derivative specifier.
- */
-enum MG2DDiffCoeff {
- /**
- * Zeroth derivative, i.e. function value.
- */
- MG2D_DIFF_COEFF_00,
- /**
- * First derivative wrt coord1.
- */
- MG2D_DIFF_COEFF_01,
- /**
- * First derivative wrt coord0.
- */
- MG2D_DIFF_COEFF_10,
- /**
- * Second derivative, once wrt coord0 and once wrt coord1
- */
- MG2D_DIFF_COEFF_11,
- /**
- * Second derivative wrt coord1
- */
- MG2D_DIFF_COEFF_02,
- /**
- * Second derivative wrt coord0
- */
- MG2D_DIFF_COEFF_20,
- /**
- * Total number of allowed derivatives.
- */
- MG2D_DIFF_COEFF_NB,
-};
-
-enum MG2DLogLevel {
- /**
- * The log message indicates abnormal program failure. Should never happen
- * unless there are bugs or grossly invaid user input.
- * Will typically be followed by program termination.
- */
- MG2D_LOG_FATAL = 0x0,
- /**
- * The log message indicates an error state, so that requested operation
- * cannot complete successfully.
- * Will typically be followed by the API function being called returning an
- * error.
- */
- MG2D_LOG_ERROR = 0x10,
- /**
- * The log message indicates a suspicious or suboptimal program state.
- */
- MG2D_LOG_WARNING = 0x20,
- /**
- * The log message provides commonly useful information about normal program
- * behaviour.
- */
- MG2D_LOG_INFO = 0x30,
- /**
- * The log message provides detailed extra information about normal program
- * behaviour.
- */
- MG2D_LOG_VERBOSE = 0x40,
- /**
- * The log message provides highly detailed extra information about normal
- * program behaviour.
- */
- MG2D_LOG_DEBUG = 0x50,
-};
+#include "mg2d_constants.h"
typedef struct MG2DInternal MG2DInternal;
diff --git a/mg2d_constants.h b/mg2d_constants.h
new file mode 100644
index 0000000..1ab4bc6
--- /dev/null
+++ b/mg2d_constants.h
@@ -0,0 +1,134 @@
+/*
+ * Public API constants.
+ * Copyright 2019 Anton Khirnov <anton@khirnov.net>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MG2D_CONSTANTS_H
+#define MG2D_CONSTANTS_H
+
+enum MG2DError {
+ MG2D_ERR_DIVERGE = -0xff00,
+};
+
+/**
+ * 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,
+};
+
+/**
+ * Derivative specifier.
+ */
+enum MG2DDiffCoeff {
+ /**
+ * Zeroth derivative, i.e. function value.
+ */
+ MG2D_DIFF_COEFF_00,
+ /**
+ * First derivative wrt coord1.
+ */
+ MG2D_DIFF_COEFF_01,
+ /**
+ * First derivative wrt coord0.
+ */
+ MG2D_DIFF_COEFF_10,
+ /**
+ * Second derivative, once wrt coord0 and once wrt coord1
+ */
+ MG2D_DIFF_COEFF_11,
+ /**
+ * Second derivative wrt coord1
+ */
+ MG2D_DIFF_COEFF_02,
+ /**
+ * Second derivative wrt coord0
+ */
+ MG2D_DIFF_COEFF_20,
+ /**
+ * Total number of allowed derivatives.
+ */
+ MG2D_DIFF_COEFF_NB,
+};
+
+enum MG2DLogLevel {
+ /**
+ * The log message indicates abnormal program failure. Should never happen
+ * unless there are bugs or grossly invaid user input.
+ * Will typically be followed by program termination.
+ */
+ MG2D_LOG_FATAL = 0x0,
+ /**
+ * The log message indicates an error state, so that requested operation
+ * cannot complete successfully.
+ * Will typically be followed by the API function being called returning an
+ * error.
+ */
+ MG2D_LOG_ERROR = 0x10,
+ /**
+ * The log message indicates a suspicious or suboptimal program state.
+ */
+ MG2D_LOG_WARNING = 0x20,
+ /**
+ * The log message provides commonly useful information about normal program
+ * behaviour.
+ */
+ MG2D_LOG_INFO = 0x30,
+ /**
+ * The log message provides detailed extra information about normal program
+ * behaviour.
+ */
+ MG2D_LOG_VERBOSE = 0x40,
+ /**
+ * The log message provides highly detailed extra information about normal
+ * program behaviour.
+ */
+ MG2D_LOG_DEBUG = 0x50,
+};
+
+#endif // MG2D_CONSTANTS_H