diff options
Diffstat (limited to 'src/InterpLocalUniform.c')
-rw-r--r-- | src/InterpLocalUniform.c | 191 |
1 files changed, 126 insertions, 65 deletions
diff --git a/src/InterpLocalUniform.c b/src/InterpLocalUniform.c index d4fafa8..76882d4 100644 --- a/src/InterpLocalUniform.c +++ b/src/InterpLocalUniform.c @@ -10,9 +10,10 @@ ** InterpLocalUniform - main driver routine ** ** check_boundary_tolerances - check boundary tolerances for consistency +** get_error_point_info - get per-point error reporting info from par table ** get_and_decode_molecule_family - get & decode molecule_family from par table ** get_molecule_positions - get molecule_positions from parameter table -** get_Jacobian_query - get Jacobian-query info from parameter table +** get_Jacobian_info - get Jacobian-query info from parameter table ** set_error_info - set error information in parameter table ** set_molecule_structure - set molecule structure info in parameter table ** set_molecule_min_max_m - set molecule size info in parameter table @@ -62,6 +63,9 @@ #include "Lagrange-maximum-degree/all_prototypes.h" #include "Hermite/all_prototypes.h" +#undef AEILOCALINTERP_DEBUG /* define this for verbose debugging output */ +#undef AEILOCALINTERP_DEBUG2 /* define this for even more verbose debugging output */ + /* the rcs ID and its dummy function to use it */ static const char* rcsid = "$Header$"; CCTK_FILEVERSION(AEITHorns_AEILocalInterp_src_InterpLocalUniform_c) @@ -125,6 +129,9 @@ static const CCTK_REAL boundary_off_centering_tolerance[MAX_N_BOUNDARIES], const CCTK_REAL boundary_extrapolation_tolerance[MAX_N_BOUNDARIES]); static + int get_error_point_info(int param_table_handle, + struct error_info *p_error_info); +static int get_and_decode_molecule_family (int param_table_handle, int buffer_size, char molecule_family_string_buffer[], @@ -139,7 +146,7 @@ static struct Jacobian_info* p_Jacobian_info); static int set_error_info(int param_table_handle, - struct error_flags* p_error_flags); + struct error_info* p_error_info); static int set_molecule_structure (int param_table_handle, @@ -151,12 +158,11 @@ static const struct molecule_min_max_m_info* p_molecule_min_max_m_info); static - int get_and_check_INT - (int param_table_handle, const char name[], - bool mandatory_flag, int default_value, - bool check_range_flag, int min_value, int max_value, - const char max_value_string[], - CCTK_INT* p_value); + int get_and_check_INT(int param_table_handle, const char name[], + bool mandatory_flag, int default_value, + bool check_range_flag, int min_value, int max_value, + const char max_value_string[], + CCTK_INT* p_value); static int get_INT_array(int param_table_handle, const char name[], bool default_flag, int default_value, @@ -1153,12 +1159,22 @@ check_boundary_tolerances(N_boundaries, /**************************************/ { +struct error_info error_info; +status = get_error_point_info(param_table_handle, + &error_info); +if (status != 0) + then return status; /*** ERROR RETURN ***/ + +/**************************************/ + + { #define MOLECULE_FAMILY_BUFSIZ (MAX_MOLECULE_FAMILY_STRLEN+1) char molecule_family_string[MOLECULE_FAMILY_BUFSIZ]; enum molecule_family molecule_family; -status = get_and_decode_molecule_family(param_table_handle, - MOLECULE_FAMILY_BUFSIZ, molecule_family_string, - &molecule_family); +status = get_and_decode_molecule_family + (param_table_handle, + MOLECULE_FAMILY_BUFSIZ, molecule_family_string, + &molecule_family); if (status != 0) then return status; /*** ERROR RETURN ***/ @@ -1524,8 +1540,11 @@ if (p_interp_fn == NULL_INTERP_FN_PTR) } /* call the subfunction to actually do the interpolation */ +#ifdef AEILOCALINTERP_DEBUG +printf("AEILocalInterp::InterpLocalUniform.c: calling interpolator fn (N_interp_points=%d)\n", N_interp_points); +fflush(stdout); +#endif { -struct error_flags error_flags; struct molecule_structure_flags molecule_structure_flags; const int return_code = (*p_interp_fn)(coord_origin, coord_delta, @@ -1542,33 +1561,34 @@ const int return_code N_output_arrays, output_array_type_codes, output_arrays, operand_indices, operation_codes, - &error_flags, + &error_info, &molecule_structure_flags, p_molecule_min_max_m_info, p_molecule_positions, p_Jacobian_info); +#ifdef AEILOCALINTERP_DEBUG +printf("AEILocalInterp::InterpLocalUniform.c: back from interpolator fn with return_code=%d\n", return_code); +fflush(stdout); +#endif /******************************************************************************/ /* - * is an interpolation point out of range? + * set any further error status in the parameter table */ -if (return_code == CCTK_ERROR_INTERP_POINT_OUTSIDE) +status = set_error_info(param_table_handle, + &error_info); +if (status != 0) then { - status = set_error_info(param_table_handle, - &error_flags); - if (status != 0) + free(input_array_offsets); + free(operand_indices); + free(operation_codes); + if (p_Jacobian_info != NULL) then { - free(input_array_offsets); - free(operand_indices); - free(operation_codes); - if (p_Jacobian_info != NULL) - then { - free(Jacobian_info.Jacobian_offset); - free(Jacobian_info.Jacobian_pointer); - } - return status; /*** ERROR RETURN ***/ + free(Jacobian_info.Jacobian_offset); + free(Jacobian_info.Jacobian_pointer); } + return status; /*** ERROR RETURN ***/ } /******************************************************************************/ @@ -1625,6 +1645,10 @@ if (p_Jacobian_info != NULL) free(Jacobian_info.Jacobian_pointer); } +#ifdef AEILOCALINTERP_DEBUG +printf("AEILocalInterp::InterpLocalUniform.c: returning %d\n", return_code); +fflush(stdout); +#endif return return_code; /*** NORMAL RETURN ***/ } } @@ -1641,6 +1665,7 @@ return return_code; /*** NORMAL RETURN ***/ } } } + } } /******************************************************************************/ @@ -1687,6 +1712,56 @@ int ibndry; /******************************************************************************/ /* + * This function tries to get + * CCTK_POINTER per_point_status + * from the parameter table, and sets found_per_point_status to + * indicate whether or not that key was found. + * + * If per_point_status is found, this function casts it to a CCTK_INT* + * and stores it in p_error_info->per_point_status. If not (if there's + * no such key in the table), this function sets + * p_error_info->per_point_status to a NULL pointer. + * + * Results: + * This function returns 0 for ok, or the (nonzero) return code for error. + */ +static + int get_error_point_info(int param_table_handle, + struct error_info *p_error_info) +{ +CCTK_POINTER per_point_status; +int status; + +status = Util_TableGetPointer(param_table_handle, + &per_point_status, + "per_point_status"); + +if (status == 1) + then { + p_error_info->found_per_point_status = true; + p_error_info->per_point_status = (CCTK_INT*) per_point_status; + } +else if (status == UTIL_ERROR_TABLE_NO_SUCH_KEY) + then { + p_error_info->found_per_point_status = false; + p_error_info->per_point_status = NULL; + } +else { + CCTK_VWarn(ERROR_MSG_SEVERITY_LEVEL, + __LINE__, __FILE__, CCTK_THORNSTRING, +"\n" +" CCTK_InterpLocalUniform(): bad \"per_point_status\" table entry!\n" +" error status=%d", + status); + return status; /*** ERROR RETURN ***/ + } + +return 0; /*** NORMAL RETURN ***/ +} + +/******************************************************************************/ + +/* * This function gets * const char molecule_family[] * from the parameter table, or sets the default value "cube" if this @@ -1931,46 +2006,33 @@ return 0; /*** NORMAL RETURN ***/ /******************************************************************************/ /* - * This function sets the error-info entries - * CCTK_INT error_pt - * CCTK_INT error_ibndry - * CCTK_INT error_axis - * CCTK_INT error_direction - * in the parameter table. + * If p_error_info->found_per_point_status is true, this function + * sets the paramater-table entry + * CCTK_INT error_point_status + * to the negative of p_error_info->error_count. * * Results: * This function returns 0 for ok, or the (nonzero) return code for error. */ static int set_error_info(int param_table_handle, - struct error_flags* p_error_flags) + struct error_info* p_error_info) { -const int status1 = Util_TableSetInt(param_table_handle, - p_error_flags->error_pt, - "error_pt"); -const int status2 = Util_TableSetInt(param_table_handle, - p_error_flags->error_ibndry, - "error_ibndry"); -const int status3 = Util_TableSetInt(param_table_handle, - p_error_flags->error_axis, - "error_axis"); -const int status4 = Util_TableSetInt(param_table_handle, - p_error_flags->error_direction, - "error_direction"); -if ((status1 < 0) || (status2 < 0) || (status3 < 0) || (status4 < 0)) +if (p_error_info->found_per_point_status) then { - CCTK_VWarn(ERROR_MSG_SEVERITY_LEVEL, - __LINE__, __FILE__, CCTK_THORNSTRING, + const int status = Util_TableSetInt(param_table_handle, + -p_error_info->error_count, + "error_point_status"); + if (status < 0) + then CCTK_VWarn(ERROR_MSG_SEVERITY_LEVEL, + __LINE__, __FILE__, CCTK_THORNSTRING, "\n" " CCTK_InterpLocalUniform():\n" -" error setting error-info table entry/entries!\n" -" error status1=%d status2=%d status3=%d status4=%d" - , - status1, status2, status3, status4); - return (status1 < 0) ? status1 /*** ERROR RETURN ***/ - : (status2 < 0) ? status2 /*** ERROR RETURN ***/ - : (status3 < 0) ? status3 /*** ERROR RETURN ***/ - : status4; /*** ERROR RETURN ***/ +" error setting \"error_point_status\" in parameter table!" +" error status=%d" + , + status); + return status; /*** ERROR RETURN ***/ } return 0; /*** NORMAL RETURN ***/ @@ -2097,12 +2159,11 @@ return 0; /*** NORMAL RETURN ***/ * This function returns 0 for ok, or the (nonzero) return code for error. */ static - int get_and_check_INT - (int param_table_handle, const char name[], - bool mandatory_flag, int default_value, - bool check_range_flag, int min_value, int max_value, - const char max_value_string[], - CCTK_INT* p_value) + int get_and_check_INT(int param_table_handle, const char name[], + bool mandatory_flag, int default_value, + bool check_range_flag, int min_value, int max_value, + const char max_value_string[], + CCTK_INT* p_value) { CCTK_INT value; @@ -2281,8 +2342,8 @@ return 0; /*** NORMAL RETURN ***/ */ static int get_REAL_array(int param_table_handle, const char name[], - CCTK_REAL default_value, - int N, CCTK_REAL buffer[]) + CCTK_REAL default_value, + int N, CCTK_REAL buffer[]) { const int status = Util_TableGetRealArray(param_table_handle, |