void use_units_system(int units_system_name) { if (units_systems == NULL) polymec_error("use_units_system: No valid units system is defined!"); int_real_unordered_map_t** ptr = (int_real_unordered_map_t**)int_ptr_unordered_map_get(units_systems, units_system_name); if (ptr == NULL) polymec_error("use_units_system: units system %d is not defined!", units_system_name); current_units = *ptr; }
str_grid_patch_t* str_grid_node_data_patch(str_grid_node_data_t* node_data, int i, int j, int k) { int index = patch_index(node_data, i, j, k); str_grid_patch_t** pp = (str_grid_patch_t**)int_ptr_unordered_map_get(node_data->patches, index); if (pp != NULL) return *pp; else return NULL; }
real_t physical_constant_in_units(int physical_constant_name, int units_system_name) { ASSERT(units_systems != NULL); int_real_unordered_map_t** ptr = (int_real_unordered_map_t**)int_ptr_unordered_map_get(units_systems, units_system_name); ASSERT(ptr != NULL); int_real_unordered_map_t* units = *ptr; real_t* val = int_real_unordered_map_get(units, physical_constant_name); ASSERT(val != NULL); return *val; }
void set_physical_constant(int physical_constant_name, real_t value, int units_system_name) { if (units_systems == NULL) polymec_error("set_physical_constant: No valid units system is defined!"); int_real_unordered_map_t** ptr = (int_real_unordered_map_t**)int_ptr_unordered_map_get(units_systems, units_system_name); if (ptr == NULL) polymec_error("set_physical_constant: units system %d is not defined!", units_system_name); int_real_unordered_map_t* units = *ptr; int_real_unordered_map_insert(units, physical_constant_name, value); }
real_t physical_constant_conversion_factor(int physical_constant_name, int units_system_1, int units_system_2) { ASSERT(units_systems != NULL); int_real_unordered_map_t** ptr1 = (int_real_unordered_map_t**)int_ptr_unordered_map_get(units_systems, units_system_1); ASSERT(ptr1 != NULL); int_real_unordered_map_t* units1 = *ptr1; real_t* val1 = int_real_unordered_map_get(units1, physical_constant_name); ASSERT(val1 != NULL); ASSERT(*val1 != 0.0); int_real_unordered_map_t** ptr2 = (int_real_unordered_map_t**)int_ptr_unordered_map_get(units_systems, units_system_2); ASSERT(ptr2 != NULL); int_real_unordered_map_t* units2 = *ptr2; real_t* val2 = int_real_unordered_map_get(units2, physical_constant_name); ASSERT(val2 != NULL); return (*val2)/(*val1); }
void str_grid_cell_filler_finish(str_grid_cell_filler_t* cell_filler, int token) { // Retrieve the operation tokens corresponding to this one and // finish out the fill operations. int_array_t** op_tokens_p = (int_array_t**)int_ptr_unordered_map_get(cell_filler->tokens, token); ASSERT(op_tokens_p != NULL); // Token exists in our list? int_array_t* op_tokens = *op_tokens_p; ASSERT((op_tokens->size % 2) == 0); // Should be patch index/op token pairs int n = (int)op_tokens->size/2; for (int l = 0; l < n; ++l) { int patch_index = op_tokens->data[2*n]; int op_token = op_tokens->data[2*n+1]; ASSERT(op_token >= 0); str_grid_patch_filler_t* filler = (str_grid_patch_filler_t*)(*int_ptr_unordered_map_get(cell_filler->patch_fillers, patch_index)); str_grid_patch_filler_finish(filler, op_token); } // Remove this entry from our token mapping. int_ptr_unordered_map_delete(cell_filler->tokens, token); }
static void finish_remote_copies(amr_grid_t* grid, int token) { remote_data_t** remote_data_p = (remote_data_t**)int_ptr_unordered_map_get(grid->pending_data, token); ASSERT(remote_data_p != NULL) remote_data_t* remote_data = *remote_data_p; // Finish up the data transfer. exchanger_finish_exchange(remote_data->ex, token); // Copy the data into place. patch_buffer_copy_out(remote_data->buffer, remote_data->grid_data); // Dispose of the remote data for this token. int_ptr_unordered_map_delete(grid->pending_data, token); }
void str_grid_cell_filler_insert(str_grid_cell_filler_t* cell_filler, int i, int j, int k, str_grid_patch_filler_t* patch_filler) { int index = patch_index(cell_filler, i, j, k); ASSERT(str_grid_has_patch(cell_filler->grid, i, j, k)); ptr_array_t** fillers_p = (ptr_array_t**)int_ptr_unordered_map_get(cell_filler->patch_fillers, index); ptr_array_t* fillers; if (fillers_p != NULL) fillers = *fillers_p; else { fillers = ptr_array_new(); int_ptr_unordered_map_insert_with_v_dtor(cell_filler->patch_fillers, index, fillers, DTOR(ptr_array_free)); } ptr_array_append(fillers, patch_filler); }