commit 8ead7f083d0c80d0cc427b7d9624a1e9502bc5e3
parent 391b88739003e4be5c069784988e94fbafa5edd1
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Thu, 7 Sep 2017 17:25:55 +0200
Fix GCC warnings
Diffstat:
2 files changed, 63 insertions(+), 49 deletions(-)
diff --git a/src/ssol_estimator_c.h b/src/ssol_estimator_c.h
@@ -35,19 +35,26 @@ struct mc_data {
#define MC_DATA_NULL__ { 0, 0 }
static const struct mc_data MC_DATA_NULL = MC_DATA_NULL__;
-#define MC_RECEIVER_DATA \
- struct mc_data incoming_flux; /* In W */ \
- struct mc_data incoming_if_no_atm_loss; /* In W */ \
- struct mc_data incoming_if_no_field_loss; /* In W */ \
- struct mc_data incoming_lost_in_field; /* In W */ \
- struct mc_data incoming_lost_in_atmosphere; /* In W */ \
- struct mc_data absorbed_flux; /* In W */ \
- struct mc_data absorbed_if_no_atm_loss; /* In W */ \
- struct mc_data absorbed_if_no_field_loss; /* In W */ \
- struct mc_data absorbed_lost_in_field; /* In W */ \
+#define MC_RECEIVER_DATA \
+ struct mc_data incoming_flux; /* In W */ \
+ struct mc_data incoming_if_no_atm_loss; /* In W */ \
+ struct mc_data incoming_if_no_field_loss; /* In W */ \
+ struct mc_data incoming_lost_in_field; /* In W */ \
+ struct mc_data incoming_lost_in_atmosphere; /* In W */ \
+ struct mc_data absorbed_flux; /* In W */ \
+ struct mc_data absorbed_if_no_atm_loss; /* In W */ \
+ struct mc_data absorbed_if_no_field_loss; /* In W */ \
+ struct mc_data absorbed_lost_in_field; /* In W */ \
struct mc_data absorbed_lost_in_atmosphere; /* In W */
-#define MC_RECEIVER_DATA_NULL__ \
+/*******************************************************************************
+ * One sided per shape MC data
+ ******************************************************************************/
+struct mc_primitive_1side {
+ MC_RECEIVER_DATA
+};
+
+#define MC_PRIMITIVE_1SIDE_NULL__ { \
MC_DATA_NULL__, \
MC_DATA_NULL__, \
MC_DATA_NULL__, \
@@ -57,16 +64,9 @@ static const struct mc_data MC_DATA_NULL = MC_DATA_NULL__;
MC_DATA_NULL__, \
MC_DATA_NULL__, \
MC_DATA_NULL__, \
- MC_DATA_NULL__
-
-/*******************************************************************************
- * One sided per shape MC data
- ******************************************************************************/
-struct mc_primitive_1side {
- MC_RECEIVER_DATA
-};
+ MC_DATA_NULL__ \
+}
-#define MC_PRIMITIVE_1SIDE_NULL__ { MC_RECEIVER_DATA_NULL__ }
static const struct mc_primitive_1side MC_PRIMITIVE_1SIDE_NULL =
MC_PRIMITIVE_1SIDE_NULL__;
@@ -154,26 +154,38 @@ struct mc_receiver_1side {
struct htable_shape2mc shape2mc;
};
-#define COPY_LOCAL_MC_WEIGHTS(Dst, Src) { \
- (Dst)->incoming_flux = (Src)->incoming_flux; \
- (Dst)->incoming_if_no_atm_loss = (Src)->incoming_if_no_atm_loss; \
- (Dst)->incoming_if_no_field_loss = (Src)->incoming_if_no_field_loss; \
- (Dst)->incoming_lost_in_atmosphere = (Src)->incoming_lost_in_atmosphere; \
- (Dst)->incoming_lost_in_field = (Src)->incoming_lost_in_field; \
- (Dst)->absorbed_flux = (Src)->absorbed_flux; \
- (Dst)->absorbed_if_no_atm_loss = (Src)->absorbed_if_no_atm_loss; \
- (Dst)->absorbed_if_no_field_loss = (Src)->absorbed_if_no_field_loss; \
- (Dst)->absorbed_lost_in_atmosphere = (Src)->absorbed_lost_in_atmosphere; \
- (Dst)->absorbed_lost_in_field = (Src)->absorbed_lost_in_field; \
-} (void)0
+static FINLINE void
+mc_receiver_1side_copy_mc_weights__
+ (struct mc_receiver_1side* dst, const struct mc_receiver_1side* src)
+{
+ ASSERT(dst && src);
+ dst->incoming_flux = src->incoming_flux;
+ dst->incoming_if_no_atm_loss = src->incoming_if_no_atm_loss;
+ dst->incoming_if_no_field_loss = src->incoming_if_no_field_loss;
+ dst->incoming_lost_in_atmosphere = src->incoming_lost_in_atmosphere;
+ dst->incoming_lost_in_field = src->incoming_lost_in_field;
+ dst->absorbed_flux = src->absorbed_flux;
+ dst->absorbed_if_no_atm_loss = src->absorbed_if_no_atm_loss;
+ dst->absorbed_if_no_field_loss = src->absorbed_if_no_field_loss;
+ dst->absorbed_lost_in_atmosphere = src->absorbed_lost_in_atmosphere;
+ dst->absorbed_lost_in_field = src->absorbed_lost_in_field;
+}
static INLINE void
mc_receiver_1side_init
(struct mem_allocator* allocator, struct mc_receiver_1side* mc)
{
- static const struct mc_receiver_1side r_null = { MC_RECEIVER_DATA_NULL__ };
ASSERT(mc);
- COPY_LOCAL_MC_WEIGHTS(mc, &r_null);
+ mc->incoming_flux = MC_DATA_NULL;
+ mc->incoming_if_no_atm_loss = MC_DATA_NULL;
+ mc->incoming_if_no_field_loss = MC_DATA_NULL;
+ mc->incoming_lost_in_atmosphere = MC_DATA_NULL;
+ mc->incoming_lost_in_field = MC_DATA_NULL;
+ mc->absorbed_flux = MC_DATA_NULL;
+ mc->absorbed_if_no_atm_loss = MC_DATA_NULL;
+ mc->absorbed_if_no_field_loss = MC_DATA_NULL;
+ mc->absorbed_lost_in_atmosphere = MC_DATA_NULL;
+ mc->absorbed_lost_in_field = MC_DATA_NULL;
htable_shape2mc_init(allocator, &mc->shape2mc);
}
@@ -189,7 +201,7 @@ mc_receiver_1side_copy
(struct mc_receiver_1side* dst, const struct mc_receiver_1side* src)
{
ASSERT(dst && src);
- COPY_LOCAL_MC_WEIGHTS(dst, src);
+ mc_receiver_1side_copy_mc_weights__(dst, src);
return htable_shape2mc_copy(&dst->shape2mc, &src->shape2mc);
}
@@ -198,7 +210,7 @@ mc_receiver_1side_copy_and_release
(struct mc_receiver_1side* dst, struct mc_receiver_1side* src)
{
ASSERT(dst && src);
- COPY_LOCAL_MC_WEIGHTS(dst, src);
+ mc_receiver_1side_copy_mc_weights__(dst, src);
return htable_shape2mc_copy_and_release(&dst->shape2mc, &src->shape2mc);
}
diff --git a/src/ssol_solver.c b/src/ssol_solver.c
@@ -482,8 +482,8 @@ point_shade
pt->kabs_at_pt = (1 - propagated);
pt->outgoing_flux = pt->incoming_flux * propagated;
pt->outgoing_if_no_atm_loss = pt->incoming_if_no_atm_loss * propagated;
- pt->outgoing_if_no_field_loss = point_is_receiver(pt) ?
- pt->incoming_if_no_field_loss * propagated : pt->incoming_if_no_field_loss;
+ pt->outgoing_if_no_field_loss = point_is_receiver(pt)
+ ? pt->incoming_if_no_field_loss*propagated : pt->incoming_if_no_field_loss;
if(type & SSF_TRANSMISSION) {
material_get_next_medium(mtl, in_medium, out_medium);
@@ -581,10 +581,6 @@ accum_mc_receivers_1side
res_T res = RES_OK;
ASSERT(dst && src);
- #define ACCUM_WEIGHT(Name) { \
- dst->Name.weight += src->Name.weight; \
- dst->Name.sqr_weight += src->Name.sqr_weight; \
- } (void)0
#define ACCUM_ALL { \
ACCUM_WEIGHT(incoming_flux); \
ACCUM_WEIGHT(incoming_if_no_atm_loss); \
@@ -597,6 +593,11 @@ accum_mc_receivers_1side
ACCUM_WEIGHT(absorbed_lost_in_field); \
ACCUM_WEIGHT(absorbed_lost_in_atmosphere); \
} (void)0
+
+ #define ACCUM_WEIGHT(Name) { \
+ dst->Name.weight += src->Name.weight; \
+ dst->Name.sqr_weight += src->Name.sqr_weight; \
+ } (void)0
ACCUM_ALL;
#undef ACCUM_WEIGHT
@@ -633,12 +634,12 @@ accum_mc_receivers_1side
} (void)0
ACCUM_ALL;
#undef ACCUM_WEIGHT
- #undef ACCUM_ALL
htable_prim2mc_iterator_next(&it_prim);
}
htable_shape2mc_iterator_next(&it_shape);
}
+ #undef ACCUM_ALL
exit:
return res;
@@ -725,10 +726,6 @@ update_mc
res = get_mc_receiver_1side(&thread_ctx->mc_rcvs, pt->inst, pt->side, &mc_rcv1);
if(res != RES_OK) goto error;
- #define ACCUM_WEIGHT(Name, W) { \
- mc_rcv1->Name.weight += (W); \
- mc_rcv1->Name.sqr_weight += (W)*(W); \
- } (void)0
#define ACCUM_ALL { \
ACCUM_WEIGHT(incoming_flux, pt->incoming_flux); \
ACCUM_WEIGHT(incoming_if_no_atm_loss, pt->incoming_if_no_atm_loss); \
@@ -747,6 +744,11 @@ update_mc
ACCUM_WEIGHT(absorbed_lost_in_atmosphere, \
(pt->incoming_if_no_atm_loss - pt->incoming_flux) * pt->kabs_at_pt); \
} (void)0
+
+ #define ACCUM_WEIGHT(Name, W) { \
+ mc_rcv1->Name.weight += (W); \
+ mc_rcv1->Name.sqr_weight += (W)*(W); \
+ } (void)0
ACCUM_ALL;
#undef ACCUM_WEIGHT
@@ -779,8 +781,8 @@ update_mc
} (void)0
ACCUM_ALL;
#undef ACCUM_WEIGHT
- #undef ACCUM_ALL
}
+ #undef ACCUM_ALL
exit:
return res;
@@ -969,7 +971,7 @@ trace_radiative_path
ssol_medium_copy(&in_medium, &out_medium);
}
/* Check conservation of energy */
- ASSERT(depth * pt.initial_flux * DBL_EPSILON >=
+ ASSERT((double)depth * pt.initial_flux * DBL_EPSILON >=
fabs(pt.initial_flux -
(pt.outgoing_flux + pt.partial_recv + pt.partial_atm + pt.partial_other)));