Skip to content

Commit

Permalink
Merge pull request #1841 from McStasMcXtrace/dmsc-school-qens-patches
Browse files Browse the repository at this point in the history
Union-related fixes and imports from DMSC school issue
  • Loading branch information
willend authored Feb 6, 2025
2 parents cee98ea + dc0d6ee commit d81a002
Show file tree
Hide file tree
Showing 3 changed files with 538 additions and 11 deletions.
1 change: 1 addition & 0 deletions mcstas-comps/share/union-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ union abs_logger_data_union{
struct a_event_abs_storage_struct *p_event_abs_storage;
struct a_1D_event_abs_storage_struct *p_1D_event_abs_storage;
struct a_nD_abs_storage_struct *p_nD_abs_storage;
struct a_time_abs_storage_struct *p_time_abs_storage;
// Additional logger storage structs to be addedd
};

Expand Down
21 changes: 10 additions & 11 deletions mcstas-comps/union/Union_abs_logger_1D_space_event.comp
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,11 @@ void write_temp_to_perm_abs_1D_event(union abs_logger_data_union *data_union) {
storage = data_union->p_1D_event_abs_storage;

int index;
// Add all data points to the historgram, they are saved as index / weight combinations
// Add all data points to the histogram, they are saved as index / weight combinations
for (index=0;index<storage->temp_abs_1D_event_data.num_elements;index++) {

_class_particle _localparticle;

_localparticle.x = storage->temp_abs_1D_event_data.elements[index].x_pos;
_localparticle.y = storage->temp_abs_1D_event_data.elements[index].y_pos;
_localparticle.z = storage->temp_abs_1D_event_data.elements[index].z_pos;
Expand Down Expand Up @@ -362,11 +362,11 @@ void write_temp_to_perm_final_p_abs_1D_event(union abs_logger_data_union *data_u
storage = data_union->p_1D_event_abs_storage;

int index;
// Add all data points to the historgram, they are saved as index / weight combinations
// Add all data points to the histogram, they are saved as index / weight combinations
for (index=0;index<storage->temp_abs_1D_event_data.num_elements;index++) {

_class_particle _localparticle;

_localparticle.x = storage->temp_abs_1D_event_data.elements[index].x_pos;
_localparticle.y = storage->temp_abs_1D_event_data.elements[index].y_pos;
_localparticle.z = storage->temp_abs_1D_event_data.elements[index].z_pos;
Expand All @@ -391,9 +391,9 @@ void write_temp_to_perm_final_p_abs_1D_event(union abs_logger_data_union *data_u
// Only need to define linking function for loggers once.
#ifndef UNION_ABS_LOGGER
#define UNION_ABS_LOGGER Dummy
// Linking function for loggers, finds the indicies of the specified geometries on the global_geometry_list
// Linking function for loggers, finds the indices of the specified geometries on the global_geometry_list
void manual_linking_function_abs_logger_volumes(char *input_string, struct pointer_to_global_geometry_list *global_geometry_list, struct pointer_to_1d_int_list *accepted_volumes, char *component_name) {
// Need to check a input_string of text for an occurance of name. If it is in the inputstring, yes return 1, otherwise 0.
// Need to check a input_string of text for an occurrence of name. If it is in the inputstring, yes return 1, otherwise 0.
char *token;
int loop_index;
char local_string[512];
Expand Down Expand Up @@ -529,7 +529,7 @@ exit(-1);
// Adding fake event to combat MPI writing bug
if (fake_event) {
_class_particle _localparticle;

_localparticle.x = 0.0;
_localparticle.y = 0.0;
_localparticle.z = -1.0;
Expand Down Expand Up @@ -573,11 +573,11 @@ exit(-1);
struct pointer_to_global_geometry_list *global_geometry_list = COMP_GETPAR3(Union_init, init, global_geometry_list);
struct pointer_to_global_abs_logger_list *global_specific_volumes_abs_logger_list = COMP_GETPAR3(Union_init, init, global_specific_volumes_abs_logger_list);
// In order to run the logger at the right times, pointers to this logger is stored in each volume it logs,
// and additionally for each avaiable process. If a process is not logged, the pointer is simply not stored.
// and additionally for each available process. If a process is not logged, the pointer is simply not stored.
int process_index;
// Need to find the volumes for which the processes should have a reference to this logger
if (target_geometry && strlen(target_geometry) && strcmp(target_geometry,"NULL") && strcmp(target_geometry, "0")) {
// Certain volumes were selected, find the indicies in the global_geometry_list
// Certain volumes were selected, find the indices in the global_geometry_list
manual_linking_function_abs_logger_volumes(target_geometry, global_geometry_list, &accepted_volumes, NAME_CURRENT_COMP);
// Add this logger to the global_specific_volumes_logger_list (so that conditionals can affect it)
add_element_to_abs_logger_list(global_specific_volumes_abs_logger_list, abs_logger_list_element);
Expand Down Expand Up @@ -637,4 +637,3 @@ MCDISPLAY
%}

END

Loading

0 comments on commit d81a002

Please sign in to comment.