Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
a16f2e3e
Commit
a16f2e3e
authored
5 years ago
by
rttw52
Browse files
Options
Downloads
Patches
Plain Diff
Can now restrict the range of LOS down the los z-axis (if you dont want it to be 0->boxsize)
parent
c7262ad3
No related branches found
No related tags found
1 merge request
!1050
Line-of-sight output along the z-axis
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/line_of_sight.c
+35
-4
35 additions, 4 deletions
src/line_of_sight.c
src/line_of_sight.h
+9
-1
9 additions, 1 deletion
src/line_of_sight.h
with
44 additions
and
5 deletions
src/line_of_sight.c
+
35
−
4
View file @
a16f2e3e
...
@@ -81,6 +81,21 @@ void los_init(double dim[3], struct los_props *los_params,
...
@@ -81,6 +81,21 @@ void los_init(double dim[3], struct los_props *los_params,
/* Where are we saving them? */
/* Where are we saving them? */
parser_get_param_string
(
params
,
"LineOfSight:basename"
,
los_params
->
basename
);
parser_get_param_string
(
params
,
"LineOfSight:basename"
,
los_params
->
basename
);
/* Min/max range allowed when sightline is shooting down x,y and z
* (simulation axes). */
los_params
->
range_when_shooting_down_axis
[
0
][
0
]
=
0
.;
los_params
->
range_when_shooting_down_axis
[
0
][
1
]
=
dim
[
0
];
parser_get_opt_param_double_array
(
params
,
"LineOfSight:range_when_shooting_down_x"
,
2
,
los_params
->
range_when_shooting_down_axis
[
0
]);
los_params
->
range_when_shooting_down_axis
[
1
][
0
]
=
0
.;
los_params
->
range_when_shooting_down_axis
[
1
][
1
]
=
dim
[
1
];
parser_get_opt_param_double_array
(
params
,
"LineOfSight:range_when_shooting_down_y"
,
2
,
los_params
->
range_when_shooting_down_axis
[
1
]);
los_params
->
range_when_shooting_down_axis
[
2
][
0
]
=
0
.;
los_params
->
range_when_shooting_down_axis
[
2
][
1
]
=
dim
[
2
];
parser_get_opt_param_double_array
(
params
,
"LineOfSight:range_when_shooting_down_z"
,
2
,
los_params
->
range_when_shooting_down_axis
[
2
]);
}
}
/**
/**
...
@@ -107,7 +122,8 @@ void generate_sightlines(struct line_of_sight *Los,
...
@@ -107,7 +122,8 @@ void generate_sightlines(struct line_of_sight *Los,
Ypos
=
((
float
)
rand
()
/
(
float
)(
RAND_MAX
)
*
(
params
->
allowed_losrange_y
[
1
]
-
params
->
allowed_losrange_y
[
0
]))
+
Ypos
=
((
float
)
rand
()
/
(
float
)(
RAND_MAX
)
*
(
params
->
allowed_losrange_y
[
1
]
-
params
->
allowed_losrange_y
[
0
]))
+
params
->
allowed_losrange_y
[
0
];
params
->
allowed_losrange_y
[
0
];
create_sightline
(
Xpos
,
Ypos
,
simulation_x_axis
,
simulation_y_axis
,
create_sightline
(
Xpos
,
Ypos
,
simulation_x_axis
,
simulation_y_axis
,
simulation_z_axis
,
periodic
,
dim
,
&
Los
[
count
]);
simulation_z_axis
,
periodic
,
dim
,
&
Los
[
count
],
params
->
range_when_shooting_down_axis
[
simulation_z_axis
]);
count
+=
1
;
count
+=
1
;
}
}
...
@@ -118,7 +134,8 @@ void generate_sightlines(struct line_of_sight *Los,
...
@@ -118,7 +134,8 @@ void generate_sightlines(struct line_of_sight *Los,
Ypos
=
((
float
)
rand
()
/
(
float
)(
RAND_MAX
)
*
(
params
->
allowed_losrange_z
[
1
]
-
params
->
allowed_losrange_z
[
0
]))
+
Ypos
=
((
float
)
rand
()
/
(
float
)(
RAND_MAX
)
*
(
params
->
allowed_losrange_z
[
1
]
-
params
->
allowed_losrange_z
[
0
]))
+
params
->
allowed_losrange_z
[
0
];
params
->
allowed_losrange_z
[
0
];
create_sightline
(
Xpos
,
Ypos
,
simulation_y_axis
,
simulation_z_axis
,
create_sightline
(
Xpos
,
Ypos
,
simulation_y_axis
,
simulation_z_axis
,
simulation_x_axis
,
periodic
,
dim
,
&
Los
[
count
]);
simulation_x_axis
,
periodic
,
dim
,
&
Los
[
count
],
params
->
range_when_shooting_down_axis
[
simulation_x_axis
]);
count
+=
1
;
count
+=
1
;
}
}
...
@@ -129,7 +146,8 @@ void generate_sightlines(struct line_of_sight *Los,
...
@@ -129,7 +146,8 @@ void generate_sightlines(struct line_of_sight *Los,
Ypos
=
((
float
)
rand
()
/
(
float
)(
RAND_MAX
)
*
(
params
->
allowed_losrange_z
[
1
]
-
params
->
allowed_losrange_z
[
0
]))
+
Ypos
=
((
float
)
rand
()
/
(
float
)(
RAND_MAX
)
*
(
params
->
allowed_losrange_z
[
1
]
-
params
->
allowed_losrange_z
[
0
]))
+
params
->
allowed_losrange_z
[
0
];
params
->
allowed_losrange_z
[
0
];
create_sightline
(
Xpos
,
Ypos
,
simulation_x_axis
,
simulation_z_axis
,
create_sightline
(
Xpos
,
Ypos
,
simulation_x_axis
,
simulation_z_axis
,
simulation_y_axis
,
periodic
,
dim
,
&
Los
[
count
]);
simulation_y_axis
,
periodic
,
dim
,
&
Los
[
count
],
params
->
range_when_shooting_down_axis
[
simulation_y_axis
]);
count
+=
1
;
count
+=
1
;
}
}
...
@@ -141,7 +159,8 @@ void generate_sightlines(struct line_of_sight *Los,
...
@@ -141,7 +159,8 @@ void generate_sightlines(struct line_of_sight *Los,
void
create_sightline
(
const
double
Xpos
,
const
double
Ypos
,
void
create_sightline
(
const
double
Xpos
,
const
double
Ypos
,
enum
los_direction
xaxis
,
enum
los_direction
yaxis
,
enum
los_direction
xaxis
,
enum
los_direction
yaxis
,
enum
los_direction
zaxis
,
const
int
periodic
,
enum
los_direction
zaxis
,
const
int
periodic
,
const
double
dim
[
3
],
struct
line_of_sight
*
los
)
{
const
double
dim
[
3
],
struct
line_of_sight
*
los
,
const
double
range_when_shooting_down_axis
[
2
])
{
los
->
Xpos
=
Xpos
;
los
->
Xpos
=
Xpos
;
los
->
Ypos
=
Ypos
;
los
->
Ypos
=
Ypos
;
los
->
particles_in_los_local
=
0
;
los
->
particles_in_los_local
=
0
;
...
@@ -154,6 +173,8 @@ void create_sightline(const double Xpos, const double Ypos,
...
@@ -154,6 +173,8 @@ void create_sightline(const double Xpos, const double Ypos,
los
->
dim
[
1
]
=
dim
[
1
];
los
->
dim
[
1
]
=
dim
[
1
];
los
->
dim
[
2
]
=
dim
[
2
];
los
->
dim
[
2
]
=
dim
[
2
];
los
->
num_intersecting_top_level_cells
=
0
;
los
->
num_intersecting_top_level_cells
=
0
;
los
->
range_when_shooting_down_axis
[
0
]
=
range_when_shooting_down_axis
[
0
];
los
->
range_when_shooting_down_axis
[
1
]
=
range_when_shooting_down_axis
[
1
];
}
}
/**
/**
...
@@ -191,6 +212,11 @@ void los_first_loop_mapper(void *restrict map_data, int count,
...
@@ -191,6 +212,11 @@ void los_first_loop_mapper(void *restrict map_data, int count,
/* Don't consider inhibited parts. */
/* Don't consider inhibited parts. */
if
(
parts
[
i
].
time_bin
==
time_bin_inhibited
)
continue
;
if
(
parts
[
i
].
time_bin
==
time_bin_inhibited
)
continue
;
/* Don't consider part if outwith allowed z-range. */
if
(
parts
[
i
].
x
[
LOS_list
->
zaxis
]
<
LOS_list
->
range_when_shooting_down_axis
[
0
]
||
parts
[
i
].
x
[
LOS_list
->
zaxis
]
>
LOS_list
->
range_when_shooting_down_axis
[
1
])
continue
;
/* Distance from this part to LOS along x dim. */
/* Distance from this part to LOS along x dim. */
dx
=
parts
[
i
].
x
[
LOS_list
->
xaxis
]
-
LOS_list
->
Xpos
;
dx
=
parts
[
i
].
x
[
LOS_list
->
xaxis
]
-
LOS_list
->
Xpos
;
...
@@ -515,6 +541,11 @@ void do_line_of_sight(struct engine *e) {
...
@@ -515,6 +541,11 @@ void do_line_of_sight(struct engine *e) {
/* Don't consider inhibited parts. */
/* Don't consider inhibited parts. */
if
(
cell_parts
[
i
].
time_bin
==
time_bin_inhibited
)
continue
;
if
(
cell_parts
[
i
].
time_bin
==
time_bin_inhibited
)
continue
;
/* Don't consider part if outwith allowed z-range. */
if
(
cell_parts
[
i
].
x
[
LOS_list
[
j
].
zaxis
]
<
LOS_list
[
j
].
range_when_shooting_down_axis
[
0
]
||
cell_parts
[
i
].
x
[
LOS_list
[
j
].
zaxis
]
>
LOS_list
[
j
].
range_when_shooting_down_axis
[
1
])
continue
;
/* Distance from this part to LOS along x dim. */
/* Distance from this part to LOS along x dim. */
dx
=
cell_parts
[
i
].
x
[
LOS_list
[
j
].
xaxis
]
-
LOS_list
[
j
].
Xpos
;
dx
=
cell_parts
[
i
].
x
[
LOS_list
[
j
].
xaxis
]
-
LOS_list
[
j
].
Xpos
;
...
...
This diff is collapsed.
Click to expand it.
src/line_of_sight.h
+
9
−
1
View file @
a16f2e3e
...
@@ -69,6 +69,9 @@ struct line_of_sight {
...
@@ -69,6 +69,9 @@ struct line_of_sight {
/* How many top level cells does ths LOS intersect? */
/* How many top level cells does ths LOS intersect? */
int
num_intersecting_top_level_cells
;
int
num_intersecting_top_level_cells
;
/* The min--max range to consider for parts in LOS. */
double
range_when_shooting_down_axis
[
2
];
};
};
struct
los_props
{
struct
los_props
{
...
@@ -96,6 +99,10 @@ struct los_props {
...
@@ -96,6 +99,10 @@ struct los_props {
* allowed. */
* allowed. */
double
allowed_losrange_z
[
2
];
double
allowed_losrange_z
[
2
];
/* The min--max range to consider when LOS is shooting down each
* simulation axis. */
double
range_when_shooting_down_axis
[
3
][
2
];
/* Basename for line of sight HDF5 files. */
/* Basename for line of sight HDF5 files. */
char
basename
[
200
];
char
basename
[
200
];
};
};
...
@@ -119,7 +126,8 @@ void write_hdf5_header(hid_t h_file, const struct engine *e,
...
@@ -119,7 +126,8 @@ void write_hdf5_header(hid_t h_file, const struct engine *e,
void
create_sightline
(
const
double
Xpos
,
const
double
Ypos
,
void
create_sightline
(
const
double
Xpos
,
const
double
Ypos
,
enum
los_direction
xaxis
,
enum
los_direction
yaxis
,
enum
los_direction
xaxis
,
enum
los_direction
yaxis
,
enum
los_direction
zaxis
,
const
int
periodic
,
enum
los_direction
zaxis
,
const
int
periodic
,
const
double
dim
[
3
],
struct
line_of_sight
*
los
);
const
double
dim
[
3
],
struct
line_of_sight
*
los
,
const
double
range_when_shooting_down_axis
[
2
]);
void
los_struct_dump
(
const
struct
los_props
*
internal_los
,
FILE
*
stream
);
void
los_struct_dump
(
const
struct
los_props
*
internal_los
,
FILE
*
stream
);
void
los_struct_restore
(
const
struct
los_props
*
internal_los
,
FILE
*
stream
);
void
los_struct_restore
(
const
struct
los_props
*
internal_los
,
FILE
*
stream
);
int
does_los_intersect
(
const
struct
cell
*
c
,
const
struct
line_of_sight
*
los
);
int
does_los_intersect
(
const
struct
cell
*
c
,
const
struct
line_of_sight
*
los
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment