From 0595b414b78936d85408cd902690b54a380faa28 Mon Sep 17 00:00:00 2001 From: schnetter <> Date: Wed, 3 Apr 2002 14:33:00 +0000 Subject: Replacement version of CactusBase/CartGrid3D for use with mesh refinement. darcs-hash:20020403143326-07bb3-687978f66afa7dca09e3ac4cd702b18fef8e1e89.gz --- CarpetAttic/CartGrid3D/COPYRIGHT | 352 ++++++++++++++++++ CarpetAttic/CartGrid3D/README | 23 ++ CarpetAttic/CartGrid3D/doc/documentation.tex | 88 +++++ CarpetAttic/CartGrid3D/interface.ccl | 18 + CarpetAttic/CartGrid3D/par/byrange_full.par | 15 + CarpetAttic/CartGrid3D/param.ccl | 171 +++++++++ CarpetAttic/CartGrid3D/schedule.ccl | 26 ++ CarpetAttic/CartGrid3D/src/CartGrid3D.c | 431 ++++++++++++++++++++++ CarpetAttic/CartGrid3D/src/DecodeSymParameters.c | 93 +++++ CarpetAttic/CartGrid3D/src/GHExtension.c | 94 +++++ CarpetAttic/CartGrid3D/src/ParamCheck.c | 100 ++++++ CarpetAttic/CartGrid3D/src/SetSymmetry.c | 288 +++++++++++++++ CarpetAttic/CartGrid3D/src/Startup.c | 107 ++++++ CarpetAttic/CartGrid3D/src/Symmetry.c | 224 ++++++++++++ CarpetAttic/CartGrid3D/src/SymmetryCondition.c | 103 ++++++ CarpetAttic/CartGrid3D/src/SymmetryWrappers.c | 432 +++++++++++++++++++++++ CarpetAttic/CartGrid3D/src/make.code.defn | 17 + 17 files changed, 2582 insertions(+) create mode 100644 CarpetAttic/CartGrid3D/COPYRIGHT create mode 100644 CarpetAttic/CartGrid3D/README create mode 100644 CarpetAttic/CartGrid3D/doc/documentation.tex create mode 100644 CarpetAttic/CartGrid3D/interface.ccl create mode 100644 CarpetAttic/CartGrid3D/par/byrange_full.par create mode 100644 CarpetAttic/CartGrid3D/param.ccl create mode 100644 CarpetAttic/CartGrid3D/schedule.ccl create mode 100644 CarpetAttic/CartGrid3D/src/CartGrid3D.c create mode 100644 CarpetAttic/CartGrid3D/src/DecodeSymParameters.c create mode 100644 CarpetAttic/CartGrid3D/src/GHExtension.c create mode 100644 CarpetAttic/CartGrid3D/src/ParamCheck.c create mode 100644 CarpetAttic/CartGrid3D/src/SetSymmetry.c create mode 100644 CarpetAttic/CartGrid3D/src/Startup.c create mode 100644 CarpetAttic/CartGrid3D/src/Symmetry.c create mode 100644 CarpetAttic/CartGrid3D/src/SymmetryCondition.c create mode 100644 CarpetAttic/CartGrid3D/src/SymmetryWrappers.c create mode 100644 CarpetAttic/CartGrid3D/src/make.code.defn (limited to 'CarpetAttic') diff --git a/CarpetAttic/CartGrid3D/COPYRIGHT b/CarpetAttic/CartGrid3D/COPYRIGHT new file mode 100644 index 000000000..57b2896b0 --- /dev/null +++ b/CarpetAttic/CartGrid3D/COPYRIGHT @@ -0,0 +1,352 @@ + + +This thorn is (c) Copyright the authors listed in the sources files. This +thorn is distributed under the GNU GPL with the specific exception that +the GNU GPL does not migrate to code linking to or using infrastructure +from this thorn. + +- The Cactus Team + +************************************************************************** + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. + + diff --git a/CarpetAttic/CartGrid3D/README b/CarpetAttic/CartGrid3D/README new file mode 100644 index 000000000..0a761f9b9 --- /dev/null +++ b/CarpetAttic/CartGrid3D/README @@ -0,0 +1,23 @@ +Thorn CartGrid3D +Authors : Gabrielle Allen, Gerd Lanfermann, Joan Masso +CVS info : $Header: /home/eschnett/C/carpet/Carpet/CarpetAttic/CartGrid3D/Attic/README,v 1.1 2002/04/03 16:33:26 schnetter Exp $ +-------------------------------------------------------------------------- + +1. Purpose of the thorn + +This thorn sets up a Cartesian grid, for a given domain. It also +provides a method for registering symmetries of Grid Functions +across the grid axes, and a call for applying symmetry boundary +conditions. + +2. Additional information + +This thorn currently only works in 3D + + + +NOTE. This thorn is almost a copy of CactusBase/CartGrid3D. It +contains modifications by Erik Schnetter +to make it work with mesh refinement. These modifications are meant +to be folded back into that very thorn. This thorn here is only a +temporary replacement. diff --git a/CarpetAttic/CartGrid3D/doc/documentation.tex b/CarpetAttic/CartGrid3D/doc/documentation.tex new file mode 100644 index 000000000..8a7961040 --- /dev/null +++ b/CarpetAttic/CartGrid3D/doc/documentation.tex @@ -0,0 +1,88 @@ +\documentclass{article} +\begin{document} + +\title{CartGrid3D} +\author{Gabrielle Allen, Gerd Lanfermann} +\date{1999} +\maketitle + +\abstract{Cartesian coordinates and symmetries for 3D grids} + +\section{Purpose} + +Allows you to set up coordinates on a 3D Cartesian grid in a +flexible manner. Different grid domains (e.g. octant) can +be chosen to allow you to exploit any symmetry in your +problem. Routines for registering symmetries of grid functions +and applying symmetry conditions across the coordinate axes +are provided. + +\section{Comments} + +\subsection{Coordinates} + +The Cartesian coordinates supplied by this thorn are +grid functions with the standard names {\tt x}, {\tt y}, and +{\tt z}. To use these coordinates you need to {\tt inherit} +from {\tt grid}. The coordinates are +registered with the flesh using the same names "x", "y" +and "z". In addition a grid function {\tt r} (registered as +"r") is provided, containing the radial coordinate from +the origin where +$$ +r = \sqrt{x^2+y^2+z^2} +$$ + +{\tt CartGrid3D} registers the lower and upper range of each coordinate +with the flesh. + +\subsection{Symmetries} + +If your problem and initial data allow it, {\tt CartGrid3D} +allows you to enforce either an even or odd parity +symmetry condition for any grid functions at each +coordinate axes. For a function $\phi(x,y,z)$, +even parity symmetry on the $x$-axis means +$$ +\phi(-x,y,z) = \phi(x,y,z) +$$ +while odd parity symmetry means +$$ +\phi(-x,y,z) = -\phi(x,y,z) +$$ + +Note that the symmetries will only be enforced if a +symmetry domain is chosen (that is, if +{\tt domain} is {\tt octant}, {\tt quadrant} or {\tt bitant}). + +\subsection{Registering Symmetry Behaviour} + +Each grid function can register how it behaves under a coordinate +change using function calls in {\tt CartGrid3D}. These symmetry +properties can then be used by other thorns, for example {\tt +CactusBase/Boundary} uses them to enforce symmetry boundary conditions +across coordinate axis. Symmetries should obviously be registered +before they are used, but since they can be different for different grids, +they must be registered {\it after} the {\tt CCTK\_STARTUP} timebin. The +usual place to register symmetries is in the {\tt CCTK\_BASEGRID} timebin. + +For example, to register the symmetries of the {\it xy} component of the +metric tensor from C + +{\tt +\begin{verbatim} +static int one=1; +int sym[3]; +sym[0] = -one; +sym[1] = -one; +sym[2] = one; +SetCartSymVN(cctkGH, sym,"einstein::gxy"); +\end{verbatim} +} + +% Automatically created from the ccl files by using gmake thorndoc +\include{interface} +\include{param} +\include{schedule} + +\end{document} diff --git a/CarpetAttic/CartGrid3D/interface.ccl b/CarpetAttic/CartGrid3D/interface.ccl new file mode 100644 index 000000000..c71573061 --- /dev/null +++ b/CarpetAttic/CartGrid3D/interface.ccl @@ -0,0 +1,18 @@ +# Interface definition for thorn CartGrid3D +# $Header: /home/eschnett/C/carpet/Carpet/CarpetAttic/CartGrid3D/Attic/interface.ccl,v 1.1 2002/04/03 16:33:26 schnetter Exp $ + +implements: grid + +INCLUDE HEADER: Symmetry.h in Symmetry.h + +public: + +REAL gridspacings type=SCALAR +{ + coarse_dx, coarse_dy, coarse_dz +} "3D Cartesian grid spacings" + +REAL coordinates type=GF +{ + x, y, z, r +} "3D Cartesian grid coordinates" diff --git a/CarpetAttic/CartGrid3D/par/byrange_full.par b/CarpetAttic/CartGrid3D/par/byrange_full.par new file mode 100644 index 000000000..ebeb11311 --- /dev/null +++ b/CarpetAttic/CartGrid3D/par/byrange_full.par @@ -0,0 +1,15 @@ + +!DESC "Create coordinates by range on a full grid" + +ActiveThorns = "pugh pughslab cartgrid3d ioutil ioascii" + +driver::global_nsize = 10 + +grid::type = "byrange" +grid::domain = "full" +grid::xyzmin = -10 +grid::xyzmax = 10 + +IO::outdir = byrange_full +IOASCII::out1D_vars = "grid::x grid::y grid::z" +IOASCII::out1D_every = 1 diff --git a/CarpetAttic/CartGrid3D/param.ccl b/CarpetAttic/CartGrid3D/param.ccl new file mode 100644 index 000000000..433a6f0ac --- /dev/null +++ b/CarpetAttic/CartGrid3D/param.ccl @@ -0,0 +1,171 @@ +# Parameter definitions for thorn CartGrid3D +# $Header: /home/eschnett/C/carpet/Carpet/CarpetAttic/CartGrid3D/Attic/param.ccl,v 1.1 2002/04/03 16:33:26 schnetter Exp $ + +shares: driver + +USES BOOLEAN periodic +USES BOOLEAN periodic_x +USES BOOLEAN periodic_y +USES BOOLEAN periodic_z + + +private: + +BOOLEAN no_origin "DEPRECATED: Don't place grid points on the coordinate origin/axes" +{ + : :: "" +} "yes" + +BOOLEAN no_originx "DEPRECATED: Don't place grid points on the x-coordinate origin/axes" +{ + : :: "" +} "yes" + +BOOLEAN no_originy "DEPRECATED: Don't place grid points on the y-coordinate origin/axes" +{ + : :: "" +} "yes" + +BOOLEAN no_originz "DEPRECATED: Don't place grid points on the z-coordinate origin/axes" +{ + : :: "" +} "yes" + +BOOLEAN avoid_originx "Don't place grid points on the x-coordinate origin/axes" +{ + : :: "" +} "yes" + +BOOLEAN avoid_originy "Don't place grid points on the y-coordinate origin/axes" +{ + : :: "" +} "yes" + +BOOLEAN avoid_originz "Don't place grid points on the z-coordinate origin/axes" +{ + : :: "" +} "yes" + +BOOLEAN avoid_origin "Don't place grid points on the coordinate origin/axes" +{ + : :: "" +} "yes" + + + +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" +} "box" + +KEYWORD domain "Domain type" +{ + "octant" :: "Use an octant about the origin" + "quadrant" :: "Use a quadrant in x-y plane" + "bitant" :: "Use a bitant about the x-y plane" + "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" + +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/CarpetAttic/CartGrid3D/schedule.ccl b/CarpetAttic/CartGrid3D/schedule.ccl new file mode 100644 index 000000000..be9caa160 --- /dev/null +++ b/CarpetAttic/CartGrid3D/schedule.ccl @@ -0,0 +1,26 @@ +# Schedule definitions for thorn CartGrid3D +# $Header: /home/eschnett/C/carpet/Carpet/CarpetAttic/CartGrid3D/Attic/schedule.ccl,v 1.1 2002/04/03 16:33:27 schnetter Exp $ + +STORAGE: coordinates gridspacings + +schedule SymmetryStartup at CCTK_STARTUP +{ + LANG: C +} "Register GH Extension for GridSymmetry" + +schedule RegisterCartGrid3DCoords at CCTK_STARTUP +{ + LANG:C +} "Register coordinates for the Cartesian grid" + +schedule ParamCheck_CartGrid3D at CCTK_PARAMCHECK +{ + LANG:C +} "Check coordinates for CartGrid3D" + +schedule CartGrid3D as SpatialCoordinates at CCTK_BASEGRID +{ + LANG:C +} "Set up spatial 3D Cartesian coordinates on the GH" + + diff --git a/CarpetAttic/CartGrid3D/src/CartGrid3D.c b/CarpetAttic/CartGrid3D/src/CartGrid3D.c new file mode 100644 index 000000000..865397439 --- /dev/null +++ b/CarpetAttic/CartGrid3D/src/CartGrid3D.c @@ -0,0 +1,431 @@ + /*@@ + @file CartGrid3D.c + @date Thu Oct 7 13:20:06 1999 + @author Tom Goodale + @desc + Set up coordinates for a 3D Cartesian grid. + C Conversion of Fortran routine written by Gab. + @enddesc + @@*/ + +/*#define CCTK_DEBUG*/ + +#include +#include +#include + +#include "cctk.h" +#include "cctk_Arguments.h" +#include "cctk_Parameters.h" + +static const char *rcsid = "$Header: /home/eschnett/C/carpet/Carpet/CarpetAttic/CartGrid3D/src/Attic/CartGrid3D.c,v 1.1 2002/04/03 16:33:28 schnetter Exp $"; + +CCTK_FILEVERSION(CactusBase_CartGrid3D_CartGrid3D_c) + +void DecodeSymParameters3D(int sym[6]); +void CartGrid3D(CCTK_ARGUMENTS); + +#define max(a,b) ((a) > (b) ? (a) : (b)) +#define SQR(a) ((a)*(a)) + +void CartGrid3D(CCTK_ARGUMENTS) +{ + + DECLARE_CCTK_ARGUMENTS + DECLARE_CCTK_PARAMETERS + + int iconv, i, j, k; + double dconv; + CCTK_REAL x_origin,y_origin,z_origin; + CCTK_REAL this_dx,this_dy,this_dz; + CCTK_REAL xmin1,ymin1,zmin1,xmax1,ymax1,zmax1; + CCTK_REAL lowerx,upperx,lowery,uppery,lowerz,upperz; + int lowerxi,upperxi,loweryi,upperyi,lowerzi,upperzi; + char infoline[120]; + int ierr; + + int domainsym[6]; + int cntstag[3]; + + + if (cctk_levfac[0] == 1 && cctk_levfac[1] == 1 && cctk_levfac[2] == 1) { + /* Calculate the coordinate ranges only for the coarsest level */ + + + + /* Some compilers warn about variables which might be uninitialized + because they are assigned in some if/else statements only */ + x_origin = y_origin = z_origin = 0.0; + lowerxi = loweryi = lowerzi = 0; + upperxi = cctk_gsh[0]-1; + upperyi = cctk_gsh[1]-1; + upperzi = cctk_gsh[2]-1; + this_dx = this_dy = this_dz = 0.0; + + /* Avoid origin? Default is yes */ + cntstag[0] = no_origin && no_originx && avoid_origin && avoid_originx; + cntstag[1] = no_origin && no_originy && avoid_origin && avoid_originy; + cntstag[2] = no_origin && no_originz && avoid_origin && avoid_originz; + + /* Determine symmetries of domain */ + DecodeSymParameters3D(domainsym); + + /* Calculate physical indices, using symmetries and periodicity */ + if (domainsym[0]) + { + lowerxi = cctk_nghostzones[0]; + } + else + { + lowerxi = 0; + } + if (domainsym[2]) + { + loweryi = cctk_nghostzones[1]; + } + else + { + loweryi = 0; + } + if (domainsym[4]) + { + lowerzi = cctk_nghostzones[2]; + } + else + { + lowerzi = 0; + } + + if (periodic) + { + if (periodic_x) + { + lowerxi = cctk_nghostzones[0]; + upperxi = cctk_gsh[0]-1-cctk_nghostzones[0]; + } + if (periodic_y) + { + loweryi = cctk_nghostzones[1]; + upperyi = cctk_gsh[1]-1-cctk_nghostzones[1]; + } + if (periodic_z) + { + lowerzi = cctk_nghostzones[2]; + upperzi = cctk_gsh[2]-1-cctk_nghostzones[2]; + } + } + + dconv = pow(2, cctk_convlevel); + iconv = (int)dconv; + + /**************************************************************** + * + * BYRANGE + * + * User gives: minimum and maximum values of coordinates and + * the number of gridpoints on the coarse grid + * + ***************************************************************/ + /************************************************************** + * + * BOX (-0.5 to 0.5) + * + * User gives: number of gridpoints on the coarse grid + * + **************************************************************/ + + if (CCTK_Equals(type,"byrange") || CCTK_Equals(type,"box")) + { + + if (CCTK_Equals(type,"box")) + { + + /* Coordinates are all -0.5 to 0.5 */ + xmax1 = 0.5; + ymax1 = 0.5; + zmax1 = 0.5; + + xmin1 = -0.5; + ymin1 = -0.5; + zmin1 = -0.5; + + } + else + { + + if (xyzmax != -424242) + { + xmax1 = xyzmax; + ymax1 = xyzmax; + zmax1 = xyzmax; + } + else + { + xmax1 = xmax; + ymax1 = ymax; + zmax1 = zmax; + } + + if (xyzmin != -424242) + { + xmin1 = xyzmin; + ymin1 = xyzmin; + zmin1 = xyzmin; + } + else + { + xmin1 = xmin; + ymin1 = ymin; + zmin1 = zmin; + } + + } + + + + /* Grid spacing on coarsest grid */ + /* TODO: Put the coordinates into arrays, and loop over the + dimensions. That gets ride of all the triplicated code. */ + if (domainsym[0]) + { + if (cntstag[0]) + { + *coarse_dx = xmax1 / (cctk_gsh[0] - cctk_nghostzones[0] - 0.5); + x_origin = - (cctk_nghostzones[0] - 0.5) * *coarse_dx * iconv; + } + else + { + *coarse_dx = xmax1 / (cctk_gsh[0] - cctk_nghostzones[0] - 1); + x_origin = - cctk_nghostzones[0] * *coarse_dx * iconv; + } + } + else + { + *coarse_dx = (xmax1 - xmin1) / max(cctk_gsh[0] - 1, 1); + x_origin = xmin1; + } + + if (domainsym[2]) + { + if (cntstag[1]) + { + *coarse_dy = ymax1 / (cctk_gsh[1] - cctk_nghostzones[1] - 0.5); + y_origin = - (cctk_nghostzones[1] - 0.5) * *coarse_dy * iconv; + } + else + { + *coarse_dy = ymax1 / (cctk_gsh[1] - cctk_nghostzones[1] - 1); + y_origin = - cctk_nghostzones[1] * *coarse_dy * iconv; + } + } + else + { + *coarse_dy = (ymax1 - ymin1) / max(cctk_gsh[1] - 1, 1); + y_origin = ymin1; + } + + if (domainsym[4]) + { + if (cntstag[2]) + { + *coarse_dz = zmax1 / (cctk_gsh[2] - cctk_nghostzones[2] - 0.5); + z_origin = - (cctk_nghostzones[2] - 0.5) * *coarse_dz * iconv; + } + else + { + *coarse_dz = zmax1 / (cctk_gsh[2] - cctk_nghostzones[2] - 1); + z_origin = - cctk_nghostzones[2] * *coarse_dz * iconv; + } + } + else + { + *coarse_dz = (zmax1 - zmin1) / max(cctk_gsh[2] - 1, 1); + z_origin = zmin1; + } + + /* dx,dy,dz on the grid we are on */ + this_dx = *coarse_dx * iconv; + this_dy = *coarse_dy * iconv; + this_dz = *coarse_dz * iconv; + + } + + /************************************************************** + * BYSPACING + * + * User gives: grid spacing on the coarsest GH and + * the number of gridpoints on the coarsest GH + * + **************************************************************/ + + else if (CCTK_Equals(type,"byspacing")) + { + + /* Dx, Dy, Dx on the coarsest grid */ + + if (dxyz > 0) + { + *coarse_dx = dxyz; + *coarse_dy = dxyz; + *coarse_dz = dxyz; + } + else + { + *coarse_dx = dx; + *coarse_dy = dy; + *coarse_dz = dz; + } + + /* dx, dy, dz on the grid we are on */ + this_dx = *coarse_dx * iconv; + this_dy = *coarse_dy * iconv; + this_dz = *coarse_dz * iconv; + + + + /* Set minimum values of coordinates */ + if (domainsym[0]) + { + x_origin = (- cctk_nghostzones[0] + cntstag[0] * 0.5) * this_dx; + } + else + { + x_origin = - 0.5 * (cctk_gsh[0]-1 - cntstag[0] * (cctk_gsh[0])%2) + * this_dx; + } + + if (domainsym[2]) + { + y_origin = (- cctk_nghostzones[1] + cntstag[1] * 0.5) * this_dy; + } + else + { + y_origin = - 0.5 * (cctk_gsh[1]-1 - cntstag[1] * (cctk_gsh[1])%2) + * this_dy; + } + + if (domainsym[4]) + { + z_origin = (- cctk_nghostzones[2] + cntstag[2] * 0.5) * this_dz; + } + else + { + z_origin = - 0.5 * (cctk_gsh[2]-1 - cntstag[2] * (cctk_gsh[2])%2) + * this_dz; + } + } + + } else { /* if (not coarsest refinement level) */ + + /* Use the already calculated coordinate ranges for all but the + coarsest levels */ + + this_dx = cctk_delta_space[0] / cctk_levfac[0]; + this_dy = cctk_delta_space[1] / cctk_levfac[1]; + this_dz = cctk_delta_space[2] / cctk_levfac[2]; + + x_origin = cctk_origin_space[0]; + y_origin = cctk_origin_space[1]; + z_origin = cctk_origin_space[2]; + + } /* if (not coarsest refinement level) */ + + + + /* Set spatial coordinates */ + + for(i=0; i < cctk_lsh[0]; i++) + { + for(j=0; j < cctk_lsh[1]; j++) + { + for(k=0; k < cctk_lsh[2]; k++) + { + x[CCTK_GFINDEX3D(cctkGH,i,j,k)] = this_dx*(i+cctk_lbnd[0]) + x_origin; + y[CCTK_GFINDEX3D(cctkGH,i,j,k)] = this_dy*(j+cctk_lbnd[1]) + y_origin; + z[CCTK_GFINDEX3D(cctkGH,i,j,k)] = this_dz*(k+cctk_lbnd[2]) + z_origin; + r[CCTK_GFINDEX3D(cctkGH,i,j,k)] = sqrt(SQR(x[CCTK_GFINDEX3D(cctkGH,i,j,k)])+ + SQR(y[CCTK_GFINDEX3D(cctkGH,i,j,k)])+ + SQR(z[CCTK_GFINDEX3D(cctkGH,i,j,k)])); + } + } + } + + if (cctk_levfac[0] == 1 && cctk_levfac[1] == 1 && cctk_levfac[2] == 1) { + /* Register the coordinate ranges only for the coarsest level */ + + cctk_delta_space[0] = this_dx; + cctk_delta_space[1] = this_dy; + cctk_delta_space[2] = this_dz; + + cctk_origin_space[0] = x_origin; + cctk_origin_space[1] = y_origin; + cctk_origin_space[2] = z_origin; + + lowerx = x_origin; + upperx = x_origin+this_dx*(cctk_gsh[0]-1); + ierr = CCTK_CoordRegisterRange(cctkGH,lowerx,upperx,-1,"x","cart3d"); + assert (ierr==0); + ierr = CCTK_CoordRegisterRangePhysIndex(cctkGH,lowerxi,upperxi,-1,"x","cart3d"); + assert (ierr==0); + + lowery = y_origin; + uppery = y_origin+this_dy*(cctk_gsh[1]-1); + ierr = CCTK_CoordRegisterRange(cctkGH,lowery,uppery,-1,"y","cart3d"); + assert (ierr==0); + ierr = CCTK_CoordRegisterRangePhysIndex(cctkGH,loweryi,upperyi,-1,"y","cart3d"); + assert (ierr==0); + + lowerz = z_origin; + upperz = z_origin+this_dz*(cctk_gsh[2]-1); + ierr = CCTK_CoordRegisterRange(cctkGH,lowerz,upperz,-1,"z","cart3d"); + assert (ierr==0); + ierr = CCTK_CoordRegisterRangePhysIndex(cctkGH,lowerzi,upperzi,-1,"z","cart3d"); + assert (ierr==0); + + CCTK_INFO("Grid Spacings:"); + sprintf(infoline," %s%12.7e %s%12.7e %s%12.7e ", + "dx=>",cctk_delta_space[0], + "dy=>",cctk_delta_space[1], + "dz=>",cctk_delta_space[2]); + CCTK_INFO(infoline); + + CCTK_INFO("Computational Coordinates:"); + sprintf(infoline," %s[%6.3f,%6.3f] %s[%6.3f,%6.3f] %s[%6.3f,%6.3f] ", + "x=>",lowerx,upperx, + "y=>",lowery,uppery, + "z=>",lowerz,upperz); + CCTK_INFO(infoline); + + CCTK_INFO("Indices of Physical Coordinates:"); + sprintf(infoline," %s[%d,%d] %s[%d,%d] %s[%d,%d] ", + "x=>",lowerxi,upperxi, + "y=>",loweryi,upperyi, + "z=>",lowerzi,upperzi); + CCTK_INFO(infoline); + + } /* if (coarsest refinement level) */ + + +#ifdef CCTK_DEBUG + printf("\n"); + printf("CartGrid3D\n"); + printf(" ----------\n"); + printf("Dx,Dy,Dz on coarse grid %6.3f %6.3f, %6.3f\n", *coarse_dx,*coarse_dy,*coarse_dz); + printf("Dx,Dy,Dz on this grid %6.3f %6.3f, %6.3f\n", cctk_delta_space[0],cctk_delta_space[1],cctk_delta_space[2]); + printf(" Convergence level = %d\n",cctk_convlevel); + printf(" Minimum global coords %6.3f %6.3f %6.3f\n", x_origin,y_origin,z_origin); + printf(" Maximum global coords %6.3f %6.3f %6.3f\n", x_origin+this_dx*(cctk_gsh[0]-1), + y_origin+this_dy*(cctk_gsh[1]-1), + z_origin+this_dz*(cctk_gsh[2]-1)); + printf(" Minimum local coords %6.3f %6.3f %6.3f\n", x[0],y[0],z[0]); + printf(" Maximum local coords %6.3f %6.3f %6.3f\n", x[CCTK_GFINDEX3D(cctkGH, cctk_lsh[0]-1,cctk_lsh[1]-1,cctk_lsh[2]-1)], + y[CCTK_GFINDEX3D(cctkGH, cctk_lsh[0]-1,cctk_lsh[1]-1,cctk_lsh[2]-1)], + z[CCTK_GFINDEX3D(cctkGH, cctk_lsh[0]-1,cctk_lsh[1]-1,cctk_lsh[2]-1)]); + +#endif + + return; + +} + + diff --git a/CarpetAttic/CartGrid3D/src/DecodeSymParameters.c b/CarpetAttic/CartGrid3D/src/DecodeSymParameters.c new file mode 100644 index 000000000..9336eee6e --- /dev/null +++ b/CarpetAttic/CartGrid3D/src/DecodeSymParameters.c @@ -0,0 +1,93 @@ + /*@@ + @file DecodeSymParameters.c + @date Wed May 10 18:58:00 EST 2000 + @author Erik Schnetter + @desc + Decode the symmetry parameters. + @enddesc + @version $Header: /home/eschnett/C/carpet/Carpet/CarpetAttic/CartGrid3D/src/Attic/DecodeSymParameters.c,v 1.1 2002/04/03 16:33:28 schnetter Exp $ + @@*/ + +#include "cctk.h" +#include "cctk_Arguments.h" +#include "cctk_Parameters.h" + +static const char *rcsid = "$Header: /home/eschnett/C/carpet/Carpet/CarpetAttic/CartGrid3D/src/Attic/DecodeSymParameters.c,v 1.1 2002/04/03 16:33:28 schnetter Exp $"; + +CCTK_FILEVERSION(CactusBase_CartGrid3D_DecodeSymParameters_c) + +void DecodeSymParameters3D(int sym[6]); + +/*@@ + @routine DecodeSymParameters3D + @date Thu May 11 11:49:08 2000 + @author Erik Schnetter + @desc + Decode the Symmetry parameters. + returns the symmetry flags (yes/no=1/0) + in the array sym + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ + +void DecodeSymParameters3D(int sym[6]) +{ + DECLARE_CCTK_PARAMETERS + + /* The default is as set by the explicit symmetry parameters */ + /* lower faces */ + sym[0] = symmetry_xmin; + sym[2] = symmetry_ymin; + sym[4] = symmetry_zmin; + + /* upper faces */ + sym[1] = symmetry_xmax; + sym[3] = symmetry_ymax; + sym[5] = symmetry_zmax; + + /* The default can be overridden by bitant, quadrant, and octant mode */ + if (CCTK_Equals(domain, "bitant")) + { + if (CCTK_Equals(bitant_plane, "xy")) + { + sym[4] = 1; + } + else if (CCTK_Equals(bitant_plane, "xz")) + { + sym[2] = 1; + } + else if (CCTK_Equals(bitant_plane, "yz")) + { + sym[0] = 1; + } + } + else if (CCTK_Equals(domain, "quadrant")) + { + if (CCTK_Equals(quadrant_direction, "x")) + { + sym[2] = 1; + sym[4] = 1; + } + else if (CCTK_Equals(quadrant_direction, "y")) + { + sym[0] = 1; + sym[4] = 1; + } + else if (CCTK_Equals(quadrant_direction, "z")) + { + sym[0] = 1; + sym[2] = 1; + } + } + else if (CCTK_Equals(domain, "octant")) + { + sym[0] = 1; + sym[2] = 1; + sym[4] = 1; + } +} diff --git a/CarpetAttic/CartGrid3D/src/GHExtension.c b/CarpetAttic/CartGrid3D/src/GHExtension.c new file mode 100644 index 000000000..a6e54ea19 --- /dev/null +++ b/CarpetAttic/CartGrid3D/src/GHExtension.c @@ -0,0 +1,94 @@ + /*@@ + @file GHExtension.c + @date Mon Mar 15 15:48:42 1999 + @author Gerd Lanfermann + @desc + Set up the symmetry GH extension. This should really be done + with StoredData + @enddesc + @version $Id: GHExtension.c,v 1.1 2002/04/03 16:33:29 schnetter Exp $ + @@*/ + +#include + +#include "cctk.h" +#include "Symmetry.h" + +static const char *rcsid = "$Header: /home/eschnett/C/carpet/Carpet/CarpetAttic/CartGrid3D/src/Attic/GHExtension.c,v 1.1 2002/04/03 16:33:29 schnetter Exp $"; + +CCTK_FILEVERSION(CactusBase_CartGrid3D_GHExtension_c) + +int Symmetry_InitGHex(cGH *GH); +void *Symmetry_AllocGHex(tFleshConfig *config, int convlevel, cGH *GH); +int Symmetry_InitFGHex(cGH *GH); + +void *Symmetry_AllocGHex(tFleshConfig *config, int convlevel, cGH *GH) +{ + + int gf,grid_dim,NumVars; /* Number of dimensions, grid functions */ + SymmetryGHex *newGHex; /* Type of GHextension is EinsteinBoundGHex */ + + + /* avoid compiler warnings about unused arguments */ + config = config; + convlevel = convlevel; + GH = GH; + + NumVars = CCTK_NumVars(); /* Get number of grid functions */ + grid_dim = CCTK_MaxDim(); /* Get maximal dimension of the grid */ + + /* allocate the GHextension */ + newGHex = (SymmetryGHex*)malloc(sizeof(SymmetryGHex)); + + /* allocation for the number of grid functions*/ + newGHex->GFSym = (int **)malloc(NumVars*sizeof(int *)); + + /* allocation for the number of dimensions*/ + for (gf=0;gfGFSym[gf] = (int *)malloc(2*grid_dim*sizeof(int)); + } + + /* Now we have something, that looks like [0..NumVars-1][0..grid_dim-1] + and we return that: This will be merged into + the GH and can be referenced in the following manner: + int handle = CCTK_GHExtensionHandle("Symmetry"); + ..... which returns a pointer the GHextension + BoundGHEx = ((pGH *)GH->extensions[handle]); + ..... BoundGHex can now be used as: + BoundGHex->GFSym[3][2] = 1 ; + */ + + return newGHex; + +} + +int Symmetry_InitGHex(cGH *GH) +{ + int retval = 0; + SymmetryGHex *newGHex; + int handle; + int gf,d; + int NumVars =CCTK_NumVars(); + int grid_dim; + + grid_dim = CCTK_MaxDim(); + handle = CCTK_GHExtensionHandle("Symmetry"); + newGHex = (SymmetryGHex*) GH->extensions[handle]; + + /* ... and initialize them: */ + for (gf=0;gfGFSym[gf][d] = GFSYM_UNSET; /* not set */ + } + } + + return retval; +} + + + + + diff --git a/CarpetAttic/CartGrid3D/src/ParamCheck.c b/CarpetAttic/CartGrid3D/src/ParamCheck.c new file mode 100644 index 000000000..49d3bd9d5 --- /dev/null +++ b/CarpetAttic/CartGrid3D/src/ParamCheck.c @@ -0,0 +1,100 @@ + /*@@ + @file ParamCheck.c + @date Thu Oct 7 17:11:44 1999 + @author Tom Goodale + @desc + C version of Gab's paramcheck stuff + @enddesc + @@*/ + +#include "cctk.h" +#include "cctk_Arguments.h" +#include "cctk_Parameters.h" + +static const char *rcsid = "$Header: /home/eschnett/C/carpet/Carpet/CarpetAttic/CartGrid3D/src/Attic/ParamCheck.c,v 1.1 2002/04/03 16:33:29 schnetter Exp $"; + +CCTK_FILEVERSION(CactusBase_CartGrid3D_ParamCheck_c) + +void ParamCheck_CartGrid3D(CCTK_ARGUMENTS); + + /*@@ + @routine ParamCheckCartGrid3D + @date Tue Feb 23 1999 + @author Gabrielle Allen + @desc + Check parameters for CartGrid3D + @enddesc + @calls + @calledby + @history + @hdate Thu Oct 7 17:23:15 1999 @hauthor Tom Goodale + @hdesc Converted to C + @endhistory + +@@*/ +void ParamCheck_CartGrid3D(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS + DECLARE_CCTK_PARAMETERS + + int iflag; + + iflag = 0; + + if (CCTK_Equals(type,"byrange")) + { + if (CCTK_Equals(domain,"octant")) + { + iflag++; + } + else if (CCTK_Equals(domain,"quadrant")) + { + iflag++; + } + else if (CCTK_Equals(domain,"bitant")) + { + iflag++; + } + else if (CCTK_Equals(domain,"full")) + { + iflag++; + } + + } + else if (CCTK_Equals(type,"byspacing")) + { + if (CCTK_Equals(domain,"bitant")) + { + iflag++; + } + else if (CCTK_Equals(domain,"quadrant")) + { + iflag++; + } else if (CCTK_Equals(domain,"octant")) + { + iflag++; + } + else if (CCTK_Equals(domain,"full")) + { + iflag++; + } + } + else if (CCTK_Equals(type,"box")) + { + iflag++; + + if (!CCTK_Equals(domain,"full")) + CCTK_PARAMWARN("No symmetries can be used with box grid"); + } + + /* No grid was set up */ + + if (iflag != 1) + { + CCTK_PARAMWARN("No grid set up in CartGrid3D"); + } + + return; + +} + diff --git a/CarpetAttic/CartGrid3D/src/SetSymmetry.c b/CarpetAttic/CartGrid3D/src/SetSymmetry.c new file mode 100644 index 000000000..be215c90c --- /dev/null +++ b/CarpetAttic/CartGrid3D/src/SetSymmetry.c @@ -0,0 +1,288 @@ + +/*@@ + @file Symmetry.c + @date Mon Mar 15 15:09:00 1999 + @author Gerd Lanfermann + @desc + This file contains the routines for registering and applying symmetry + boundary conditions + @enddesc + @@*/ + +#include + +#include "cctk.h" +#include "cctk_Parameters.h" +#include "cctk_FortranString.h" +#include "Symmetry.h" + +static const char *rcsid = "$Header: /home/eschnett/C/carpet/Carpet/CarpetAttic/CartGrid3D/src/Attic/SetSymmetry.c,v 1.1 2002/04/03 16:33:29 schnetter Exp $"; + +CCTK_FILEVERSION(CactusBase_CartGrid3D_SetSymmetry_c) + +#define MAX_DIM 3 +#define MAX_FACE 6 + + +/******************************************************************** + ********************* Local Data Types *********************** + ********************************************************************/ + +/******************************************************************** + ********************* Local Routine Prototypes ********************* + ********************************************************************/ + +void DecodeSymParameters3D(int sym[6]); + +void CCTK_FCALL CCTK_FNAME(SetCartSymVI) + (int *ierr, cGH *GH, int *sym, int *vi); +void CCTK_FCALL CCTK_FNAME(SetCartSymVN) + (int *ierr, cGH *GH, int *sym, ONE_FORTSTRING_ARG); +void CCTK_FCALL CCTK_FNAME(SetCartSymGI) + (int *ierr, cGH *GH, int *sym, int *gi); +void CCTK_FCALL CCTK_FNAME(SetCartSymGN) + (int *ierr, cGH *GH, int *sym, ONE_FORTSTRING_ARG); + + + +/******************************************************************** + ********************* External Routines ********************** + ********************************************************************/ + + /*@@ + @routine SetCartSymmetry + @date Mon Mar 15 15:10:58 1999 + @author Gerd Lanfermann + @desc + This routine sets the GH extension (EinsteinBoundGHex *bGHex), + which describes the symmetry boundary type of each GF. Takes + the name of the GF ("implementation::gfname") and the symmetry operators + sx,sy,sz and inserts them in the array bGHex. + These values will looked up by the application routines SymmetryWrappers + @enddesc + @calls + @calledby + @history enhanced by E.Schnetter + + @endhistory + +@@*/ + +int SetCartSymVI(cGH *GH, int *sym, int vi) +{ + + DECLARE_CCTK_PARAMETERS + + int domainsym[MAX_FACE]; + SymmetryGHex *sGHex; + int dir; + + /* Pointer to the SymmetryGHextension */ + sGHex = (SymmetryGHex *)GH->extensions[CCTK_GHExtensionHandle("Symmetry")]; + + /* Reference the hash table in the GHex and tell it what kind of + symmetry is being applied + (depending on sym and the grid layout) + If there is no symmetry necessary,set ESYM_NOSYM + When we apply a symmetry and find ESYM_UNSET, something went wrong! + */ + +#ifdef SYM_DEBUG + printf("SetSymmetry: %s [%d,%d,%d]\n",CCTK_VarName(vi), sym[0],sym[1],sym[2]); +#endif + + DecodeSymParameters3D(domainsym); + for (dir=0; dirGFSym[vi][dir] = sym[dir/2]; + } + else + { + sGHex->GFSym[vi][dir] = GFSYM_NOSYM; + } + } + +#ifdef SYM_DEBUG + printf("SetSymmetry: %s [%d,%d,%d]\n\n",imp_gf, + sGHex->GFSym[vi][0], + sGHex->GFSym[vi][2], + sGHex->GFSym[vi][4]); +#endif + return 0; +} + +void CCTK_FCALL CCTK_FNAME(SetCartSymVI) + (int *ierr, cGH *GH, int *sym, int *vi) +{ + *ierr = SetCartSymVI(GH, sym, *vi); +} + + /*@@ + @routine SetCartSymVN + @date Thu May 11 13:32:55 2000 + @author Gerd Lanfermann + @desc + Applies symmetry boundary conditions from + variable index + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ + +int SetCartSymVN(cGH *GH, int *sym, const char *vn) { + int vi; + vi = CCTK_VarIndex(vn); + + if (vi>-1) + { + return(SetCartSymVI(GH, sym, vi)); + } + else + { + CCTK_VWarn(1,__LINE__,__FILE__,CCTK_THORNSTRING, + "Cannot find variable %s in SetCartSymVN",vn); + return(-1); + } +} + +void CCTK_FCALL CCTK_FNAME(SetCartSymVN) + (int *ierr, cGH *GH, int *sym, ONE_FORTSTRING_ARG) +{ + ONE_FORTSTRING_CREATE(vn) + *ierr = SetCartSymVN(GH, sym, vn); + free(vn); +} + + + + /*@@ + @routine SetCartSymGI + @date + @author Gerd Lanfermann + @desc + Applies symmetry boundary conditions from + Group index + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ + +int SetCartSymGI(cGH *GH, int *sym, int gi) +{ + + DECLARE_CCTK_PARAMETERS + + int domainsym[MAX_FACE]; + SymmetryGHex *sGHex; + int first_vari,numvars,vi; + int dir; + + sGHex = (SymmetryGHex *)GH->extensions[CCTK_GHExtensionHandle("Symmetry")]; + + first_vari = CCTK_FirstVarIndexI(gi); + numvars = CCTK_NumVarsInGroupI(gi); + + if (first_vari<0) + { + CCTK_VWarn(1,__LINE__,__FILE__,CCTK_THORNSTRING, + "Cannot find group %s (grp.index: %d) in SetCartSymGI", + CCTK_GroupName(gi),first_vari); + return(-1); + } + + /* Reference the hash table in the GHex and tell it what kind of + symmetry is being applied + (depending on sym and the grid layout) + If there is no symmetry necessary,set ESYM_NOSYM + When we apply a symmetry and find ESYM_UNSET, something went wrong! + */ + for (vi=first_vari; viGFSym[vi][dir] = sym[dir/2]; + } + else + { + sGHex->GFSym[vi][dir] = GFSYM_NOSYM; + } + } + +#ifdef SYM_DEBUG + printf("SetSymmetry: %s [%d,%d,%d]\n\n",imp_gf, + sGHex->GFSym[vi][0], + sGHex->GFSym[vi][2], + sGHex->GFSym[vi][4]); +#endif + } + return(0); +} + +void CCTK_FCALL CCTK_FNAME(SetCartSymGI) + (int *ierr, cGH *GH, int *sym, int *gi) +{ + *ierr = SetCartSymGI(GH, sym, *gi); +} + + + + /*@@ + @routine + @date + @author + @desc + Applies symmetry boundary conditions from + "Implementation::Groupname" + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ + +int SetCartSymGN(cGH *GH, int *sym, const char *gn) +{ + int gi = CCTK_GroupIndex(gn); + + if (gi>-1) + { + return(SetCartSymGI(GH, sym, gi)); + } + else + { + CCTK_VWarn(1,__LINE__,__FILE__,CCTK_THORNSTRING, + "Cannot find group %s in SetCartSymGN",gn); + return(-1); + } +} + +void CCTK_FCALL CCTK_FNAME(SetCartSymGN) + (int *ierr, cGH *GH, int *sym, ONE_FORTSTRING_ARG) +{ + ONE_FORTSTRING_CREATE(gn) + *ierr = SetCartSymGN(GH, sym, gn); + free(gn); +} + + diff --git a/CarpetAttic/CartGrid3D/src/Startup.c b/CarpetAttic/CartGrid3D/src/Startup.c new file mode 100644 index 000000000..b91951c38 --- /dev/null +++ b/CarpetAttic/CartGrid3D/src/Startup.c @@ -0,0 +1,107 @@ + /*@@ + @file Startup.c + @date Mon Mar 15 15:48:42 1999 + @author Gerd Lanfermann + @desc + Startup file to register the GHextension and coordinates + @enddesc + @@*/ + +#include "cctk.h" + +static const char *rcsid = "$Header: /home/eschnett/C/carpet/Carpet/CarpetAttic/CartGrid3D/src/Attic/Startup.c,v 1.1 2002/04/03 16:33:29 schnetter Exp $"; + +CCTK_FILEVERSION(CactusBase_CartGrid3D_Startup_c) + +void *Symmetry_AllocGHex(tFleshConfig *config, int convlevel, cGH *GH); +int Symmetry_InitGHex(cGH *GH); +int SymmetryStartup(void); +int RegisterCartGrid3DCoords(void); + + /*@@ + @routine SymmetryStartup + @date Mon Mar 15 15:49:16 1999 + @author Gerd Lanfermann + @desc + Routine registers the Setup and Initialation routines for the + GHExtension, which holds the symmetry BCs. We name the + GHextension "Symmetry" and get an integer ("handle") + identifying the GHex. + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ + +/* Store the handle in a global variable for the moment. */ +int Symmetry_handle; + + +int SymmetryStartup(void) +{ + Symmetry_handle = CCTK_RegisterGHExtension("Symmetry"); + + /* Register the allocation and init routine */ + CCTK_RegisterGHExtensionSetupGH(Symmetry_handle,Symmetry_AllocGHex); + CCTK_RegisterGHExtensionInitGH(Symmetry_handle,Symmetry_InitGHex); + + return 0; +} + + + /*@@ + @routine RegisterCartGrid3DCoords + @date + @author Gabrielle Allen + @desc + Routine registers the coordinates provided by CartGrid3D + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ + +int RegisterCartGrid3DCoords(void) +{ + + int ierr; + int nerrors=0; + + ierr=CCTK_CoordRegisterSystem(3,"cart3d"); + ierr=CCTK_CoordRegisterSystem(3,"spher3d"); + + ierr=CCTK_CoordRegisterData(1,"grid::x","x","cart3d"); + if (ierr<0) + { + CCTK_WARN(1,"Problem with registering coordinate x"); + nerrors--; + } + ierr=CCTK_CoordRegisterData(2,"grid::y","y","cart3d"); + if (ierr<0) + { + CCTK_WARN(1,"Problem with registering coordinate y"); + nerrors--; + } + ierr=CCTK_CoordRegisterData(3,"grid::z","z","cart3d"); + if (ierr<0) + { + CCTK_WARN(1,"Problem with registering coordinate z"); + nerrors--; + } + ierr=CCTK_CoordRegisterData(1,"grid::r","r","spher3d"); + if (ierr<0) + { + CCTK_WARN(1,"Problem with registering coordinate r"); + nerrors--; + } + + return nerrors; +} + + diff --git a/CarpetAttic/CartGrid3D/src/Symmetry.c b/CarpetAttic/CartGrid3D/src/Symmetry.c new file mode 100644 index 000000000..0c5f6b002 --- /dev/null +++ b/CarpetAttic/CartGrid3D/src/Symmetry.c @@ -0,0 +1,224 @@ + + /*@@ + @file Symmetry.c + @date Tue Apr 18 14:14:16 2000 + @author Gerd Lanfermann + @desc + Routines to apply the 1/2/3D Symmetries for + all symmetry domains (octant/bitant/quadrant). + @enddesc + @@*/ + +#include +#include +#include +#include + +#include "cctk.h" + +static const char *rcsid = "$Header: /home/eschnett/C/carpet/Carpet/CarpetAttic/CartGrid3D/src/Attic/Symmetry.c,v 1.1 2002/04/03 16:33:29 schnetter Exp $"; + +CCTK_FILEVERSION(CactusBase_CartGrid3D_Symmetry_c) + +/*#define SYM_DEBUG*/ + +int CartApplySym3Di(cGH *GH, int *doSym, int *cntstag, + int *lssh, int *ghostz, int *sym, CCTK_REAL *var); +int CartApplySym2Di(cGH *GH, int *doSym, int *cntstag, + int *lssh, int *ghostz, int *sym, CCTK_REAL *var); +int CartApplySym1Di(cGH *GH, int *doSym, int *cntstag, + int *lssh, int *ghostz, int *sym, CCTK_REAL *var); + + +/*@@ + @routine CartApplySym3Di + @date Tue Apr 18 14:17:23 2000 + @author Gerd Lanfermann + @desc Apply Symmetry BC to 3D variables + + Variables passed through: + cGH *GH pointer to cGH + int *doSym flags whether to apply a symmetries on a given face + size 2*dim, here we only check for lower faces:0,2,4 + int *cntstag value used when the gridpoints are staggered + around the origin + int *lssh size of the domain, + int *ghostz size of the ghostzone + int *sym symmetry values + CCTK_REAL *var pointer to variable + + index convention: + i ~ x ~ 0 + j ~ y ~ 1 + k ~ z ~ 2 + + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ + + +int CartApplySym3Di(cGH *GH, int *doSym, int *cntstag, + int *lssh, int *ghostz, int *sym, CCTK_REAL *var) +{ + + int i,j,k; + +#ifdef SYM_DEBUG + printf(" doSym: %d %d / %d %d / %d %d \n", + doSym[0],doSym[1], + doSym[2],doSym[3], + doSym[4],doSym[5]); + printf(" lssh: %d %d %d sym: %d %d %d \n", + lssh[0],lssh[1],lssh[2], sym[0], sym[2], sym[4] ); + printf(" ghostz %d %d %d \n",ghostz[0],ghostz[1],ghostz[2]); + printf(" cntstag: %d %d %d\n",cntstag[0],cntstag[1],cntstag[2]); +#endif + + if (doSym[0] == 1) + { + for(k=0; k < lssh[2]; k++) + { + for(j=0; j < lssh[1]; j++) + { + for(i=0; i < ghostz[0]; i++) + { + var[CCTK_GFINDEX3D(GH,i,j,k)] = + sym[0]*var[CCTK_GFINDEX3D(GH,2*ghostz[0]-cntstag[0]-i,j,k)]; + } + } + } + } + if (doSym[2] == 1) + { + for(i=0; i < lssh[0]; i++) + { + for(k=0; k < lssh[2]; k++) + { + for(j=0; j < ghostz[1]; j++) + { + var[CCTK_GFINDEX3D(GH,i,j,k)] = + sym[2]*var[CCTK_GFINDEX3D(GH,i,2*ghostz[1]-cntstag[1]-j,k)]; + } + } + } + } + if (doSym[4] == 1) + { + for(i=0; i < lssh[0]; i++) + { + for(j=0; j < lssh[1]; j++) + { + for(k=0; k < ghostz[2]; k++) + { + var[CCTK_GFINDEX3D(GH,i,j,k)] = + sym[4]*var[CCTK_GFINDEX3D(GH,i,j,2*ghostz[2]-cntstag[2]-k)]; + } + } + } + } + return(0); +} + + +/*@@ + @routine CartApplySym2Di + @date Tue Apr 18 14:17:23 2000 + @author Gerd Lanfermann + @desc Apply Symmetry BC to 2D variables + + + index convention: + i ~ x ~ 0 + j ~ y ~ 1 + k ~ z ~ 2 + + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ + +int CartApplySym2Di(cGH *GH, int *doSym, int *cntstag, + int *lssh, int *ghostz, int *sym, CCTK_REAL *var) +{ + int i,j; + + if (doSym[0] == 1) + { + for(j=0; j < lssh[1]; j++) + { + for(i=0; i < ghostz[0]; i++) + { + var[CCTK_GFINDEX2D(GH,i,j)] = + sym[0]*var[CCTK_GFINDEX2D(GH,2*ghostz[0]-cntstag[0]-i,j)]; + } + } + } + + if (doSym[2] == 1) + { + for(i=0; i < lssh[0]; i++) + { + for(j=0; j < ghostz[1]; j++) + { + var[CCTK_GFINDEX2D(GH,i,j)] = + sym[2]*var[CCTK_GFINDEX2D(GH,i,2*ghostz[1]-cntstag[1]-j)]; + } + } + } + + return(0); +} + + +/*@@ + @routine CartApplySym1Di + @date Tue Apr 18 14:17:23 2000 + @author Gerd Lanfermann + @desc Apply Symmetry BC to 1D variables + + + index convention: + i ~ x ~ 0 + j ~ y ~ 1 + k ~ z ~ 2 + + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ + +int CartApplySym1Di(cGH *GH, int *doSym, int *cntstag, + int *lssh, int *ghostz, int *sym, CCTK_REAL *var) +{ + int i; + + + /* avoid compiler warnings about unused parameters */ + GH = GH; + lssh = lssh; + + if (doSym[0] == 1) + { + for(i=0; i < ghostz[0]; i++) + { + var[CCTK_GFINDEX1D(GH,i)] = + sym[0]*var[CCTK_GFINDEX1D(GH,2*ghostz[0]-cntstag[0]-i)]; + } + } + + return(0); +} + diff --git a/CarpetAttic/CartGrid3D/src/SymmetryCondition.c b/CarpetAttic/CartGrid3D/src/SymmetryCondition.c new file mode 100644 index 000000000..e94bbb34b --- /dev/null +++ b/CarpetAttic/CartGrid3D/src/SymmetryCondition.c @@ -0,0 +1,103 @@ + /*@@ + @file SymmetryCondition.c + @date Thu Oct 7 16:45:19 1999 + @author Tom Goodale + @desc + C version of Gerd's symmetry stuff. + @enddesc + @@*/ + +#include "cctk.h" + +static const char *rcsid = "$Header: /home/eschnett/C/carpet/Carpet/CarpetAttic/CartGrid3D/src/Attic/SymmetryCondition.c,v 1.1 2002/04/03 16:33:30 schnetter Exp $"; + +CCTK_FILEVERSION(CactusBase_CartGrid3D_SymmetryCondition_c) + + +/*@@ + @routine SymmetryCondition + @date Mon Mar 15 15:51:57 1999 + @author Gerd Lanfermann + @desc + Routine performs the symmetry boundary operations. + @enddesc + @calls + @calledby + @history + @hdate Thu Oct 7 16:47:35 1999 @hauthor Tom Goodale + @hdesc Converted to C + @endhistory +@@*/ + + +#define GFINDEX3D(sh,i,j,k) ((i) + sh[0]*((j)+sh[1]*(k))) + +void SymmetryCondition(int nxyz[],CCTK_REAL var[], int nghostzones,int sym[], int doSym[]) +{ + int i,j,k; + + int sw; + + /* + * Apply symmetry if + * * the grid chunk has a physical boundary (bbox) + * * its size in a direction is bigger than one (sh) + * * we actually want a symmetry (sx.ne.ESYM_UNSET) + */ + if (doSym[1] == 1 || doSym[3] == 1 || doSym[5] == 1) + { + CCTKi_NotYetImplemented("Right hand side boundary conditions"); + } + + if (doSym[0] == 1) + { + for(k=0; k < nxyz[2]; k++) + { + for(j=0; j < nxyz[1]; j++) + { + for(sw=0; sw < nghostzones; sw++) + { + var[GFINDEX3D(nxyz,sw,j,k)] = + sym[0]*var[GFINDEX3D(nxyz,2*nghostzones-1-sw,j,k)]; + } + } + } + } + + if (doSym[2] == 1) + { + for(k=0; k < nxyz[2]; k++) + { + for(sw=0; sw < nghostzones; sw++) + { + for(i=0; i < nxyz[0]; i++) + { + var[GFINDEX3D(nxyz,i,sw,k)] = + sym[2]*var[GFINDEX3D(nxyz,i,2*nghostzones-1-sw,k)]; + } + } + } + } + + if (doSym[4] == 1) + { + for(sw=0; sw < nghostzones; sw++) + { + for(j=0; j < nxyz[1]; j++) + { + for(i=0; i < nxyz[0]; i++) + { + var[GFINDEX3D(nxyz,i,j,sw)] = + sym[4]*var[GFINDEX3D(nxyz,i,j,2*nghostzones-1-sw)]; + } + } + } + } + + return; +} + +void CCTK_FNAME(SymmetryCondition)(int nxyz[],CCTK_REAL var[], int *nghostzones,int sym[], int doSym[]) +{ + SymmetryCondition(nxyz, var, *nghostzones, sym, doSym); +} diff --git a/CarpetAttic/CartGrid3D/src/SymmetryWrappers.c b/CarpetAttic/CartGrid3D/src/SymmetryWrappers.c new file mode 100644 index 000000000..cc3f6a690 --- /dev/null +++ b/CarpetAttic/CartGrid3D/src/SymmetryWrappers.c @@ -0,0 +1,432 @@ + /*@@ + @file SymmetryWrappers.c + @date April 2000 + @author Gerd Lanfermann + @desc + Apply symmetry boundary conditions + @enddesc + @@*/ + +#include + +#include "cctk.h" +#include "cctk_Parameters.h" +#include "cctk_FortranString.h" +#include "Symmetry.h" + +void CCTK_FCALL CCTK_FNAME(CartSymGI)(int *ierr, cGH *GH, int *gi); +void CCTK_FCALL CCTK_FNAME(CartSymGN) + (int *ierr, cGH *GH, ONE_FORTSTRING_ARG); +void CCTK_FCALL CCTK_FNAME(CartSymVI)(int *ierr, cGH *GH, int *vi); +void CCTK_FCALL CCTK_FNAME(CartSymVN) + (int *ierr, cGH *GH, ONE_FORTSTRING_ARG); + +int CartApplySym3Di(cGH *GH, + int *doSym, + int *cntstag, + int *lssh, + int *ghostz, + int *sym, + CCTK_REAL *var); + +int CartApplySym2Di(cGH *GH, + int *doSym, + int *cntstag, + int *lssh, + int *ghostz, + int *sym, + CCTK_REAL *var); + +int CartApplySym1Di(cGH *GH, + int *doSym, + int *cntstag, + int *lssh, + int *ghostz, + int *sym, + CCTK_REAL *var); + + +static const char *rcsid = "$Header: /home/eschnett/C/carpet/Carpet/CarpetAttic/CartGrid3D/src/Attic/SymmetryWrappers.c,v 1.1 2002/04/03 16:33:30 schnetter Exp $"; + +CCTK_FILEVERSION(CactusBase_CartGrid3D_SymmetryWrappers_c) + +/*$#define SYM_DEBUG$*/ + + + /*@@ + @routine + @date + @author + @desc + + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ + +int CartSymGI(cGH *GH, int gi) +{ + DECLARE_CCTK_PARAMETERS + + int numvars, vi, first_vi; + int idim, gdim; + int berr=-1,ierr=-1; + int time; + int *doSym, *dstag, *lssh, *cntstag; + SymmetryGHex *sGHex; + + /* Get out if we are sure no symmetries should be applied */ + /* FIXME: There has to be a better way early bailout! */ + /*$if (CCTK_Equals(domain,"full")) return 0;$*/ + + first_vi = CCTK_FirstVarIndexI(gi); + if (first_vi<0) + { + CCTK_VWarn(1,__LINE__,__FILE__,CCTK_THORNSTRING, + "CartSymGI: Cannot find group %d (%s)",gi,CCTK_GroupName(gi)); + return(-1); + } + + numvars = CCTK_NumVarsInGroupI(gi); + gdim = CCTK_GroupDimI(gi); + + + sGHex = (SymmetryGHex*)GH->extensions[CCTK_GHExtensionHandle("Symmetry")]; + doSym = (int *)malloc((2*gdim)*sizeof(int)); + dstag = (int *)malloc(gdim*sizeof(int)); + lssh = (int *)malloc(gdim*sizeof(int)); + cntstag= (int *)malloc(gdim*sizeof(int)); + + /* get the directional staggering of the group */ + ierr = CCTK_GroupStaggerDirArrayGI(dstag, gdim, gi); + + /* Set value to one if grid is staggered around the center */ + + /* Avoid origin? Default is yes */ + cntstag[0] = no_origin && no_originx && avoid_origin && avoid_originx; + cntstag[1] = no_origin && no_originy && avoid_origin && avoid_originy; + cntstag[2] = no_origin && no_originz && avoid_origin && avoid_originz; + + /* Use next time level, if present */ + time = 0; + /*if (time < 0) + { + time = 0; + }*/ + + for (vi=first_vi; viGFSym[vi][idim*2] == GFSYM_UNSET)) + { + CCTK_VWarn(0,__LINE__,__FILE__,CCTK_THORNSTRING, + "Symmetries unspecified for %s",CCTK_FullName(vi)); + } + + lssh[idim] = GH->cctk_lssh[CCTK_LSSH_IDX(dstag[idim],idim)]; + + doSym[idim*2] = (((sGHex->GFSym[vi][idim*2]!=GFSYM_NOSYM) && + (sGHex->GFSym[vi][idim*2]!=GFSYM_UNSET)) && + lssh[idim]>1 && GH->cctk_bbox[idim*2]==1); + doSym[idim*2+1] = 0; + + } + +#ifdef SYM_DEBUG + printf(" DOSYM: %s [%d,%d] [%d,%d] [%d,%d] --- %d %d %d \n", + CCTK_VarName(vi), + doSym[0],doSym[1], + doSym[2],doSym[3], + doSym[4],doSym[5], + sGHex->GFSym[vi][0], + sGHex->GFSym[vi][2], + sGHex->GFSym[vi][4]); +#endif + + switch (gdim) + { + case 1: berr = CartApplySym1Di(GH, + doSym, + cntstag, + lssh, + GH->cctk_nghostzones, + sGHex->GFSym[vi], + GH->data[vi][time]); break; + case 2: berr = CartApplySym2Di(GH, + doSym, + cntstag, + lssh, + GH->cctk_nghostzones, + sGHex->GFSym[vi], + GH->data[vi][time]); break; + case 3: berr = CartApplySym3Di(GH, + doSym, + cntstag, + lssh, + GH->cctk_nghostzones, + sGHex->GFSym[vi], + GH->data[vi][time]); break; + default: berr = -1; CCTK_WARN(1, "No Symmetries for GF of dim>3"); + } + berr=(berr>-1)?0:-1; + } + + free(dstag); + free(doSym); + free(lssh); + free(cntstag); + + return(ierr); +} + +void CCTK_FCALL CCTK_FNAME(CartSymGI)(int *ierr, cGH *GH, int *gi) +{ + *ierr = CartSymGI(GH,*gi); + return; +} + + + + /*@@ + @routine + @date + @author + @desc + + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ + +int CartSymGN(cGH *GH, const char *gn) +{ + int gi=CCTK_GroupIndex(gn); + int retval=-1; + if (gi>-1) + { + retval = CartSymGI(GH,gi); + } + else + { + CCTK_VWarn(1,__LINE__,__FILE__,CCTK_THORNSTRING, + "CartSymGN: Cannot find group %s",gn); + } + return retval; +} + +void CCTK_FCALL CCTK_FNAME(CartSymGN) + (int *ierr, cGH *GH, ONE_FORTSTRING_ARG) +{ + ONE_FORTSTRING_CREATE(gn) + *ierr = CartSymGN(GH,gn); + free(gn); + return; +} + + + /*@@ + @routine + @date + @author + @desc + + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ + +int CartSymVI(cGH *GH, int vi) +{ + DECLARE_CCTK_PARAMETERS + + int gi; + int idim, gdim; + int berr=-1; + int time; + int *doSym, *dstag, *lssh, *cntstag; + SymmetryGHex *sGHex; + + /* Get out if we are sure no symmetries should be applied */ + /* FIXME: There has to be a better way early bailout! */ + if (CCTK_Equals(domain,"full")) return 0; + + /* get the dimension/directional staggering of the + group that vi belongs to */ + gi = CCTK_GroupIndexFromVarI(vi); + if (gi<0) + { + CCTK_VWarn(1,__LINE__,__FILE__,CCTK_THORNSTRING, + "Cannot find variable index %d (%s) in CartSymVI", + vi,CCTK_FullName(vi)); + return(-1); + } + + gdim = CCTK_GroupDimI(gi); + + sGHex = (SymmetryGHex*)GH->extensions[CCTK_GHExtensionHandle("Symmetry")]; + doSym = (int *)malloc((2*gdim)*sizeof(int)); + dstag = (int *)malloc(gdim*sizeof(int)); + lssh = (int *)malloc(gdim*sizeof(int)); + cntstag= (int *)malloc(gdim*sizeof(int)); + + /* get the directional staggering of the group */ + berr = CCTK_GroupStaggerDirArrayGI(dstag, gdim, gi); + + /* Avoid origin? Default is yes */ + cntstag[0] = no_origin && no_originx && avoid_origin && avoid_originx; + cntstag[1] = no_origin && no_originy && avoid_origin && avoid_originy; + cntstag[2] = no_origin && no_originz && avoid_origin && avoid_originz; + + /* Use next time level, if present */ + time = 0; + /* if (time < 0) + { + time = 0; + }*/ + + + /* Apply Symmetries to lower sides [0,2,4] if: + + if the Symmetry is activated (== NOT NOSYM) + + if the Symmetry is set (== NOT UNSET) + + if the length in the direction is more than 1 grid point + + if the processor has a lower physical boundary. + Whether a grid allows a symmetry along a direction (e.g. octant=all) + is part if the Symmetry Setup process. + + No Symmetries for "upper" sides : [1,3,5] + */ + for (idim=0; idimGFSym[vi][idim*2]==GFSYM_UNSET) + { + CCTK_VWarn(0,__LINE__,__FILE__,CCTK_THORNSTRING, + "Symmetries unspecified for %s", CCTK_FullName(vi)); + } + + lssh[idim] = GH->cctk_lssh[CCTK_LSSH_IDX(dstag[idim],idim)]; + + doSym[idim*2] = (((sGHex->GFSym[vi][idim*2]!=GFSYM_NOSYM) && + (sGHex->GFSym[vi][idim*2]!=GFSYM_UNSET)) && + lssh[idim]>1 && GH->cctk_bbox[idim*2]); + doSym[idim*2+1] = 0; + } + +#ifdef SYM_DEBUG + printf(" DOSYM: %s [%d,%d] [%d,%d] [%d,%d] --- %d %d %d \n", + CCTK_VarName(vi), + doSym[0],doSym[1], + doSym[2],doSym[3], + doSym[4],doSym[5], + sGHex->GFSym[vi][0], + sGHex->GFSym[vi][2], + sGHex->GFSym[vi][4]); +#endif + + + + switch (gdim) + { + case 1: berr = CartApplySym1Di(GH, + doSym, + cntstag, + lssh, + GH->cctk_nghostzones, + sGHex->GFSym[vi], + GH->data[vi][time]); break; + case 2: berr = CartApplySym2Di(GH, + doSym, + cntstag, + lssh, + GH->cctk_nghostzones, + sGHex->GFSym[vi], + GH->data[vi][time]); break; + case 3: berr = CartApplySym3Di(GH, + doSym, + cntstag, + lssh, + GH->cctk_nghostzones, + sGHex->GFSym[vi], + GH->data[vi][time]); break; + default: berr = -1; CCTK_WARN(1, "No Symmetries for GF dim>3"); + } + + free(lssh); + free(dstag); + free(doSym); + free(cntstag); + + return(berr); +} + +void CCTK_FCALL CCTK_FNAME(CartSymVI)(int *ierr, cGH *GH, int *vi) +{ + *ierr = CartSymVI(GH, *vi); + return; +} + + + + /*@@ + @routine + @date + @author + @desc + + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ + +int CartSymVN(cGH *GH, const char *vn) +{ + int retval=-1; + int vi=CCTK_VarIndex(vn); + + if (vi>-1) + { + retval = CartSymVI(GH, vi); + } + else + { + CCTK_VWarn(1,__LINE__,__FILE__,CCTK_THORNSTRING, + "Cannot find variable %s in CartSymVN",vn); + } + return retval; +} + +void CCTK_FCALL CCTK_FNAME(CartSymVN) + (int *ierr, cGH *GH, ONE_FORTSTRING_ARG) +{ + ONE_FORTSTRING_CREATE(vn) + *ierr = CartSymVN(GH,vn); + free(vn); + return; +} + diff --git a/CarpetAttic/CartGrid3D/src/make.code.defn b/CarpetAttic/CartGrid3D/src/make.code.defn new file mode 100644 index 000000000..3ee0bb482 --- /dev/null +++ b/CarpetAttic/CartGrid3D/src/make.code.defn @@ -0,0 +1,17 @@ +# Main make.code.defn file for thorn CartGrid3D +# $Header: /home/eschnett/C/carpet/Carpet/CarpetAttic/CartGrid3D/src/Attic/make.code.defn,v 1.1 2002/04/03 16:33:30 schnetter Exp $ + +# Source files in this directory +SRCS = DecodeSymParameters.c\ + CartGrid3D.c\ + GHExtension.c\ + ParamCheck.c\ + Startup.c\ + SetSymmetry.c\ + Symmetry.c\ + SymmetryWrappers.c + + +# Subdirectories containing source files +SUBDIRS = + -- cgit v1.2.3