├── SimpleBCs ├── configuration.ccl ├── src │ ├── a.out │ ├── make.code.defn │ ├── x │ ├── x.cc │ └── register.cc ├── README ├── interface.ccl ├── param.ccl ├── x ├── schedule.ccl └── doc │ └── documentation.tex └── README.md /SimpleBCs/configuration.ccl: -------------------------------------------------------------------------------- 1 | # Configuration definitions for thorn SimpleBCs 2 | -------------------------------------------------------------------------------- /SimpleBCs/src/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenrbrandt/srbutils/main/SimpleBCs/src/a.out -------------------------------------------------------------------------------- /SimpleBCs/src/make.code.defn: -------------------------------------------------------------------------------- 1 | # Main make.code.defn file for thorn SimpleBCs 2 | 3 | # Source files in this directory 4 | SRCS = register.cc 5 | 6 | # Subdirectories containing source files 7 | SUBDIRS = 8 | -------------------------------------------------------------------------------- /SimpleBCs/README: -------------------------------------------------------------------------------- 1 | Cactus Code Thorn AutoBC 2 | Author(s) : Steven R. Brandt 3 | Maintainer(s): Steven R. Brandt 4 | Licence : LGPL 5 | -------------------------------------------------------------------------- 6 | 7 | 1. Purpose 8 | 9 | not documented 10 | -------------------------------------------------------------------------------- /SimpleBCs/interface.ccl: -------------------------------------------------------------------------------- 1 | # Interface definition for thorn SimpleBCs 2 | implements: SimpleBCs 3 | inherits: 4 | 5 | CCTK_INT FUNCTION Boundary_SelectGroupForBC(CCTK_POINTER_TO_CONST IN GH, \ 6 | CCTK_INT IN faces, CCTK_INT IN boundary_width, CCTK_INT IN table_handle, \ 7 | CCTK_STRING IN group_name, CCTK_STRING IN bc_name) 8 | REQUIRES FUNCTION Boundary_SelectGroupForBC 9 | -------------------------------------------------------------------------------- /SimpleBCs/param.ccl: -------------------------------------------------------------------------------- 1 | # Parameter definitions for thorn SimpleBCs 2 | 3 | CCTK_STRING bc_name[10] "A list of boundary condition names" STEERABLE = RECOVER 4 | { 5 | "([a-zA-Z][a-zA-Z]*|)" :: "A boundary condition name" 6 | } "" 7 | 8 | CCTK_STRING bc_groups[10] "For each bc_name, a list of groups" STEERABLE = RECOVER 9 | { 10 | "(\s*\w+::\w+(\s+\w+::\w+)*\s*|)" :: "A list of groups delimited by whitespace, e.g. MyThorn::a MyThorn::b" 11 | } "" 12 | 13 | CCTK_BOOLEAN verbose "Verbose output" STEERABLE = RECOVER 14 | { 15 | : :: "do verbose?" 16 | } false 17 | -------------------------------------------------------------------------------- /SimpleBCs/x: -------------------------------------------------------------------------------- 1 | CCTK_STRING HamiltonianVarString "Hamiltonian constraint variable name" STEERABLE = RECOVER 2 | { 3 | "ML_BSSN::H" :: "ML_BSSN thorn Hamiltonian constraint gridfunction name" 4 | "Baikal::HGF" :: "Baikal thorn Hamiltonian constraint gridfunction name" 5 | "BaikalVacuum::HGF" :: "BaikalVacuum thorn Hamiltonian constraint gridfunction name" 6 | "LeanBSSNMoL::hc" :: "LeanBSSNMoL thorn Hamiltonian constraint gridfunction name" 7 | ".+" :: "Or use you can use your own thorn's Hamiltonian constraint gridfunction name" 8 | } "ML_BSSN::H" 9 | -------------------------------------------------------------------------------- /SimpleBCs/schedule.ccl: -------------------------------------------------------------------------------- 1 | # Schedule definitions for thorn SimpleBCS 2 | 3 | Schedule group RegisterAndApplySimpleBCs in MoL_PostStep 4 | { 5 | } "Register and apply the BCs for this Thorn" 6 | 7 | Schedule group ApplyBCs as ApplySimpleBCs in RegisterAndApplySimpleBCs 8 | { 9 | } "Turn on BCs" 10 | 11 | Schedule RegisterSimpleBCs in RegisterAndApplySimpleBCs before ApplySimpleBCs 12 | { 13 | LANG: C 14 | } "Do the registration" 15 | Schedule RegisterSimpleBCs as SyncSimpleBCs in RegisterAndApplySimpleBCs before RegisterSimpleBCs 16 | { 17 | LANG: C 18 | OPTIONS: LEVEL 19 | } "Do the sync" 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SimpleBCs 2 | 3 | To use the SimpleBCs "Simple Boundary Conditions" thorn, include the following in your thornlist: 4 | 5 | ``` 6 | !TARGET = $ARR 7 | !TYPE = git 8 | !URL = https://github.com/stevenrbrandt/srbutils 9 | !REPO_BRANCH = main 10 | !REPO_PATH= $2 11 | !CHECKOUT = 12 | srbutils/SimpleBCs 13 | ``` 14 | 15 | After updating your repo, compiling, and building cactus, you can use this thorn by making a few simple additions to your parameter file. The following lines will apply periodic boundary conditions to grid functions "MyThorn:uu" and "MyThorn::vv", and "flat" boundary conditions to "MyThornn::ww and MyThorn::xx". 16 | 17 | Note that SimpleBCs will also synchronize ghost zones when it applies boundary conditions. 18 | 19 | ``` 20 | # Activate Periodic Cactus 21 | ActiveThorns = "PeriodicCarpet" 22 | 23 | # Activate SimpleBCs 24 | # By default RegisterAndApplySimpleBCs will run in MoL_PostStep only, 25 | # but you can schedule it to run in other bins if appropriate. 26 | ActiveThorns = "SimpleBCs" 27 | SimpleBCS::bc_name[0] = "none" 28 | SimpleBCS::bc_groups[0] = "MyThorn::uu MyThorn::vv" 29 | SimpleBCS::bc_name[1] = "flat" 30 | SimpleBCS::bc_groups[0] = "MyThorn::ww MyThorn::xx" 31 | ``` 32 | -------------------------------------------------------------------------------- /SimpleBCs/src/x: -------------------------------------------------------------------------------- 1 | struct GF { 2 | std::string thorn, name; 3 | GF(const std::string& t,const std::string n) : thorn(t), name(n) {} 4 | ~GF() {} 5 | }; 6 | 7 | inline std::ostream& operator<<(std::ostream& o, const GF& gf) { 8 | return o << gf.thorn << "::" << gf.name; 9 | } 10 | 11 | struct BC { 12 | std::string name; 13 | std::vector gfs; 14 | BC(const std::string& n) : name(n) {} 15 | ~BC() {} 16 | }; 17 | 18 | inline std::ostream& operator<<(std::ostream& o,const BC& bc) { 19 | o << "BC(name=" << bc.name; 20 | for(int i=0;i= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c=='_'; 27 | } 28 | 29 | std::vector parse_bc_string(std::string s) { 30 | char last_c=0; 31 | std::string buf; 32 | std::vector tokens; 33 | for(int i=0;i 0) tokens.push_back(buf); 41 | buf.clear(); 42 | buf.push_back(c); 43 | } else if(c == ',' || c == ' ' || c == '\t' || c == '\r' || c == '\n') { 44 | ; // ignore 45 | } else { 46 | std::cerr << "Illegal character in input: '" << c << "'" << std::endl; 47 | abort(); 48 | } 49 | last_c = c; 50 | } 51 | if(buf.size() > 0) tokens.push_back(buf); 52 | return tokens; 53 | } 54 | 55 | std::vector create_bcs(std::vector&& vs) { 56 | int i=0; 57 | std::vector vb; 58 | vb.push_back(BC("none")); 59 | while(i < vs.size()) { 60 | if(is_alpha(vs.at(i).at(0)) && vs.at(i+1) == ":") { 61 | BC bc(vs.at(i)); 62 | vb.push_back(bc); 63 | i += 2; 64 | } else if(is_alpha(vs.at(i).at(0)) && vs.at(i+1) == "::" && is_alpha(vs.at(i+2).at(0))) { 65 | GF gf(vs.at(i), vs.at(i+2)); 66 | vb.at(vb.size()-1).gfs.push_back(gf); 67 | i += 3; 68 | } else { 69 | i += 1; 70 | } 71 | } 72 | std::cout << "BCs:" << std::endl; 73 | for(int i=0;i gfs; 19 | BC(const std::string& n) : name(n) {} 20 | ~BC() {} 21 | }; 22 | 23 | inline std::ostream& operator<<(std::ostream& o,const BC& bc) { 24 | o << "BC(name=" << bc.name; 25 | for(int i=0;i= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c=='_'; 32 | } 33 | 34 | std::vector parse_bc_string(std::string s) { 35 | char last_c=0; 36 | std::string buf; 37 | std::vector tokens; 38 | for(int i=0;i 0) tokens.push_back(buf); 46 | buf.clear(); 47 | buf.push_back(c); 48 | } else if(c == ',' || c == ' ' || c == '\t' || c == '\r' || c == '\n') { 49 | ; // ignore 50 | } else { 51 | std::cerr << "Illegal character in input: '" << c << "'" << std::endl; 52 | abort(); 53 | } 54 | last_c = c; 55 | } 56 | if(buf.size() > 0) tokens.push_back(buf); 57 | return tokens; 58 | } 59 | 60 | std::vector create_bcs(std::vector&& vs) { 61 | int i=0; 62 | std::vector vb; 63 | vb.push_back(BC("none")); 64 | while(i < vs.size()) { 65 | if(is_alpha(vs.at(i).at(0)) && vs.at(i+1) == ":") { 66 | BC bc(vs.at(i)); 67 | vb.push_back(bc); 68 | i += 2; 69 | } else if(is_alpha(vs.at(i).at(0)) && vs.at(i+1) == "::" && is_alpha(vs.at(i+2).at(0))) { 70 | GF gf(vs.at(i), vs.at(i+2)); 71 | vb.at(vb.size()-1).gfs.push_back(gf); 72 | i += 3; 73 | } else { 74 | i += 1; 75 | } 76 | } 77 | std::cout << "BCs:" << std::endl; 78 | for(int i=0;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | const size_t max_num_bc = 10; 11 | 12 | /* 13 | * Provide an iostream for generating a CCTK_INFO() message. 14 | * Output is generated when the destructor is called. 15 | */ 16 | struct CCTKINFOstream : public std::ostringstream { 17 | CCTKINFOstream() {} 18 | ~CCTKINFOstream() { 19 | std::string s = str(); 20 | CCTK_INFO(s.c_str()); 21 | } 22 | }; 23 | 24 | /* 25 | * Provide an iostream for generating a CCTK_ERROR() call. 26 | * Output is generated when the destructor is called. 27 | * The code will also exit when the destructor is called. 28 | */ 29 | struct CCTKERRORstream : public std::ostringstream { 30 | CCTKERRORstream() {} 31 | ~CCTKERRORstream() { 32 | std::string s = str(); 33 | CCTK_ERROR(s.c_str()); 34 | } 35 | }; 36 | 37 | /* 38 | * This class represents a grid function. Both the full name "MyThorn::a" and 39 | * the group id are stored. 40 | */ 41 | struct GF { 42 | std::string name; 43 | int groupId; 44 | GF(const std::string& n) : name(n), groupId(CCTK_GroupIndex(n.c_str())) {} 45 | ~GF() {} 46 | }; 47 | 48 | inline std::ostream& operator<<(std::ostream& o, const GF& gf) { 49 | return o << gf.name << "(groupId=" << gf.groupId << ")"; 50 | } 51 | 52 | /* 53 | * This class represents a Boundary Condition. It contains the name of the boundary 54 | * condition and a vector of the grid functions it applies to. 55 | */ 56 | struct BC { 57 | std::string name; 58 | std::vector gfs; 59 | BC(const std::string& n) : name(n) { 60 | if(n == "") name = "?"; 61 | } 62 | ~BC() {} 63 | }; 64 | 65 | inline std::ostream& operator<<(std::ostream& o,const BC& bc) { 66 | o << "BC(name=" << bc.name; 67 | for(size_t i=0;i bcs; 81 | if(init) { 82 | if(Carpet::is_local_mode()) { 83 | CCTKERRORstream() << "This code must run in local mode: " << __FILE__ << ":" <<__LINE__; 84 | } 85 | for(size_t i=0;i> gn) { 91 | GF gf(gn); 92 | if(gf.groupId < 0) { 93 | CCTKERRORstream() << "Invalid group name: " << gn; 94 | } 95 | bc.gfs.push_back(gf); 96 | } 97 | if(bcn.size() > 0 && bc.gfs.size() > 0) { 98 | bcs.push_back(bc); 99 | if(verbose) { 100 | CCTKINFOstream() << "Adding " << bc; 101 | } 102 | } else if(bc.gfs.size() > 0) { 103 | CCTKERRORstream() << "Boundary condition with no name at index i=" << i <<": " << bc; 104 | } 105 | } 106 | init = false; 107 | } 108 | int ierr = 0; 109 | for(auto& bc : bcs) { 110 | const char *bc_name = bc.name.c_str(); 111 | for(auto& gf : bc.gfs) { 112 | const char *gf_name = gf.name.c_str(); 113 | if(Carpet::is_local_mode()) { 114 | ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, 1, -1, gf_name, bc_name); 115 | if(verbose) 116 | CCTKINFOstream() << "select for bc: " << bc_name << " -> " << gf_name; 117 | if(ierr < 0) 118 | CCTKERRORstream() << "select for bc: " << bc_name << " -> " << gf_name << " failed!"; 119 | } 120 | if(Carpet::is_level_mode()) { 121 | ierr = CCTK_SyncGroupI(cctkGH,gf.groupId); 122 | if(ierr < 0) CCTKERRORstream() << "Sync for group " << gf << " failed!"; 123 | } 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /SimpleBCs/doc/documentation.tex: -------------------------------------------------------------------------------- 1 | % *======================================================================* 2 | % Cactus Thorn template for ThornGuide documentation 3 | % Author: Ian Kelley 4 | % Date: Sun Jun 02, 2002 5 | % $Header$ 6 | % 7 | % Thorn documentation in the latex file doc/documentation.tex 8 | % will be included in ThornGuides built with the Cactus make system. 9 | % The scripts employed by the make system automatically include 10 | % pages about variables, parameters and scheduling parsed from the 11 | % relevant thorn CCL files. 12 | % 13 | % This template contains guidelines which help to assure that your 14 | % documentation will be correctly added to ThornGuides. More 15 | % information is available in the Cactus UsersGuide. 16 | % 17 | % Guidelines: 18 | % - Do not change anything before the line 19 | % % START CACTUS THORNGUIDE", 20 | % except for filling in the title, author, date, etc. fields. 21 | % - Each of these fields should only be on ONE line. 22 | % - Author names should be separated with a \\ or a comma. 23 | % - You can define your own macros, but they must appear after 24 | % the START CACTUS THORNGUIDE line, and must not redefine standard 25 | % latex commands. 26 | % - To avoid name clashes with other thorns, 'labels', 'citations', 27 | % 'references', and 'image' names should conform to the following 28 | % convention: 29 | % ARRANGEMENT_THORN_LABEL 30 | % For example, an image wave.eps in the arrangement CactusWave and 31 | % thorn WaveToyC should be renamed to CactusWave_WaveToyC_wave.eps 32 | % - Graphics should only be included using the graphicx package. 33 | % More specifically, with the "\includegraphics" command. Do 34 | % not specify any graphic file extensions in your .tex file. This 35 | % will allow us to create a PDF version of the ThornGuide 36 | % via pdflatex. 37 | % - References should be included with the latex "\bibitem" command. 38 | % - Use \begin{abstract}...\end{abstract} instead of \abstract{...} 39 | % - Do not use \appendix, instead include any appendices you need as 40 | % standard sections. 41 | % - For the benefit of our Perl scripts, and for future extensions, 42 | % please use simple latex. 43 | % 44 | % *======================================================================* 45 | % 46 | % Example of including a graphic image: 47 | % \begin{figure}[ht] 48 | % \begin{center} 49 | % \includegraphics[width=6cm]{MyArrangement_MyThorn_MyFigure} 50 | % \end{center} 51 | % \caption{Illustration of this and that} 52 | % \label{MyArrangement_MyThorn_MyLabel} 53 | % \end{figure} 54 | % 55 | % Example of using a label: 56 | % \label{MyArrangement_MyThorn_MyLabel} 57 | % 58 | % Example of a citation: 59 | % \cite{MyArrangement_MyThorn_Author99} 60 | % 61 | % Example of including a reference 62 | % \bibitem{MyArrangement_MyThorn_Author99} 63 | % {J. Author, {\em The Title of the Book, Journal, or periodical}, 1 (1999), 64 | % 1--16. {\tt http://www.nowhere.com/}} 65 | % 66 | % *======================================================================* 67 | 68 | % If you are using CVS use this line to give version information 69 | % $Header$ 70 | 71 | \documentclass{article} 72 | 73 | % Use the Cactus ThornGuide style file 74 | % (Automatically used from Cactus distribution, if you have a 75 | % thorn without the Cactus Flesh download this from the Cactus 76 | % homepage at www.cactuscode.org) 77 | \usepackage{../../../../doc/latex/cactus} 78 | 79 | \begin{document} 80 | 81 | % The author of the documentation 82 | \author{Steven R. Brandt \textless sbrandt@cct.lsu.edu\textgreater} 83 | 84 | % The title of the document (not necessarily the name of the Thorn) 85 | \title{SimpleBCs} 86 | 87 | % the date your document was last changed, if your document is in CVS, 88 | % please use: 89 | % \date{$ $Date$ $} 90 | % when using git instead record the commit ID: 91 | % \date{\gitrevision{}} 92 | \date{August 16 2022} 93 | 94 | \maketitle 95 | 96 | % Do not delete next line 97 | % START CACTUS THORNGUIDE 98 | 99 | % Add all definitions used in this documentation here 100 | % \def\mydef etc 101 | 102 | % Add an abstract for this thorn's documentation 103 | \begin{abstract} 104 | 105 | \end{abstract} 106 | 107 | % The following sections are suggestive only. 108 | % Remove them or add your own. 109 | 110 | \section{Introduction} 111 | 112 | \section{Physical System} 113 | 114 | \section{Numerical Implementation} 115 | 116 | \section{Using This Thorn} 117 | 118 | \subsection{Obtaining This Thorn} 119 | 120 | \subsection{Basic Usage} 121 | 122 | \subsection{Special Behaviour} 123 | 124 | \subsection{Interaction With Other Thorns} 125 | 126 | \subsection{Examples} 127 | 128 | \subsection{Support and Feedback} 129 | 130 | \section{History} 131 | 132 | \subsection{Thorn Source Code} 133 | 134 | \subsection{Thorn Documentation} 135 | 136 | \subsection{Acknowledgements} 137 | 138 | 139 | \begin{thebibliography}{9} 140 | 141 | \end{thebibliography} 142 | 143 | % Do not delete next line 144 | % END CACTUS THORNGUIDE 145 | 146 | \end{document} 147 | --------------------------------------------------------------------------------