htgop

Optical properties of a gas mixture
git clone git://git.meso-star.fr/htgop.git
Log | Files | Refs | README | LICENSE

commit ad6902011ff7d23bf4d4a14eacffe8790c5313cb
parent 2117886419f9a6a7de14de53d9c83c002ab8df22
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu,  2 Aug 2018 17:58:45 +0200

Add funcs that retrieve the min/max of radiative properties

Diffstat:
Msrc/htgop.c | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/htgop.h | 51++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 122 insertions(+), 1 deletion(-)

diff --git a/src/htgop.c b/src/htgop.c @@ -749,6 +749,78 @@ htgop_position_to_layer_id return RES_OK; } +#define DEFINE_LAYER_GET_K_BOUNDS(Domain, Data) \ + res_T \ + htgop_layer_get_##Domain##_##Data##_bounds \ + (const struct htgop_layer* layer, double bounds[2]) \ + { \ + size_t i; \ + if(!layer || !bounds) return RES_BAD_ARG; \ + bounds[0] = DBL_MAX; \ + bounds[1] =-DBL_MAX; \ + FOR_EACH(i, 0, layer->Domain##_spectral_intervals_count) { \ + struct htgop_layer_##Domain##_spectral_interval band; \ + double tmp[2]; \ + HTGOP(layer_get_##Domain##_spectral_interval(layer, i, &band)); \ + HTGOP(layer_##Domain##_spectral_interval_get_##Data##_bounds \ + (&band, tmp)); \ + bounds[0] = MMIN(bounds[0], tmp[0]); \ + bounds[1] = MMAX(bounds[1], tmp[1]); \ + } \ + return RES_OK; \ + } +DEFINE_LAYER_GET_K_BOUNDS(lw, ka) +DEFINE_LAYER_GET_K_BOUNDS(sw, ka) +DEFINE_LAYER_GET_K_BOUNDS(sw, ks) +#undef DEFINE_LAYER_GET_K_BOUNDS + +#define DEFINE_LAYER_SPECTRAL_INTERVAL_GET_K_BOUNDS(Domain, Data) \ + res_T \ + htgop_layer_##Domain##_spectral_interval_get_##Data##_bounds \ + (const struct htgop_layer_##Domain##_spectral_interval* band, \ + double bounds[2]) \ + { \ + size_t i; \ + if(!band || !bounds) return RES_BAD_ARG; \ + bounds[0] = DBL_MAX; \ + bounds[1] =-DBL_MAX; \ + FOR_EACH(i, 0, band->quadrature_length) { \ + struct htgop_layer_##Domain##_spectral_interval_tab tab; \ + double tmp[2]; \ + HTGOP(layer_##Domain##_spectral_interval_get_tab(band, i, &tab)); \ + HTGOP(layer_##Domain##_spectral_interval_tab_get_##Data##_bounds \ + (&tab, tmp)); \ + bounds[0] = MMIN(bounds[0], tmp[0]); \ + bounds[1] = MMAX(bounds[1], tmp[1]); \ + } \ + return RES_OK; \ + } +DEFINE_LAYER_SPECTRAL_INTERVAL_GET_K_BOUNDS(lw, ka) +DEFINE_LAYER_SPECTRAL_INTERVAL_GET_K_BOUNDS(sw, ka) +DEFINE_LAYER_SPECTRAL_INTERVAL_GET_K_BOUNDS(sw, ks) +#undef DEFINE_LAYER_SPECTRAL_INTERVAL_GET_K_BOUNDS + +#define DEFINE_LAYER_SPECTRAL_INTERVAL_TAB_GET_K_BOUNDS(Domain, Data) \ + res_T \ + htgop_layer_##Domain##_spectral_interval_tab_get_##Data##_bounds \ + (const struct htgop_layer_##Domain##_spectral_interval_tab* tab, \ + double bounds[2]) \ + { \ + size_t i; \ + if(!tab || !bounds) return RES_BAD_ARG; \ + bounds[0] = DBL_MAX; \ + bounds[1] =-DBL_MAX; \ + FOR_EACH(i, 0, tab->tab_length) { \ + bounds[0] = MMIN(bounds[0], tab->ka_tab[i]); \ + bounds[1] = MMAX(bounds[1], tab->ka_tab[i]); \ + } \ + return RES_OK; \ + } +DEFINE_LAYER_SPECTRAL_INTERVAL_TAB_GET_K_BOUNDS(lw, ka) +DEFINE_LAYER_SPECTRAL_INTERVAL_TAB_GET_K_BOUNDS(sw, ka) +DEFINE_LAYER_SPECTRAL_INTERVAL_TAB_GET_K_BOUNDS(sw, ks) +#undef DEFINE_LAYER_SPECTRAL_INTERVAL_TAB_GET_K_BOUNDS + /******************************************************************************* * Local functions ******************************************************************************/ diff --git a/src/htgop.h b/src/htgop.h @@ -286,9 +286,57 @@ htgop_sample_sw_spectral_interval_CIE_1931_Z size_t* ispecint); /* Id of the sampled interval */ /******************************************************************************* + * Retrieve the boundaries of the radiative properties + ******************************************************************************/ +HTGOP_API res_T +htgop_layer_get_lw_ka_bounds + (const struct htgop_layer* layer, + double bounds[2]); + +HTGOP_API res_T +htgop_layer_get_sw_ka_bounds + (const struct htgop_layer* layer, + double bounds[2]); + +HTGOP_API res_T +htgop_layer_get_sw_ks_bounds + (const struct htgop_layer* layer, + double bounds[2]); + +HTGOP_API res_T +htgop_layer_lw_spectral_interval_get_ka_bounds + (const struct htgop_layer_lw_spectral_interval* specint, + double bounds[2]); + +HTGOP_API res_T +htgop_layer_sw_spectral_interval_get_ka_bounds + (const struct htgop_layer_sw_spectral_interval* specint, + double bounds[2]); + +HTGOP_API res_T +htgop_layer_sw_spectral_interval_get_ks_bounds + (const struct htgop_layer_sw_spectral_interval* specint, + double bounds[2]); + +HTGOP_API res_T +htgop_layer_lw_spectral_interval_tab_get_ka_bounds + (const struct htgop_layer_lw_spectral_interval_tab* tab, + double bounds[2]); + +HTGOP_API res_T +htgop_layer_sw_spectral_interval_tab_get_ka_bounds + (const struct htgop_layer_sw_spectral_interval_tab* tab, + double bounds[2]); + +HTGOP_API res_T +htgop_layer_sw_spectral_interval_tab_get_ks_bounds + (const struct htgop_layer_sw_spectral_interval_tab* tab, + double bounds[2]); + +/******************************************************************************* * Miscellaneous functions ******************************************************************************/ -/* Return the layer index into which the subimitted a 1D position lies */ +/* Return the layer index into which the submitted a 1D position lies */ HTGOP_API res_T htgop_position_to_layer_id (const struct htgop* htgop, @@ -301,6 +349,7 @@ htgop_spectral_interval_sample_quadrature const double r, /* Canonical random number in [0, 1[ */ size_t* iquad_point); /* Id of the sample quadrature point */ + END_DECLS #endif /* HTGOP */