commit a6bc2cb94b0059aab8ca95fbb1efd14f664226e1
parent 239c28761df05b1b9c7fcd7c3b1311e0a4cf6548
Author: Benjamin Piaud <benjamin.piaud@meso-star.com>
Date: Thu, 23 Nov 2017 11:03:08 +0100
0 is allowed to ks. Change default value of ks to 0
Diffstat:
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/s4vs.c b/src/s4vs.c
@@ -29,6 +29,7 @@
#include <rsys/cstr.h>
#include <rsys/float3.h>
#include <rsys/mem_allocator.h>
+#include <rsys/clock_time.h>
#include <star/s3d.h>
#include <star/s3daw.h>
@@ -45,9 +46,10 @@ compute_4v_s(struct s3d_scene* scene, const size_t max_steps, const double ks)
struct smc_integrator integrator;
struct smc_estimator* estimator = NULL;
struct smc_estimator_status estimator_status;
+ struct time t1,t2,dt;
float S, V, reference;
res_T res = RES_OK;
- ASSERT(scene && max_steps > 0 && ks > 0);
+ ASSERT(scene && max_steps > 0 && ks >= 0);
S3D(scene_view_create(scene, S3D_SAMPLE|S3D_TRACE, &view));
@@ -81,7 +83,11 @@ compute_4v_s(struct s3d_scene* scene, const size_t max_steps, const double ks)
integrator.max_failures = max_steps / 1000; /* cancel if 0.1% of the realization fail */
/* Solve */
+ time_current(&t1);
SMC(solve(smc, &integrator, &ctx, &estimator));
+ time_current(&t2);
+ time_sub(&dt,&t2,&t1);
+ printf("Computation time : %li msec.\n \n", time_val(&dt, TIME_MSEC));
/* Print the simulation results */
SMC(estimator_get_status(estimator, &estimator_status));
@@ -156,9 +162,10 @@ main(int argc, char* argv[])
{
struct s3d_scene* scene = NULL;
unsigned long nsteps = 10000;
- double ks = 1.0;
+ double ks = 0.0;
res_T res = RES_OK;
int err = 0;
+ struct time t1,t2,dt;
/* Check command arguments */
if(argc < 2 || argc > 4) {
@@ -167,11 +174,15 @@ main(int argc, char* argv[])
}
/* Import file's content in the scene */
+ time_current(&t1);
res = import_obj(argv[1], &scene);
if(res != RES_OK) {
fprintf(stderr, "Couldn't import `%s'\n", argv[1]);
goto error;
}
+ time_current(&t2);
+ time_sub(&dt,&t2,&t1);
+ printf("obj file loaded in %li msec.\n \n", time_val(&dt, TIME_MSEC));
/* Set number of realizations */
if(argc >= 3) {
@@ -185,7 +196,7 @@ main(int argc, char* argv[])
/* Set ks */
if(argc >= 4) {
res = cstr_to_double(argv[3], &ks);
- if(res != RES_OK || ks <= 0) {
+ if(res != RES_OK || ks < 0) {
fprintf(stderr, "Invalid k-scattering value `%s'\n", argv[3]);
goto error;
}