diff options
author | schnetter <schnetter@6ca9aeac-0e4f-0410-a746-fe4df63e9d0c> | 2004-08-18 12:52:30 +0000 |
---|---|---|
committer | schnetter <schnetter@6ca9aeac-0e4f-0410-a746-fe4df63e9d0c> | 2004-08-18 12:52:30 +0000 |
commit | b41f1e06fcb0ac02580567bf20598f2c51f5aa60 (patch) | |
tree | d597b197232d80c1a382aa818d0f2e661dddfa81 | |
parent | c57d0ad5c7138d13da5eb10ed2b57f08e61b9b2a (diff) |
Add new thorn.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/InterpToArray/trunk@2 6ca9aeac-0e4f-0410-a746-fe4df63e9d0c
-rw-r--r-- | README | 11 | ||||
-rw-r--r-- | doc/documentation.tex | 144 | ||||
-rw-r--r-- | interface.ccl | 11 | ||||
-rw-r--r-- | param.ccl | 275 | ||||
-rw-r--r-- | schedule.ccl | 10 | ||||
-rw-r--r-- | src/interp.c | 324 | ||||
-rw-r--r-- | src/make.code.defn | 8 |
7 files changed, 783 insertions, 0 deletions
@@ -0,0 +1,11 @@ +CVS info : $Header$ + +Cactus Code Thorn InterpToArray +Thorn Author(s) : Erik Schnetter <schnetter@aei.mpg.de> +Thorn Maintainer(s) : Erik Schnetter <schnetter@aei.mpg.de> +-------------------------------------------------------------------------- + +Purpose of the thorn: + +Interpolate grid functions to grid arrays on a grid of selectable +locations, so that these can e.g. be output more easily. diff --git a/doc/documentation.tex b/doc/documentation.tex new file mode 100644 index 0000000..4a57c9c --- /dev/null +++ b/doc/documentation.tex @@ -0,0 +1,144 @@ +% *======================================================================* +% Cactus Thorn template for ThornGuide documentation +% Author: Ian Kelley +% Date: Sun Jun 02, 2002 +% $Header$ +% +% Thorn documentation in the latex file doc/documentation.tex +% will be included in ThornGuides built with the Cactus make system. +% The scripts employed by the make system automatically include +% pages about variables, parameters and scheduling parsed from the +% relevant thorn CCL files. +% +% This template contains guidelines which help to assure that your +% documentation will be correctly added to ThornGuides. More +% information is available in the Cactus UsersGuide. +% +% Guidelines: +% - Do not change anything before the line +% % START CACTUS THORNGUIDE", +% except for filling in the title, author, date, etc. fields. +% - Each of these fields should only be on ONE line. +% - Author names should be separated with a \\ or a comma. +% - You can define your own macros, but they must appear after +% the START CACTUS THORNGUIDE line, and must not redefine standard +% latex commands. +% - To avoid name clashes with other thorns, 'labels', 'citations', +% 'references', and 'image' names should conform to the following +% convention: +% ARRANGEMENT_THORN_LABEL +% For example, an image wave.eps in the arrangement CactusWave and +% thorn WaveToyC should be renamed to CactusWave_WaveToyC_wave.eps +% - Graphics should only be included using the graphicx package. +% More specifically, with the "\includegraphics" command. Do +% not specify any graphic file extensions in your .tex file. This +% will allow us to create a PDF version of the ThornGuide +% via pdflatex. +% - References should be included with the latex "\bibitem" command. +% - Use \begin{abstract}...\end{abstract} instead of \abstract{...} +% - Do not use \appendix, instead include any appendices you need as +% standard sections. +% - For the benefit of our Perl scripts, and for future extensions, +% please use simple latex. +% +% *======================================================================* +% +% Example of including a graphic image: +% \begin{figure}[ht] +% \begin{center} +% \includegraphics[width=6cm]{MyArrangement_MyThorn_MyFigure} +% \end{center} +% \caption{Illustration of this and that} +% \label{MyArrangement_MyThorn_MyLabel} +% \end{figure} +% +% Example of using a label: +% \label{MyArrangement_MyThorn_MyLabel} +% +% Example of a citation: +% \cite{MyArrangement_MyThorn_Author99} +% +% Example of including a reference +% \bibitem{MyArrangement_MyThorn_Author99} +% {J. Author, {\em The Title of the Book, Journal, or periodical}, 1 (1999), +% 1--16. {\tt http://www.nowhere.com/}} +% +% *======================================================================* + +% If you are using CVS use this line to give version information +% $Header$ + +\documentclass{article} + +% Use the Cactus ThornGuide style file +% (Automatically used from Cactus distribution, if you have a +% thorn without the Cactus Flesh download this from the Cactus +% homepage at www.cactuscode.org) +\usepackage{../../../../doc/latex/cactus} + +\begin{document} + +% The author of the documentation +\author{Erik Schnetter \textless schnetter@aei.mpg.de\textgreater} + +% The title of the document (not necessarily the name of the Thorn) +\title{} + +% the date your document was last changed, if your document is in CVS, +% please use: +% \date{$ $Date$ $} +\date{July 15 2004} + +\maketitle + +% Do not delete next line +% START CACTUS THORNGUIDE + +% Add all definitions used in this documentation here +% \def\mydef etc + +% Add an abstract for this thorn's documentation +\begin{abstract} + +\end{abstract} + +% The following sections are suggestive only. +% Remove them or add your own. + +\section{Introduction} + +\section{Physical System} + +\section{Numerical Implementation} + +\section{Using This Thorn} + +\subsection{Obtaining This Thorn} + +\subsection{Basic Usage} + +\subsection{Special Behaviour} + +\subsection{Interaction With Other Thorns} + +\subsection{Examples} + +\subsection{Support and Feedback} + +\section{History} + +\subsection{Thorn Source Code} + +\subsection{Thorn Documentation} + +\subsection{Acknowledgements} + + +\begin{thebibliography}{9} + +\end{thebibliography} + +% Do not delete next line +% END CACTUS THORNGUIDE + +\end{document} diff --git a/interface.ccl b/interface.ccl new file mode 100644 index 0000000..032367d --- /dev/null +++ b/interface.ccl @@ -0,0 +1,11 @@ +# Interface definition for thorn InterpToArray +# $Header$ + +IMPLEMENTS: InterpToArray + +PUBLIC: + +REAL scalars[nscalars] TYPE=scalar +REAL arrays1d[narrays1d] TYPE=array DIM=1 SIZE=array1d_npoints_i +REAL arrays2d[narrays2d] TYPE=array DIM=2 SIZE=array2d_npoints_i,array2d_npoints_j +REAL arrays3d[narrays3d] TYPE=array DIM=3 SIZE=array3d_npoints_i,array3d_npoints_j,array3d_npoints_k diff --git a/param.ccl b/param.ccl new file mode 100644 index 0000000..fee89d6 --- /dev/null +++ b/param.ccl @@ -0,0 +1,275 @@ +# Parameter definitions for thorn InterpToArray +# $Header$ + +RESTRICTED: + +STRING interpolator_name "Name of the interpolator" STEERABLE=always +{ + ".*" :: "must be a registered interpolator" +} "Lagrange polynomial interpolation" + +STRING interpolator_options "Options for the interpolator" STEERABLE=always +{ + ".*" :: "must be a valid option specification" +} "order=2" + +STRING interpolator_coordinates "Coordinate system" STEERABLE=always +{ + ".*" :: "must be a registered coordinate system" +} "cart3d" + + + +INT nscalars "Number of grid scalars" +{ + 0:100 :: "" +} 0 + +STRING scalar_vars[100] "Names of the grid functions that should be interpolated on a point" STEERABLE=always +{ + "^$" :: "do not interpolate" + "^[A-Za-z][A-Za-z0-9_]*[:][:][A-Za-z][A-Za-z0-9_]*$" :: "grid function name" +} "" + +REAL scalar_x0 "Origin" STEERABLE=always +{ + *:* :: "" +} 0.0 + +REAL scalar_y0 "Origin" STEERABLE=always +{ + *:* :: "" +} 0.0 + +REAL scalar_z0 "Origin" STEERABLE=always +{ + *:* :: "" +} 0.0 + + + +INT narrays1d "Number of 1D grid arrays" +{ + 0:100 :: "" +} 0 + +STRING array1d_vars[100] "Names of the grid functions that should be interpolated on a line point" STEERABLE=always +{ + "^$" :: "do not interpolate" + "^[A-Za-z][A-Za-z0-9_]*[:][:][A-Za-z][A-Za-z0-9_]*$" :: "grid function name" +} "" + +REAL array1d_x0 "Origin" STEERABLE=always +{ + *:* :: "" +} 0.0 + +REAL array1d_y0 "Origin" STEERABLE=always +{ + *:* :: "" +} 0.0 + +REAL array1d_z0 "Origin" STEERABLE=always +{ + *:* :: "" +} 0.0 + +INT array1d_npoints_i "Number of grid points for the 1D grid arrays in the i direction" +{ + 0:100 :: "" +} 10 + +REAL array1d_dx_i "Spacing" STEERABLE=always +{ + (0:* :: "" +} 0.0 + +REAL array1d_dy_i "Spacing" STEERABLE=always +{ + (0:* :: "" +} 0.0 + +REAL array1d_dz_i "Spacing" STEERABLE=always +{ + (0:* :: "" +} 0.0 + +BOOLEAN array1d_logarithmic_i "Logarithmic?" STEERABLE=always +{ +} "no" + + + +INT narrays2d "Number of 2D grid arrays" +{ + 0:100 :: "" +} 0 + +STRING array2d_vars[100] "Names of the grid functions that should be interpolated on a 2D grid" STEERABLE=always +{ + "^$" :: "do not interpolate" + "^[A-Za-z][A-Za-z0-9_]*[:][:][A-Za-z][A-Za-z0-9_]*$" :: "grid function name" +} "" + +REAL array2d_x0 "Origin" STEERABLE=always +{ + *:* :: "" +} 0.0 + +REAL array2d_y0 "Origin" STEERABLE=always +{ + *:* :: "" +} 0.0 + +REAL array2d_z0 "Origin" STEERABLE=always +{ + *:* :: "" +} 0.0 + +INT array2d_npoints_i "Number of grid points for the 2D grid arrays in the i direction" +{ + 0:100 :: "" +} 10 + +REAL array2d_dx_i "Spacing" STEERABLE=always +{ + (0:* :: "" +} 0.0 + +REAL array2d_dy_i "Spacing" STEERABLE=always +{ + (0:* :: "" +} 0.0 + +REAL array2d_dz_i "Spacing" STEERABLE=always +{ + (0:* :: "" +} 0.0 + +BOOLEAN array2d_logarithmic_i "Logarithmic?" STEERABLE=always +{ +} "no" + +INT array2d_npoints_j "Number of grid points for the 2D grid arrays in the j direction" +{ + 0:100 :: "" +} 10 + +REAL array2d_dx_j "Spacing" STEERABLE=always +{ + (0:* :: "" +} 0.0 + +REAL array2d_dy_j "Spacing" STEERABLE=always +{ + (0:* :: "" +} 0.0 + +REAL array2d_dz_j "Spacing" STEERABLE=always +{ + (0:* :: "" +} 0.0 + +BOOLEAN array2d_logarithmic_j "Logarithmic?" STEERABLE=always +{ +} "no" + + + +INT narrays3d "Number of 3D grid arrays" +{ + 0:100 :: "" +} 0 + +STRING array3d_vars[100] "Names of the grid functions that should be interpolated on a 3D grid" STEERABLE=always +{ + "^$" :: "do not interpolate" + "^[A-Za-z][A-Za-z0-9_]*[:][:][A-Za-z][A-Za-z0-9_]*$" :: "grid function name" +} "" + +REAL array3d_x0 "Origin" STEERABLE=always +{ + *:* :: "" +} 0.0 + +REAL array3d_y0 "Origin" STEERABLE=always +{ + *:* :: "" +} 0.0 + +REAL array3d_z0 "Origin" STEERABLE=always +{ + *:* :: "" +} 0.0 + +INT array3d_npoints_i "Number of grid points for the 3D grid arrays in the i direction" +{ + 0:100 :: "" +} 10 + +REAL array3d_dx_i "Spacing" STEERABLE=always +{ + (0:* :: "" +} 0.0 + +REAL array3d_dy_i "Spacing" STEERABLE=always +{ + (0:* :: "" +} 0.0 + +REAL array3d_dz_i "Spacing" STEERABLE=always +{ + (0:* :: "" +} 0.0 + +BOOLEAN array3d_logarithmic_i "Logarithmic?" STEERABLE=always +{ +} "no" + +INT array3d_npoints_j "Number of grid points for the 3D grid arrays in the j direction" +{ + 0:100 :: "" +} 10 + +REAL array3d_dx_j "Spacing" STEERABLE=always +{ + (0:* :: "" +} 0.0 + +REAL array3d_dy_j "Spacing" STEERABLE=always +{ + (0:* :: "" +} 0.0 + +REAL array3d_dz_j "Spacing" STEERABLE=always +{ + (0:* :: "" +} 0.0 + +BOOLEAN array3d_logarithmic_j "Logarithmic?" STEERABLE=always +{ +} "no" + +INT array3d_npoints_k "Number of grid points for the 3D grid arrays in the k direction" +{ + 0:100 :: "" +} 10 + +REAL array3d_dx_k "Spacing" STEERABLE=always +{ + (0:* :: "" +} 0.0 + +REAL array3d_dy_k "Spacing" STEERABLE=always +{ + (0:* :: "" +} 0.0 + +REAL array3d_dz_k "Spacing" STEERABLE=always +{ + (0:* :: "" +} 0.0 + +BOOLEAN array3d_logarithmic_k "Logarithmic?" STEERABLE=always +{ +} "no" diff --git a/schedule.ccl b/schedule.ccl new file mode 100644 index 0000000..561a8c4 --- /dev/null +++ b/schedule.ccl @@ -0,0 +1,10 @@ +# Schedule definitions for thorn InterpToArray +# $Header$ + +SCHEDULE InterpToArray AT analysis +{ + LANG: C + OPTIONS: global + STORAGE: scalars arrays1d arrays2d arrays3d + TRIGGERS: scalars arrays1d arrays2d arrays3d +} "Interpolate to grid arrays" diff --git a/src/interp.c b/src/interp.c new file mode 100644 index 0000000..8ce8424 --- /dev/null +++ b/src/interp.c @@ -0,0 +1,324 @@ +/* $Header$ */ + +#include <assert.h> +#include <stdlib.h> + +#include "cctk.h" +#include "cctk_Arguments.h" +#include "cctk_Parameters.h" + +#include "util_Table.h" + + + +void +InterpToArray (CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + int interpolator; + int options_table; + int coord_handle; + + CCTK_REAL * restrict coordsx; + CCTK_REAL * restrict coordsy; + CCTK_REAL * restrict coordsz; + CCTK_POINTER_TO_CONST coords[3]; + CCTK_INT * restrict inputs; + CCTK_INT * restrict output_types; + CCTK_POINTER * restrict outputs; + + int nvars; + int npoints; + + int n; + int i, j, k; + int d; + int ierr; + + + + interpolator = CCTK_InterpHandle (interpolator_name); + assert (interpolator >= 0); + + options_table = Util_TableCreateFromString (interpolator_options); + assert (options_table >= 0); + + coord_handle = CCTK_CoordSystemHandle (interpolator_coordinates); + assert (coord_handle >= 0); + + + + /* Scalars */ + { + nvars = nscalars; + if (nvars > 0) { + npoints = 1; + + coordsx = malloc (npoints * sizeof * coordsx); + assert (coordsx); + coordsy = malloc (npoints * sizeof * coordsy); + assert (coordsy); + coordsz = malloc (npoints * sizeof * coordsz); + assert (coordsz); + coords[0] = coordsx; + coords[1] = coordsy; + coords[2] = coordsz; + + n = 0; + assert (n <= npoints); + coordsx[n] = scalar_x0; + coordsy[n] = scalar_y0; + coordsz[n] = scalar_z0; + ++n; + assert (n == npoints); + + inputs = malloc (nvars * sizeof * inputs); + assert (inputs); + + for (n=0; n<nvars; ++n) { + inputs[n] = CCTK_VarIndex (scalar_vars[n]); + if (inputs[n] < 0) { + inputs[n] = -1; + } + } + + output_types = malloc (nvars * sizeof * output_types); + assert (output_types); + + for (n=0; n<nvars; ++n) { + output_types[n] = CCTK_VARIABLE_REAL; + } + + outputs = malloc (nvars * sizeof * outputs); + assert (outputs); + + for (n=0; n<nvars; ++n) { + outputs[n] = &scalars[npoints * n]; + } + + ierr = CCTK_InterpGridArrays + (cctkGH, 3, interpolator, options_table, coord_handle, + npoints, CCTK_VARIABLE_REAL, coords, + nvars, inputs, + nvars, output_types, outputs); + + free (coordsx); + free (coordsy); + free (coordsz); + free (inputs); + free (output_types); + } + } + + + + /* 1D Arrays */ + { + nvars = narrays1d; + if (nvars > 0) { + npoints = array1d_npoints_i; + + coordsx = malloc (npoints * sizeof * coordsx); + assert (coordsx); + coordsy = malloc (npoints * sizeof * coordsy); + assert (coordsy); + coordsz = malloc (npoints * sizeof * coordsz); + assert (coordsz); + coords[0] = coordsx; + coords[1] = coordsy; + coords[2] = coordsz; + + n = 0; + for (i=0; i<array1d_npoints_i; ++i) { + assert (n <= npoints); + coordsx[n] = array1d_x0 + i * array1d_dx_i; + coordsy[n] = array1d_y0 + i * array1d_dy_i; + coordsz[n] = array1d_z0 + i * array1d_dz_i; + ++n; + } + assert (n == npoints); + + inputs = malloc (nvars * sizeof * inputs); + assert (inputs); + + for (n=0; n<nvars; ++n) { + inputs[n] = CCTK_VarIndex (array1d_vars[n]); + assert (inputs[n] >= 0); + if (inputs[n] < 0) { + inputs[n] = -1; + } + } + + output_types = malloc (nvars * sizeof * output_types); + assert (output_types); + + for (n=0; n<nvars; ++n) { + output_types[n] = CCTK_VARIABLE_REAL; + } + + outputs = malloc (nvars * sizeof * outputs); + assert (outputs); + + for (n=0; n<nvars; ++n) { + outputs[n] = &arrays1d[npoints * n]; + } + + ierr = CCTK_InterpGridArrays + (cctkGH, 3, interpolator, options_table, coord_handle, + npoints, CCTK_VARIABLE_REAL, coords, + nvars, inputs, + nvars, output_types, outputs); + + free (coordsx); + free (coordsy); + free (coordsz); + free (inputs); + free (output_types); + } + } + + + + /* 2D Arrays */ + { + nvars = narrays2d; + if (nvars > 0) { + npoints = array2d_npoints_i * array2d_npoints_j; + + coordsx = malloc (npoints * sizeof * coordsx); + assert (coordsx); + coordsy = malloc (npoints * sizeof * coordsy); + assert (coordsy); + coordsz = malloc (npoints * sizeof * coordsz); + assert (coordsz); + coords[0] = coordsx; + coords[1] = coordsy; + coords[2] = coordsz; + + n = 0; + for (j=0; j<array2d_npoints_j; ++j) { + for (i=0; i<array2d_npoints_i; ++i) { + assert (n <= npoints); + coordsx[n] = array2d_x0 + i * array2d_dx_i + j * array2d_dx_j; + coordsy[n] = array2d_y0 + i * array2d_dy_i + j * array2d_dy_j; + coordsz[n] = array2d_z0 + i * array2d_dz_i + j * array2d_dz_j; + ++n; + } + } + assert (n == npoints); + + inputs = malloc (nvars * sizeof * inputs); + assert (inputs); + + for (n=0; n<nvars; ++n) { + inputs[n] = CCTK_VarIndex (array2d_vars[n]); + if (inputs[n] < 0) { + inputs[n] = -1; + } + } + + output_types = malloc (nvars * sizeof * output_types); + assert (output_types); + + for (n=0; n<nvars; ++n) { + output_types[n] = CCTK_VARIABLE_REAL; + } + + outputs = malloc (nvars * sizeof * outputs); + assert (outputs); + + for (n=0; n<nvars; ++n) { + outputs[n] = &arrays2d[npoints * n]; + } + + ierr = CCTK_InterpGridArrays + (cctkGH, 3, interpolator, options_table, coord_handle, + npoints, CCTK_VARIABLE_REAL, coords, + nvars, inputs, + nvars, output_types, outputs); + + free (coordsx); + free (coordsy); + free (coordsz); + free (inputs); + free (output_types); + } + } + + + + /* 3D Arrays */ + { + nvars = narrays3d; + if (nvars > 0) { + npoints = array3d_npoints_i * array3d_npoints_j * array3d_npoints_k; + + coordsx = malloc (npoints * sizeof * coordsx); + assert (coordsx); + coordsy = malloc (npoints * sizeof * coordsy); + assert (coordsy); + coordsz = malloc (npoints * sizeof * coordsz); + assert (coordsz); + coords[0] = coordsx; + coords[1] = coordsy; + coords[2] = coordsz; + + n = 0; + for (k=0; k<array3d_npoints_k; ++k) { + for (j=0; j<array3d_npoints_j; ++j) { + for (i=0; i<array3d_npoints_i; ++i) { + assert (n <= npoints); + coordsx[n] = array3d_x0 + i * array3d_dx_i + j * array3d_dx_j + k * array3d_dx_k; + coordsy[n] = array3d_y0 + i * array3d_dy_i + j * array3d_dy_j + k * array3d_dy_k; + coordsz[n] = array3d_z0 + i * array3d_dz_i + j * array3d_dz_j + k * array3d_dz_k; + ++n; + } + } + } + assert (n == npoints); + + inputs = malloc (nvars * sizeof * inputs); + assert (inputs); + + for (n=0; n<nvars; ++n) { + inputs[n] = CCTK_VarIndex (array3d_vars[n]); + if (inputs[n] < 0) { + inputs[n] = -1; + } + } + + output_types = malloc (nvars * sizeof * output_types); + assert (output_types); + + for (n=0; n<nvars; ++n) { + output_types[n] = CCTK_VARIABLE_REAL; + } + + outputs = malloc (nvars * sizeof * outputs); + assert (outputs); + + for (n=0; n<nvars; ++n) { + outputs[n] = &arrays3d[npoints * n]; + } + + ierr = CCTK_InterpGridArrays + (cctkGH, 3, interpolator, options_table, coord_handle, + npoints, CCTK_VARIABLE_REAL, coords, + nvars, inputs, + nvars, output_types, outputs); + + free (coordsx); + free (coordsy); + free (coordsz); + free (inputs); + free (output_types); + } + } + + + + ierr = Util_TableDestroy (options_table); + assert (! ierr); +} diff --git a/src/make.code.defn b/src/make.code.defn new file mode 100644 index 0000000..c544e8f --- /dev/null +++ b/src/make.code.defn @@ -0,0 +1,8 @@ +# Main make.code.defn file for thorn InterpToArray +# $Header$ + +# Source files in this directory +SRCS = interp.c + +# Subdirectories containing source files +SUBDIRS = |