From bdbe4b70a827be52b9dd15db1a490bc1f52600c0 Mon Sep 17 00:00:00 2001 From: pollney Date: Thu, 8 Nov 2007 15:28:39 +0000 Subject: Recognise the "whiskycartoon" tag. Patch provided by Thorsten. git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/Cartoon2D/trunk@99 eec4d7dc-71c2-46d6-addf-10296150bf52 --- src/ApplyCartoon.c | 258 +++++++++++++++++++++++++++++------------------------ 1 file changed, 143 insertions(+), 115 deletions(-) diff --git a/src/ApplyCartoon.c b/src/ApplyCartoon.c index b1417d6..f0e48ed 100644 --- a/src/ApplyCartoon.c +++ b/src/ApplyCartoon.c @@ -1,20 +1,24 @@ - /*@@ - @file ApplyCartoon.c - @date 6 Jan 2003 - @author David Rideout - @desc - Applies the Cartoon boundary condition to all variables - selected for a bc. - @enddesc - @version $Header$ - @@*/ +/*@@ + @file ApplyCartoon.c + @date 6 Jan 2003 + @author David Rideout + @desc + Applies the Cartoon boundary condition to all variables + selected for a bc. + @enddesc + @version $Header$ + @@*/ #include "cctk.h" #include "cctk_Arguments.h" +#include "cctk_Parameters.h" #include "util_Table.h" #include "Cartoon2D.h" #include "Cartoon2D_tensors.h" +#include "cctk_Groups.h" #include +#include + static const char *rcsid = "$Header$"; @@ -57,42 +61,49 @@ void Cartoon_ApplyBoundaries(CCTK_ARGUMENTS); ********************* Scheduled Routines ********************** ********************************************************************/ - /*@@ - @routine Cartoon_ApplyBoundaries - @date 6 Jan 2003 - @author David Rideout - @desc - This will apply the Cartoon boundary condition to all - variables selected for any (physical) boundary condition. - @enddesc - @calls - @history - @endhistory - @var CCTK_ARGUMENTS - @vdesc Cactus argument list - @vtype CCTK_* - @vio in - @endvar - @returntype void - @returndesc - @endreturndesc -@@*/ +/*@@ + @routine Cartoon_ApplyBoundaries + @date 6 Jan 2003 + @author David Rideout + @desc + This will apply the Cartoon boundary condition to all + variables selected for any (physical) boundary condition. + @enddesc + @calls + @history + @endhistory + @var CCTK_ARGUMENTS + @vdesc Cactus argument list + @vtype CCTK_* + @vio in + @endvar + @returntype void + @returndesc + @endreturndesc + @@*/ void Cartoon_ApplyBoundaries(CCTK_ARGUMENTS) { DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + int num_vars, err, i, gi, group_tags_table; CCTK_INT * vars; char tensortype[TENSORTYPE_BUFF_SIZE]; char prolongtype[PROLONG_BUFF_SIZE]; int prolongmethod; + int tableindex, len; + + + + /* Check grid size */ if(cctk_gsh[1] != 2*cctk_nghostzones[1]+1) - { - CCTK_WARN(0, "Grid size in y direction inappropriate."); - } + { + CCTK_WARN(0, "Grid size in y direction inappropriate."); + } /* Allocate memory to hold selected bcs */ num_vars = Boundary_SelectedGVs(cctkGH, 0, NULL, NULL, NULL, NULL, NULL); @@ -104,11 +115,11 @@ void Cartoon_ApplyBoundaries(CCTK_ARGUMENTS) /* get all selected vars */ err = Boundary_SelectedGVs(cctkGH, num_vars, vars, NULL, NULL, NULL, NULL); if (err != num_vars) - { - CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, - "Boundary_SelectedGVs returned %d selected variables, but %d " - "expected", err, num_vars); - } + { + CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Boundary_SelectedGVs returned %d selected variables, but %d " + "expected", err, num_vars); + } /* Apply CartoonBC to each of them. */ /* One should probably check to see that the entire group has been @@ -127,10 +138,10 @@ void Cartoon_ApplyBoundaries(CCTK_ARGUMENTS) "condition", gi); } if (vars[i] != CCTK_FirstVarIndexI(gi)) - { - /* not a group leader -- skip to next var index */ - continue; - } + { + /* not a group leader -- skip to next var index */ + continue; + } /* Here one should check that the entire group is registered, * using CCTK_NumVarsInGroupI. @@ -143,85 +154,102 @@ void Cartoon_ApplyBoundaries(CCTK_ARGUMENTS) "Tags table for variable group %s is %d", CCTK_GroupName(gi), group_tags_table); } - - /* Get tensor type from group tags table */ - err = Util_TableGetString(group_tags_table, TENSORTYPE_BUFF_SIZE, - tensortype, "tensortypealias"); - if (err<0) - { - CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, - "Error in TAGS table for variable group %s", - CCTK_GroupName(gi)); - } -#ifdef DEBUG - printf("Cartoon_ApplyBoundaries: tensor type is %s\n",tensortype); -#endif - - /* Get prolongation type from group tags table */ + - err = Util_TableGetString(group_tags_table, PROLONG_BUFF_SIZE, - prolongtype, "Prolongation"); + /* This lines are writen for Whisky2D to avoid to treat the hydrovariables with Cartoon */ + + len = Util_TableGetString(group_tags_table,0,NULL,"whiskycartoon"); - if (err == UTIL_ERROR_TABLE_NO_SUCH_KEY) - { - /* Use the default */ + char* value = malloc (len + 1); + Util_TableGetString (group_tags_table, len + 1, value, "whiskycartoon"); + - prolongmethod = PROLONG_LAGRANGE; - } - else if (err < 0) - { - CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING, - "Error (%d) in TAGS table for variable group %s", err, - CCTK_GroupName(gi)); - } - else - { - if (CCTK_Equals(prolongtype, "None")) + if (len <= 0 || CCTK_Equals(value, "yes")) { - prolongmethod = PROLONG_NONE; /* But why? */ - } - else if (CCTK_Equals(prolongtype, "Lagrange")) - { - prolongmethod = PROLONG_LAGRANGE; - } - else if (CCTK_Equals(prolongtype, "TVD")) - { - prolongmethod = PROLONG_ENO; - } - else if (CCTK_Equals(prolongtype, "ENO")) - { - prolongmethod = PROLONG_ENO; - } - else - { - CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING, - "Error in TAGS table for variable group %s", - CCTK_GroupName(gi)); - } - } - - /* Here one should check that the group's size is correct for the - * specified tensortype. - */ + free(value); + + /*###################################################################*/ + + + /* Get tensor type from group tags table */ + err = Util_TableGetString(group_tags_table, TENSORTYPE_BUFF_SIZE, + tensortype, "tensortypealias"); + if (err<0) + { + CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Error in TAGS table for variable group %s", + CCTK_GroupName(gi)); + } +#ifdef DEBUG + printf("Cartoon_ApplyBoundaries: tensor type is %s\n",tensortype); +#endif - /* Call BndCartoon2DVI, passing the appropriate tensor type integer - macro */ - if (CCTK_Equals(tensortype, "scalar")) - { - BndCartoon2DVI(cctkGH, TENSORTYPE_SCALAR, prolongmethod, vars[i]); - } else if ((CCTK_Equals(tensortype, "u")) || (CCTK_Equals(tensortype, "d"))) - { - BndCartoon2DVI(cctkGH, TENSORTYPE_U, prolongmethod, vars[i]); - } else if (CCTK_Equals(tensortype, "dd_sym")) - { - BndCartoon2DVI(cctkGH, TENSORTYPE_DDSYM, prolongmethod, vars[i]); - } else - { - CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING, - "invalid tensor type for group %s", CCTK_GroupName(gi)); - } + /* Get prolongation type from group tags table */ + + err = Util_TableGetString(group_tags_table, PROLONG_BUFF_SIZE, + prolongtype, "Prolongation"); + + if (err == UTIL_ERROR_TABLE_NO_SUCH_KEY) + { + /* Use the default */ + + prolongmethod = PROLONG_LAGRANGE; + } + else if (err < 0) + { + CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING, + "Error (%d) in TAGS table for variable group %s", err, + CCTK_GroupName(gi)); + } + else + { + if (CCTK_Equals(prolongtype, "None")) + { + prolongmethod = PROLONG_NONE; /* But why? */ + } + else if (CCTK_Equals(prolongtype, "Lagrange")) + { + prolongmethod = PROLONG_LAGRANGE; + } + else if (CCTK_Equals(prolongtype, "TVD")) + { + prolongmethod = PROLONG_ENO; + } + else if (CCTK_Equals(prolongtype, "ENO")) + { + prolongmethod = PROLONG_ENO; + } + else + { + CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING, + "Error in TAGS table for variable group %s", + CCTK_GroupName(gi)); + } + } + + /* Here one should check that the group's size is correct for the + * specified tensortype. + */ + + /* Call BndCartoon2DVI, passing the appropriate tensor type integer + macro */ + if (CCTK_Equals(tensortype, "scalar")) + { + BndCartoon2DVI(cctkGH, TENSORTYPE_SCALAR, prolongmethod, vars[i]); + } else if ((CCTK_Equals(tensortype, "u")) || + (CCTK_Equals(tensortype, "d"))) + { + BndCartoon2DVI(cctkGH, TENSORTYPE_U, prolongmethod, vars[i]); + } else if (CCTK_Equals(tensortype, "dd_sym")) + { + BndCartoon2DVI(cctkGH, TENSORTYPE_DDSYM, prolongmethod, vars[i]); + } else + { + CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING, + "invalid tensor type for group %s", CCTK_GroupName(gi)); + } + } } - /* Free data */ free(vars); } -- cgit v1.2.3