aboutsummaryrefslogtreecommitdiff
path: root/brill_data.h
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2014-10-26 11:30:59 +0100
committerAnton Khirnov <anton@khirnov.net>2014-10-30 11:39:00 +0100
commit4c52660b125a296b449efb4f30c18d498f21e17c (patch)
tree9e384ef75a5db13c7b7ee056dbd4f2682c2a5f93 /brill_data.h
Initial commit.
Diffstat (limited to 'brill_data.h')
-rw-r--r--brill_data.h128
1 files changed, 128 insertions, 0 deletions
diff --git a/brill_data.h b/brill_data.h
new file mode 100644
index 0000000..125970b
--- /dev/null
+++ b/brill_data.h
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2014 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/>.
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+
+enum BDQFuncType {
+ /**
+ * q(ρ, z) = A ρ^2 exp(-ρ^2 - z^2)
+ */
+ BD_Q_FUNC_GUNDLACH,
+ /**
+ * q(ρ, z) = A ρ^2 / (1 + r^n); where r^2 = ρ^2 + z^2
+ */
+ BD_Q_FUNC_EPPLEY,
+};
+
+typedef struct BDContext {
+ /**
+ * private data
+ */
+ void *priv;
+
+ /*******************************
+ * options, set by the caller *
+ *******************************/
+
+ /**
+ * The choice of the q function in the exponent.
+ * Defaults to BD_Q_FUNC_GUNDLACH.
+ */
+ enum BDQFuncType q_func_type;
+ /**
+ * The amplitude in the q function.
+ * Defaults to 1.
+ */
+ double amplitude;
+ /**
+ * For BD_Q_FUNC_EPPLEY, the power in the denominator.
+ * Must be >= 4.
+ * Defaults to 5.
+ */
+ unsigned int eppley_n;
+
+ /* the solver parameters */
+
+ /**
+ * The number of basis functions in the ρ direction.
+ * Defaults to 80.
+ */
+ unsigned int nb_coeffs_rho;
+ /**
+ * The number of basis functions in the z direction. 0 means the same as
+ * nb_coeffs_rho. Defaults to 0.
+ * Using values other than 0 or nb_coeffs_rho is unsupported for now.
+ */
+ unsigned int nb_coeffs_z;
+
+ /**
+ * The difference between the number of collocation points and the number
+ * of basis functions in the rho direction. I.e. the number of collocation
+ * points used will be nb_coeffs_rho + overdet_rho.
+ * Defaults to 0;
+ */
+ int overdet_rho;
+ /**
+ * Same as overdet_rho, but for the z direction.
+ */
+ int overdet_z;
+
+ /**
+ * The difference between the index of the collocation grid used for the ρ
+ * direction and nb_coeffs_rho. The 'extra' collocation points furthest from
+ * the origin are discarded.
+ * Defaults to 3.
+ */
+ unsigned int colloc_grid_offset_rho;
+ /**
+ * Same as colloc_grid_offset_rho, but for the z direction.
+ */
+ unsigned int colloc_grid_offset_z;
+
+ /**
+ * The scaling factor used in the basis functions in the ρ direction.
+ * Defaults to 3.
+ */
+ double basis_scale_factor_rho;
+ /**
+ * Same as basis_scale_factor_rho, but for the z direction
+ */
+ double basis_scale_factor_z;
+
+ /**********
+ * output *
+ **********/
+ /**
+ * The coefficients of the solution expanded in the basis.
+ * The ρ index increases along rows, z along columns.
+ *
+ * The data is owned and managed by this library and is read-only for
+ * the caller.
+ */
+ double *psi_minus1_coeffs;
+ /**
+ * The number of array elements between two rows.
+ */
+ ptrdiff_t stride;
+} BDContext;
+
+BDContext *bd_context_alloc(void);
+
+void bd_context_free(BDContext **bd);
+
+int bd_solve(BDContext *bd);