rnatm

Load and structure data describing an atmosphere
git clone git://git.meso-star.fr/rnatm.git
Log | Files | Refs | README | LICENSE

commit e759a3c0e7a87efdf7afff64d9fab421d0d2dc3a
parent 8496db0d322e0a291c69b3ee12f9101c0d61b7cb
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu, 17 Nov 2022 11:20:42 +0100

Implement the rnatm_fetch_cell_list function

Diffstat:
Msrc/rnatm.h | 2+-
Msrc/rnatm_mesh.c | 37+++++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/src/rnatm.h b/src/rnatm.h @@ -317,7 +317,7 @@ rnatm_fetch_cell_list * the stack or on the heap) an array whose capacity is * RNATM_MAX_COMPONENTS_COUNT */ struct rnatm_cell_pos* cells, - size_t* ncells); /* Total number of atmospheric components */ + size_t* ncells); /* Total number of atmospheric components. May be NULL */ RNATM_API res_T rnatm_cell_get_radcoef diff --git a/src/rnatm_mesh.c b/src/rnatm_mesh.c @@ -175,6 +175,43 @@ error: goto exit; } +res_T +rnatm_fetch_cell_list + (const struct rnatm* atm, + const double pos[3], + struct rnatm_cell_pos* cells, + size_t* ncells) +{ + size_t cpnt = RNATM_GAS; + size_t naerosols = 0; + size_t i = 0; + res_T res = RES_OK; + + if(!atm || !pos || !cells) { + res = RES_BAD_ARG; + goto error; + } + + naerosols = darray_aerosol_size_get(&atm->aerosols); + ASSERT(naerosols+1/*gas*/ < RNATM_MAX_COMPONENTS_COUNT); + + do { + res = rnatm_fetch_cell(atm, pos, cpnt, cells+i); + if(res != RES_OK) goto error; + + ++i; + + } while(++cpnt < naerosols); + ASSERT(i == naerosols+1); + + if(ncells) *ncells = naerosols + 1; + +exit: + return res; +error: + goto exit; +} + /******************************************************************************* * Local functions ******************************************************************************/