aboutsummaryrefslogtreecommitdiff
path: root/src/ApplyCartoon.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ApplyCartoon.c')
-rw-r--r--src/ApplyCartoon.c247
1 files changed, 72 insertions, 175 deletions
diff --git a/src/ApplyCartoon.c b/src/ApplyCartoon.c
index b97c289..e5f3bc0 100644
--- a/src/ApplyCartoon.c
+++ b/src/ApplyCartoon.c
@@ -84,189 +84,86 @@ void Cartoon_ApplyBoundaries(CCTK_ARGUMENTS);
void Cartoon_ApplyBoundaries(CCTK_ARGUMENTS)
{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
- DECLARE_CCTK_ARGUMENTS;
- DECLARE_CCTK_PARAMETERS;
+ int num_vars, err, i;
+ CCTK_INT * vars;
- int num_vars, err, i, gi, group_tags_table;
- CCTK_INT * vars;
- char tensortype[TENSORTYPE_BUFF_SIZE];
- char prolongtype[PROLONG_BUFF_SIZE];
- int prolongmethod = -1;
+ //return;
- int whiskycartoon, len;
+ /* Allocate memory to hold selected bcs */
+ num_vars = Boundary_SelectedGVs(cctkGH, 0, NULL, NULL, NULL, NULL, NULL);
+ vars = malloc(num_vars*sizeof *vars);
-
-
-
- /* Check grid size */
- if(cctk_gsh[1] != 2*cctk_nghostzones[1]+1)
- {
- 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);
-#ifdef DEBUG
- printf("Cartoon_ApplyBoundaries: num_vars is %d\n",num_vars);
-#endif
- vars = malloc(num_vars*sizeof *vars);
-
- /* 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);
+ /* 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);
}
- /* Apply CartoonBC to each of them. */
- /* One should probably check to see that the entire group has been
- * selected, since Cartoon operates on an entire group at a time.
- * For now I'll just skip a variable if it is not a 'group leader'.
- */
- for (i=0; i<num_vars; ++i) {
-#ifdef DEBUG
- printf("Cartoon_ApplyBoundaries: i=%d applying cartoon to vi %d\n",i,
- vars[i]);
-#endif
- gi = CCTK_GroupIndexFromVarI(vars[i]);
- if (gi<0) {
- CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Invalid variable index %d selected for a boundary "
- "condition", gi);
- }
- if (vars[i] != CCTK_FirstVarIndexI(gi))
- {
- /* not a group leader -- skip to next var index */
- continue;
- }
-
- /* Here one should check that the entire group is registered,
- * using CCTK_NumVarsInGroupI.
+ /* Apply CartoonBC to each of them. */
+ /* One should probably check to see that the entire group has been
+ * selected, since Cartoon operates on an entire group at a time.
+ * For now I'll just skip a variable if it is not a 'group leader'.
*/
+ for (i = 0; i < num_vars; i++) {
+ char tensortype[TENSORTYPE_BUFF_SIZE];
+ char prolongtype[PROLONG_BUFF_SIZE];
+ int group_tags_table, ret;
- /* Get table handle for group tags table */
- group_tags_table = CCTK_GroupTagsTableI(gi);
- if (group_tags_table<0) {
- CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Tags table for variable group %s is %d", CCTK_GroupName(gi),
- group_tags_table);
- }
-
-
- /* This lines are writen for Whisky2D to avoid to treat the hydrovariables with Cartoon */
-
- len = Util_TableGetString(group_tags_table,0,NULL,"whiskycartoon");
-
- whiskycartoon = 1; /* default is yes */
- if (len >= 0)
- {
- char* value = malloc (len + 1);
- Util_TableGetString (group_tags_table, len + 1, value, "whiskycartoon");
- if (CCTK_Equals(value, "yes"))
- {
- whiskycartoon = 1;
- }
- else if (CCTK_Equals(value, "no"))
- {
- whiskycartoon = 0;
- }
- else
- {
+ int gi = CCTK_GroupIndexFromVarI(vars[i]);
+ if (gi < 0) {
CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Tags table entry \"whiskycartoon\" for variable group %s should be either \"yes\" or \"no\", but is \"%s\"",
- CCTK_GroupName(gi), value);
- }
- free (value);
- }
-
- if (whiskycartoon)
- {
-
- /*###################################################################*/
-
-
- /* 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");
-
- 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.
- */
+ "Invalid variable index %d selected for a boundary "
+ "condition", gi);
+ }
+ if (vars[i] != CCTK_FirstVarIndexI(gi)) {
+ /* not a group leader -- skip to next var index */
+ continue;
+ }
+
+ /* Get table handle for group tags table */
+ group_tags_table = CCTK_GroupTagsTableI(gi);
+ if (group_tags_table < 0) {
+ CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Tags table for variable group %s is %d", CCTK_GroupName(gi),
+ group_tags_table);
+ }
+
+ /* Get tensor type from group tags table */
+ ret = Util_TableGetString(group_tags_table, TENSORTYPE_BUFF_SIZE,
+ tensortype, "tensortypealias");
+ if (ret < 0) {
+ CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Error in TAGS table for variable group %s",
+ CCTK_GroupName(gi));
+ }
+
+ /* Get prolongation type from group tags table */
+ ret = Util_TableGetString(group_tags_table, PROLONG_BUFF_SIZE,
+ prolongtype, "Prolongation");
+
+ if (!(ret == UTIL_ERROR_TABLE_NO_SUCH_KEY ||
+ (ret >= 0 && CCTK_Equals(prolongtype, "Lagrange"))))
+ continue;
+
+ /* Call BndCartoon2DVI, passing the appropriate tensor type integer
+ macro */
+ if (CCTK_Equals(tensortype, "scalar")) {
+ BndCartoon2DVI(cctkGH, TENSORTYPE_SCALAR, vars[i]);
+ } else if ((CCTK_Equals(tensortype, "u")) || (CCTK_Equals(tensortype, "d"))) {
+ BndCartoon2DVI(cctkGH, TENSORTYPE_U, vars[i]);
+ } else if (CCTK_Equals(tensortype, "dd_sym")) {
+ BndCartoon2DVI(cctkGH, TENSORTYPE_DDSYM, vars[i]);
+ } else {
+ CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "invalid tensor type for group %s", CCTK_GroupName(gi));
+ }
+ }
- /* 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);
+ /* Free data */
+ free(vars);
}