Skip to content

Commit ae49ed3

Browse files
authored
Merge branch 'off_file_mesh_component' into main
2 parents de3fa90 + bef5c1d commit ae49ed3

File tree

14 files changed

+2735
-1191
lines changed

14 files changed

+2735
-1191
lines changed

mcstas-comps/examples/Tests_union/Geometry_test/Geometry_test.instr

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616
* Test of all Union geometry components in one file
1717
*
1818
* %Description
19-
* Use of all basic geometries, sphere, cylinder, cone and box
19+
* Use of all basic geometries, mesh(as a torus), sphere, cylinder, cone and box
2020
*
21-
* %Example: dummy=1 Detector: detector_scat_I=40.2053
21+
* %Example: meshfile="torus.off" Detector: detector_scat_I=40.2053
2222
*
2323
* %Parameters
2424
*
2525
* %End
2626
*******************************************************************************/
2727

28-
DEFINE INSTRUMENT Geometry_test(dummy=1)
28+
DEFINE INSTRUMENT Geometry_test(string meshfile="torus.off")
2929

3030
DECLARE
3131
%{
@@ -96,10 +96,20 @@ COMPONENT sample_box = Union_box(
9696
AT (-0.01,0,0) RELATIVE sample_pos
9797
ROTATED (34,17,0) RELATIVE sample_pos
9898

99-
COMPONENT sample_cone = Union_cone(
100-
radius_top=0.031, radius_bottom=0.005, yheight=0.04, priority=22, material_string="Cu")
101-
AT (0.02,-0.03,0) RELATIVE sample_pos
102-
ROTATED (0,0,20) RELATIVE sample_pos
99+
/* COMPONENT sample_cone = Union_cone( */
100+
/* radius_top=0.031, radius_bottom=0.005, yheight=0.04, priority=22, material_string="Cu") */
101+
/* AT (0.02,-0.03,0) RELATIVE sample_pos */
102+
/* ROTATED (0,0,20) RELATIVE sample_pos */
103+
104+
COMPONENT sample_torus = Union_mesh(
105+
filename = meshfile,
106+
material_string="Al",
107+
coordinate_scale =0.025,
108+
priority=346,
109+
skip_convex_check=1
110+
) AT (0,0,0.02) RELATIVE sample_pos
111+
ROTATED (0,45,0) RELATIVE sample_pos
112+
103113

104114
COMPONENT test_logger_1D = Union_logger_1D(
105115
variable="time", min_value=1E-4, max_value=8E-4, n1=200, filename="logger_1D.dat"
28.2 KB
Binary file not shown.

mcstas-comps/examples/Tests_union/Geometry_test/torus.off

Lines changed: 866 additions & 0 deletions
Large diffs are not rendered by default.

mcstas-comps/share/union-lib.c

Lines changed: 956 additions & 605 deletions
Large diffs are not rendered by default.

mcstas-comps/union/Powder_process.comp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ int Powder_physics_my(double *my,double *k_initial, union data_transfer_union da
429429

430430
int method_switch = 1;
431431
// For test
432-
int line_v,line0,line,count;
432+
int line_v,line0,line;
433433

434434
// Should not interfer with the global variables
435435
double vx = k_initial[0]*K2V;
@@ -475,7 +475,7 @@ int Powder_physics_my(double *my,double *k_initial, union data_transfer_union da
475475
/* not yet set: we compute the sum up to the corresponding speed in the table cache */
476476
//printf("Nq and sum not yet set, have to do this calculation now\n");
477477
double line_v = line_info->v_min + line*(line_info->v_max - line_info->v_min)/CHAR_BUF_LENGTH;
478-
for(line0=0; line0<count; line0++) {
478+
for(line0=0; line0<line_info->count; line0++) {
479479
if (line_info->q_v[line0] <= 2*line_v) { /* q < 2*kf: restrict structural range */
480480
line_info->my_s_v2_sum += line_info->my_s_v2[line0];
481481
if (line_info->Nq < line0+1) line_info->Nq=line0+1; /* determine maximum line index which can scatter */
@@ -491,7 +491,7 @@ int Powder_physics_my(double *my,double *k_initial, union data_transfer_union da
491491

492492
line_info->xs_calls++;
493493

494-
for(line=line0; line<count; line++) {
494+
for(line=line0; line<line_info->count; line++) {
495495
if (line_info->q_v[line] <= 2*v) { /* q < 2*kf: restrict structural range */
496496
line_info->my_s_v2_sum += line_info->my_s_v2[line];
497497
if (line_info->Nq < line+1) line_info->Nq=line+1; /* determine maximum line index which can scatter */

mcstas-comps/union/Union_box.comp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ struct surface_stack_struct cut_surface_stack;
235235

236236
INITIALIZE
237237
%{
238+
// Initialize this Volume
239+
geometry_struct_init(&(this_box_volume.geometry));
238240
// Initializes the focusing system for this volume including input sanitation.
239241
focus_initialize(&this_box_volume.geometry, POS_A_COMP_INDEX(INDEX_CURRENT_COMP+target_index), POS_A_CURRENT_COMP, ROT_A_CURRENT_COMP, target_index, target_x, target_y, target_z, focus_aw, focus_ah, focus_xw, focus_xh, focus_r, NAME_CURRENT_COMP);
240242

mcstas-comps/union/Union_cone.comp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ struct surface_stack_struct cut_surface_stack;
221221

222222
INITIALIZE
223223
%{
224+
geometry_struct_init(&(this_cone_volume.geometry));
224225
// Initializes the focusing system for this volume including input sanitation.
225226
focus_initialize(&this_cone_volume.geometry, POS_A_COMP_INDEX(INDEX_CURRENT_COMP+target_index), POS_A_CURRENT_COMP, ROT_A_CURRENT_COMP, target_index, target_x, target_y, target_z, focus_aw, focus_ah, focus_xw, focus_xh, focus_r, NAME_CURRENT_COMP);
226227

mcstas-comps/union/Union_cylinder.comp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ struct surface_stack_struct cut_surface_stack;
190190

191191
INITIALIZE
192192
%{
193+
geometry_struct_init(&(this_cylinder_volume.geometry));
193194
// Initializes the focusing system for this volume including input sanitation.
194195
focus_initialize(&this_cylinder_volume.geometry, POS_A_COMP_INDEX(INDEX_CURRENT_COMP+target_index), POS_A_CURRENT_COMP, ROT_A_CURRENT_COMP, target_index, target_x, target_y, target_z, focus_aw, focus_ah, focus_xw, focus_xh, focus_r, NAME_CURRENT_COMP);
195196

mcstas-comps/union/Union_logger_2D_space.comp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ void record_to_temp_2DS(Coords *position, double *k_new, double *k_old, double p
147147
if (add_point == 1) {
148148

149149
double p1,p2;
150+
p1=p2=0;
150151

151152
// dim_1_choice = 0 for x, 1 for y, 2 for z. Done in initialize from input. "x" "y" "z".
152153
if (storage->dim_1_choice == 0)
@@ -262,6 +263,7 @@ void record_to_perm_2DS(Coords *position, double *k_new, double *k_old, double p
262263
if (add_point == 1) {
263264
//printf("storage was set \n");
264265
double p1,p2;
266+
p1=p2=0;
265267

266268
// dim_1_choice = 0 for x, 1 for y, 2 for z. Done in initialize from input "x" "y" "z".
267269
if (storage->dim_1_choice == 0)

mcstas-comps/union/Union_logger_2D_space_time.comp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ void record_to_temp_2DS_t(Coords *position, double *k_new, double *k_old, double
149149
if (add_point == 1) {
150150

151151
double p1,p2;
152+
p1=p2=0;
152153

153154
// dim_1_choice = 0 for x, 1 for y, 2 for z. Done in initialize from input. "x" "y" "z".
154155
if (storage->dim_1_choice == 0)
@@ -270,6 +271,7 @@ void record_to_perm_2DS_t(Coords *position, double *k_new, double *k_old, double
270271
if (add_point == 1) {
271272
//printf("storage was set \n");
272273
double p1,p2;
274+
p1=p2=0;
273275

274276
// dim_1_choice = 0 for x, 1 for y, 2 for z. Done in initialize from input. "x" "y" "z".
275277
if (storage->dim_1_choice == 0)

0 commit comments

Comments
 (0)