/* * Copyright 2014-2015 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 BRILL_DATA_INTERNAL_H #define BRILL_DATA_INTERNAL_H #include #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])) #define ALIGN(x, a) (((x)+(a)-1)&~((a)-1)) #define REQ_ALIGNMENT(x) (32 / sizeof(x)) /* * 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[2]; const QFunc *q_func; int nb_colloc_points[2]; int nb_coeffs[2]; double *coeffs; ptrdiff_t coeffs_stride; } BDPriv; #define NB_COEFFS(s) (s->nb_coeffs[0] * s->nb_coeffs[1]) #define NB_COLLOC_POINTS(s) (s->nb_colloc_points[0] * s->nb_colloc_points[1]) 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