From 22cbb417693f750031102acdbbd75be97c8b6927 Mon Sep 17 00:00:00 2001 From: Roland Haas Date: Fri, 22 Mar 2024 11:56:01 -0500 Subject: [PATCH] GridX: explore if one can provide a Grid implementation for CarpetX --- GridX/README | 9 +++ GridX/configuration.ccl | 3 + GridX/doc/documentation.tex | 146 ++++++++++++++++++++++++++++++++++++ GridX/interface.ccl | 17 +++++ GridX/param.ccl | 131 ++++++++++++++++++++++++++++++++ GridX/schedule.ccl | 17 +++++ GridX/src/grid.cc | 48 ++++++++++++ GridX/src/make.code.defn | 7 ++ 8 files changed, 378 insertions(+) create mode 100644 GridX/README create mode 100644 GridX/configuration.ccl create mode 100644 GridX/doc/documentation.tex create mode 100644 GridX/interface.ccl create mode 100644 GridX/param.ccl create mode 100644 GridX/schedule.ccl create mode 100644 GridX/src/grid.cc create mode 100644 GridX/src/make.code.defn diff --git a/GridX/README b/GridX/README new file mode 100644 index 000000000..2a0024e7a --- /dev/null +++ b/GridX/README @@ -0,0 +1,9 @@ +Cactus Code Thorn GridX +Author(s) : Roland Haas +Maintainer(s): Roland Haas +Licence : NCSA +-------------------------------------------------------------------------- + +1. Purpose + +not documented diff --git a/GridX/configuration.ccl b/GridX/configuration.ccl new file mode 100644 index 000000000..c4362ec2c --- /dev/null +++ b/GridX/configuration.ccl @@ -0,0 +1,3 @@ +# Configuration definitions for thorn GridX + +REQUIRES Loop diff --git a/GridX/doc/documentation.tex b/GridX/doc/documentation.tex new file mode 100644 index 000000000..cab1a9061 --- /dev/null +++ b/GridX/doc/documentation.tex @@ -0,0 +1,146 @@ +% *======================================================================* +% 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{Roland Haas \textless rhaas@illinois.edu\textgreater} + +% The title of the document (not necessarily the name of the Thorn) +\title{GridX} + +% the date your document was last changed, if your document is in CVS, +% please use: +% \date{$ $Date$ $} +% when using git instead record the commit ID: +% \date{\gitrevision{}} +\date{March 22 2024} + +\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/GridX/interface.ccl b/GridX/interface.ccl new file mode 100644 index 000000000..dd839cd0b --- /dev/null +++ b/GridX/interface.ccl @@ -0,0 +1,17 @@ +# Interface definition for thorn GridX +implements: Grid +inherits: CoordBase + +USES INCLUDE HEADER: loop_device.hxx + +public: + +REAL gridspacings type=SCALAR tags='Checkpoint="no"' +{ + coarse_dx, coarse_dy, coarse_dz +} "3D Cartesian grid spacings" + +REAL coordinates type=GF tags='Prolongation="None" Checkpoint="no"' +{ + x, y, z, r +} "3D Cartesian grid coordinates" diff --git a/GridX/param.ccl b/GridX/param.ccl new file mode 100644 index 000000000..665f00ae8 --- /dev/null +++ b/GridX/param.ccl @@ -0,0 +1,131 @@ +# Parameter definitions for thorn GridX + +# TODO: all ignored for now + +restricted: + +REAL dx "Coarse grid spacing in x-direction" +{ + 0:* :: "Positive" +} 0.3 +REAL dy "Coarse grid spacing in y-direction" +{ + 0:* :: "Positive" +} 0.3 +REAL dz "Coarse grid spacing in z-direction" +{ + 0:* :: "Positive" +} 0.3 +REAL dxyz "Coarse grid spacing in x,y,z-directions" +{ + 0:* :: "Positive" +} 0.0 + + +REAL xmin "Coordinate minimum in x-direction" +{ + : :: "Anything" +} -1.0 +REAL ymin "Coordinate minimum in y-direction" +{ + : :: "Anything" +} -1.0 +REAL zmin "Coordinate minimum in z-direction" +{ + : :: "Anything" +} -1.0 +REAL xyzmin "Coordinate minimum in x,y,z-directions" +{ + : :: "Anything" +} -424242 + + +REAL xmax "Coordinate maximum in x-direction" +{ + : :: "Anything" +} 1.0 +REAL ymax "Coordinate maximum in y-direction" +{ + : :: "Anything" +} 1.0 +REAL zmax "Coordinate maximum in z-direction" +{ + : :: "Anything" +} 1.0 +REAL xyzmax "Coordinate maximum in xyz-directions" +{ + : :: "Anything" +} -424242 + + +KEYWORD type "Grid type" +{ + "box" :: "Box grid from -0.5 to 0.5" + "byrange" :: "Specify min and max values" + "byspacing" :: "Specify grid spacings" + "coordbase" :: "Get specification from CoordBase" + "multipatch" :: "Get specification from MultiPatch" +} "box" + +KEYWORD domain "Domain type" +{ + "octant" :: "Use an octant about the origin" + "quadrant" :: "Use a quadrant in x-y plane" + "quadrant_reflect_rotate" :: "Use a quadrant with rotation symmetry about an axis" + "bitant" :: "Use a bitant about the x-y plane" + "bitant_rotate" :: "Use a bitant with rotation symmetry about an axis" + "full" :: "Use the full domain" +} "full" + +KEYWORD bitant_plane "Plane defining bitant domain" +{ + "xy" :: "xy-plane" + "xz" :: "xz-plane" + "yz" :: "yz-plane" +} "xy" + +KEYWORD quadrant_direction "Direction defining quadrant domain" +{ + "x" :: "x-direction" + "y" :: "y-direction" + "z" :: "z-direction" +} "z" + +KEYWORD rotation_axis "Axis about which the rotation symmetry is to be applied" +{ + "x" :: "x-axis" + "y" :: "y-axis" + "z" :: "z-axis" +} "z" + + +BOOLEAN symmetry_xmin "Symmetry boundary condition on lower x boundary" +{ + : :: "Logical" +} "no" + +BOOLEAN symmetry_ymin "Symmetry boundary condition on lower y boundary" +{ + : :: "Logical" +} "no" + +BOOLEAN symmetry_zmin "Symmetry boundary condition on lower z boundary" +{ + : :: "Logical" +} "no" + +BOOLEAN symmetry_xmax "Symmetry boundary condition on upper x boundary" +{ + : :: "Logical" +} "no" + +BOOLEAN symmetry_ymax "Symmetry boundary condition on upper y boundary" +{ + : :: "Logical" +} "no" + +BOOLEAN symmetry_zmax "Symmetry boundary condition on upper z boundary" +{ + : :: "Logical" +} "no" + diff --git a/GridX/schedule.ccl b/GridX/schedule.ccl new file mode 100644 index 000000000..358783ea9 --- /dev/null +++ b/GridX/schedule.ccl @@ -0,0 +1,17 @@ +# Schedule definitions for thorn GridX + +STORAGE: coordinates gridspacings + +schedule GridX_SetRanges at CCTK_BASEGRID as SpatialSpacings before SpatialCoordinates +{ + LANG:C + WRITES: GRID::gridspacings(everywhere) +} "Set up ranges for spatial 3D Cartesian coordinates (on all grids)" + +# TODO: schedule in postregrid, don't rely on CarpetX scheduling BaseGrid on +# its own +schedule GridX_SetCoordinates as SpatialCoordinates at CCTK_BASEGRID +{ + LANG:C + WRITES: GRID::coordinates(everywhere) +} "Set up spatial 3D Cartesian coordinates on the GH" diff --git a/GridX/src/grid.cc b/GridX/src/grid.cc new file mode 100644 index 000000000..f8b79349c --- /dev/null +++ b/GridX/src/grid.cc @@ -0,0 +1,48 @@ +#include "cctk.h" +#include "cctk_Arguments.h" +#include "cctk_Parameters.h" + +#include +#include + +#include "loop_device.hxx" + +// TODO: this should not call itself "grid" since it only provides spacings and +// coords and would alos be used with non-Cartesian grids but Cartesian point +// labels + +extern "C" +void GridX_SetRanges(CCTK_ARGUMENTS) { + DECLARE_CCTK_PARAMETERS; + DECLARE_CCTK_ARGUMENTSX_GridX_SetRanges; + + static int level_run_on = -1; + static int patch_run_on = -1; + + #pragma omp critical + if(level_run_on == -1 || level_run_on > cctk_level || + patch_run_on == -1 || patch_run_on > cctk_patch) { + assert((level_run_on == -1 && patch_run_on == -1) || + (level_run_on != -1 || patch_run_on != -1)); + *coarse_dx = cctk_delta_space[0]; + *coarse_dy = cctk_delta_space[1]; + *coarse_dz = cctk_delta_space[2]; + level_run_on = cctk_level; + patch_run_on = cctk_patch; + } +} + +extern "C" +void GridX_SetCoordinates(CCTK_ARGUMENTS) { + DECLARE_CCTK_PARAMETERS; + DECLARE_CCTK_ARGUMENTSX_GridX_SetCoordinates; + + grid.loop_all_device<0,0,0>( + grid.nghostzones, + [=] CCTK_DEVICE(const Loop::PointDesc &p) CCTK_ATTRIBUTE_ALWAYS_INLINE { + x(p.I) = p.x; + y(p.I) = p.x; + z(p.I) = p.x; + r(p.I) = sqrt(p.x*p.x + p.y*p.y + p.z*p.z); + }); +} diff --git a/GridX/src/make.code.defn b/GridX/src/make.code.defn new file mode 100644 index 000000000..62a34d15c --- /dev/null +++ b/GridX/src/make.code.defn @@ -0,0 +1,7 @@ +# Main make.code.defn file for thorn GridX + +# Source files in this directory +SRCS = grid.cc + +# Subdirectories containing source files +SUBDIRS =