aboutsummaryrefslogtreecommitdiff
path: root/internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'internal.h')
-rw-r--r--internal.h83
1 files changed, 83 insertions, 0 deletions
diff --git a/internal.h b/internal.h
new file mode 100644
index 0000000..87490e1
--- /dev/null
+++ b/internal.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2014-2015 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 BRILL_DATA_INTERNAL_H
+#define BRILL_DATA_INTERNAL_H
+
+#include "brill_data.h"
+
+#define MAX(x, y) ((x) > (y) ? (x) : (y))
+#define SQR(x) ((x) * (x))
+
+#define ARRAY_ELEMS(x) (sizeof(x) / sizeof(x[0]))
+
+/*
+ * small number to avoid r=0 singularities
+ */
+#define EPS 1E-08
+
+/* a set of basis functions */
+typedef struct BasisSet {
+ /* evaluate the idx-th basis function at the specified point*/
+ double (*eval) (double coord, int idx, double sf);
+ /* evaluate the first derivative of the idx-th basis function at the specified point*/
+ double (*eval_diff1)(double coord, int idx, double sf);
+ /* evaluate the second derivative of the idx-th basis function at the specified point*/
+ double (*eval_diff2)(double coord, int idx, double sf);
+ /**
+ * Get the idx-th collocation point for the specified order.
+ * idx runs from 0 to order - 1 (inclusive)
+ */
+ double (*colloc_point)(int order, int idx, double sf);
+} BasisSet;
+
+typedef struct QFunc {
+ double (*q)(const BDContext *bd, double rho, double z);
+ double (*dq_rho)(const BDContext *bd, double rho, double z);
+ double (*dq_z)(const BDContext *bd, double rho, double z);
+ double (*d2q_rho)(const BDContext *bd, double rho, double z);
+ double (*d2q_z)(const BDContext *bd, double rho, double z);
+ double (*d2q_rho_z)(const BDContext *bd, double rho, double z);
+} QFunc;
+
+typedef struct BDPriv {
+ const BasisSet *basis;
+ const QFunc *q_func;
+
+ int nb_colloc_points;
+ int nb_colloc_points_rho;
+ int nb_colloc_points_z;
+
+ int colloc_grid_order_rho;
+ int colloc_grid_order_z;
+ int nb_coeffs;
+
+ double *coeffs;
+} BDPriv;
+
+extern const BasisSet bdi_sb_even_basis;
+
+extern const QFunc bdi_q_func_gundlach;
+extern const QFunc bdi_q_func_eppley;
+
+int bdi_solve(BDContext *bd);
+
+void bdi_log(const BDContext *bd, int level, const char *fmt, ...);
+void bdi_log_default_callback(const BDContext *bd, int level,
+ const char *fmt, va_list vl);
+
+#endif // BRILL_DATA_INTERNAL_H