| 1 | /* |
|---|
| 2 | Copyright (C) 2011 J. Alberdi, M. Oliveira, Y. Pouillon, and M. Verstraete |
|---|
| 3 | |
|---|
| 4 | This program is free software; you can redistribute it and/or modify |
|---|
| 5 | it under the terms of the GNU Lesser General Public License as published by |
|---|
| 6 | the Free Software Foundation; either version 3 of the License, or |
|---|
| 7 | (at your option) any later version. |
|---|
| 8 | |
|---|
| 9 | This program is distributed in the hope that it will be useful, |
|---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 | GNU Lesser General Public License for more details. |
|---|
| 13 | |
|---|
| 14 | You should have received a copy of the GNU Lesser General Public License |
|---|
| 15 | along with this program; if not, write to the Free Software |
|---|
| 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|---|
| 17 | |
|---|
| 18 | $Id$ |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | /** |
|---|
| 22 | * @file pspio_meshfunc.h |
|---|
| 23 | * @brief header file for the handling of functions defined on a mesh |
|---|
| 24 | */ |
|---|
| 25 | |
|---|
| 26 | #ifndef PSPIO_MESHFUNC_H |
|---|
| 27 | #define PSPIO_MESHFUNC_H |
|---|
| 28 | |
|---|
| 29 | #ifdef HAVE_CONFIG_H |
|---|
| 30 | #include "config.h" |
|---|
| 31 | #endif |
|---|
| 32 | |
|---|
| 33 | #include <gsl/gsl_spline.h> |
|---|
| 34 | |
|---|
| 35 | #include "pspio_error.h" |
|---|
| 36 | #include "pspio_mesh.h" |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | /** |
|---|
| 40 | * Mesh function structure |
|---|
| 41 | */ |
|---|
| 42 | typedef struct{ |
|---|
| 43 | pspio_mesh_t *mesh; /**< Pointer to mesh */ |
|---|
| 44 | double *f; /**< values of the function on the mesh */ |
|---|
| 45 | gsl_spline *spl; /**< gsl spline structure */ |
|---|
| 46 | gsl_interp_accel *acc; /**< accelerator for interpolation lookups */ |
|---|
| 47 | } pspio_meshfunc_t; |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | /** |
|---|
| 51 | * Allocates memory and preset function structure |
|---|
| 52 | * |
|---|
| 53 | * @param[in,out] func: function structure |
|---|
| 54 | * @param[in] mesh: mesh structure |
|---|
| 55 | * @return error code |
|---|
| 56 | */ |
|---|
| 57 | int pspio_meshfunc_alloc(pspio_meshfunc_t *func, pspio_mesh_t *mesh); |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | /** |
|---|
| 61 | * Sets the function data. |
|---|
| 62 | * @param[in,out] func: function structure to set. |
|---|
| 63 | * @param[in] f: values of the function on the mesh. |
|---|
| 64 | * @return error code |
|---|
| 65 | */ |
|---|
| 66 | int pspio_meshfunc_set(pspio_meshfunc_t *func, double *f); |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | /** |
|---|
| 70 | * Frees all memory associated with function structure |
|---|
| 71 | * |
|---|
| 72 | * @param[in,out] func: function structure |
|---|
| 73 | */ |
|---|
| 74 | void pspio_meshfunc_free(pspio_meshfunc_t *func); |
|---|
| 75 | |
|---|
| 76 | #endif |
|---|