atrtp

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

commit 024a138098f3b8d3c569d54aca5397002e029c7c
parent 7e626b3632d466b3e89373583b84faf186c9cff5
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Tue, 31 Oct 2023 10:43:20 +0100

Merge branch 'release_0.1'

Diffstat:
M.gitignore | 14+++++++-------
AMakefile | 148+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MREADME.md | 45++++++++++++++++++++++++++-------------------
Aatrtp.5 | 120+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aatrtp.pc.in | 10++++++++++
Dcmake/CMakeLists.txt | 119-------------------------------------------------------------------------------
Aconfig.mk | 77+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ddoc/atrtp.5.scd | 97-------------------------------------------------------------------------------
Amake.sh | 71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/atrtp.c | 2+-
Msrc/atrtp.h | 2+-
Msrc/atrtp_c.h | 2+-
Msrc/atrtp_log.c | 2+-
Msrc/atrtp_log.h | 2+-
Msrc/test_atrtp.c | 2+-
Msrc/test_atrtp_load.c | 2+-
16 files changed, 466 insertions(+), 249 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,12 +1,12 @@ .gitignore -CMakeCache.txt -CMakeFiles -Makefile -tmp [Bb]uild* *.sw[po] -*.[ao] -*.orig +*.[aod] +*.so *~ +test* +!test*.[ch] +.config +.test tags - +*.pc diff --git a/Makefile b/Makefile @@ -0,0 +1,148 @@ +# Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) +# Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique +# +# 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +.POSIX: +.SUFFIXES: # Clean up default inference rules + +include config.mk + +LIBNAME_STATIC = libatrtp.a +LIBNAME_SHARED = libatrtp.so +LIBNAME = $(LIBNAME_$(LIB_TYPE)) + +################################################################################ +# Library building +################################################################################ +SRC = src/atrtp.c src/atrtp_log.c +OBJ = $(SRC:.c=.o) +DEP = $(SRC:.c=.d) + +build_library: .config $(DEP) + @$(MAKE) -fMakefile $$(for i in $(DEP); do echo -f $${i}; done) \ + $$(if [ -n "$(LIBNAME)" ]; then \ + echo "$(LIBNAME)"; \ + else \ + echo "$(LIBNAME_SHARED)"; \ + fi) + +$(DEP) $(OBJ): config.mk + +$(LIBNAME_SHARED): $(OBJ) + $(CC) $(CFLAGS_SO) $(RSYS_CFLAGS) -o $@ $(OBJ) $(LDFLAGS_SO) $(RSYS_LIBS) + +$(LIBNAME_STATIC): libatrtp.o + $(AR) -rc $@ $? + $(RANLIB) $@ + +libatrtp.o: $(OBJ) + $(LD) -r $(OBJ) -o $@ + $(OBJCOPY) $(OCPFLAGS) $@ + +.config: config.mk + @if ! $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys; then \ + echo "rsys $(RSYS_VERSION) not found" >&2; exit 1; fi + @echo "config done" > $@ + +.SUFFIXES: .c .d .o +.c.d: + @$(CC) $(CFLAGS_SO) $(RSYS_CFLAGS) -MM -MT "$(@:.d=.o) $@" $< -MF $@ + +.c.o: + $(CC) $(CFLAGS_SO) $(RSYS_CFLAGS) -DATRTP_SHARED_BUILD -c $< -o $@ + +################################################################################ +# Installation +################################################################################ +pkg: + sed -e 's#@PREFIX@#$(PREFIX)#g'\ + -e 's#@VERSION@#$(VERSION)#g'\ + -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\ + atrtp.pc.in > atrtp.pc + +atrtp-local.pc: atrtp.pc.in + sed -e '1d'\ + -e 's#^includedir=.*#includedir=./src/#'\ + -e 's#^libdir=.*#libdir=./#'\ + -e 's#@VERSION@#$(VERSION)#g'\ + -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\ + atrtp.pc.in > $@ + +install: build_library pkg + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib" $(LIBNAME) + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib/pkgconfig" atrtp.pc + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/include/astoria" src/atrtp.h + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/doc/atrtp" COPYING README.md + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/man/man5" atrtp.5 + +uninstall: + rm -f "$(DESTDIR)$(PREFIX)/lib/$(LIBNAME)" + rm -f "$(DESTDIR)$(PREFIX)/lib/pkgconfig/atrtp.pc" + rm -f "$(DESTDIR)$(PREFIX)/share/doc/atrtp/COPYING" + rm -f "$(DESTDIR)$(PREFIX)/share/doc/atrtp/README.md" + rm -f "$(DESTDIR)$(PREFIX)/include/astoria/atrtp.h" + rm -f "$(DESTDIR)$(PREFIX)/share/man/man5/atrtp.5" + +################################################################################ +# Miscellaneous targets +################################################################################ +all: build_library build_tests + +clean: clean_test + rm -f $(OBJ) $(TEST_OBJ) $(LIBNAME) + rm -f .config .test libatrtp.o atrtp.pc atrtp-local.pc + +distclean: clean + rm -f $(DEP) $(TEST_DEP) + +lint: + shellcheck -o all make.sh + mandoc -Tlint -Wall atrtp.5 + +################################################################################ +# Tests +################################################################################ +TEST_SRC =\ + src/test_atrtp.c\ + src/test_atrtp_load.c +TEST_OBJ = $(TEST_SRC:.c=.o) +TEST_DEP = $(TEST_SRC:.c=.d) + +PKG_CONFIG_LOCAL = PKG_CONFIG_PATH="./:$${PKG_CONFIG_PATH}" $(PKG_CONFIG) +ATRTP_CFLAGS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags atrtp-local.pc) +ATRTP_LIBS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs atrtp-local.pc) + +test: build_tests + @$(SHELL) make.sh run_test $(TEST_SRC) + +build_tests: build_library $(TEST_DEP) .test + @$(MAKE) -fMakefile -f.test $$(for i in $(TEST_DEP); do echo -f"$${i}"; done) test_bin + +.test: Makefile make.sh + @$(SHELL) make.sh config_test $(TEST_SRC) > $@ + +clean_test: + $(SHELL) make.sh clean_test $(TEST_SRC) + rm -f test_file.atrtp + +$(TEST_DEP): config.mk atrtp-local.pc + @$(CC) $(CFLAGS_EXE) $(ATRTP_CFLAGS) $(RSYS_CFLAGS) \ + -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@ + +$(TEST_OBJ): config.mk atrtp-local.pc + $(CC) $(CFLAGS_EXE) $(ATRTP_CFLAGS) $(RSYS_CFLAGS) -c $(@:.o=.c) -o $@ + +test_atrtp test_atrtp_load: config.mk atrtp-local.pc $(LIBNAME) + $(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS_EXE) $(ATRTP_LIBS) $(RSYS_LIBS) diff --git a/README.md b/README.md @@ -1,38 +1,45 @@ # AsToRia: Thermodynamic Properties This C library loads the thermodynamic properties of a gas mixture. +See `atrtp.5` for format specification. -## How to build +## Requirements -This library is compatible GNU/Linux 64-bits. It relies the -[CMake](http://www.cmake.org) and the -[RCMake](https://gitlab.com/vaplv/rcmake/) packages to build. -It also depends on the -[RSys](https://gitlab.com/vaplv/rsys/) library. It optionally depends on -the [AsciiDoc](https://asciidoc.org/) suite of tools; if available, the man -pages of the reference documentation will be generated. +- C compiler +- POSIX make +- pkg-config +- [RSys](https://gitlab.com/vaplv/rsys) +- [mandoc](https://mandoc.bsd.lv) -First ensure that CMake is installed on your system. Then install the RCMake -package as well as the aforementioned prerequisites. Finally generate the -project from the `cmake/CMakeLists.txt` file by appending to the -`CMAKE_PREFIX_PATH` variable the install directories of its dependencies. The -resulting project can be edited, built, tested and installed as any CMake -project. Refer to the [CMake documentation](https://cmake.org/documentation) -for further informations on CMake. +## Installation + +Edit config.mk as needed, then run: + + make clean install ## Release notes +### Version 0.1 + +- Write the man page directly in mdoc's roff macros, instead of using + the scdoc markup language as a source for man pages. +- Replace CMake by Makefile as build system. +- Update compiler and linker flags to increase the security and + robustness of generated binaries. +- Provide a pkg-config file to link the library as an external + dependency. + ### Version 0.0.1 Use scdoc rather than asciidoc as file format for man sources. ## Copyright -Copyright (C) 2022, 2023 [|Méso|Star](http://www.meso-star.com) (<contact@meso-star.com>) +Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique (CNRS) ## License -AtrTP is free software released under the GPL v3+ license: GNU GPL version 3 or -later. You are welcome to redistribute it under certain conditions; refer to -the COPYING file for details. +AtrTP is free software released under the GPL v3+ license: GNU GPL +version 3 or later. You are welcome to redistribute it under certain +conditions; refer to the COPYING file for details. diff --git a/atrtp.5 b/atrtp.5 @@ -0,0 +1,120 @@ +.\" Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) +.\" Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique +.\" +.\" 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 +.\" the Free Software Foundation, either version 3 of the License, or +.\" (at your option) any later version. +.\" +.\" This program is distributed in the hope that it will be useful, +.\" but WITHOUT ANY WARRANTY; without even the implied warranty of +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +.\" GNU General Public License for more details. +.\" +.\" You should have received a copy of the GNU General Public License +.\" along with this program. If not, see <http://www.gnu.org/licenses/>. +.Dd August 30, 2023 +.Dt ATRTP 5 +.Os +.Sh NAME +.Nm atrtp +.Nd AsToRia: Thermodynamic Properties +.Sh DESCRIPTION +.Nm +is a binary file format to store a set of thermodynamic porperties for each +node of a volumetric mesh representing a medium in combustion. +An +.Nm +file begins by a header that describes the data layout followed by a list of +per node properties. +.Pp +The header consist of 2 integers. +The first integer is a power of two +.Pq usually 4096 +that defines the size of the memory page in bytes +.Pq Va pagesize +on which the thermodynamic properties are aligned. +By aligning data to +.Va pagesize , +and depending on system requirements, memory mapping can be used to +automatically load/unload pages on demand +.Pq see Xr mmap 2 . +The other integer stores the number of elements in the list. +In the following, we'll call it +.Va #nodes , +for "number of nodes", in reference to the mesh nodes to which these properties +will be attached. +.Pp +Fill bytes follow the file header to align thermodynamic +properties to +.Va pagesize . +Properties are then listed with 8 double-precision floating-point numbers per +element (i.e. per node). +The data per node are as follows: +.Bl -dash -offset indent -compact +.It +The pressure in Pascal +.It +The temperature in Kelvin +.It +The molar fraction of H2O in mol(H2O)/mol(mixture) +.It +The molar fraction of CO2 in mol(CO2)/mol(mixture) +.It +The molar fraction of CO in mol(CO)/mol(mixture) +.It +The volumic fraction of soot in m^3(soot)/m^3 +.It +The number of soot primary particules per agregate +.It +The soot primary particles diameter in nm +.El +.Pp +Finally, fill bytes are added to align the overall file size to +.Va pagesize . +.Pp +Data are encoded with respect to the little endian bytes ordering, i.e. least +significant bytes are stored first. +.Pp +The file format is as follows: +.Bl -column (thermo-props) (::=) () +.It Ao Va atrtp Ac Ta ::= Ta Ao Va pagesize Ac Ao Va #nodes Ac +.It Ta Ta Aq Va padding +.It Ta Ta Aq Va thermo-props +.It Ta Ta Aq Va padding +.It Ao Va pagesize Ac Ta ::= Ta Vt uint64_t +.It Ao Va #nodes Ac Ta ::= Ta Vt uint64_t +.It \ Ta Ta +.It Ao Va padding Ac Ta ::= Ta Op Vt int8_t ... +# Ensure alignment on +.Va pagesize +.It \ Ta Ta +.It Ao Va thermo-props Ac Ta ::= Ta Ao Va thermo-prop Ac Va ... +.It Ao Va thermo-prop Ac Ta ::= Ta Ao Va pressure Ac +# In Pascal +.It Ta Ta Ao Va temperature Ac +.It Ta Ta Ao Va xH2O Ac # Molar fraction of H2O +.It Ta Ta Ao Va xCO2 Ac # Molar fraction of CO2 +.It Ta Ta Ao Va xCO Ac # Molar fraction of CO +.It Ta Ta Ao Va vf-soot Ac # Volumic fraction of soot +.It Ta Ta Ao Va np-soot Ac # Soot particles per agregate +.It Ta Ta Ao Va dp-soot Ac # Soot particles diameter +.It \ Ta Ta +.It Ao Va pressure Ac Ta ::= Ta Vt double +# In Pascal +.It Ao Va temperature Ac Ta ::= Ta Vt double +# In Kelvin +.It Ao Va xH2O Ac Ta ::= Ta Vt double +# In mol(H2O)/mol(mixture) +.It Ao Va xCO2 Ac Ta ::= Ta Vt double +# In mol(CO2)/mol(mixture) +.It Ao Va xCO Ac Ta ::= Ta Vt double +# In mol(CO)/mol(mixture) +.It Ao Va vf-soot Ac Ta ::= Ta Vt double +# In m^3(soot)/m^3 +.It Ao Va np-soot Ac Ta ::= Ta Vt double +.It Ao Va dp-soot Ac Ta ::= Ta Vt double +# In nm +.El +.Sh SEE ALSO +.Xr mmap 2 diff --git a/atrtp.pc.in b/atrtp.pc.in @@ -0,0 +1,10 @@ +prefix=@PREFIX@ +includedir=${prefix}/include +libdir=${prefix}/lib + +Requires: rsys >= @RSYS_VERSION@ +Name: atrtp +Description: AsToRia Thermodynamic Properties library +Version: @VERSION@ +Libs: -L${libdir} -latrtp +CFlags: -I${includedir} diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -1,119 +0,0 @@ -# Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) -# Copyright (C) 2020, 2021 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 -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -cmake_minimum_required(VERSION 3.1) -project(atrtp C) -enable_testing() - -set(ATRTP_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../src) -option(NO_TEST "Do not build tests" OFF) - -################################################################################ -# Check dependencies -################################################################################ -find_package(RCMake 0.4 REQUIRED) -find_package(RSys 0.10 REQUIRED) - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${RCMAKE_SOURCE_DIR}) -include(rcmake) -include(rcmake_runtime) - -include_directories(${RSys_INCLUDE_DIR}) - -################################################################################ -# Configure and define targets -################################################################################ -set(VERSION_MAJOR 0) -set(VERSION_MINOR 0) -set(VERSION_PATCH 1) -set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) - -set(ATRTP_FILES_SRC - atrtp.c - atrtp_log.c) -set(ATRTP_FILES_INC - atrtp_c.h - atrtp_log.h) -set(ATRTP_FILES_INC_API - atrtp.h) - -set(ATRTP_FILES_DOC COPYING README.md) - -# Prepend each file in the `ATRTP_FILES_<SRC|INC>' list by `ATRTP_SOURCE_DIR' -rcmake_prepend_path(ATRTP_FILES_SRC ${ATRTP_SOURCE_DIR}) -rcmake_prepend_path(ATRTP_FILES_INC ${ATRTP_SOURCE_DIR}) -rcmake_prepend_path(ATRTP_FILES_INC_API ${ATRTP_SOURCE_DIR}) -rcmake_prepend_path(ATRTP_FILES_DOC ${PROJECT_SOURCE_DIR}/../) - -add_library(atrtp SHARED ${ATRTP_FILES_SRC} ${ATRTP_FILES_INC} ${ATRTP_FILES_INC_API}) -target_link_libraries(atrtp RSys) - -set_target_properties(atrtp PROPERTIES - DEFINE_SYMBOL ATRTP_SHARED_BUILD - VERSION ${VERSION} - SOVERSION ${VERSION_MAJOR}) - -rcmake_setup_devel(atrtp AtrTP ${VERSION} astoria/atrtp_version.h) - -################################################################################ -# Add tests -################################################################################ -if(NOT NO_TEST) - function(build_test _name) - add_executable(${_name} ${ATRTP_SOURCE_DIR}/${_name}.c) - target_link_libraries(${_name} atrtp RSys ${ARGN}) - endfunction() - - function(new_test _name) - build_test(${_name} ${ARGN}) - add_test(${_name} ${_name}) - endfunction() - - new_test(test_atrtp) - new_test(test_atrtp_load) -endif() - -################################################################################ -# Man page -############################################################################### -find_program(SCDOC NAMES scdoc) -if(NOT SCDOC) - message(WARNING - "The `scdoc' program is missing. " - "The Astoria Thermodynamic Properties man page cannot be generated.") -else() - set(_src ${PROJECT_SOURCE_DIR}/../doc/atrtp.5.scd) - add_custom_command( - OUTPUT atrtp.5 - COMMAND ${SCDOC} < ${_src} > atrtp.5 - DEPENDS ${_src} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Buid ROFF man page atrtp.5" - VERBATIM) - add_custom_target(man-roff ALL DEPENDS atrtp.5) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/atrtp.5 DESTINATION share/man/man5) -endif() - -################################################################################ -# Define output & install directories -################################################################################ -install(TARGETS atrtp - ARCHIVE DESTINATION bin - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) -install(FILES ${ATRTP_FILES_INC_API} DESTINATION include/astoria) -install(FILES ${ATRTP_FILES_DOC} DESTINATION share/doc/atrtp) - diff --git a/config.mk b/config.mk @@ -0,0 +1,77 @@ +VERSION = 0.1.0 +PREFIX = /usr/local + +LIB_TYPE = SHARED +#LIB_TYPE = STATIC + +BUILD_TYPE = RELEASE +#BUILD_TYPE = DEBUG + +################################################################################ +# Tools +################################################################################ +AR = ar +CC = cc +LD = ld +OBJCOPY = objcopy +PKG_CONFIG = pkg-config +RANLIB = ranlib + +################################################################################ +# Dependencies +################################################################################ +PCFLAGS_SHARED = +PCFLAGS_STATIC = --static +PCFLAGS = $(PCFLAGS_$(LIB_TYPE)) + +RSYS_VERSION = 0.14 +RSYS_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags rsys) +RSYS_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs rsys) + +################################################################################ +# Compilation options +################################################################################ +WFLAGS =\ + -Wall\ + -Wcast-align\ + -Wconversion\ + -Wextra\ + -Wmissing-declarations\ + -Wmissing-prototypes\ + -Wshadow + +CFLAGS_HARDENED =\ + -D_FORTIFY_SOURCES=2\ + -fcf-protection=full\ + -fstack-clash-protection\ + -fstack-protector-strong + +CFLAGS_COMMON =\ + -std=c89\ + -pedantic\ + -fvisibility=hidden\ + -fstrict-aliasing\ + $(CFLAGS_HARDENED)\ + $(WFLAGS) + +CFLAGS_DEBUG = -g $(CFLAGS_COMMON) +CFLAGS_RELEASE = -O2 -DNDEBUG $(CFLAGS_COMMON) +CFLAGS = $(CFLAGS_$(BUILD_TYPE)) + +CFLAGS_SO = $(CFLAGS) -fPIC +CFLAGS_EXE = $(CFLAGS) -fPIE + +################################################################################ +# Linker options +################################################################################ +LDFLAGS_HARDENED = -Wl,-z,relro,-z,now +LDFLAGS_DEBUG = $(LDFLAGS_HARDENED) +LDFLAGS_RELEASE = -s $(LDFLAGS_HARDENED) +LDFLAGS = $(LDFLAGS_$(BUILD_TYPE)) + +LDFLAGS_SO = $(LDFLAGS) -shared -Wl,--no-undefined +LDFLAGS_EXE = $(LDFLAGS) -pie + +OCPFLAGS_DEBUG = --localize-hidden +OCPFLAGS_RELEASE = --localize-hidden --strip-unneeded +OCPFLAGS = $(OCPFLAGS_$(BUILD_TYPE)) diff --git a/doc/atrtp.5.scd b/doc/atrtp.5.scd @@ -1,97 +0,0 @@ -atrtp(5) - -; Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) -; Copyright (C) 2020, 2021 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 -; the Free Software Foundation, either version 3 of the License, or -; (at your option) any later version. -; -; This program is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with this program. If not, see <http://www.gnu.org/licenses/>. - -# NAME - -atrtp - AsToRia: Thermodynamic Properties - -# DESCRIPTION - -*atrtp* is a binary file format to store a set of thermodynamic porperties for -each node a volumetric mesh representing a medium in combustion. An *atrtp* -file begins by a header that describes the data layout followed by a list of -per node properties. - -The header is made up of 2 64-bit integers. The first integer is a power of -two (usually 4096) that defines the _<pagesize>_ in bytes to which the -thermodynamic properties are aligned. The remaining integer store the number -of items in the list. In the following grammar, we name it _<#nodes>_, for -"number of nodes", in reference to the mesh nodes to which these properties -would be attached. - -Note that by aligning the thermodynamic data to _<pagesize>_, and depending on -the system requirements, memory mapping can be used to automatically -load/unload those data on demand (see for example the POSIX C function -*mmap*(2)). - -Padding bytes follow the file header to ensure alignment of the thermodynamic -properties to _<pagesize>_. These properties are then listed with 8 double -precision floating point numbers per item (i.e. per node). The set of per node -data are: - -- The pressure in Pascal -- The temperature in Kelvin -- The molar fraction of H20 in mol(H20)/mol(mixture) -- The molar fraction of CO2 in mol(CO2)/mol(mixture) -- The molar fraction of CO in mol(CO)/mol(mixture) -- The volumic fraction of soot in m^3(soot)/m^3 -- The number of soot primary particules per agregate -- The soot primary particles diameter in nm - -Finally, additional padding bytes are added after the listed properties to -align the overall file size to _<pagesize>_. - -# BINARY FILE FORMAT - -Data are encoded with respect to the little endian bytes ordering, i.e. least -significant bytes are stored first. - -``` -<atrtp> ::= <pagesize> <#nodes> - <padding> - <thermo-props> - <padding> - -<pagesize> ::= INT64 -<#cells> ::= INT64 -<padding> ::= [ BYTE ... ] - -<thermo-props> ::= <thermo-prop> - [ <thermo-prop ... ] -<therm-prop> ::= <pressure> - <temperature> - <xH2O> - <xCO2> - <xCO> - <vf-soot> - <np-soot> - <dp-soot> - -<pressure> ::= <double> # Pressure in Pa -<temperature> ::= <double> # Temperature in K -<xH2O> ::= <double> # Molar fraction of H2O in mol(H2O)/mol(mixture) -<xCO2> ::= <double> # Molar fraction of CO2 in mol(CO2)/mol(mixture) -<xCO> ::= <double> # Molar fraction of CO in mol(CO)/mol(mixture) -<vf-soot> ::= <double> # Volumic fraction of soot in m^3(soot)/ m^3 -<np-soot> ::= <double> # Number of primary particles per agregate -<dp-soot> ::= <double> # Primary particles diameter in nm -``` - -# SEE ALSO - -*mmap*(2) diff --git a/make.sh b/make.sh @@ -0,0 +1,71 @@ +#!/bin/sh + +# Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) +# Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique +# +# 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +set -e + +config_test() +{ + for i in "$@"; do + test=$(basename "${i}" ".c") + test_list="${test_list} ${test}" + printf "%s: %s\n" "${test}" "src/${test}.o" + done + printf "test_bin: %s\n" "${test_list}" +} + +run_test() +{ + for i in "$@"; do + test=$(basename "${i}" ".c") + + printf "%s " "${test}" + if "./${test}" > /dev/null 2>&1; then + printf "\033[1;32mOK\033[m\n" + else + printf "\033[1;31mError\033[m\n" + fi + done 2> /dev/null +} + +clean_test() +{ + for i in "$@"; do + rm -f "$(basename "${i}" ".c")" + done +} + +install() +{ + prefix=$1 + shift 1 + + mkdir -p "${prefix}" + + for i in "$@"; do + dst="${prefix}/${i##*/}" + + if cmp -s "${i}" "${dst}"; then + printf "Up to date %s\n" "${dst}" + else + printf "Installing %s\n" "${dst}" + cp "${i}" "${prefix}" + fi + done +} + +"$@" diff --git a/src/atrtp.c b/src/atrtp.c @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * 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/src/atrtp.h b/src/atrtp.h @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * 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/src/atrtp_c.h b/src/atrtp_c.h @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * 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/src/atrtp_log.c b/src/atrtp_log.c @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * 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/src/atrtp_log.h b/src/atrtp_log.h @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * 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/src/test_atrtp.c b/src/test_atrtp.c @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * 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/src/test_atrtp_load.c b/src/test_atrtp_load.c @@ -1,5 +1,5 @@ /* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2020, 2021 CNRS + * Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique * * 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