aboutsummaryrefslogtreecommitdiff
path: root/src/diffraction-gpu.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2017-12-07 11:51:56 +0100
committerThomas White <taw@physics.org>2018-02-27 17:12:41 +0100
commit911a5a47ecee5fce2ad3d16bd1460f779011c083 (patch)
tree539204221aceafd73c8ce6ba140e6c5c59b3628a /src/diffraction-gpu.c
parent0f24c4fb9451f1c32fb89534b37bf7f804e37d99 (diff)
pattern_sim: Add --flat
Diffstat (limited to 'src/diffraction-gpu.c')
-rw-r--r--src/diffraction-gpu.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/diffraction-gpu.c b/src/diffraction-gpu.c
index 22abcfd2..ea50b3fa 100644
--- a/src/diffraction-gpu.c
+++ b/src/diffraction-gpu.c
@@ -72,7 +72,8 @@ struct gpu_context
};
-static void check_sinc_lut(struct gpu_context *gctx, int n, int no_fringes)
+static void check_sinc_lut(struct gpu_context *gctx, int n,
+ int no_fringes, int flat)
{
cl_int err;
cl_image_format fmt;
@@ -105,8 +106,10 @@ static void check_sinc_lut(struct gpu_context *gctx, int n, int no_fringes)
for ( i=1; i<SINC_LUT_ELEMENTS; i++ ) {
double x, val;
x = (double)i/SINC_LUT_ELEMENTS;
- if ( no_fringes && (x > 1.0/n) && (1.0-x > 1.0/n) ) {
+ if ( (flat || no_fringes) && (x > 1.0/n) && (1.0-x > 1.0/n) ) {
val = 0.0;
+ } else if ( flat ) {
+ val = n;
} else {
val = fabs(sin(M_PI*n*x)/sin(M_PI*x));
}
@@ -279,7 +282,7 @@ static int do_panels(struct gpu_context *gctx, struct image *image,
int get_diffraction_gpu(struct gpu_context *gctx, struct image *image,
int na, int nb, int nc, UnitCell *ucell,
- int no_fringes)
+ int no_fringes, int flat)
{
double ax, ay, az;
double bx, by, bz;
@@ -297,9 +300,9 @@ int get_diffraction_gpu(struct gpu_context *gctx, struct image *image,
}
/* Ensure all required LUTs are available */
- check_sinc_lut(gctx, na, no_fringes);
- check_sinc_lut(gctx, nb, no_fringes);
- check_sinc_lut(gctx, nc, no_fringes);
+ check_sinc_lut(gctx, na, no_fringes, flat);
+ check_sinc_lut(gctx, nb, no_fringes, flat);
+ check_sinc_lut(gctx, nc, no_fringes, flat);
/* Unit cell */
cell_get_cartesian(ucell, &ax, &ay, &az, &bx, &by, &bz, &cx, &cy, &cz);