commit fd89ed39c48a441f035fedf1754007b38d4c1cd3
parent a2289484f1fd7d069aa9f797bc534466a6848fd9
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Fri, 22 Jul 2022 12:27:04 +0200
Checks that the aerosols are included in the gas
Diffstat:
1 file changed, 30 insertions(+), 0 deletions(-)
diff --git a/src/rnatm_mesh.c b/src/rnatm_mesh.c
@@ -127,6 +127,8 @@ error:
res_T
setup_meshes(struct rnatm* atm, const struct rnatm_create_args* args)
{
+ double gas_low[3];
+ double gas_upp[3];
struct suvm_device* suvm = NULL;
struct smsh_create_args smsh_args = SMSH_CREATE_ARGS_DEFAULT;
struct smsh* smsh = NULL;
@@ -149,14 +151,42 @@ setup_meshes(struct rnatm* atm, const struct rnatm_create_args* args)
res = setup_uvm(atm, args, args->gas.smsh_filename, suvm, smsh,
&atm->gas.volume, &atm->gas.ntetrahedra, &atm->gas.nvertices);
if(res != RES_OK) goto error;
+ res = suvm_volume_get_aabb(atm->gas.volume, gas_low, gas_upp);
+ if(res != RES_OK) goto error;
/* Load and structure aerosol volumetric meshes */
FOR_EACH(i, 0, args->naerosols) {
+ double aerosol_low[3];
+ double aerosol_upp[3];
struct aerosol* aerosol = darray_aerosol_data_get(&atm->aerosols)+i;
const char* filename = args->aerosols[i].smsh_filename;
+
+ /* Load and structure the aerosol mesh */
res = setup_uvm(atm, args, filename, suvm, smsh, &aerosol->volume,
&aerosol->ntetrahedra, &aerosol->nvertices);
if(res != RES_OK) goto error;
+ res = suvm_volume_get_aabb(aerosol->volume, aerosol_low, aerosol_upp);
+ if(res != RES_OK) goto error;
+
+ /* Check that the aerosol is included in the gas */
+ if(gas_low[0] > aerosol_low[0]
+ || gas_low[1] > aerosol_low[1]
+ || gas_low[2] > aerosol_low[2]
+ || gas_upp[0] < aerosol_upp[0]
+ || gas_upp[1] < aerosol_upp[1]
+ || gas_upp[2] < aerosol_upp[2]) {
+ log_err(atm,
+ "The aerosol %lu may not be included in the gas "
+ "(gas AABB: {%g, %g, %g} - {%g, %g, %g}; "
+ "aerosol AABB: {%g, %g, %g} - {%g, %g, %g})\n",
+ (unsigned long)i,
+ SPLIT3(gas_low),
+ SPLIT3(gas_upp),
+ SPLIT3(aerosol_low),
+ SPLIT3(aerosol_upp));
+ res = RES_BAD_ARG;
+ goto error;
+ }
}
exit: