commit 00a9259698486399b75ce42878b5feef6b7a2c6f
parent 37a24a4f3c675e20c7f0f5c4bee4061aa6e74d62
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Fri, 9 Feb 2024 15:50:03 +0100
Refactor the analysis of a probe at a boundary
This commit breaks the support of the probe calculation on a border.
This is a first step to add the support of the calculation of several
probes on a boundary on a single invocation of stardis that will
distribute the calculation of probes and not the realisations of each
probe calculation. The probes will be submitted in an input file with
each line following the same grammar as the option used to define a
single probe. This commit refactor the code to prepare the analysis of
this file.
To simplify the code, the input arguments of a probe on a boundary are
now stored in their own data structure. In the near future, the same
will apply to all calculation modes. Sharing some variables and not
others is a source of confusion and does not give any specific advantage
(memory space does not limit here). That is why the calculation of the
probe on a border is broken by this commit: the probe data are stored
elsewhere and the calculation code still does not manage this update.
Note that a probe has a side indicator, which can be a medium name. This
indicator must not exceed a specific length fixed in hard by Stardis.
This constant is currently defined in the stardis-green-type header and
reported in man pages. In order to set it to a single location, we have
added a new Makefile configuration macro used to define the C
STANDARDIS_MAX_NAME_LENGTH macro in the stardis-args header. This same
variable is used to configure manual pages and Green type header files.
Diffstat:
10 files changed, 668 insertions(+), 544 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -5,9 +5,11 @@
*~
tags
.config
+src/stardis-args.h
src/stardis-default.h
src/stardis-green-types.h
src/stardis-prog-properties.h
src/stardis-version.h
stardis
doc/stardis.1
+doc/stardis-input.5
diff --git a/Makefile b/Makefile
@@ -55,6 +55,7 @@ SRC =\
# Headers to configure
HDR=\
+ src/stardis-args.h\
src/stardis-default.h\
src/stardis-green-types.h\
src/stardis-prog-properties.h\
@@ -110,6 +111,10 @@ src/stardis-default.h: config.mk src/stardis-default.h.in
-e 's/@STARDIS_ARGS_DEFAULT_VERBOSE_LEVEL@/$(STARDIS_ARGS_DEFAULT_VERBOSE_LEVEL)/' \
$@.in > $@
+src/stardis-args.h: config.mk src/stardis-args.h.in
+ sed -e 's/@STARDIS_MAX_NAME_LENGTH@/$(STARDIS_MAX_NAME_LENGTH)/' \
+ $@.in > $@
+
src/stardis-version.h: config.mk src/stardis-version.h.in
sed -e 's/@STARDIS_APP_VERSION_MAJOR@/$(VERSION_MAJOR)/' \
-e 's/@STARDIS_APP_VERSION_MINOR@/$(VERSION_MINOR)/' \
@@ -118,6 +123,7 @@ src/stardis-version.h: config.mk src/stardis-version.h.in
src/stardis-green-types.h: config.mk src/stardis-green-types.h.in
sed -e 's/@STARDIS_GREEN_TYPES_VERSION@/$(GREEN_TYPES_VERSION)/' \
+ -e "s/@STARDIS_MAX_NAME_LENGTH@/$$(($(STARDIS_MAX_NAME_LENGTH)-1))/" \
$@.in > $@
src/stardis-prog-properties.h: config.mk src/stardis-prog-properties.h.in
@@ -135,7 +141,7 @@ src/stardis-prog-properties.h: config.mk src/stardis-prog-properties.h.in
################################################################################
# Man pages
################################################################################
-man: doc/stardis.1
+man: doc/stardis.1 doc/stardis-input.5
doc/stardis.1: doc/stardis.1.in
sed -e 's/@STARDIS_ARGS_DEFAULT_COMPUTE_TIME@/$(STARDIS_ARGS_DEFAULT_COMPUTE_TIME)/' \
@@ -154,6 +160,10 @@ doc/stardis.1: doc/stardis.1.in
-e 's/@STARDIS_ARGS_DEFAULT_VERBOSE_LEVEL@/$(STARDIS_ARGS_DEFAULT_VERBOSE_LEVEL)/' \
$@.in > $@
+doc/stardis-input.5: doc/stardis-input.5.in
+ sed -e "s/@STARDIS_MAX_NAME_LENGTH@/$$(($(STARDIS_MAX_NAME_LENGTH)-1))/" \
+ $@.in > $@
+
################################################################################
# Installation
################################################################################
@@ -180,7 +190,7 @@ uninstall:
# Miscellaneous targets
################################################################################
clean:
- rm -f $(HDR) $(OBJ) .config stardis doc/stardis.1
+ rm -f $(HDR) $(OBJ) .config stardis doc/stardis.1 doc/stardis-input.5
distclean: clean
rm -f $(DEP)
diff --git a/config.mk b/config.mk
@@ -42,6 +42,9 @@ STARDIS_ARGS_DEFAULT_SAMPLES_COUNT = 10000
STARDIS_ARGS_DEFAULT_SCALE_FACTOR = 1
STARDIS_ARGS_DEFAULT_VERBOSE_LEVEL = 1
+# Including NULL char
+STARDIS_MAX_NAME_LENGTH = 64
+
################################################################################
# Tools
################################################################################
diff --git a/doc/stardis-input.5 b/doc/stardis-input.5
@@ -1,363 +0,0 @@
-.\" Copyright (C) 2018-2023 |Méso|Star>
-.\"
-.\" 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 January 31, 2024
-.Dt STARDIS-INPUT 5
-.Os
-.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-.\" Name and short description
-.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-.Sh NAME
-.Nm stardis-input
-.Nd thermal system description for
-.Xr stardis 1
-.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-.\" Detailed description
-.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-.Sh DESCRIPTION
-.Nm
-is the format used by the
-.Xr stardis 1
-program to describe a thermal system.
-It is a line-by-line ASCII syntax.
-.Pp
-A thermal system is composed of lines of text, each one describing
-either a program
-.Pq an user-provided shared object ,
-a medium frontier
-.Pq solid or fluid ,
-a boundary condition, a connection between two media, the scale of the
-whole geometry, or the radiative temperature around the system.
-In the medium, boundary and connection cases, description lines include
-a list of file names that constitute the limit, boundary or connection.
-.Xr stardis 1
-only accepts triangle mesh geometry files in STL format.
-If a scale is specified, it defines the scaling factor to apply to the
-geometry to have it expressed in meters
-.Pq e.g. 1e-3 if the geometry is in mm .
-.Pp
-Any physical quantity involved in descriptions is expected in the
-International System of Units
-.Pq second, meter, kilogram, kelvin, watt, joule .
-However, the geometry provided to
-.Xr stardis 1
-can be described in any unit, multiple of meters or not, as long as the
-scaling factor is provided.
-.Pp
-Properties are defined directly as constants in the input file.
-Several properties can also be defined by programs, i.e. shared objects
-provided by the user
-.Pq compiled libraries .
-The latter allow user-defined variable properties to be supplied to
-.Xr stardis 1 .
-Depending on the type of description they use, programs must
-export a given list of mandatory functions.
-They can also export some other optional functions.
-The exact list with names and types can be found in the public header
-.Pa stardis-prog.h ,
-which is installed together with
-.Xr stardis 1
-binary.
-.Pp
-A medium limit, a boundary or a connection description can be split
-across files and a single file or description line can describe more
-than one frontier
-.Pq more than one connex region .
-The main semantic constraint on descriptions is that enclosures must be
-defined by a single description line, to ensure that every constitutive
-part of the system is made from a single medium.
-.Pp
-Description lines can be submitted to
-.Xr stardis 1
-in any order, with the exception of programs that must be
-defined before use, and can be split across more than one file, through
-multiple use of option
-.Fl M .
-.Pp
-When a description line is parsed, the first step is to split it in
-different parts.
-.Xr stardis 1
-relies on the
-.Xr wordexp 3
-POSIX function for this step.
-As a consequence the rules that apply at this stage all come from
-the wordexp rules: environment variables can be used and are
-substituted, including inside arithmetic expressions, text inside quote
-pairs is considered a single item, whitespace characters can be escaped
-so that the current item continues past it
-.Po see
-.Xr wordexp 3
-for details
-.Pc .
-Note however that both the use of undefined environment variables and
-the use of command substitution will be reported as an error as these
-features are not enabled in
-.Xr stardis 1 .
-.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-.\" Grammar in Backus-Naur form
-.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-.Sh GRAMMAR
-In what follows, some lines end with a backslash
-.Pq Li \e .
-This is used as a convenience to continue a description next line.
-However, this trick cannot be used in actual description files and
-actual description lines must be kept single-line.
-Text introduced by the sharp character
-.Pq Li #
-in descriptions is a comment and is not part of the description.
-.Pp
-The file format is as follows:
-.Bl -column (description-line) (::) ()
-.It Ao Va thermal-system Ac Ta ::= Ta Ao Va description-line Ac
-.It Ta Ta ...
-.It Ao Va description-line Ac Ta ::= Ta Ao Va comment Ac
-.It Ta \& \& | Ta Ao Va program Ac Op Ao Va comment Ac
-.It Ta \& \& | Ta Ao Va medium Ac Op Ao Va comment Ac
-.It Ta \& \& | Ta Ao Va connection Ac Op Ao Va comment Ac
-.It Ta \& \& | Ta Ao Va boundary-condition Ac Op Ao Va comment Ac
-.It Ta \& \& | Ta Ao Va scaling Ac Op Ao Va comment Ac
-# At most once
-.It Ta \& \& | Ta Ao Va rad-temps Ac Op Ao Va comment Ac
-# At most once
-.It \ Ta Ta
-.It Ao Va comment Ac Ta ::= Ta Li # Vt string
-.It Ao Va program Ac Ta ::= Ta Li PROGRAM Ao Va prog-name Ac Ao Va lib-path Ac Op Ao Va args Ac
-.It Ao Va scaling Ac Ta ::= Ta Li SCALE Vt real
-# Geometry scaling in ]0, INF)
-.It \ Ta Ta
-.It Ao Va rad-temps Ac Ta ::= Ta Li TRAD Ao Va temp Ac Ao Va Tref Ac
-# Radiative temperatures
-.It Ao Va temp Ac Ta ::= Ta Vt real No # Temperature > 0 [K]
-.It Ao Va Tref Ac Ta ::= Ta Vt real No # Reference temperature > 0 [K]
-.El
-.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-.Ss Media
-.Bl -column (description-line) (::) ()
-.It Ao Va medium Ac Ta ::= Ta Ao Va fluid Ac | Ao Va solid Ac
-.It \ Ta Ta
-.It Ao Va fluid Ac Ta ::= Ta Ao Va fluid-const Ac | Ao Va fluid-prog Ac
-.It Ao Va fluid-const Ac Ta ::= Ta
-.Li FLUID Ao Va medium-name Ac Ao Va rho Ac Ao Va cp Ac \e
-.It Ta Ta Ao Va initial-temp Ac Ao Va imposed-temp Ac \e
-.It Ta Ta Ao Va triangle-sides Ac ...
-.It Ao Va fluid-prog Ac Ta ::= Ta Li FLUID_PROG Ao Va medium-name Ac Ao Va prog-desc Ac
-.It \ Ta Ta
-.It Ao Va solid Ac Ta ::= Ta Ao Va solid-const Ac | Ao Va solid-prog Ac
-.It Ao Va solid-const Ac Ta ::= Ta
-.Li SOLID Ao Va medium-name Ac Ao Va lambda Ac Ao Va rho Ac Ao Va cp Ac \e
-.It Ta Ta Ao Va initial-temp Ac Ao Va imposed-temp Ac \e
-.It Ta Ta Ao Va volumic-power Ac Ao Va triangle-sides Ac No ...
-.It Ao Va solid-prog Ac Ta ::= Ta Li SOLID_PROG Ao Va medium-name Ac Ao Va prog-desc Ac
-.It \ Ta Ta
-.It Ao Va lambda Ac Ta ::= Ta Vt real No # Conductivity > 0 [W/m/K]
-.It Ao Va rho Ac Ta ::= Ta Vt real No # Volumic mass > 0 [kg/m^3]
-.It Ao Va cp Ac Ta ::= Ta Vt real No # Capacity > 0 [J/K/kg]
-.It Ao Va volumic-power Ac Ta ::= Ta Vt real No # [W/m^3]
-.El
-.Pp
-Delta is the numerical parameter that defines the length of a conductive
-random walk step.
-The user can define it manually or let Stardis calculate it
-automatically from the volume of the solid.
-In the latter case, delta is set to V/(6*A), V and A being the solid's
-volume and surface respectively:
-.Bl -column (description-line) (::) ()
-.It Ao Va delta Ac Ta ::= Ta Li AUTO | Vt real
-.El
-.Pp
-Media's descriptions, either solids or fluids, include two possible
-temperatures: initial and imposed.
-If imposed temperature is set
-.Pq that is not Li UNKNOWN ,
-initial temperature must be defined at the same value.
-In other words, one cannot define a medium with an imposed temperature
-that changes at
-.Li t= Ns Ar 0 :
-.Bl -column (description-line) (::) ()
-.It Ao Va initial-temp Ac Ta ::= Ta Vt real No # Temperature > 0 [K]
-.It Ao Va imposed-temp Ac Ta ::= Ta Li UNKNOWN No # Temperature has to be solved
-.It Ta \& \& | Ta Vt real No # Temperature > 0 [K]
-.El
-.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-.Ss Connection
-.Bl -column (description-line) (::) ()
-.It Ao Va connection Ac Ta ::= Ta Ao Va solid-fluid Ac | Ao Va solid-solid Ac
-.It \ Ta Ta
-.It Ao Va solid-fluid Ac Ta ::= Ta Ao Va solid-fluid-const Ac | Ao Va solid-fluid-prog Ac
-.It Ao Va solid-fluid-const Ac Ta ::= Ta Li SOLID_FLUID_CONNECTION Ao Va connect-name Ac \e
-.It Ta Ta Ao Va Tref Ac Ao Va emissivity Ac Ao Va specular-fraction Ac \e
-.It Ta Ta Ao Va hc Ac Ao Va triangles Ac ...
-.It Ao Va solid-fluid-prog Ac Ta ::= Ta Li SOLID_FLUID_CONNECTION_PROG \e
-.It Ta Ta Ao Va connect-name Ac Ao Va prog-desc Ac
-.It \ Ta Ta
-.It Ao Va solid-solid Ac Ta ::= Ta Ao Va solid-solid-const Ac | Ao Va solid-solid-prog Ac
-.It Ao Va solid-solid-const Ac Ta ::= Ta Li SOLID_SOLID_CONNECTION Ao Va connect-name Ac \e
-.It Ta Ta Ao Va contact-resistance Ac Ao Va triangles Ac ...
-.It Ao Va solid-solid-prog Ac Ta ::= Ta Li SOLID_SOLID_CONNECTION_PROG \e
-.It Ta Ta Ao Va connect-name Ac Ao Va prog-desc Ac
-.It \ Ta Ta
-.It Ao Va emissivity Ac Ta ::= Ta Vt real No # \&In [0,1]
-.It Ao Va specular-fraction Ac Ta ::= Ta Vt real No # \&In [0,1]
-.It Ao Va hc Ac Ta ::= Ta Vt real No # Convective coefficient > 0 [W/m^2/K]
-.It Ao Va contact-resistance Ac Ta ::= Ta Vt real No # > 0 [K/m^-2/W]
-.El
-.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-.Ss Boundary conditions
-.Bl -column (description-line) (::) ()
-.It Ao Va boundary-condition Ac Ta ::= Ta
-.Aq Va dirichlet
-.It Ta \& \& | Ta Aq Va robin
-.It Ta \& \& | Ta Aq Va neumann
-.It Ta \& \& | Ta Aq Va robin-neumann
-.It \ Ta Ta
-.\" Dirichlet
-.It Ao Va dirichlet Ac Ta ::= Ta Ao Va dirichlet-const Ac | Ao Va dirichlet-prog Ac
-.It Ao Va dirichlet-const Ac Ta ::= Ta Li T_BOUNDARY_FOR_SOLID Ao Va bound-name Ac \e
-.It Ta Ta Ao Va temp Ac Ao Va triangles Ac ...
-.It Ao Va dirichlet-prog Ac Ta ::= Ta Li T_BOUNDARY_FOR_SOLID_PROG Ao Va bound-name Ac \e
-.It Ta Ta Ao Va prog-desc Ac
-.It \ Ta Ta
-.\" Robin
-.It Ao Va robin Ac Ta ::= Ta Ao Va robin-fluid Ac | Ao Va robin-solid Ac
-.It Ao Va robin-fluid Ac Ta ::= Ta Ao Va robin-fluid-const Ac | Ao Va robin-fluid-prog Ac
-.It Ao Va robin-solid Ac Ta ::= Ta Ao Va robin-solid-const Ac | Ao Va robin-solid-prog Ac
-.It Ao Va robin-fluid-const Ac Ta ::= Ta Li H_BOUNDARY_FOR_FLUID Ao Va bound-name Ac \e
-.It Ta Ta Ao Va robin-const-desc Ac
-.It Ao Va robin-solid-const Ac Ta ::= Ta Li H_BOUNDARY_FOR_SOLID Ao Va bound-name Ac \e
-.It Ta Ta Ao Va robin-const-desc Ac
-.It Ao Va robin-const-desc Ac Ta ::= Ta Ao Va Tref Ac Ao Va emissivity Ac Ao Va specular-fraction Ac
-.It Ta Ta Ao Va hc Ac Ao Va outside-temp Ac Ao Va triangles Ac ...
-.It Ao Va robin-fluid-prog Ac Ta ::= Ta Li H_BOUNDARY_FOR_FLUID_PROG Ao Va bound-name Ac \e
-.It Ta Ta Ao Va prog-desc Ac
-.It Ao Va robin-solid-prog Ac Ta ::= Ta Li H_BOUNDARY_FOR_SOLID_PROG Ao Va bound-name Ac \e
-.It Ta Ta Ao Va prog-desc Ac
-.It \ Ta Ta
-.\" Neumann
-.It Ao Va neumann Ac Ta ::= Ta Ao Va neumann-const Ac | Ao Va neumann-prog Ac
-.It Ao Va neumann-const Ac Ta ::= Ta Li F_BOUNDARY_FOR_SOLID Ao Va bound-name Ac \e
-.It Ta Ta Ao Va flux Ac Ao Va triangles Ac ...
-.It Ao Va neumann-prog Ac Ta ::= Ta Li F_BOUNDARY_FOR_SOLID_PROG Ao Va bound-name Ac \e
-.It Ta Ta Ao Va prog-desc Ac
-.It \ Ta Ta
-.\" Robin & Neumann
-.It Ao Va robin-neumann Ac Ta ::= Ta Ao Va robin-neumann-const Ac
-.It Ta \& \& | Ta Ao Va robin-neumann-prog Ac
-.It Ao Va robin-neumann-const Ac Ta ::= Ta Li HF_BOUNDARY_FOR_SOLID Ao Va bound-name Ac \e
-.It Ta Ta Ao Va Tref Ac Ao Va emissivity Ac Ao Va specular-fraction Ac \e
-.It Ta Ta Ao Va hc Ac Ao Va outside-temp Ac Ao Va flux Ac Ao Va triangles Ac ...
-.It Ao Va robin-neumann-prog Ac Ta ::= Ta Li HF_BOUNDARY_FOR_SOLID_PROG Ao Va bound-name Ac \e
-.It Ta Ta Ao Va prog-desc Ac
-.It \ Ta Ta
-.It Ao Va flux Ac Ta ::= Ta Vt real No # [W/m^2]
-.It Ao Va outside-temp Ac Ta ::= Ta Vt real No # Temperature > 0 [K]
-.El
-.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-.Ss Miscellaneous
-Names, either file names or description names
-.Pq boundary names, medium names, program names, or connection names ,
-are a sequence of one or more ASCII characters, including
-numbers and special characters like
-.Ql \&. ,
-.Ql _ ,
-or
-.Ql -
-as one may consider using in standard file names.
-Description names are case-sensitive and two different description
-lines, either in the same description file or from different description
-files, cannot use the same name.
-Additionally, description names cannot a number, nor be one of the
-keywords defined by the present grammar and their lowercase
-counterparts.
-Finally, description names cannot be longer than 63 characters.
-.Bl -column (description-line) (::) ()
-.It Ao Va bound-name Ac Ta ::= Ta Vt string
-.It Ao Va medium-name Ac Ta ::= Ta Vt string
-.It Ao Va prog-name Ac Ta ::= Ta Vt string
-.It Ao Va connect-name Ac Ta ::= Ta Vt string
-.It \ Ta Ta
-.It Ao Va stl-path Ac Ta ::= Ta Pa path
-.It Ao Va lib-path Ac Ta ::= Ta Pa path
-.It \ Ta Ta
-.It Ao Va args Ac Ta ::= Ta Vt string No ...
-.It Ao Va prog-desc Ac Ta ::= Ta Ao Va prog-name Ac Ao Va triangle-sides Ac ... \e
-.It Ta Ta Op Li PROG_PARAMS Op Ao Va args Ac
-.It \ Ta Ta
-.It Ao Va triangle-sides Ac Ta ::= Ta Ao Va side-specifier Ac Ao Va triangles Ac
-.It Ao Va triangles Ac Ta ::= Ta Ao Va stl-path Ac
-.El
-.Pp
-Side descriptions in side specifiers rely on the following convention:
-we first consider the direct triangle's normal (right-hand rule), then
-we define the
-.Li BACK
-side of a triangle to be the side this normal comes out from.
-That means that a closed set of triangles with normals pointing outside
-should be used with the
-.Li FRONT
-side specifier to describe inside medium:
-.Bl -column (description-line) (::) ()
-.It Ao Va side-specifier Ac Ta ::= Ta Li FRONT | Li BACK | Li BOTH
-.El
-.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-.\" File examples
-.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-.Sh EXAMPLES
-Define a system consisting of a solid cube named
-.Ql Cube 1 ,
-with a Robin-type boundary condition and radiative exchange with the
-environment.
-The cube geometry is read from the file
-.Pa cube.stl
-and the solid medium properties are
-.No lambda= Ns Ar 0.1 No W/m/K ,
-.No rho= Ns Ar 25 No kg/m^3 ,
-.No cp= Ns Ar 2 No J/K/kg .
-The numerical parameter delta, that is used for solid conductive walks, is
-.Ar 0.05 .
-The initial temperature of the cube is
-.Ar 0 No K , its temperature is unknown
-.Pq it has to be solved ,
-and its volumic power is
-.Ar 2.5 No W/m^3 .
-The boundary properties are
-.No emissivity= Ns Ar 0 ,
-.No specular-fraction= Ns Ar 0,
-.No hc= Ns Ar 10 No W/m^2/K
-and
-.No external-temperature= Ns Ar 100 No K .
-The radiative environment is at
-.Ar 300 No K .
-Finally, the linearization of radiative transfer involving Robin's
-boundary condition uses
-.Ar 310 No K
-as reference temperature and is set to
-.Ar 330 No K
-when linearisation involves the radiative environment:
-.Bd -literal -offset Ds
-SOLID Cube\ 1 0.1 25 2 0.05 0 UNKNOWN 2.5 FRONT cube.stl
-H_BOUNDARY_FOR_SOLID HdT 310 0 0 10 100 cube.stl
-TRAD 300 330
-.Ed
-.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-.\" External references
-.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-.Sh SEE ALSO
-.Xr stardis 1 ,
-.Xr wordexp 3
-.Rs
-.%T The StL Format: Standard Data Format for Fabbers
-.%A Marshall Burns
-.%D 1993
-.%U https://www.fabbers.com/tech/STL_Format
-.Re
diff --git a/doc/stardis-input.5.in b/doc/stardis-input.5.in
@@ -0,0 +1,364 @@
+.\" Copyright (C) 2018-2023 |Méso|Star>
+.\"
+.\" 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 January 31, 2024
+.Dt STARDIS-INPUT 5
+.Os
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.\" Name and short description
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh NAME
+.Nm stardis-input
+.Nd thermal system description for
+.Xr stardis 1
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.\" Detailed description
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh DESCRIPTION
+.Nm
+is the format used by the
+.Xr stardis 1
+program to describe a thermal system.
+It is a line-by-line ASCII syntax.
+.Pp
+A thermal system is composed of lines of text, each one describing
+either a program
+.Pq an user-provided shared object ,
+a medium frontier
+.Pq solid or fluid ,
+a boundary condition, a connection between two media, the scale of the
+whole geometry, or the radiative temperature around the system.
+In the medium, boundary and connection cases, description lines include
+a list of file names that constitute the limit, boundary or connection.
+.Xr stardis 1
+only accepts triangle mesh geometry files in STL format.
+If a scale is specified, it defines the scaling factor to apply to the
+geometry to have it expressed in meters
+.Pq e.g. 1e-3 if the geometry is in mm .
+.Pp
+Any physical quantity involved in descriptions is expected in the
+International System of Units
+.Pq second, meter, kilogram, kelvin, watt, joule .
+However, the geometry provided to
+.Xr stardis 1
+can be described in any unit, multiple of meters or not, as long as the
+scaling factor is provided.
+.Pp
+Properties are defined directly as constants in the input file.
+Several properties can also be defined by programs, i.e. shared objects
+provided by the user
+.Pq compiled libraries .
+The latter allow user-defined variable properties to be supplied to
+.Xr stardis 1 .
+Depending on the type of description they use, programs must
+export a given list of mandatory functions.
+They can also export some other optional functions.
+The exact list with names and types can be found in the public header
+.Pa stardis-prog.h ,
+which is installed together with
+.Xr stardis 1
+binary.
+.Pp
+A medium limit, a boundary or a connection description can be split
+across files and a single file or description line can describe more
+than one frontier
+.Pq more than one connex region .
+The main semantic constraint on descriptions is that enclosures must be
+defined by a single description line, to ensure that every constitutive
+part of the system is made from a single medium.
+.Pp
+Description lines can be submitted to
+.Xr stardis 1
+in any order, with the exception of programs that must be
+defined before use, and can be split across more than one file, through
+multiple use of option
+.Fl M .
+.Pp
+When a description line is parsed, the first step is to split it in
+different parts.
+.Xr stardis 1
+relies on the
+.Xr wordexp 3
+POSIX function for this step.
+As a consequence the rules that apply at this stage all come from
+the wordexp rules: environment variables can be used and are
+substituted, including inside arithmetic expressions, text inside quote
+pairs is considered a single item, whitespace characters can be escaped
+so that the current item continues past it
+.Po see
+.Xr wordexp 3
+for details
+.Pc .
+Note however that both the use of undefined environment variables and
+the use of command substitution will be reported as an error as these
+features are not enabled in
+.Xr stardis 1 .
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.\" Grammar in Backus-Naur form
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh GRAMMAR
+In what follows, some lines end with a backslash
+.Pq Li \e .
+This is used as a convenience to continue a description next line.
+However, this trick cannot be used in actual description files and
+actual description lines must be kept single-line.
+Text introduced by the sharp character
+.Pq Li #
+in descriptions is a comment and is not part of the description.
+.Pp
+The file format is as follows:
+.Bl -column (description-line) (::) ()
+.It Ao Va thermal-system Ac Ta ::= Ta Ao Va description-line Ac
+.It Ta Ta ...
+.It Ao Va description-line Ac Ta ::= Ta Ao Va comment Ac
+.It Ta \& \& | Ta Ao Va program Ac Op Ao Va comment Ac
+.It Ta \& \& | Ta Ao Va medium Ac Op Ao Va comment Ac
+.It Ta \& \& | Ta Ao Va connection Ac Op Ao Va comment Ac
+.It Ta \& \& | Ta Ao Va boundary-condition Ac Op Ao Va comment Ac
+.It Ta \& \& | Ta Ao Va scaling Ac Op Ao Va comment Ac
+# At most once
+.It Ta \& \& | Ta Ao Va rad-temps Ac Op Ao Va comment Ac
+# At most once
+.It \ Ta Ta
+.It Ao Va comment Ac Ta ::= Ta Li # Vt string
+.It Ao Va program Ac Ta ::= Ta Li PROGRAM Ao Va prog-name Ac Ao Va lib-path Ac Op Ao Va args Ac
+.It Ao Va scaling Ac Ta ::= Ta Li SCALE Vt real
+# Geometry scaling in ]0, INF)
+.It \ Ta Ta
+.It Ao Va rad-temps Ac Ta ::= Ta Li TRAD Ao Va temp Ac Ao Va Tref Ac
+# Radiative temperatures
+.It Ao Va temp Ac Ta ::= Ta Vt real No # Temperature > 0 [K]
+.It Ao Va Tref Ac Ta ::= Ta Vt real No # Reference temperature > 0 [K]
+.El
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Ss Media
+.Bl -column (description-line) (::) ()
+.It Ao Va medium Ac Ta ::= Ta Ao Va fluid Ac | Ao Va solid Ac
+.It \ Ta Ta
+.It Ao Va fluid Ac Ta ::= Ta Ao Va fluid-const Ac | Ao Va fluid-prog Ac
+.It Ao Va fluid-const Ac Ta ::= Ta
+.Li FLUID Ao Va medium-name Ac Ao Va rho Ac Ao Va cp Ac \e
+.It Ta Ta Ao Va initial-temp Ac Ao Va imposed-temp Ac \e
+.It Ta Ta Ao Va triangle-sides Ac ...
+.It Ao Va fluid-prog Ac Ta ::= Ta Li FLUID_PROG Ao Va medium-name Ac Ao Va prog-desc Ac
+.It \ Ta Ta
+.It Ao Va solid Ac Ta ::= Ta Ao Va solid-const Ac | Ao Va solid-prog Ac
+.It Ao Va solid-const Ac Ta ::= Ta
+.Li SOLID Ao Va medium-name Ac Ao Va lambda Ac Ao Va rho Ac Ao Va cp Ac \e
+.It Ta Ta Ao Va initial-temp Ac Ao Va imposed-temp Ac \e
+.It Ta Ta Ao Va volumic-power Ac Ao Va triangle-sides Ac No ...
+.It Ao Va solid-prog Ac Ta ::= Ta Li SOLID_PROG Ao Va medium-name Ac Ao Va prog-desc Ac
+.It \ Ta Ta
+.It Ao Va lambda Ac Ta ::= Ta Vt real No # Conductivity > 0 [W/m/K]
+.It Ao Va rho Ac Ta ::= Ta Vt real No # Volumic mass > 0 [kg/m^3]
+.It Ao Va cp Ac Ta ::= Ta Vt real No # Capacity > 0 [J/K/kg]
+.It Ao Va volumic-power Ac Ta ::= Ta Vt real No # [W/m^3]
+.El
+.Pp
+Delta is the numerical parameter that defines the length of a conductive
+random walk step.
+The user can define it manually or let Stardis calculate it
+automatically from the volume of the solid.
+In the latter case, delta is set to V/(6*A), V and A being the solid's
+volume and surface respectively:
+.Bl -column (description-line) (::) ()
+.It Ao Va delta Ac Ta ::= Ta Li AUTO | Vt real
+.El
+.Pp
+Media's descriptions, either solids or fluids, include two possible
+temperatures: initial and imposed.
+If imposed temperature is set
+.Pq that is not Li UNKNOWN ,
+initial temperature must be defined at the same value.
+In other words, one cannot define a medium with an imposed temperature
+that changes at
+.Li t= Ns Ar 0 :
+.Bl -column (description-line) (::) ()
+.It Ao Va initial-temp Ac Ta ::= Ta Vt real No # Temperature > 0 [K]
+.It Ao Va imposed-temp Ac Ta ::= Ta Li UNKNOWN No # Temperature has to be solved
+.It Ta \& \& | Ta Vt real No # Temperature > 0 [K]
+.El
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Ss Connection
+.Bl -column (description-line) (::) ()
+.It Ao Va connection Ac Ta ::= Ta Ao Va solid-fluid Ac | Ao Va solid-solid Ac
+.It \ Ta Ta
+.It Ao Va solid-fluid Ac Ta ::= Ta Ao Va solid-fluid-const Ac | Ao Va solid-fluid-prog Ac
+.It Ao Va solid-fluid-const Ac Ta ::= Ta Li SOLID_FLUID_CONNECTION Ao Va connect-name Ac \e
+.It Ta Ta Ao Va Tref Ac Ao Va emissivity Ac Ao Va specular-fraction Ac \e
+.It Ta Ta Ao Va hc Ac Ao Va triangles Ac ...
+.It Ao Va solid-fluid-prog Ac Ta ::= Ta Li SOLID_FLUID_CONNECTION_PROG \e
+.It Ta Ta Ao Va connect-name Ac Ao Va prog-desc Ac
+.It \ Ta Ta
+.It Ao Va solid-solid Ac Ta ::= Ta Ao Va solid-solid-const Ac | Ao Va solid-solid-prog Ac
+.It Ao Va solid-solid-const Ac Ta ::= Ta Li SOLID_SOLID_CONNECTION Ao Va connect-name Ac \e
+.It Ta Ta Ao Va contact-resistance Ac Ao Va triangles Ac ...
+.It Ao Va solid-solid-prog Ac Ta ::= Ta Li SOLID_SOLID_CONNECTION_PROG \e
+.It Ta Ta Ao Va connect-name Ac Ao Va prog-desc Ac
+.It \ Ta Ta
+.It Ao Va emissivity Ac Ta ::= Ta Vt real No # \&In [0,1]
+.It Ao Va specular-fraction Ac Ta ::= Ta Vt real No # \&In [0,1]
+.It Ao Va hc Ac Ta ::= Ta Vt real No # Convective coefficient > 0 [W/m^2/K]
+.It Ao Va contact-resistance Ac Ta ::= Ta Vt real No # > 0 [K/m^-2/W]
+.El
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Ss Boundary conditions
+.Bl -column (description-line) (::) ()
+.It Ao Va boundary-condition Ac Ta ::= Ta
+.Aq Va dirichlet
+.It Ta \& \& | Ta Aq Va robin
+.It Ta \& \& | Ta Aq Va neumann
+.It Ta \& \& | Ta Aq Va robin-neumann
+.It \ Ta Ta
+.\" Dirichlet
+.It Ao Va dirichlet Ac Ta ::= Ta Ao Va dirichlet-const Ac | Ao Va dirichlet-prog Ac
+.It Ao Va dirichlet-const Ac Ta ::= Ta Li T_BOUNDARY_FOR_SOLID Ao Va bound-name Ac \e
+.It Ta Ta Ao Va temp Ac Ao Va triangles Ac ...
+.It Ao Va dirichlet-prog Ac Ta ::= Ta Li T_BOUNDARY_FOR_SOLID_PROG Ao Va bound-name Ac \e
+.It Ta Ta Ao Va prog-desc Ac
+.It \ Ta Ta
+.\" Robin
+.It Ao Va robin Ac Ta ::= Ta Ao Va robin-fluid Ac | Ao Va robin-solid Ac
+.It Ao Va robin-fluid Ac Ta ::= Ta Ao Va robin-fluid-const Ac | Ao Va robin-fluid-prog Ac
+.It Ao Va robin-solid Ac Ta ::= Ta Ao Va robin-solid-const Ac | Ao Va robin-solid-prog Ac
+.It Ao Va robin-fluid-const Ac Ta ::= Ta Li H_BOUNDARY_FOR_FLUID Ao Va bound-name Ac \e
+.It Ta Ta Ao Va robin-const-desc Ac
+.It Ao Va robin-solid-const Ac Ta ::= Ta Li H_BOUNDARY_FOR_SOLID Ao Va bound-name Ac \e
+.It Ta Ta Ao Va robin-const-desc Ac
+.It Ao Va robin-const-desc Ac Ta ::= Ta Ao Va Tref Ac Ao Va emissivity Ac Ao Va specular-fraction Ac
+.It Ta Ta Ao Va hc Ac Ao Va outside-temp Ac Ao Va triangles Ac ...
+.It Ao Va robin-fluid-prog Ac Ta ::= Ta Li H_BOUNDARY_FOR_FLUID_PROG Ao Va bound-name Ac \e
+.It Ta Ta Ao Va prog-desc Ac
+.It Ao Va robin-solid-prog Ac Ta ::= Ta Li H_BOUNDARY_FOR_SOLID_PROG Ao Va bound-name Ac \e
+.It Ta Ta Ao Va prog-desc Ac
+.It \ Ta Ta
+.\" Neumann
+.It Ao Va neumann Ac Ta ::= Ta Ao Va neumann-const Ac | Ao Va neumann-prog Ac
+.It Ao Va neumann-const Ac Ta ::= Ta Li F_BOUNDARY_FOR_SOLID Ao Va bound-name Ac \e
+.It Ta Ta Ao Va flux Ac Ao Va triangles Ac ...
+.It Ao Va neumann-prog Ac Ta ::= Ta Li F_BOUNDARY_FOR_SOLID_PROG Ao Va bound-name Ac \e
+.It Ta Ta Ao Va prog-desc Ac
+.It \ Ta Ta
+.\" Robin & Neumann
+.It Ao Va robin-neumann Ac Ta ::= Ta Ao Va robin-neumann-const Ac
+.It Ta \& \& | Ta Ao Va robin-neumann-prog Ac
+.It Ao Va robin-neumann-const Ac Ta ::= Ta Li HF_BOUNDARY_FOR_SOLID Ao Va bound-name Ac \e
+.It Ta Ta Ao Va Tref Ac Ao Va emissivity Ac Ao Va specular-fraction Ac \e
+.It Ta Ta Ao Va hc Ac Ao Va outside-temp Ac Ao Va flux Ac Ao Va triangles Ac ...
+.It Ao Va robin-neumann-prog Ac Ta ::= Ta Li HF_BOUNDARY_FOR_SOLID_PROG Ao Va bound-name Ac \e
+.It Ta Ta Ao Va prog-desc Ac
+.It \ Ta Ta
+.It Ao Va flux Ac Ta ::= Ta Vt real No # [W/m^2]
+.It Ao Va outside-temp Ac Ta ::= Ta Vt real No # Temperature > 0 [K]
+.El
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Ss Miscellaneous
+Names, either file names or description names
+.Pq boundary names, medium names, program names, or connection names ,
+are a sequence of one or more ASCII characters, including
+numbers and special characters like
+.Ql \&. ,
+.Ql _ ,
+or
+.Ql -
+as one may consider using in standard file names.
+Description names are case-sensitive and two different description
+lines, either in the same description file or from different description
+files, cannot use the same name.
+Additionally, description names cannot a number, nor be one of the
+keywords defined by the present grammar and their lowercase
+counterparts.
+Finally, description names cannot be longer than
+@STARDIS_MAX_NAME_LENGTH@ characters.
+.Bl -column (description-line) (::) ()
+.It Ao Va bound-name Ac Ta ::= Ta Vt string
+.It Ao Va medium-name Ac Ta ::= Ta Vt string
+.It Ao Va prog-name Ac Ta ::= Ta Vt string
+.It Ao Va connect-name Ac Ta ::= Ta Vt string
+.It \ Ta Ta
+.It Ao Va stl-path Ac Ta ::= Ta Pa path
+.It Ao Va lib-path Ac Ta ::= Ta Pa path
+.It \ Ta Ta
+.It Ao Va args Ac Ta ::= Ta Vt string No ...
+.It Ao Va prog-desc Ac Ta ::= Ta Ao Va prog-name Ac Ao Va triangle-sides Ac ... \e
+.It Ta Ta Op Li PROG_PARAMS Op Ao Va args Ac
+.It \ Ta Ta
+.It Ao Va triangle-sides Ac Ta ::= Ta Ao Va side-specifier Ac Ao Va triangles Ac
+.It Ao Va triangles Ac Ta ::= Ta Ao Va stl-path Ac
+.El
+.Pp
+Side descriptions in side specifiers rely on the following convention:
+we first consider the direct triangle's normal (right-hand rule), then
+we define the
+.Li BACK
+side of a triangle to be the side this normal comes out from.
+That means that a closed set of triangles with normals pointing outside
+should be used with the
+.Li FRONT
+side specifier to describe inside medium:
+.Bl -column (description-line) (::) ()
+.It Ao Va side-specifier Ac Ta ::= Ta Li FRONT | Li BACK | Li BOTH
+.El
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.\" File examples
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh EXAMPLES
+Define a system consisting of a solid cube named
+.Ql Cube 1 ,
+with a Robin-type boundary condition and radiative exchange with the
+environment.
+The cube geometry is read from the file
+.Pa cube.stl
+and the solid medium properties are
+.No lambda= Ns Ar 0.1 No W/m/K ,
+.No rho= Ns Ar 25 No kg/m^3 ,
+.No cp= Ns Ar 2 No J/K/kg .
+The numerical parameter delta, that is used for solid conductive walks, is
+.Ar 0.05 .
+The initial temperature of the cube is
+.Ar 0 No K , its temperature is unknown
+.Pq it has to be solved ,
+and its volumic power is
+.Ar 2.5 No W/m^3 .
+The boundary properties are
+.No emissivity= Ns Ar 0 ,
+.No specular-fraction= Ns Ar 0,
+.No hc= Ns Ar 10 No W/m^2/K
+and
+.No external-temperature= Ns Ar 100 No K .
+The radiative environment is at
+.Ar 300 No K .
+Finally, the linearization of radiative transfer involving Robin's
+boundary condition uses
+.Ar 310 No K
+as reference temperature and is set to
+.Ar 330 No K
+when linearisation involves the radiative environment:
+.Bd -literal -offset Ds
+SOLID Cube\ 1 0.1 25 2 0.05 0 UNKNOWN 2.5 FRONT cube.stl
+H_BOUNDARY_FOR_SOLID HdT 310 0 0 10 100 cube.stl
+TRAD 300 330
+.Ed
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.\" External references
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh SEE ALSO
+.Xr stardis 1 ,
+.Xr wordexp 3
+.Rs
+.%T The StL Format: Standard Data Format for Fabbers
+.%A Marshall Burns
+.%D 1993
+.%U https://www.fabbers.com/tech/STL_Format
+.Re
diff --git a/src/stardis-args.c b/src/stardis-args.c
@@ -102,8 +102,7 @@ split_line
}
static char
-mode_option
- (const int m)
+mode_option(const int m)
{
int found = 0;
char res = '?';
@@ -152,6 +151,123 @@ print_multiple_modes
} while(m < modes);
}
+static res_T
+parse_position_and_time(const char* str, double pos[3], double time[2])
+{
+ char buf[128];
+ double pos_and_time[5];
+ size_t len;
+ res_T res = RES_OK;
+ ASSERT(str && pos && time);
+
+
+ if(strlen(str) >= sizeof(buf)-1/*NULL char*/) {
+ fprintf(stderr,
+ "Could not duplicate the string defining a position and, optionally, "
+ "a time range `%s'\n", str);
+ res = RES_MEM_ERR;
+ goto error;
+ }
+ strncpy(buf, str, sizeof(buf));
+
+ res = cstr_to_list_double(str, ',', pos_and_time, &len, 5);
+ if(res != RES_OK
+ || len < 3 /* Invalid position */
+ || len > 5 /* Too many fields */) {
+ fprintf(stderr,
+ "Error parsing position and optional time range `%s'\n", str);
+ res = RES_BAD_ARG;
+ goto error;
+ }
+
+ pos[0] = pos_and_time[0];
+ pos[1] = pos_and_time[1];
+ pos[2] = pos_and_time[2];
+
+ switch(len) {
+ /* No time was parsed => Steady state */
+ case 3:
+ time[0] = INF;
+ time[1] = INF;
+ break;
+ /* A single time was parsed => the time range is degenerated */
+ case 4:
+ time[0] = pos_and_time[3];
+ time[1] = pos_and_time[3];
+ break;
+ /* A time range was parsed and must be not degenerated */
+ case 5:
+ time[0] = pos_and_time[3];
+ time[1] = pos_and_time[4];
+ if(time[0] > time[1]) {
+ fprintf(stderr, "Invalid time range [%g, %g}\n", time[0], time[1]);
+ res = RES_BAD_ARG;
+ goto error;
+ }
+ break;
+ default: FATAL("Unreachable code\n"); break;
+ }
+
+exit:
+ return res;
+error:
+ goto exit;
+}
+
+static res_T
+parse_side_indicator(const char* str, char side_name[STARDIS_MAX_NAME_LENGTH])
+{
+ res_T res = RES_OK;
+ ASSERT(str && side_name);
+
+ if(strlen(str) >= STARDIS_MAX_NAME_LENGTH) {
+ fprintf(stderr,
+ "Side indicator could not exceed %d characters `%s'\n",
+ STARDIS_MAX_NAME_LENGTH-1, str);
+ res = RES_MEM_ERR;
+ goto error;
+ }
+ strncpy(side_name, str, STARDIS_MAX_NAME_LENGTH);
+
+exit:
+ return res;
+error:
+ goto exit;
+}
+
+static res_T
+parse_probe_boundary(const char* str, struct stardis_probe_boundary* probe)
+{
+ char buf[128];
+ char* pos_and_time = NULL;
+ char* side = NULL;
+ char* ctx = NULL;
+ res_T res = RES_OK;
+ ASSERT(str && probe);
+
+ if(strlen(str) >= sizeof(buf)-1/*NULL char*/) {
+ fprintf(stderr,
+ "Could not duplicate string defining probe at boundary `%s'\n", str);
+ res = RES_MEM_ERR;
+ goto error;
+ }
+ strncpy(buf, str, sizeof(buf));
+
+ pos_and_time = strtok_r(buf, ":", &ctx);
+ side = strtok_r(NULL, "", &ctx);
+
+ res = parse_position_and_time(pos_and_time, probe->position, probe->time);
+ if(res != RES_OK) goto error;
+
+ res = parse_side_indicator(side, probe->side);
+ if(res != RES_OK) goto error;
+
+exit:
+ return res;
+error:
+ goto exit;
+}
+
/*******************************************************************************
* Public Functions
******************************************************************************/
@@ -587,39 +703,15 @@ parse_args
case 'P':
if(args->mode & EXCLUSIVE_MODES) {
- res = RES_BAD_ARG;
logger_print(args->logger, LOG_ERROR,
- "Options -%c and -%c are exclusive.\n",
- (char)opt, mode_option(args->mode));
- goto error;
- }
- args->mode |= MODE_PROBE_COMPUTE_ON_INTERFACE;
-
- ERR(str_set(&keep, optarg));
- line = split_line(optarg, ':');
- if(!line) {
- res = RES_MEM_ERR;
- str_release(&keep);
- goto error;
- }
-
- /* We expect 1 or 2 parts in line */
- if(!line[0] || (line[1] && line[2])) {
- logger_print((args->logger), LOG_ERROR,
- "Invalid argument for option ""-%c"": %s\n",
- opt, str_cget(&keep));
- str_release(&keep);
+ "Options -%c and -%c are exclusive.\n",
+ (char)opt, mode_option(args->mode));
res = RES_BAD_ARG;
goto error;
}
-
- /* First part is pos and optional time, optional second part is a
- * medium name (OK if NULL) */
- GET_POS_AND_OPTIONAL_TIME_RANGE(line[0], args->pos_and_time,
- str_cget(&keep));
- if(line[1])
- args->medium_name = optarg + strlen(line[0]) + 1;
-
+ args->mode |= MODE_PROBE_COMPUTE_ON_INTERFACE;
+ res = parse_probe_boundary(optarg, &args->probe_boundary);
+ if(res != RES_OK) goto error;
break;
case 'R':
diff --git a/src/stardis-args.h b/src/stardis-args.h
@@ -1,141 +0,0 @@
-/* Copyright (C) 2018-2023 |Méso|Star> (contact@meso-star.com)
- *
- * 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/>. */
-
-#ifndef STARDIS_ARGS_H
-#define STARDIS_ARGS_H
-
-#include <sdis.h>
-
-#include <rsys/rsys.h>
-#include <rsys/dynamic_array_str.h>
-
-struct camera;
-struct logger;
-struct mem_allocator;
-struct stardis;
-
-enum stardis_mode {
- /* Ordered so that print_multiple_modes() prints in alphabetical order */
- UNDEF_MODE = 0,
- MODE_DUMP_C_CHUNKS = BIT(0), /* -c */
- MODE_DUMP_PATHS = BIT(1), /* -D */
- MODE_DUMP_MODEL = BIT(2), /* -d */
- MODE_EXTENDED_RESULTS = BIT(3), /* -e */
- MODE_FLUX_BOUNDARY_COMPUTE = BIT(4), /* -F */
- MODE_BIN_GREEN = BIT(5), /* -G */
- MODE_GREEN = BIT(6), /* -g */
- MODE_DUMP_HELP = BIT(7), /* -h */
- MODE_MEDIUM_COMPUTE = BIT(8), /* -m */
- MODE_PROBE_COMPUTE_ON_INTERFACE = BIT(9), /* -P */
- MODE_PROBE_COMPUTE = BIT(10), /* -p */
- MODE_IR_COMPUTE = BIT(11), /* -R */
- MODE_MAP_COMPUTE = BIT(12), /* -S */
- MODE_BOUNDARY_COMPUTE = BIT(13), /* -s */
- MODE_VERBOSITY = BIT(14), /* -V */
- MODE_DUMP_VERSION = BIT(15), /* -v */
-
- GREEN_COMPATIBLE_MODES
- = MODE_PROBE_COMPUTE | MODE_PROBE_COMPUTE_ON_INTERFACE | MODE_MEDIUM_COMPUTE
- | MODE_BOUNDARY_COMPUTE,
-
- SURFACE_COMPUTE_MODES
- = MODE_BOUNDARY_COMPUTE | MODE_FLUX_BOUNDARY_COMPUTE | MODE_MAP_COMPUTE,
-
- EXT_COMPATIBLE_MODES
- = GREEN_COMPATIBLE_MODES | MODE_MEDIUM_COMPUTE | MODE_FLUX_BOUNDARY_COMPUTE,
-
- REGION_COMPUTE_MODES = SURFACE_COMPUTE_MODES | MODE_MEDIUM_COMPUTE,
-
- COMPUTE_MODES = GREEN_COMPATIBLE_MODES | MODE_IR_COMPUTE | SURFACE_COMPUTE_MODES,
-
- EXCLUSIVE_MODES = COMPUTE_MODES,
-
- SHORT_EXIT_MODES = MODE_DUMP_HELP | MODE_DUMP_VERSION,
-
- USE_STDOUT_MODES
- = MODE_DUMP_C_CHUNKS | MODE_DUMP_HELP | MODE_DUMP_VERSION | MODE_IR_COMPUTE
- | MODE_GREEN,
-
- RANDOM_RW_MODES
- = MODE_PROBE_COMPUTE | MODE_PROBE_COMPUTE_ON_INTERFACE | MODE_MEDIUM_COMPUTE
- | MODE_BOUNDARY_COMPUTE | MODE_FLUX_BOUNDARY_COMPUTE
-};
-
-STATIC_ASSERT(GREEN_COMPATIBLE_MODES == (COMPUTE_MODES & GREEN_COMPATIBLE_MODES),
- Cannot_have_a_GREEN_COMPATIBLE_MODE_that_is_not_a_COMPUTE_MODE);
-
-enum dump_path_type {
- DUMP_NONE = 0,
- DUMP_SUCCESS = BIT(0),
- DUMP_ERROR = BIT(1),
- DUMP_ALL = DUMP_SUCCESS | DUMP_ERROR
-};
-
-struct args {
- struct logger* logger;
- struct mem_allocator* allocator;
- struct darray_str model_files;
- char* medium_name;
- char* solve_filename;
- char* bin_green_filename;
- char* end_paths_filename;
- char* dump_model_filename;
- char* paths_filename;
- char* rndgen_state_in_filename;
- char* rndgen_state_out_filename;
- char* chunks_prefix;
- char* camera;
- size_t samples;
- double pos_and_time[5];
- unsigned nthreads;
- unsigned picard_order;
- int mode;
- enum dump_path_type dump_paths;
- int verbose;
-};
-
-res_T
-init_args
- (struct logger* logger,
- struct mem_allocator* mem,
- struct args** args);
-
-void
-release_args
- (struct args* args);
-
-void
-print_version
- (FILE* stream);
-
-void
-short_help
- (FILE* stream,
- const char* prog);
-
-res_T
-parse_args
- (const int argc,
- char** argv,
- struct args* args,
- struct mem_allocator* allocator);
-
-res_T
-parse_camera
- (struct logger* logger,
- char* cam_param,
- struct stardis* stardis);
-
-#endif /* STRADIS_ARGS_H */
diff --git a/src/stardis-args.h.in b/src/stardis-args.h.in
@@ -0,0 +1,154 @@
+/* Copyright (C) 2018-2023 |Méso|Star> (contact@meso-star.com)
+ *
+ * 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/>. */
+
+#ifndef STARDIS_ARGS_H
+#define STARDIS_ARGS_H
+
+#define STARDIS_MAX_NAME_LENGTH @STARDIS_MAX_NAME_LENGTH@
+
+#include <sdis.h>
+
+#include <rsys/rsys.h>
+#include <rsys/dynamic_array_str.h>
+
+struct camera;
+struct logger;
+struct mem_allocator;
+struct stardis;
+
+struct stardis_probe_boundary {
+ double position[3];
+ double time[2]; /* Observation time */
+ char side[STARDIS_MAX_NAME_LENGTH];
+};
+#define STARDIS_PROBE_BOUNDARY_NULL__ {{0,0,0},{0,0},{0}}
+static const struct stardis_probe_boundary STARDIS_PROBE_BOUNDARY_NULL =
+ STARDIS_PROBE_BOUNDARY_NULL__;
+
+enum stardis_mode {
+ /* Ordered so that print_multiple_modes() prints in alphabetical order */
+ UNDEF_MODE = 0,
+ MODE_DUMP_C_CHUNKS = BIT(0), /* -c */
+ MODE_DUMP_PATHS = BIT(1), /* -D */
+ MODE_DUMP_MODEL = BIT(2), /* -d */
+ MODE_EXTENDED_RESULTS = BIT(3), /* -e */
+ MODE_FLUX_BOUNDARY_COMPUTE = BIT(4), /* -F */
+ MODE_BIN_GREEN = BIT(5), /* -G */
+ MODE_GREEN = BIT(6), /* -g */
+ MODE_DUMP_HELP = BIT(7), /* -h */
+ MODE_MEDIUM_COMPUTE = BIT(8), /* -m */
+ MODE_PROBE_COMPUTE_ON_INTERFACE = BIT(9), /* -P */
+ MODE_PROBE_COMPUTE = BIT(10), /* -p */
+ MODE_IR_COMPUTE = BIT(11), /* -R */
+ MODE_MAP_COMPUTE = BIT(12), /* -S */
+ MODE_BOUNDARY_COMPUTE = BIT(13), /* -s */
+ MODE_VERBOSITY = BIT(14), /* -V */
+ MODE_DUMP_VERSION = BIT(15), /* -v */
+
+ GREEN_COMPATIBLE_MODES
+ = MODE_PROBE_COMPUTE | MODE_PROBE_COMPUTE_ON_INTERFACE | MODE_MEDIUM_COMPUTE
+ | MODE_BOUNDARY_COMPUTE,
+
+ SURFACE_COMPUTE_MODES
+ = MODE_BOUNDARY_COMPUTE | MODE_FLUX_BOUNDARY_COMPUTE | MODE_MAP_COMPUTE,
+
+ EXT_COMPATIBLE_MODES
+ = GREEN_COMPATIBLE_MODES | MODE_MEDIUM_COMPUTE | MODE_FLUX_BOUNDARY_COMPUTE,
+
+ REGION_COMPUTE_MODES = SURFACE_COMPUTE_MODES | MODE_MEDIUM_COMPUTE,
+
+ COMPUTE_MODES = GREEN_COMPATIBLE_MODES | MODE_IR_COMPUTE | SURFACE_COMPUTE_MODES,
+
+ EXCLUSIVE_MODES = COMPUTE_MODES,
+
+ SHORT_EXIT_MODES = MODE_DUMP_HELP | MODE_DUMP_VERSION,
+
+ USE_STDOUT_MODES
+ = MODE_DUMP_C_CHUNKS | MODE_DUMP_HELP | MODE_DUMP_VERSION | MODE_IR_COMPUTE
+ | MODE_GREEN,
+
+ RANDOM_RW_MODES
+ = MODE_PROBE_COMPUTE | MODE_PROBE_COMPUTE_ON_INTERFACE | MODE_MEDIUM_COMPUTE
+ | MODE_BOUNDARY_COMPUTE | MODE_FLUX_BOUNDARY_COMPUTE
+};
+
+STATIC_ASSERT(GREEN_COMPATIBLE_MODES == (COMPUTE_MODES & GREEN_COMPATIBLE_MODES),
+ Cannot_have_a_GREEN_COMPATIBLE_MODE_that_is_not_a_COMPUTE_MODE);
+
+enum dump_path_type {
+ DUMP_NONE = 0,
+ DUMP_SUCCESS = BIT(0),
+ DUMP_ERROR = BIT(1),
+ DUMP_ALL = DUMP_SUCCESS | DUMP_ERROR
+};
+
+struct args {
+ struct logger* logger;
+ struct mem_allocator* allocator;
+ struct darray_str model_files;
+ char* medium_name;
+ char* solve_filename;
+ char* bin_green_filename;
+ char* end_paths_filename;
+ char* dump_model_filename;
+ char* paths_filename;
+ char* rndgen_state_in_filename;
+ char* rndgen_state_out_filename;
+ char* chunks_prefix;
+ char* camera;
+ size_t samples;
+ double pos_and_time[5];
+ unsigned nthreads;
+ unsigned picard_order;
+ int mode;
+ enum dump_path_type dump_paths;
+ int verbose;
+
+ struct stardis_probe_boundary probe_boundary;
+};
+
+res_T
+init_args
+ (struct logger* logger,
+ struct mem_allocator* mem,
+ struct args** args);
+
+void
+release_args
+ (struct args* args);
+
+void
+print_version
+ (FILE* stream);
+
+void
+short_help
+ (FILE* stream,
+ const char* prog);
+
+res_T
+parse_args
+ (const int argc,
+ char** argv,
+ struct args* args,
+ struct mem_allocator* allocator);
+
+res_T
+parse_camera
+ (struct logger* logger,
+ char* cam_param,
+ struct stardis* stardis);
+
+#endif /* STRADIS_ARGS_H */
diff --git a/src/stardis-green-types.h.in b/src/stardis-green-types.h.in
@@ -21,8 +21,8 @@
/* The number of the file format as presented thereafter */
#define GREEN_FILE_FORMAT_VERSION @STARDIS_GREEN_TYPES_VERSION@
-/* The max length for a description name */
-#define DESC_NAME_MAX_LEN 63
+/* The max length for a description name *WITHOUT* null char */
+#define DESC_NAME_MAX_LEN @STARDIS_MAX_NAME_LENGTH@
/* The string at the beginning of a binary Green file that identifies it */
#define BIN_FILE_IDENT_STRING "GREEN_BIN_FILE:"
diff --git a/src/stardis-main.c b/src/stardis-main.c
@@ -33,14 +33,10 @@
#endif
int
-main
- (int argc,
- char** argv)
+main(int argc, char** argv)
{
struct args* args = NULL;
struct stardis stardis;
- int logger_initialized = 0, allocator_initialized = 0,
- args_initialized = 0, stardis_initialized = 0, name_initialized = 0;
int err = EXIT_SUCCESS;
struct mem_allocator allocator;
struct logger logger;
@@ -50,6 +46,13 @@ main
struct str name;
res_T res = RES_OK;
+ /* Initialisation statuses */
+ int logger_initialized = 0;
+ int allocator_initialized = 0;
+ int args_initialized = 0;
+ int stardis_initialized = 0;
+ int name_initialized = 0;
+
time_current(&start);
#ifdef STARDIS_ENABLE_MPI