atrstm

Load and structure a combustion gas mixture
git clone git://git.meso-star.fr/atrstm.git
Log | Files | Refs | README | LICENSE

commit 6abeb5f1b03f8db60bf58bd213c91ca4a7a44a25
parent e86e8da52a10ecb4239e884e0d90edd1a5c074a2
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Fri, 15 Jan 2021 13:42:39 +0100

Add the internal dump_optprops function

Diffstat:
Msrc/atrstm_optprops.c | 85+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/atrstm_optprops.h | 7+++++++
2 files changed, 92 insertions(+), 0 deletions(-)

diff --git a/src/atrstm_optprops.c b/src/atrstm_optprops.c @@ -14,6 +14,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "atrstm_c.h" +#include "atrstm_log.h" #include "atrstm_optprops.h" #include <astoria/atrri.h> @@ -72,3 +73,87 @@ exit: error: goto exit; } + +res_T +dump_optprops + (const struct atrstm* atrstm, + const struct atrri_refractive_index* refract_id, + FILE* stream) +{ + struct optprops_compute_args args = OPTPROPS_COMPUTE_ARGS_NULL; + struct atrtp_desc desc = ATRTP_DESC_NULL; + struct optprops props_min; + struct optprops props_max; + size_t inode; + + res_T res = RES_OK; + ASSERT(atrstm && stream); + + res = atrtp_get_desc(atrstm->atrtp, &desc); + if(res != RES_OK) goto error; + + /* Setup the constant input params of the optical properties computation */ + args.lambda = refract_id->wavelength; + args.n = refract_id->n; + args.kappa = refract_id->kappa; + args.gyration_radius_prefactor = atrstm->gyration_radius_prefactor; + args.fractal_dimension = atrstm->fractal_dimension; + + props_min.ka = DBL_MAX; + props_max.ka =-DBL_MAX; + props_min.ks = DBL_MAX; + props_max.ks =-DBL_MAX; + props_min.kext = DBL_MAX; + props_max.kext =-DBL_MAX; + + #define FPRINTF(Text, Args) { \ + const int n = fprintf(stream, Text COMMA_##Args LIST_##Args); \ + if(n < 0) { \ + log_err(atrstm, "Error writing optical properties.\n"); \ + res = RES_IO_ERR; \ + goto error; \ + } \ + } (void)0 + + FPRINTF("# Ka Ks Kext\n", ARG0()); + + FOR_EACH(inode, 0, desc.nnodes) { + struct optprops props; + const double* node; + + /* Fetch the thermodynamic properties of the node */ + node = atrtp_desc_get_node_properties(&desc, inode); + + /* Setup the per node input args of the optical properties computation */ + args.soot_volumic_fraction = + node[ATRTP_SOOT_VOLFRAC]; + args.soot_primary_particles_count = + node[ATRTP_SOOT_PRIMARY_PARTICLES_COUNT]; + args.soot_primary_particles_diameter = + node[ATRTP_SOOT_PRIMARY_PARTICLES_DIAMETER]; + + /* Compute the node optical properties */ + optprops_compute(&props, &args); + + FPRINTF("%g %g %g\n", ARG3(props.ka, props.ks, props.kext)); + + props_min.ka = MMIN(props_min.ka, props.ka); + props_max.ka = MMAX(props_max.ka, props.ka); + props_min.ks = MMIN(props_min.ks, props.ks); + props_max.ks = MMAX(props_max.ks, props.ks); + props_min.kext = MMIN(props_min.kext, props.kext); + props_max.kext = MMAX(props_max.kext, props.kext); + + } + + FPRINTF("# Bounds = [%g %g %g], [%g, %g, %g]\n", ARG6 + (props_min.ka, props_min.ks, props_min.kext, + props_max.ka, props_max.ks, props_max.kext)); + + #undef FPRINTF + +exit: + return res; +error: + goto exit; +} diff --git a/src/atrstm_optprops.h b/src/atrstm_optprops.h @@ -54,6 +54,13 @@ primitive_compute_optprops const struct suvm_primitive* prim, struct optprops optprops[]); /* Per primitive node optical properties */ +/* Write per node optical properties regarding the submitted refracted index */ +extern LOCAL_SYM res_T +dump_optprops + (const struct atrstm* atrstm, + const struct atrri_refractive_index* refract_id, + FILE* stream); + static INLINE res_T primitive_compute_optprops_range (const struct atrstm* atrstm,