commit 4fb3fbed41d5bcff9dba2414d88466cea5941605
parent 050eda4e4cff99a4496c35b8a5de6b03fca0f847
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 28 Apr 2020 12:29:42 +0200
Merge branch 'release_0.4'
Diffstat:
20 files changed, 567 insertions(+), 374 deletions(-)
diff --git a/README.md b/README.md
@@ -33,15 +33,24 @@ formats on which it relies.
## Release notes
+### Version 0.4
+
+- Set the minimum number of scattering angles to 2 rather than the previous
+ and arbitrary limit fixed to 100.
+- Fix a bug in the generation of the shape of the helical pipe.
+- Update the short help of the command as well as the man pages.
+- Add the `-D` option that discards all computations for large scattering
+ angles.
+- Add the `--version` that prints the current version of the `schiff` command.
+
### Version 0.3.1
- Reformat the man pages.
## License
-Schiff is developed by [|Meso|Star>](http://www.meso-star.com) for the
-the [National Center for Scientific Research](http://www.cnrs.fr/index.php)
-(CNRS). It is a free software copyright (C) CNRS 2015-2016 released under the
-[OSI](http://opensource.org)-approved GPLv3+ license. You are welcome to
-redistribute it under certain conditions; refer to the COPYING file for
-details.
+Copyright (C) 2020 [|Meso|Star>](http://www.meso-star.com)
+(contact@meso-star.com). Copyright (C) 2015, 2016 CNRS. Schiff is free
+software released under the GPL v3+ license: GNU GPL version 3 or later. You
+are welcome to redistribute it under certain conditions; refer to the COPYING
+file for details.
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Copyright (C) 2015-2016 CNRS
+# Copyright (C) 2020 |Meso|Star> (contact@meso-star.com)
+# Copyright (C) 2015, 2016 CNRS
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -26,22 +27,19 @@ get_filename_component(_current_source_dir ${CMAKE_CURRENT_LIST_FILE} PATH)
set(LibYAML_DIR ${_current_source_dir}/)
find_package(LibYAML REQUIRED)
-find_package(RCMake 0.2 REQUIRED)
-find_package(RSys 0.3 REQUIRED)
-find_package(Star3D 0.3 REQUIRED)
-find_package(StarSchiff 0.3 REQUIRED)
-find_package(StarSP 0.3 REQUIRED)
-if(MSVC)
- find_package(MuslGetopt REQUIRED)
- include_directories(${MuslGetopt_INCLUDE_DIR})
-endif()
+find_package(RCMake 0.4 REQUIRED)
+find_package(RSys 0.8 REQUIRED)
+find_package(Star3D 0.6 REQUIRED)
+find_package(StarSchiff 0.4 REQUIRED)
+find_package(StarSP 0.8 REQUIRED)
include_directories(
${LibYAML_INCLUDE_DIR}
${RSys_INCLUDE_DIR}
${Star3D_INCLUDE_DIR}
${StarSchiff_INCLUDE_DIR}
- ${StarSP_INCLUDE_DIR})
+ ${StarSP_INCLUDE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${RCMAKE_SOURCE_DIR})
include(rcmake)
@@ -51,10 +49,22 @@ include(rcmake_runtime)
# Configure and define the targets
################################################################################
set(VERSION_MAJOR 0)
-set(VERSION_MINOR 3)
-set(VERSION_PATCH 1)
+set(VERSION_MINOR 4)
+set(VERSION_PATCH 0)
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
+set(SCHIFF_ARGS_DEFAULT_NINSAMPLES "100")
+set(SCHIFF_ARGS_DEFAULT_NREALISATIONS "10000")
+set(SCHIFF_ARGS_DEFAULT_NANGLES "1000")
+set(SCHIFF_ARGS_DEFAULT_NANGLES_INV "2000")
+
+configure_file(${SCHIFF_SOURCE_DIR}/schiff_version.h.in
+ ${CMAKE_CURRENT_BINARY_DIR}/schiff_version.h @ONLY)
+configure_file(${SCHIFF_SOURCE_DIR}/schiff_args.h.in
+ ${CMAKE_CURRENT_BINARY_DIR}/schiff_args.h @ONLY)
+configure_file(${PROJECT_SOURCE_DIR}/../doc/schiff.1.in
+ ${CMAKE_CURRENT_BINARY_DIR}/schiff.1 @ONLY)
+
set(SCHIFF_FILES_SRC
schiff.c
schiff_args.c
@@ -68,16 +78,18 @@ set(SCHIFF_FILES_INC
schiff_optical_properties.h
schiff_streamline.h)
set(SCHIFF_FILES_DOC COPYING README.md)
-set(SCHIFF_FILES_MAN1 schiff.1)
-set(SCHIFF_FILES_MAN5 schiff-geometry.5 schiff-output.5)
-# Prepend each file in the `SCHIFF_FILES_<SRC|INC>' list by the absolute
+# Prepend each file in the `SCHIFF_FILES_<SRC|INC|DOC>' list by the absolute
# path of the directory in which they lie
rcmake_prepend_path(SCHIFF_FILES_SRC ${SCHIFF_SOURCE_DIR})
rcmake_prepend_path(SCHIFF_FILES_INC ${SCHIFF_SOURCE_DIR})
rcmake_prepend_path(SCHIFF_FILES_DOC ${PROJECT_SOURCE_DIR}/../)
-rcmake_prepend_path(SCHIFF_FILES_MAN1 ${PROJECT_SOURCE_DIR}/../doc/)
-rcmake_prepend_path(SCHIFF_FILES_MAN5 ${PROJECT_SOURCE_DIR}/../doc/)
+
+set(SCHIFF_FILES_MAN1
+ ${CMAKE_CURRENT_BINARY_DIR}/schiff.1)
+set(SCHIFF_FILES_MAN5
+ ${PROJECT_SOURCE_DIR}/../doc/schiff-geometry.5
+ ${PROJECT_SOURCE_DIR}/../doc/schiff-output.5)
if(CMAKE_COMPILER_IS_GNUCC)
set(MATH_LIB m)
@@ -85,9 +97,6 @@ endif()
add_executable(schiff ${SCHIFF_FILES_SRC} ${SCHIFF_FILES_INC})
target_link_libraries(schiff LibYAML RSys Star3D StarSchiff StarSP ${MATH_LIB})
-if(MSVC)
- target_link_libraries(schiff MuslGetopt)
-endif()
set_target_properties(schiff PROPERTIES
VERSION ${VERSION}
SOVERSION ${VERSION_MAJOR})
diff --git a/doc/schiff-geometry.5 b/doc/schiff-geometry.5
@@ -391,7 +391,7 @@ and spherical soft particles have a fixed radius:
.PP
.RS 4
.nf
-- sphere: { radius 1.12, proba: 2.0, slices: 64 }
+- sphere: { radius: 1.12, proba: 2.0, slices: 64 }
- cylinder:
radius: {lognormal: { sigma: 2.3, mu: 0.2 } }
diff --git a/doc/schiff.1 b/doc/schiff.1
@@ -1,143 +0,0 @@
-.\" Copying and distribution of this file, with or without modification,
-.\" are permitted in any medium without royalty provided the copyright
-.\" notice and this notice are preserved. This file is offered as-is,
-.\" without any warranty.
-.TH SCHIFF 1
-.SH NAME
-schiff \- estimate radiative properties of soft particles
-.SH SYNOPSIS
-.nf
-\fBschiff \fR[\fIOPTIONS\fR]... [\fIFILE\fR]
-.fi
-.SH DESCRIPTION
-\fBschiff\fR computes the radiative properties of soft particles with an
-"Approximation Method for Short Wavelength or High Energy Scattering" [1]. The
-implemented model is detailed in [2]. It relies on the Monte\-Carlo method to
-solve Maxwell's equations within Schiff's approximation; it estimates total
-cross sections (extinction, absorption and scattering cross-sections) in
-addition of the inverse cumulative phase function.
-.PP
-The shapes of the soft particles are controlled by the
-.BR schiff-geometry (5)
-file submitted by the \fB\-i\fR option. The per wavelength optical properties
-of the soft particles are stored in \fIFILE\fR where each line is formatted as
-"W N K Ne" whith "W" is the wavelength in vacuum expressed in micron, "N" and
-"K" are the real and imaginary parts, respectively, of the refractive index,
-and "Ne" the refractive index of the medium. With no \fIFILE\fR, the optical
-properties are read from standard input.
-.PP
-The estimated results follows the
-.BR schiff-output (5)
-format and are written to the \fIOUTPUT\fR file or to standard ouptut whether
-the \fB\-o \fIOUTPUT\fR option is defined or not, respectively.
-.SH OPTIONS
-.TP
-.B \-a \fINUM_ANGLES\fR
-number of phase function scattering angles to estimate. These angles are
-uniformaly distributed in [0, PI], i.e. the value of the i^th angle, i in
-[0, \fINUM_ANGLES\fR-1], is i*PI/(\fINUM_ANGLES\fR-1). Default is 1000.
-.TP
-.B \-A \fINUM_ANGLES\fR
-number of scattering angles computed from the inverse cumulative phase
-function. The value of the i^th angle, i in [0, \fINUM_ANGLES\fR-1], is
-CDF^-1(i/(\fINUM_ANGLES-1\fR). Default is 2000.
-.TP
-.B \-d \fINUM_DIRS\fR
-number of sampled directions for each sampled geometry. Default is 100.
-.TP
-.B \-g \fINUM_PARTICLES\fR
-number of sampled soft particle instances. This is actually the number of
-realisations. Default is 10000.
-.TP
-.B \-G \fICOUNT\fR
-sample \fICOUNT\fR soft particles with respect to the defined distribution,
-dump their geometric data and exit. The data are written to \fIOUTPUT\fR or the
-standard output whether the \fB-o\fR \fIOUTPUT\fR option is defined or not,
-respectively. The outputted data followed the Alias Wavefront obj file format.
-.TP
-.B \-h
-display short help and exit.
-.TP
-.B \-i \fIDISTRIBUTION\fR
-define the
-.BR schiff-geometry (5)
-file that controls the geometry distribution of the soft particles.
-.TP
-.B \-l \fILENGTH\fR
-characteristic length in micron of the soft particles. Used for the definition
-of the angle that sets the limit between small and large scattering angles (see
-equation. 7 in [2]).
-.TP
-.B \-n \fINUM_THREADS\fR
-hint on the number of threads to use during the integration. By default use as
-many threads as CPU cores.
-.TP
-.B \-o \fIOUTPUT\fR
-write results to \fIOUTPUT\fR with respect to the
-.BR schiff-output (5)
-format. If not defined, write results to standard output.
-.TP
-.B \-q
-do not print the helper message when no \fIFILE\fR is submitted.
-.TP
-.B \-w \fIW0\fR[\fB:\fIW1\fR]...
-list of wavelengths in vacuum (expressed in micron) to integrate.
-.SH EXAMPLES
-Estimate the radiative properties of soft particles whose shape is described in
-the \fBgeometry.yaml\fR file and its optical properties in the \fBproperties\fR
-file. The characteristic length of the soft particle shapes is \fB2.3\fR
-microns and the estimations is performed for the wavelengths \fB0.45\fR and
-\fB0.6\fR microns. The results are written to the standard output:
-.PP
-.RS 4
-.nf
-$ schiff -i geometry.yaml -l 2.3 -w 0.45:0.6 properties
-.fi
-.RE
-.PP
-The soft particles have a characteristic length of \fB1\fR and their shape is
-controlled by the \fBmy_geom.yaml\fR file. Their optical properties are read
-from the standard input. The estimated wavelelength is \fB0.66\fR microns and
-the results are written to the \fBmy_result\fR file:
-.PP
-.RS 4
-.nf
-$ schiff -w 0.66 -l 1.0 -i my_geom.yaml -o my_result
-.fi
-.RE
-.PP
-Sample \fB10\fR soft particles whose shape is defined by the \fBgeometry.yaml\fR
-file and write their triangulated geometric data to the \fBtemp_output\fR file.
-Use the
-.BR csplit (1)
-Unix command to split the \fBtemp_output\fR file in 10 files named
-particle<\fINUM\fR>.obj, with NUM in [0, 9], each storing the geometric data of
-a sampled soft particle:
-.PP
-.RS 4
-.nf
-$ schiff -i geometry.yaml -G 10 -o temp_output
-$ csplit temp_output -z /^g\\ / {*} -f particle -b %d.obj
-.fi
-.RE
-.PP
-.SH NOTES
-.PP
-[1] L. I. Schiff, 1956. Approximation Method for Short Wavelength or High\-Energy
-Scattering. Phys. Rev. 104 \- 1481\-1485.
-.PP
-[2] J. Charon, S. Blanco, J. F. Cornet, J. Dauchet, M. El Hafi, R. Fournier, M.
-Kaissar Abboud, S. Weitz, 2015. Monte Carlo Implementation of Schiff's
-Approximation for Estimating Radiative Properties of Homogeneous,
-Simple\-Shaped and Optically Soft Particles: Application to Photosynthetic
-Micro-Organisms. Journal of Quantitative Spectroscopy and Radiative Transfer
-172 \- 3\-23.
-.SH COPYRIGHT
-\fBschiff\fR is copyright \(co CNRS 2015-2016. License GPLv3+: GNU GPL version
-3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are
-free to change and redistribute it. There is NO WARRANTY, to the extent
-permitted by law.
-.SH SEE ALSO
-.BR csplit (1),
-.BR schiff-geometry (5),
-.BR schiff-output (5)
diff --git a/doc/schiff.1.in b/doc/schiff.1.in
@@ -0,0 +1,160 @@
+.\" Copying and distribution of this file, with or without modification,
+.\" are permitted in any medium without royalty provided the copyright
+.\" notice and this notice are preserved. This file is offered as-is,
+.\" without any warranty.
+.TH SCHIFF 1
+.SH NAME
+schiff \- estimate radiative properties of soft particles
+.SH SYNOPSIS
+.nf
+\fBschiff \fR[\fIOPTIONS\fR]... [\fIFILE\fR]
+.fi
+.SH DESCRIPTION
+\fBschiff\fR computes the radiative properties of soft particles with an
+"Approximation Method for Short Wavelength or High Energy Scattering" [1]. The
+implemented model is detailed in [2]. It relies on the Monte\-Carlo method to
+solve Maxwell's equations within Schiff's approximation; it estimates total
+cross sections (extinction, absorption and scattering cross-sections) in
+addition of the inverse cumulative phase function.
+.PP
+The shapes of the soft particles are controlled by the
+.BR schiff-geometry (5)
+file submitted by the \fB\-i\fR option. The per wavelength optical properties
+of the soft particles are stored in \fIFILE\fR where each line is formatted as
+"W N K Ne" whith "W" is the wavelength in vacuum expressed in micron, "N" and
+"K" are the real and imaginary parts, respectively, of the refractive index,
+and "Ne" the refractive index of the medium. With no \fIFILE\fR, the optical
+properties are read from standard input.
+.PP
+The estimated results follows the
+.BR schiff-output (5)
+format and are written to the \fIOUTPUT\fR file or to standard ouptut whether
+the \fB\-o \fIOUTPUT\fR option is defined or not, respectively.
+.SH OPTIONS
+.TP
+.B \-a \fINUM_ANGLES\fR
+number of phase function scattering angles to estimate. These angles are
+uniformaly distributed in [0, PI], i.e. the value of the i^th angle, i in [0,
+\fINUM_ANGLES\fR-1], is i*PI/(\fINUM_ANGLES\fR-1). Default is
+@SCHIFF_ARGS_DEFAULT_NANGLES@.
+.TP
+.B \-A \fINUM_ANGLES\fR
+number of scattering angles computed from the inverse cumulative phase
+function. The value of the i^th angle, i in [0, \fINUM_ANGLES\fR-1], is
+CDF^-1(i/(\fINUM_ANGLES-1\fR). Default is @SCHIFF_ARGS_DEFAULT_NANGLES_INV@.
+.TP
+.B \-d \fINUM_INNER_SAMPLES\fR
+number of conditioned integration variable sampling (incident direction,
+volume, ray(s)) for each sampled particle-shape. Default is
+@SCHIFF_ARGS_DEFAULT_NINSAMPLES@. Calculation of optimal value is presented in
+[3].
+.TP
+.B \-D
+discard computations of the [[inverse] cumulative] phase functions for large
+scattering angles. See the \fB\-l\fR option for the definition of large
+scattering angles.
+.TP
+.B \-g \fINUM_PARTICLES\fR
+number of sampled particle-shapes. This is actually the number of realizations
+of the Monte Carlo algorithm. Default is @SCHIFF_ARGS_DEFAULT_NREALISATIONS@.
+.TP
+.B \-G \fICOUNT\fR
+sample \fICOUNT\fR soft particles with respect to the defined distribution,
+dump their geometric data and exit. The data are written to \fIOUTPUT\fR or the
+standard output whether the \fB-o\fR \fIOUTPUT\fR option is defined or not,
+respectively. The outputted data followed the Alias Wavefront obj file format.
+.TP
+.B \-h
+display short help and exit.
+.TP
+.B \-i \fIDISTRIBUTION\fR
+define the
+.BR schiff-geometry (5)
+file that controls the geometry distribution of the soft particles.
+.TP
+.B \-l \fILENGTH\fR
+characteristic length in micron of the soft particles. Used for the definition
+of the angle that sets the limit between small and large scattering angles (see
+equation. 7 in [2]).
+.TP
+.B \-n \fINUM_THREADS\fR
+hint on the number of threads to use during the integration. By default use as
+many threads as CPU cores.
+.TP
+.B \-o \fIOUTPUT\fR
+write results to \fIOUTPUT\fR with respect to the
+.BR schiff-output (5)
+format. If not defined, write results to standard output.
+.TP
+.B \-q
+do not print the helper message when no \fIFILE\fR is submitted.
+.TP
+.B \-w \fIW0\fR[\fB:\fIW1\fR]...
+list of wavelengths in vacuum (expressed in micron) to integrate.
+.TP
+.B \-\-version
+display version information and exit.
+.SH EXAMPLES
+Estimate the radiative properties of soft particles whose shape is described in
+the \fBgeometry.yaml\fR file and its optical properties in the \fBproperties\fR
+file. The characteristic length of the soft particle shapes is \fB2.3\fR
+microns and the estimations is performed for the wavelengths \fB0.45\fR and
+\fB0.6\fR microns. The results are written to the standard output:
+.PP
+.RS 4
+.nf
+$ schiff -i geometry.yaml -l 2.3 -w 0.45:0.6 properties
+.fi
+.RE
+.PP
+The soft particles have a characteristic length of \fB1\fR and their shape is
+controlled by the \fBmy_geom.yaml\fR file. Their optical properties are read
+from the standard input. The estimated wavelelength is \fB0.66\fR microns and
+the results are written to the \fBmy_result\fR file:
+.PP
+.RS 4
+.nf
+$ schiff -w 0.66 -l 1.0 -i my_geom.yaml -o my_result
+.fi
+.RE
+.PP
+Sample \fB10\fR soft particles whose shape is defined by the \fBgeometry.yaml\fR
+file and write their triangulated geometric data to the \fBtemp_output\fR file.
+Use the
+.BR csplit (1)
+Unix command to split the \fBtemp_output\fR file in 10 files named
+particle<\fINUM\fR>.obj, with NUM in [0, 9], each storing the geometric data of
+a sampled soft particle:
+.PP
+.RS 4
+.nf
+$ schiff -i geometry.yaml -G 10 -o temp_output
+$ csplit temp_output -z /^g\\ / {*} -f particle -b %d.obj
+.fi
+.RE
+.PP
+.SH NOTES
+.PP
+[1] L. I. Schiff, 1956. Approximation Method for Short Wavelength or High\-Energy
+Scattering. Phys. Rev. 104 \- 1481\-1485.
+.PP
+[2] J. Charon, S. Blanco, J. F. Cornet, J. Dauchet, M. El Hafi, R. Fournier, M.
+Kaissar Abboud, S. Weitz, 2015. Monte Carlo Implementation of Schiff's
+Approximation for Estimating Radiative Properties of Homogeneous,
+Simple\-Shaped and Optically Soft Particles: Application to Photosynthetic
+Micro-Organisms. Journal of Quantitative Spectroscopy and Radiative Transfer
+172 \- 3\-23.
+.PP
+[3] S. Weitz, S. Blanco, J. Charon, J. Dauchet, M. El Hafi, V. Eymet, O.
+Farges, R. Fournier, and J. Gautrais, 2016. Monte Carlo efficiency
+improvement by multiple sampling of conditioned integration variables. Journal
+of Computational Physics 326 \- 30\-34.
+.SH COPYRIGHT
+Copyright \(co 2015, 2016 CNRS. Copyright \(co 2019 |Meso|Star>. License
+GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is
+free software: you are free to change and redistribute it. There is NO
+WARRANTY, to the extent permitted by law.
+.SH SEE ALSO
+.BR csplit (1),
+.BR schiff-geometry (5),
+.BR schiff-output (5)
diff --git a/src/schiff.c b/src/schiff.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2015-2016 CNRS
+/* Copyright (C) 2020 |Meso|Star> (contact@meso-star.com)
+ * Copyright (C) 2015, 2016 CNRS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -61,11 +62,18 @@ dump_geometries
unsigned itri, ntris;
double volume_scaling;
double dist_scaling;
- res = distrib->sample(rng, shape, &volume_scaling, distrib->context);
+ void* shape_data = NULL;
+ res = distrib->sample(rng, &shape_data, shape, distrib->context);
if(res != RES_OK) {
fprintf(stderr, "Couldn't sample the micro organism geometry.\n");
goto error;
}
+ res = distrib->sample_volume_scaling
+ (rng, shape_data, &volume_scaling, distrib->context);
+ if(res != RES_OK) {
+ fprintf(stderr, "Couldn't sample the volume scaling of the geometry.\n");
+ goto error;
+ }
dist_scaling = pow(volume_scaling, 1.0/3.0);
@@ -330,7 +338,7 @@ run_integration
nwlens = sa_size(args->wavelengths);
res = sschiff_integrate(sschiff, rng, distrib, args->wavelengths, nwlens,
sschiff_uniform_scattering_angles, args->nangles, args->nrealisations,
- args->ndirs, &estimator);
+ args->ninsamps, args->discard_large_angles, &estimator);
if(res != RES_OK) {
fprintf(stderr, "Schiff integration error.\n");
goto error;
diff --git a/src/schiff_args.c b/src/schiff_args.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2015-2016 CNRS
+/* Copyright (C) 2020 |Meso|Star> (contact@meso-star.com)
+ * Copyright (C) 2015, 2016 CNRS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,7 +17,9 @@
#define _POSIX_C_SOURCE 2 /* getopt support */
#include "schiff_args.h"
+#include "schiff_version.h"
#include "schiff_optical_properties.h"
+#include "schiff_geometry.h"
#include <rsys/dynamic_array_char.h>
#include <rsys/cstr.h>
@@ -26,8 +29,8 @@
#include <stdarg.h>
#include <yaml.h>
-#define MIN_NANGLES 100
-#define MIN_NANGLES_INV 100
+#define MIN_NANGLES 2
+#define MIN_NANGLES_INV 2
#ifdef COMPILER_CL
#include <getopt.h>
@@ -52,41 +55,51 @@ print_help(const char* binary)
"Photosynthetic Micro-Organisms\" (Charon et al. 2015).\n\n",
binary);
printf(
-" -a ANGLES number of phase function scattering angles. Default is %u.\n",
+" -a NUM_ANGLES number of phase function scattering angles. Default is %u.\n",
SCHIFF_ARGS_NULL.nangles);
printf(
-" -A ANGLES number of computed inverse cumulative phase function values.\n"
-" Default is %u.\n",
+" -A NUM_ANGLES number of computed inverse cumulative phase function values.\n"
+" Default is %u.\n",
SCHIFF_ARGS_NULL.nangles_inv);
printf(
-" -d DIRS number of sampled directions for each geometry.\n"
-" Default is %u.\n",
- SCHIFF_ARGS_NULL.ndirs);
+" -d NUM_INSAMPS number of (incident direction, volume, ray(s)) sampling for each\n"
+" sampled particle-shape. Default is %u.\n",
+ SCHIFF_ARGS_NULL.ninsamps);
printf(
-" -g GOEMS number of sampled geometries. This is actually the number of\n"
-" realisations. Default is %u.\n",
+" -D discard computations of the [[inverse] cumulative] phase\n"
+" functions for large scattering angles.\n");
+ printf(
+" -g NUM_SHAPES number of sampled particle-shapes. This is actually the number\n"
+" of realizations of the Monte Carlo algorithm. Default is %u.\n",
SCHIFF_ARGS_NULL.nrealisations);
printf(
-" -G NUM sampled `NUM' geometries with respect to the defined\n"
-" distribution, dump their data and exit.\n");
+" -G NUM sampled `NUM' particle shapes with respect to the defined\n"
+" distribution, dump their geometry and exit.\n");
+ printf(
+" -h display this help and exit.\n");
+ printf(
+" -i DISTRIB YAML file that defines the geometry distributions of the soft\n"
+" particles.\n");
printf(
-" -h display this help and exit.\n");
+" -l LENGTH characteristic length of the soft particles.\n");
printf(
-" -i DISTRIB YAML file that defines the geometry distributions of the soft\n"
-" particles.\n");
+" -n NTHREADS hint on the number of threads to use during the integration.\n"
+" By default use as many threads as CPU cores.\n");
printf(
-" -l LENGTH characteristic length of the soft particles.\n");
+" -o OUTPUT write results to OUTPUT. If not defined, write results to\n"
+" standard output.\n");
printf(
-" -n NTHREADS hint on the number of threads to use during the integration.\n"
-" By default use as many threads as CPU cores.\n");
+" -q do not print the helper message when no FILE is submitted.\n");
printf(
-" -o OUTPUT write results to OUTPUT. If not defined, write results to\n"
-" standard output.\n");
+" -w A[:B]... list of wavelengths in vacuum (expressed in micron) to\n"
+" integrate.\n");
printf(
-" -q do not print the helper message when no FILE is submitted.\n");
+" --version display version information and exit.\n");
+ printf("\n");
printf(
-" -w A[:B]... list of wavelengths in vacuum (expressed in micron) to\n"
-" integrate.\n\n");
+"software released under the GNU GPL license, version 3 or later. You are free\n"
+"to change or redistribute it under certain conditions\n"
+"<http://gnu.org/licenses/gpl.html>\n");
}
static int
@@ -161,7 +174,7 @@ parse_wavelengths(const char* str, struct schiff_args* args)
ASSERT(args && str);
/* How many wavelengths are submitted */
- res = cstr_to_list_double(str, NULL, &len, 0);
+ res = cstr_to_list_double(str, ':', NULL, &len, 0);
if(res != RES_OK) goto error;
/* Reserve the wavelengths memory space */
@@ -169,7 +182,7 @@ parse_wavelengths(const char* str, struct schiff_args* args)
args->wavelengths = sa_add(args->wavelengths, len);
/* Read the wavelengths */
- res = cstr_to_list_double(optarg, args->wavelengths, NULL, len);
+ res = cstr_to_list_double(optarg, ':', args->wavelengths, NULL, len);
if(res != RES_OK) goto error;
/* Check the validity of read wavelengths */
@@ -1288,7 +1301,7 @@ static res_T
parse_yaml
(const char* filename,
struct schiff_geometry** out_geoms,
- struct ssp_ran_discrete** out_ran)
+ struct ssp_ranst_discrete** out_ran)
{
yaml_parser_t parser;
yaml_document_t doc;
@@ -1297,7 +1310,7 @@ parse_yaml
size_t idistrib;
struct schiff_geometry* geoms = NULL;
double* probas = NULL;
- struct ssp_ran_discrete* ran = NULL;
+ struct ssp_ranst_discrete* ran = NULL;
FILE* file = NULL;
int doc_is_init = 0;
res_T res = RES_OK;
@@ -1330,6 +1343,11 @@ parse_yaml
doc_is_init = 1;
root = yaml_document_get_root_node(&doc);
+ if(!root) {
+ fprintf(stderr, "Unexpected empty file `%s'.\n", filename);
+ res = RES_BAD_ARG;
+ goto error;
+ }
if(root->type == YAML_MAPPING_NODE) {
ndistribs = (size_t)
(root->data.mapping.pairs.top - root->data.mapping.pairs.start);
@@ -1367,7 +1385,7 @@ parse_yaml
}
/* Create the geometry distribution random variate */
- res = ssp_ran_discrete_create(&mem_default_allocator, &ran);
+ res = ssp_ranst_discrete_create(&mem_default_allocator, &ran);
if(res != RES_OK) {
log_err(filename, root,
"couldn't allocate the random variate of geometry distributions.\n");
@@ -1401,7 +1419,7 @@ parse_yaml
}
/* Setup the geometry distributions random variate */
- res = ssp_ran_discrete_setup(ran, probas, ndistribs);
+ res = ssp_ranst_discrete_setup(ran, probas, ndistribs);
if(res != RES_OK) {
log_err(filename, root,
"couldn't setup the discrete geometry distributions.\n");
@@ -1418,7 +1436,7 @@ exit:
return res;
error:
if(ran) {
- SSP(ran_discrete_ref_put(ran));
+ SSP(ranst_discrete_ref_put(ran));
ran = NULL;
}
if(geoms) {
@@ -1442,11 +1460,23 @@ schiff_args_init
{
int quiet = 0;
int opt;
+ int i;
res_T res = RES_OK;
ASSERT(argc && argv && args);
*args = SCHIFF_ARGS_NULL;
- while((opt = getopt(argc, argv, "a:A:d:g:G:hi:l:n:o:qw:")) != -1) {
+
+ FOR_EACH(i, 1, argc) {
+ if(!strcmp(argv[i], "--version")) {
+ printf("Schiff %d.%d.%d\n",
+ SCHIFF_VERSION_MAJOR,
+ SCHIFF_VERSION_MINOR,
+ SCHIFF_VERSION_PATCH);
+ goto exit;
+ }
+ }
+
+ while((opt = getopt(argc, argv, "a:A:d:Dg:G:hi:l:n:o:qw:")) != -1) {
switch(opt) {
case 'a':
res = cstr_to_uint(optarg, &args->nangles);
@@ -1468,13 +1498,14 @@ schiff_args_init
}
break;
case 'd':
- res = cstr_to_uint(optarg, &args->ndirs);
- if(res == RES_OK && !args->ndirs) {
- fprintf(stderr, "%s: the number of directions cannot be null.\n",
+ res = cstr_to_uint(optarg, &args->ninsamps);
+ if(res == RES_OK && !args->ninsamps) {
+ fprintf(stderr, "%s: the number of inner samples cannot be null.\n",
argv[0]);
res = RES_BAD_ARG;
}
break;
+ case 'D': args->discard_large_angles = 1; break;
case 'g':
res = cstr_to_uint(optarg, &args->nrealisations);
if(res == RES_OK && !args->nrealisations) {
@@ -1588,7 +1619,7 @@ schiff_args_release(struct schiff_args* args)
count = sa_size(args->geoms);
FOR_EACH(i, 0, count) geometry_release(&args->geoms[i]);
sa_release(args->geoms);
- if(args->ran_geoms) SSP(ran_discrete_ref_put(args->ran_geoms));
+ if(args->ran_geoms) SSP(ranst_discrete_ref_put(args->ran_geoms));
args->geoms = NULL;
*args = SCHIFF_ARGS_NULL;
}
diff --git a/src/schiff_args.h b/src/schiff_args.h
@@ -1,70 +0,0 @@
-/* Copyright (C) 2015-2016 CNRS
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#ifndef SCHIFF_ARGS_H
-#define SCHIFF_ARGS_H
-
-#include "schiff_geometry.h"
-#include <rsys/rsys.h>
-#include <star/sschiff.h>
-
-struct schiff_args {
- const char* output_filename; /* File in which output data are stored */
- struct schiff_optical_properties* properties; /* List of properties */
- double* wavelengths; /* List of wavelengths to integrate */
-
- double characteristic_length; /* Characteristic length of the soft particles */
-
- /* List of parsed geometry distribution parameters and its associated random
- * variate */
- struct schiff_geometry* geoms;
- struct ssp_ran_discrete* ran_geoms;
-
- unsigned ngeoms_dump; /* # sampled geometries to dump */
- unsigned nrealisations; /* # realisation */
- unsigned ndirs; /* Number of directions to sample per realisation */
- unsigned nangles; /* Number of scattering angles */
- unsigned nangles_inv; /* Number of angles in the the inverse phase function */
-
- unsigned nthreads; /* Hint on the number of thread to use */
-};
-
-static const struct schiff_args SCHIFF_ARGS_NULL = {
- NULL, /* Output filename */
- NULL, /* List of optical properties */
- NULL, /* List of wavelength to integrate */
- -1.0, /* Caracteristic length */
- NULL, /* List of Schiff geometries */
- NULL, /* Schiff geometry random variates */
- 0, /* # Dumped geometries */
- 10000, /* # Sampled geometries */
- 100, /* # Sampled directions per geometry */
- 1000, /* # Scattering angles */
- 2000, /* # angles in the inv cumulative phase function */
- SSCHIFF_NTHREADS_DEFAULT
-};
-
-extern LOCAL_SYM res_T
-schiff_args_init
- (struct schiff_args* args,
- const int argc,
- char** argv);
-
-extern LOCAL_SYM void
-schiff_args_release
- (struct schiff_args* args);
-
-#endif /* SCHIFF_ARGS_H */
-
diff --git a/src/schiff_args.h.in b/src/schiff_args.h.in
@@ -0,0 +1,75 @@
+/* Copyright (C) 2015, 2016 CNRS
+ * Copyright (C) 2019 |Meso|Star>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef SCHIFF_ARGS_H
+#define SCHIFF_ARGS_H
+
+#include <rsys/rsys.h>
+#include <star/sschiff.h>
+
+struct schiff_geometry;
+struct schiff_optical_properties;
+
+struct schiff_args {
+ const char* output_filename; /* File in which output data are stored */
+ struct schiff_optical_properties* properties; /* List of properties */
+ double* wavelengths; /* List of wavelengths to integrate */
+
+ double characteristic_length; /* Characteristic length of the soft particles */
+ int discard_large_angles; /* Avoid analytic model for large angles */
+
+ /* List of parsed geometry distribution parameters and its associated random
+ * variate */
+ struct schiff_geometry* geoms;
+ struct ssp_ranst_discrete* ran_geoms;
+
+ unsigned ngeoms_dump; /* # sampled geometries to dump */
+ unsigned nrealisations; /* # realisation */
+ unsigned ninsamps; /* Number of inner samples per realisations */
+ unsigned nangles; /* Number of scattering angles */
+ unsigned nangles_inv; /* Number of angles in the the inverse phase function */
+
+ unsigned nthreads; /* Hint on the number of thread to use */
+};
+
+static const struct schiff_args SCHIFF_ARGS_NULL = {
+ NULL, /* Output filename */
+ NULL, /* List of optical properties */
+ NULL, /* List of wavelength to integrate */
+ -1.0, /* Caracteristic length */
+ 0, /* Discard large angles */
+ NULL, /* List of Schiff geometries */
+ NULL, /* Schiff geometry random variates */
+ 0, /* # Dumped geometries */
+ @SCHIFF_ARGS_DEFAULT_NREALISATIONS@, /* #Sampled geometries */
+ @SCHIFF_ARGS_DEFAULT_NINSAMPLES@, /* #inner samples */
+ @SCHIFF_ARGS_DEFAULT_NANGLES@, /* # Scattering angles */
+ @SCHIFF_ARGS_DEFAULT_NANGLES_INV@, /* # angles in the inv cumulative phase function */
+ SSCHIFF_NTHREADS_DEFAULT
+};
+
+extern LOCAL_SYM res_T
+schiff_args_init
+ (struct schiff_args* args,
+ const int argc,
+ char** argv);
+
+extern LOCAL_SYM void
+schiff_args_release
+ (struct schiff_args* args);
+
+#endif /* SCHIFF_ARGS_H */
+
diff --git a/src/schiff_geometry.c b/src/schiff_geometry.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2015-2016 CNRS
+/* Copyright (C) 2020 |Meso|Star> (contact@meso-star.com)
+ * Copyright (C) 2015, 2016 CNRS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -92,7 +93,7 @@ struct shape {
struct geometry_distribution_context {
struct schiff_optical_properties* properties; /* Per wavelength properties */
struct shape* shapes; /* List of shapes */
- struct ssp_ran_discrete* ran_geometries; /* Geometries random variates */
+ struct ssp_ranst_discrete* ran_geometries; /* Geometries random variates */
};
/*******************************************************************************
@@ -319,25 +320,23 @@ compute_s3d_shape_volume
(struct s3d_device* s3d, struct s3d_shape* shape, double* out_volume)
{
struct s3d_scene* scn = NULL;
+ struct s3d_scene_view* view = NULL;
float volume = 0.f;
- int mask;
res_T res = RES_OK;
ASSERT(s3d && shape && out_volume);
if(RES_OK != (res = s3d_scene_create(s3d, &scn))) goto error;
if(RES_OK != (res = s3d_scene_attach_shape(scn, shape))) goto error;
- if(RES_OK != (res = s3d_scene_begin_session(scn, S3D_TRACE))) goto error;
- if(RES_OK != (res = s3d_scene_compute_volume(scn, &volume))) goto error;
- S3D(scene_end_session(scn));
+ if(RES_OK != (res = s3d_scene_view_create(scn, 0, &view))) goto error;
+ if(RES_OK != (res = s3d_scene_view_compute_volume(view, &volume))) goto error;
exit:
if(scn) S3D(scene_ref_put(scn));
+ if(view) S3D(scene_view_ref_put(view));
/* The volume may be negative if the faces are not correctly oriented */
*out_volume = absf(volume);
return res;
error:
- S3D(scene_get_session_mask(scn, &mask));
- if(mask) S3D(scene_end_session(scn));
goto exit;
}
@@ -347,6 +346,7 @@ shape_release(struct shape* shape)
ASSERT(shape);
schiff_mesh_release(&shape->mesh);
if(shape->shape) S3D(shape_ref_put(shape->shape));
+ memset(shape, 0, sizeof(*shape));
}
static res_T
@@ -421,14 +421,12 @@ static res_T
shape_cylinder_generate_s3d_shape
(const struct shape* shape,
struct ssp_rng* rng,
- double* volume_scaling,
struct s3d_shape* s3d_shape)
{
struct s3d_vertex_data attrib;
struct mesh_context ctx;
size_t nverts, nprims;
- ASSERT(shape && volume_scaling);
- ASSERT(shape->geometry->type == SCHIFF_CYLINDER);
+ ASSERT(shape && shape->geometry->type == SCHIFF_CYLINDER);
ctx.type = SCHIFF_CYLINDER;
ctx.mesh = &shape->mesh;
@@ -444,7 +442,6 @@ shape_cylinder_generate_s3d_shape
nverts = darray_float_size_get(&shape->mesh.vertices.cartesian) / 3/*#coords*/;
nprims = darray_uint_size_get(&shape->mesh.indices) / 3/*#indices per prim*/;
- *volume_scaling = 1.0;
return s3d_mesh_setup_indexed_vertices(s3d_shape, (unsigned)nprims,
geometry_get_indices, (unsigned)nverts, &attrib, 1, &ctx);
}
@@ -453,9 +450,19 @@ static res_T
shape_cylinder_as_sphere_generate_s3d_shape
(const struct shape* shape,
struct ssp_rng* rng,
- double* volume_scaling,
struct s3d_shape* s3d_shape)
{
+ ASSERT(shape && shape->geometry->type == SCHIFF_CYLINDER_AS_SPHERE);
+ (void)rng;
+ return s3d_mesh_copy(shape->shape, s3d_shape);
+}
+
+static res_T
+shape_cylinder_as_sphere_sample_volume_scaling
+ (const struct shape* shape,
+ struct ssp_rng* rng,
+ double* volume_scaling)
+{
double radius, sphere_volume;
ASSERT(shape && volume_scaling);
ASSERT(shape->geometry->type == SCHIFF_CYLINDER_AS_SPHERE);
@@ -463,7 +470,7 @@ shape_cylinder_as_sphere_generate_s3d_shape
radius = eval_param(&shape->geometry->data.cylinder.radius_sphere, rng);
sphere_volume = 4.0/3.0 * PI * radius*radius*radius;
*volume_scaling = sphere_volume / shape->volume;
- return s3d_mesh_copy(shape->shape, s3d_shape);
+ return RES_OK;
}
static res_T
@@ -540,15 +547,13 @@ static res_T
shape_ellipsoid_generate_s3d_shape
(const struct shape* shape,
struct ssp_rng* rng,
- double* volume_scaling,
struct s3d_shape* s3d_shape)
{
struct s3d_vertex_data attrib;
struct mesh_context ctx;
size_t nverts, nprims;
double a, b, c, a2, b2, c2;
- ASSERT(shape && volume_scaling);
- ASSERT(shape->geometry->type == SCHIFF_ELLIPSOID);
+ ASSERT(shape && shape->geometry->type == SCHIFF_ELLIPSOID);
ctx.type = SCHIFF_ELLIPSOID;
ctx.mesh = &shape->mesh;
@@ -574,7 +579,6 @@ shape_ellipsoid_generate_s3d_shape
nverts = darray_uint_size_get(&shape->mesh.vertices.polar) / 2/*#theta/phi*/;
nprims = darray_uint_size_get(&shape->mesh.indices) / 3/*#indices*/;
- *volume_scaling = 1.0;
return s3d_mesh_setup_indexed_vertices(s3d_shape, (unsigned)nprims,
geometry_get_indices, (unsigned)nverts, &attrib, 1, &ctx);
}
@@ -583,9 +587,19 @@ static res_T
shape_ellipsoid_as_sphere_generate_s3d_shape
(const struct shape* shape,
struct ssp_rng* rng,
- double* volume_scaling,
struct s3d_shape* s3d_shape)
{
+ ASSERT(shape && shape->geometry->type == SCHIFF_ELLIPSOID_AS_SPHERE);
+ (void)rng;
+ return s3d_mesh_copy(shape->shape, s3d_shape);
+}
+
+static res_T
+shape_ellipsoid_as_sphere_sample_volume_scaling
+ (const struct shape* shape,
+ struct ssp_rng* rng,
+ double* volume_scaling)
+{
double radius, sphere_volume;
ASSERT(shape && volume_scaling);
ASSERT(shape->geometry->type == SCHIFF_ELLIPSOID_AS_SPHERE);
@@ -593,7 +607,7 @@ shape_ellipsoid_as_sphere_generate_s3d_shape
radius = eval_param(&shape->geometry->data.ellipsoid.radius_sphere, rng);
sphere_volume = 4.0/3.0 * PI * radius*radius*radius;
*volume_scaling = sphere_volume / shape->volume;
- return s3d_mesh_copy(shape->shape, s3d_shape);
+ return RES_OK;
}
static res_T
@@ -677,7 +691,6 @@ static res_T
shape_helical_pipe_generate_s3d_shape
(struct shape* shape,
struct ssp_rng* rng,
- double* volume_scaling,
struct s3d_shape* s3d_shape)
{
const struct schiff_helical_pipe* helical_pipe;
@@ -687,9 +700,7 @@ shape_helical_pipe_generate_s3d_shape
size_t nprims, nverts;
double pitch, height, hradius, cradius;
res_T res = RES_OK;
-
- ASSERT(shape && volume_scaling);
- ASSERT(shape->geometry->type == SCHIFF_HELICAL_PIPE);
+ ASSERT(shape && shape->geometry->type == SCHIFF_HELICAL_PIPE);
helical_pipe = &shape->geometry->data.helical_pipe;
@@ -718,8 +729,6 @@ shape_helical_pipe_generate_s3d_shape
helical_pipe_get_indices, (unsigned)nverts, &attrib, 1, &ctx);
if(res != RES_OK) goto error;
- *volume_scaling = 1.0;
-
exit:
if(vertices) {
schiff_mesh_helical_pipe_destroy_vertices(&shape->mesh, vertices);
@@ -731,11 +740,21 @@ error:
static res_T
shape_helical_pipe_as_sphere_generate_s3d_shape
- (const struct shape* shape,
+ (struct shape* shape,
struct ssp_rng* rng,
- double* volume_scaling,
struct s3d_shape* s3d_shape)
{
+ ASSERT(shape && shape->geometry->type == SCHIFF_HELICAL_PIPE_AS_SPHERE);
+ (void)rng;
+ return s3d_mesh_copy(shape->shape, s3d_shape);
+}
+
+static res_T
+shape_helical_pipe_as_sphere_sample_volume_scaling
+ (const struct shape* shape,
+ struct ssp_rng* rng,
+ double* volume_scaling)
+{
double radius, sphere_volume;
ASSERT(shape && volume_scaling);
ASSERT(shape->geometry->type == SCHIFF_HELICAL_PIPE_AS_SPHERE);
@@ -743,7 +762,7 @@ shape_helical_pipe_as_sphere_generate_s3d_shape
radius = eval_param(&shape->geometry->data.helical_pipe.radius_sphere, rng);
sphere_volume = 4.0/3.0 * PI * radius*radius*radius;
*volume_scaling = sphere_volume / shape->volume;
- return s3d_mesh_copy(shape->shape, s3d_shape);
+ return RES_OK;
}
static res_T
@@ -804,9 +823,19 @@ static res_T
shape_sphere_generate_s3d_shape
(const struct shape* shape,
struct ssp_rng* rng,
- double* volume_scaling,
struct s3d_shape* s3d_shape)
{
+ ASSERT(shape && shape->geometry->type == SCHIFF_SPHERE);
+ (void)rng;
+ return s3d_mesh_copy(shape->shape, s3d_shape);
+}
+
+static res_T
+shape_sphere_sample_volume_scaling
+ (const struct shape* shape,
+ struct ssp_rng* rng,
+ double* volume_scaling)
+{
double radius, sphere_volume;
ASSERT(shape && volume_scaling);
ASSERT(shape->geometry->type == SCHIFF_SPHERE);
@@ -814,7 +843,7 @@ shape_sphere_generate_s3d_shape
radius = eval_param(&shape->geometry->data.sphere.radius, rng);
sphere_volume = 4.0/3.0 * PI * radius*radius*radius;
*volume_scaling = sphere_volume / shape->volume;
- return s3d_mesh_copy(shape->shape, s3d_shape);
+ return RES_OK;
}
static res_T
@@ -885,7 +914,6 @@ static res_T
shape_supershape_generate_s3d_shape
(const struct shape* shape,
struct ssp_rng* rng,
- double* volume_scaling,
struct s3d_shape* s3d_shape)
{
const struct schiff_supershape* sshape;
@@ -893,8 +921,7 @@ shape_supershape_generate_s3d_shape
struct s3d_vertex_data attrib;
size_t nverts, nprims;
int iform, iattr;
- ASSERT(shape && volume_scaling);
- ASSERT(shape->geometry->type == SCHIFF_SUPERSHAPE);
+ ASSERT(shape && shape->geometry->type == SCHIFF_SUPERSHAPE);
sshape = &shape->geometry->data.supershape;
ctx.mesh = &shape->mesh;
@@ -913,7 +940,6 @@ shape_supershape_generate_s3d_shape
nverts = darray_uint_size_get(&shape->mesh.vertices.polar) / 2/*#theta/phi*/;
nprims = darray_uint_size_get(&shape->mesh.indices) / 3/*#indices*/;
- *volume_scaling = 1.0;
return s3d_mesh_setup_indexed_vertices(s3d_shape, (unsigned)nprims,
geometry_get_indices, (unsigned)nverts, &attrib, 1, &ctx);
}
@@ -922,9 +948,19 @@ static res_T
shape_supershape_as_sphere_generate_s3d_shape
(const struct shape* shape,
struct ssp_rng* rng,
- double* volume_scaling,
struct s3d_shape* s3d_shape)
{
+ ASSERT(shape && shape->geometry->type == SCHIFF_SUPERSHAPE_AS_SPHERE);
+ (void)rng;
+ return s3d_mesh_copy(shape->shape, s3d_shape);
+}
+
+static res_T
+shape_supershape_as_sphere_sample_volume_scaling
+ (const struct shape* shape,
+ struct ssp_rng* rng,
+ double* volume_scaling)
+{
double radius, sphere_volume;
ASSERT(shape && volume_scaling);
ASSERT(shape->geometry->type == SCHIFF_SUPERSHAPE_AS_SPHERE);
@@ -932,65 +968,107 @@ shape_supershape_as_sphere_generate_s3d_shape
radius = eval_param(&shape->geometry->data.supershape.radius_sphere, rng);
sphere_volume = 4.0/3.0 * PI * radius*radius*radius;
*volume_scaling = sphere_volume / shape->volume;
- return s3d_mesh_copy(shape->shape, s3d_shape);
+ return RES_OK;
}
static res_T
-geometry_sample
+geometry_sample_shape
(struct ssp_rng* rng,
+ void** shape_data,
struct s3d_shape* s3d_shape,
- double* volume_scaling,
void* ctx)
{
struct geometry_distribution_context* distrib = ctx;
struct shape* shape;
size_t isamp;
res_T res = RES_OK;
- ASSERT(rng && ctx);
+ ASSERT(rng && shape_data && ctx);
- isamp = ssp_ran_discrete(rng, distrib->ran_geometries);
+ isamp = ssp_ranst_discrete_get(rng, distrib->ran_geometries);
shape = distrib->shapes + isamp;
switch(shape->geometry->type) {
case SCHIFF_ELLIPSOID:
- res = shape_ellipsoid_generate_s3d_shape
- (shape, rng, volume_scaling, s3d_shape);
+ res = shape_ellipsoid_generate_s3d_shape(shape, rng, s3d_shape);
break;
case SCHIFF_ELLIPSOID_AS_SPHERE:
- res = shape_ellipsoid_as_sphere_generate_s3d_shape
- (shape, rng, volume_scaling, s3d_shape);
+ res = shape_ellipsoid_as_sphere_generate_s3d_shape(shape, rng, s3d_shape);
break;
case SCHIFF_CYLINDER:
- res = shape_cylinder_generate_s3d_shape
- (shape, rng, volume_scaling, s3d_shape);
+ res = shape_cylinder_generate_s3d_shape(shape, rng, s3d_shape);
break;
case SCHIFF_CYLINDER_AS_SPHERE:
- res = shape_cylinder_as_sphere_generate_s3d_shape
- (shape, rng, volume_scaling, s3d_shape);
+ res = shape_cylinder_as_sphere_generate_s3d_shape(shape, rng, s3d_shape);
break;
case SCHIFF_HELICAL_PIPE:
- res = shape_helical_pipe_generate_s3d_shape
- (shape, rng, volume_scaling, s3d_shape);
+ res = shape_helical_pipe_generate_s3d_shape(shape, rng, s3d_shape);
break;
case SCHIFF_HELICAL_PIPE_AS_SPHERE:
- res = shape_helical_pipe_as_sphere_generate_s3d_shape
- (shape, rng, volume_scaling, s3d_shape);
+ res = shape_helical_pipe_as_sphere_generate_s3d_shape(shape, rng, s3d_shape);
break;
case SCHIFF_SPHERE:
- res = shape_sphere_generate_s3d_shape
- (shape, rng, volume_scaling, s3d_shape);
+ res = shape_sphere_generate_s3d_shape(shape, rng, s3d_shape);
+ break;
+ case SCHIFF_SUPERSHAPE:
+ res = shape_supershape_generate_s3d_shape(shape, rng, s3d_shape);
break;
+ case SCHIFF_SUPERSHAPE_AS_SPHERE:
+ res = shape_supershape_as_sphere_generate_s3d_shape(shape, rng, s3d_shape);
+ break;
+ default: FATAL("Unreachable code.\n"); break;
+ }
+ if(res != RES_OK) goto error;
+
+exit:
+ *shape_data = shape;
+ return res;
+error:
+ goto exit;
+}
+
+static res_T
+geometry_sample_volume_scaling
+ (struct ssp_rng* rng,
+ void* shape_data,
+ double* volume_scaling,
+ void* ctx)
+{
+ struct shape* shape = shape_data;
+ res_T res = RES_OK;
+ ASSERT(rng && shape_data && volume_scaling && ctx);
+ (void)ctx;
+
+ switch(shape->geometry->type) {
+ case SCHIFF_ELLIPSOID:
+ case SCHIFF_CYLINDER:
+ case SCHIFF_HELICAL_PIPE:
case SCHIFF_SUPERSHAPE:
- res = shape_supershape_generate_s3d_shape
- (shape, rng, volume_scaling, s3d_shape);
+ *volume_scaling = 1;
+ break;
+ case SCHIFF_ELLIPSOID_AS_SPHERE:
+ res = shape_ellipsoid_as_sphere_sample_volume_scaling
+ (shape, rng, volume_scaling);
+ break;
+ case SCHIFF_CYLINDER_AS_SPHERE:
+ res = shape_cylinder_as_sphere_sample_volume_scaling
+ (shape, rng, volume_scaling);
+ break;
+ case SCHIFF_HELICAL_PIPE_AS_SPHERE:
+ res = shape_helical_pipe_as_sphere_sample_volume_scaling
+ (shape, rng, volume_scaling);
+ break;
+ case SCHIFF_SPHERE:
+ res = shape_sphere_sample_volume_scaling
+ (shape, rng, volume_scaling);
break;
case SCHIFF_SUPERSHAPE_AS_SPHERE:
- res = shape_supershape_as_sphere_generate_s3d_shape
- (shape, rng, volume_scaling, s3d_shape);
+ res = shape_supershape_as_sphere_sample_volume_scaling
+ (shape, rng, volume_scaling);
break;
default: FATAL("Unreachable code.\n"); break;
}
if(res != RES_OK) goto error;
+ ASSERT(*volume_scaling > 0);
exit:
return res;
@@ -1018,7 +1096,7 @@ schiff_geometry_distribution_release
sa_release(ctx->shapes);
}
if(ctx->ran_geometries)
- SSP(ran_discrete_ref_put(ctx->ran_geometries));
+ SSP(ranst_discrete_ref_put(ctx->ran_geometries));
mem_rm(ctx);
}
@@ -1029,7 +1107,7 @@ schiff_geometry_distribution_init
const struct schiff_geometry* geoms,
const size_t ngeoms,
const double characteristic_length,
- struct ssp_ran_discrete* ran_geoms,
+ struct ssp_ranst_discrete* ran_geoms,
struct schiff_optical_properties* properties)
{
struct geometry_distribution_context* ctx = NULL;
@@ -1089,12 +1167,13 @@ schiff_geometry_distribution_init
}
}
ctx->properties = properties;
- SSP(ran_discrete_ref_get(ran_geoms));
+ SSP(ranst_discrete_ref_get(ran_geoms));
ctx->ran_geometries = ran_geoms;
distrib->material.get_property = get_material_property;
distrib->material.material = properties;
- distrib->sample = geometry_sample;
+ distrib->sample = geometry_sample_shape;
+ distrib->sample_volume_scaling = geometry_sample_volume_scaling;
distrib->characteristic_length = characteristic_length;
exit:
diff --git a/src/schiff_geometry.h b/src/schiff_geometry.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 2015-2016 CNRS
+/* Copyright (C) 2020 |Meso|Star> (contact@meso-star.com)
+ * Copyright (C) 2015, 2016 CNRS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -125,21 +126,22 @@ struct schiff_supershape {
struct schiff_param radius_sphere;
unsigned nslices;
};
-#define SCHIFF_SUPERSHAPE_DEFAULT__ \
- {{{SCHIFF_PARAM_DEFAULT__, \
- SCHIFF_PARAM_DEFAULT__, \
- SCHIFF_PARAM_DEFAULT__, \
- SCHIFF_PARAM_DEFAULT__, \
- SCHIFF_PARAM_DEFAULT__, \
- SCHIFF_PARAM_DEFAULT__}, \
- {SCHIFF_PARAM_DEFAULT__, \
- SCHIFF_PARAM_DEFAULT__, \
- SCHIFF_PARAM_DEFAULT__, \
- SCHIFF_PARAM_DEFAULT__, \
- SCHIFF_PARAM_DEFAULT__, \
- SCHIFF_PARAM_DEFAULT__}}, \
- SCHIFF_PARAM_DEFAULT__, \
- 64}
+#define SCHIFF_SUPERSHAPE_DEFAULT__ { \
+ {{SCHIFF_PARAM_DEFAULT__, \
+ SCHIFF_PARAM_DEFAULT__, \
+ SCHIFF_PARAM_DEFAULT__, \
+ SCHIFF_PARAM_DEFAULT__, \
+ SCHIFF_PARAM_DEFAULT__, \
+ SCHIFF_PARAM_DEFAULT__}, \
+ {SCHIFF_PARAM_DEFAULT__, \
+ SCHIFF_PARAM_DEFAULT__, \
+ SCHIFF_PARAM_DEFAULT__, \
+ SCHIFF_PARAM_DEFAULT__, \
+ SCHIFF_PARAM_DEFAULT__, \
+ SCHIFF_PARAM_DEFAULT__}}, \
+ SCHIFF_PARAM_DEFAULT__, \
+ 64 \
+}
static const struct schiff_supershape SCHIFF_SUPERSHAPE_DEFAULT =
SCHIFF_SUPERSHAPE_DEFAULT__;
@@ -172,7 +174,7 @@ schiff_geometry_distribution_init
const struct schiff_geometry* geometry,
const size_t ngeoms,
const double characteristic_length,
- struct ssp_ran_discrete* ran_geoms,
+ struct ssp_ranst_discrete* ran_geoms,
struct schiff_optical_properties* properties);
extern LOCAL_SYM void
diff --git a/src/schiff_mesh.c b/src/schiff_mesh.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2015-2016 CNRS
+/* Copyright (C) 2020 |Meso|Star> (contact@meso-star.com)
+ * Copyright (C) 2015, 2016 CNRS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -109,14 +110,14 @@ schiff_mesh_init_sphere
FOR_EACH(itheta, 0, nthetas) {
const double theta = -PI + (double)itheta * step_theta;
darray_sincos_data_get(&sphere->thetas)[itheta].angle = theta;
- darray_sincos_data_get(&sphere->thetas)[itheta].sinus = (float)sin(theta);
- darray_sincos_data_get(&sphere->thetas)[itheta].cosine = (float)cos(theta);
+ darray_sincos_data_get(&sphere->thetas)[itheta].sinus = sin(theta);
+ darray_sincos_data_get(&sphere->thetas)[itheta].cosine = cos(theta);
}
FOR_EACH(iphi, 0, nphis-1) {
const double phi = -PI/2 + (double)(iphi + 1) * step_phi;
- darray_sincos_data_get(&sphere->phis)[iphi].angle = (float)phi;
- darray_sincos_data_get(&sphere->phis)[iphi].sinus = (float)sin(phi);
- darray_sincos_data_get(&sphere->phis)[iphi].cosine = (float)cos(phi);
+ darray_sincos_data_get(&sphere->phis)[iphi].angle = phi;
+ darray_sincos_data_get(&sphere->phis)[iphi].sinus = sin(phi);
+ darray_sincos_data_get(&sphere->phis)[iphi].cosine = cos(phi);
}
/* Build the contour vertices */
@@ -445,7 +446,7 @@ schiff_mesh_helical_pipe_create_vertices
goto error;
}
- c = pitch / 2*PI;
+ c = pitch / (2*PI);
phi_max = height * 2*PI / pitch;
step_helicoid = phi_max / (double)nsteps_helicoid;
step_circle = 2*PI / (double)nsteps_circle;
diff --git a/src/schiff_mesh.h b/src/schiff_mesh.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 2015-2016 CNRS
+/* Copyright (C) 2020 |Meso|Star> (contact@meso-star.com)
+ * Copyright (C) 2015, 2016 CNRS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/schiff_optical_properties.c b/src/schiff_optical_properties.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2015-2016 CNRS
+/* Copyright (C) 2020 |Meso|Star> (contact@meso-star.com)
+ * Copyright (C) 2015, 2016 CNRS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/schiff_optical_properties.h b/src/schiff_optical_properties.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 2015-2016 CNRS
+/* Copyright (C) 2020 |Meso|Star> (contact@meso-star.com)
+ * Copyright (C) 2015, 2016 CNRS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/schiff_streambuf.h b/src/schiff_streambuf.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 2015-2016 CNRS
+/* Copyright (C) 2020 |Meso|Star> (contact@meso-star.com)
+ * Copyright (C) 2015, 2016 CNRS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/schiff_streamline.h b/src/schiff_streamline.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 2015-2016 CNRS
+/* Copyright (C) 2020 |Meso|Star> (contact@meso-star.com)
+ * Copyright (C) 2015, 2016 CNRS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/schiff_version.h.in b/src/schiff_version.h.in
@@ -0,0 +1,25 @@
+/* Copyright (C) 2015, 2016 CNRS
+ * Copyright (C) 2019 |Meso|Star>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef SCHIFF_VERSION_H
+#define SCHIFF_VERSION_H
+
+#define SCHIFF_VERSION_MAJOR @VERSION_MAJOR@
+#define SCHIFF_VERSION_MINOR @VERSION_MINOR@
+#define SCHIFF_VERSION_PATCH @VERSION_PATCH@
+
+#endif /* SCHIFF_VERSION_H */
+
diff --git a/src/test_schiff_cylinder.sh b/src/test_schiff_cylinder.sh
@@ -1,5 +1,6 @@
#!/bin/bash
-# Copyright (C) 2015-2016 CNRS
+# Copyright (C) 2015, 2016 CNRS
+# Copyright (C) 2019 |Meso|Star>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/src/test_schiff_sphere.sh b/src/test_schiff_sphere.sh
@@ -1,5 +1,6 @@
#!/bin/bash
-# Copyright (C) 2015-2016 CNRS
+# Copyright (C) 2015, 2016 CNRS
+# Copyright (C) 2019 |Meso|Star>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by