atrtp

Thermodynamic properties of a medium in combustion
git clone git://git.meso-star.fr/atrtp.git
Log | Files | Refs | README | LICENSE

commit dd6e4a6192cacf70f232a97a5429e15a26bdc7cd
parent 9ffc360d5ffda40dc821f3a8b90e60196a566b04
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu, 29 Oct 2020 11:46:31 +0100

Rename the "nodes" in "cells"

Diffstat:
Mcmake/CMakeLists.txt | 2+-
Mdoc/atrtp | 4++--
Msrc/atrtp.c | 8++++----
Msrc/atrtp.h | 8++++----
Msrc/atrtp_c.h | 2+-
Msrc/test_atrtp_load.c | 42+++++++++++++++++++++---------------------
6 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) CNRS +# Copyright (C) 2020 CNRS # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/doc/atrtp b/doc/atrtp @@ -1,10 +1,10 @@ -<atrtp> ::= <pagesize> <#nodes> +<atrtp> ::= <pagesize> <#cells> <padding> <thermo-props> <padding> <pagesize> ::= INT64 -<#nodes> ::= INT64 +<#cells> ::= INT64 <padding> ::= [ BYTE ... ] <thermo-props> ::= <thermo-prop> diff --git a/src/atrtp.c b/src/atrtp.c @@ -34,7 +34,7 @@ reset_atrtp(struct atrtp* atrtp) { ASSERT(atrtp); atrtp->pagesize = 0; - atrtp->nnodes = 0; + atrtp->ncells = 0; if(atrtp->props) munmap(atrtp->props, atrtp->map_len); atrtp->props = NULL; atrtp->map_len = 0; @@ -59,7 +59,7 @@ load_stream(struct atrtp* atrtp, FILE* stream, const char* stream_name) } \ } (void)0 READ(&atrtp->pagesize, 1, "page size"); - READ(&atrtp->nnodes, 1, "number of nodes"); + READ(&atrtp->ncells, 1, "number of cells"); #undef READ if(!IS_ALIGNED(atrtp->pagesize, atrtp->pagesize_os)) { @@ -72,7 +72,7 @@ load_stream(struct atrtp* atrtp, FILE* stream, const char* stream_name) } /* Compute the length in bytes of the data to map */ - atrtp->map_len = atrtp->nnodes * sizeof(double[ATRTP_COUNT__]); + atrtp->map_len = atrtp->ncells * sizeof(double[ATRTP_COUNT__]); atrtp->map_len = ALIGN_SIZE(atrtp->map_len, (size_t)atrtp->pagesize); /* Find the offsets of the positions/indices data into the stream */ @@ -233,7 +233,7 @@ atrtp_get_desc(const struct atrtp* atrtp, struct atrtp_desc* desc) { if(!atrtp || !desc) return RES_BAD_ARG; desc->properties = atrtp->props; - desc->nnodes = (size_t)atrtp->nnodes; + desc->ncells = (size_t)atrtp->ncells; return RES_OK; } diff --git a/src/atrtp.h b/src/atrtp.h @@ -49,7 +49,7 @@ enum atrtp_type { struct atrtp_desc { const double* properties; /* List of double[ATRTP_COUNT__] */ - size_t nnodes; + size_t ncells; }; static const struct atrtp_desc ATRTP_DESC_NULL; @@ -99,10 +99,10 @@ atrtp_get_desc static INLINE const double* atrtp_desc_get_node_properties (const struct atrtp_desc* desc, - const size_t inode) + const size_t icell) { - ASSERT(desc && inode < desc->nnodes); - return desc->properties + inode*ATRTP_COUNT__; + ASSERT(desc && icell < desc->ncells); + return desc->properties + icell*ATRTP_COUNT__; } END_DECLS diff --git a/src/atrtp_c.h b/src/atrtp_c.h @@ -23,7 +23,7 @@ struct mem_allocator; struct atrtp { uint64_t pagesize; - uint64_t nnodes; + uint64_t ncells; double* props; size_t map_len; diff --git a/src/test_atrtp_load.c b/src/test_atrtp_load.c @@ -24,16 +24,16 @@ static void check_atrtp_desc (const struct atrtp_desc* desc, - const uint64_t nnodes) + const uint64_t ncells) { - size_t inode; + size_t icell; CHK(desc); - CHK(nnodes); + CHK(ncells); - CHK(desc->nnodes == nnodes); - FOR_EACH(inode, 0, nnodes) { + CHK(desc->ncells == ncells); + FOR_EACH(icell, 0, ncells) { size_t iprop; - const double* props = atrtp_desc_get_node_properties(desc, inode); + const double* props = atrtp_desc_get_node_properties(desc, icell); CHK(props); FOR_EACH(iprop, 0, ATRTP_COUNT__) { CHK(props[iprop] == (double)(10+iprop)); @@ -48,7 +48,7 @@ test_load(struct atrtp* atrtp) FILE* fp = NULL; const char* filename = "test_file.atrtp"; const uint64_t pagesize = 16384; - const uint64_t nnodes = 192; + const uint64_t ncells = 192; size_t i; char byte = 0; @@ -57,13 +57,13 @@ test_load(struct atrtp* atrtp) /* Write the header */ CHK(fwrite(&pagesize, sizeof(pagesize), 1, fp) == 1); - CHK(fwrite(&nnodes, sizeof(nnodes), 1, fp) == 1); + CHK(fwrite(&ncells, sizeof(ncells), 1, fp) == 1); /* Padding */ CHK(fseek(fp, (long)ALIGN_SIZE((size_t)ftell(fp), pagesize), SEEK_SET) == 0); /* Write nodes data */ - FOR_EACH(i, 0, nnodes) { + FOR_EACH(i, 0, ncells) { double props[ATRTP_COUNT__]; int iprop; CHK(ATRTP_COUNT__ < 10); @@ -89,14 +89,14 @@ test_load(struct atrtp* atrtp) rewind(fp); CHK(atrtp_load_stream(atrtp, fp, filename) == RES_OK); CHK(atrtp_get_desc(atrtp, &desc) == RES_OK); - check_atrtp_desc(&desc, nnodes); + check_atrtp_desc(&desc, ncells); CHK(atrtp_load(NULL, filename) == RES_BAD_ARG); CHK(atrtp_load(atrtp, NULL) == RES_BAD_ARG); CHK(atrtp_load(atrtp, "nop") == RES_IO_ERR); CHK(atrtp_load(atrtp, filename) == RES_OK); CHK(atrtp_get_desc(atrtp, &desc) == RES_OK); - check_atrtp_desc(&desc, nnodes); + check_atrtp_desc(&desc, ncells); fclose(fp); } @@ -107,7 +107,7 @@ test_load_fail(struct atrtp* atrtp) const char byte = 1; FILE* fp = NULL; uint64_t pagesize; - uint64_t nnodes; + uint64_t ncells; CHK(atrtp); @@ -115,11 +115,11 @@ test_load_fail(struct atrtp* atrtp) fp = tmpfile(); CHK(fp); pagesize = 4097; - nnodes = 10; + ncells = 10; CHK(fwrite(&pagesize, sizeof(pagesize), 1, fp) == 1); - CHK(fwrite(&nnodes, sizeof(nnodes), 1, fp) == 1); + CHK(fwrite(&ncells, sizeof(ncells), 1, fp) == 1); CHK(fseek(fp, (long)ALIGN_SIZE((size_t)ftell(fp), pagesize), SEEK_SET) == 0); - CHK(fseek(fp, (long)(sizeof(double[ATRTP_COUNT__])*nnodes), SEEK_CUR) == 0); + CHK(fseek(fp, (long)(sizeof(double[ATRTP_COUNT__])*ncells), SEEK_CUR) == 0); CHK(fseek(fp, (long)ALIGN_SIZE((size_t)ftell(fp), pagesize)-1, SEEK_SET) == 0); CHK(fwrite(&byte, sizeof(byte), 1, fp) == 1); /* Positioned the EOF */ rewind(fp); @@ -130,11 +130,11 @@ test_load_fail(struct atrtp* atrtp) fp = tmpfile(); CHK(fp); pagesize = (uint64_t)sysconf(_SC_PAGESIZE); - nnodes = 10; + ncells = 10; CHK(fwrite(&pagesize, sizeof(pagesize), 1, fp) == 1); - CHK(fwrite(&nnodes, sizeof(nnodes), 1, fp) == 1); + CHK(fwrite(&ncells, sizeof(ncells), 1, fp) == 1); CHK(fseek(fp, (long)ALIGN_SIZE((size_t)ftell(fp), pagesize), SEEK_SET) == 0); - CHK(fseek(fp, (long)(sizeof(double[ATRTP_COUNT__])*nnodes), SEEK_CUR) == 0); + CHK(fseek(fp, (long)(sizeof(double[ATRTP_COUNT__])*ncells), SEEK_CUR) == 0); CHK(fseek(fp, (long)ALIGN_SIZE((size_t)ftell(fp), pagesize)-2, SEEK_SET) == 0); CHK(fwrite(&byte, sizeof(byte), 1, fp) == 1); /* Positioned the EOF */ @@ -150,14 +150,14 @@ test_load_files(struct atrtp* atrtp, int argc, char** argv) CHK(atrtp); FOR_EACH(i, 1, argc) { struct atrtp_desc desc = ATRTP_DESC_NULL; - size_t inode; + size_t icell; printf("Load %s\n", argv[1]); CHK(atrtp_load(atrtp, argv[i]) == RES_OK); CHK(atrtp_get_desc(atrtp, &desc) == RES_OK); - FOR_EACH(inode, 0, desc.nnodes) { - const double* props = atrtp_desc_get_node_properties(&desc, inode); + FOR_EACH(icell, 0, desc.ncells) { + const double* props = atrtp_desc_get_node_properties(&desc, icell); size_t iprop; FOR_EACH(iprop, 0, ATRTP_COUNT__) { CHK(props[iprop] == props[iprop]); /* !NaN */