summaryrefslogtreecommitdiffstats
path: root/core/gas.c
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-10-02 19:58:36 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-10-03 10:29:15 -0700
commit23da23a53444d555f9211c9c5e6de1fb1bcd27de (patch)
tree6bae55c165306138d7ea486ed0b1475592f097f7 /core/gas.c
parent34730b898b41b19476eaa61f20273e267d63b7e8 (diff)
downloadsubsurface-23da23a53444d555f9211c9c5e6de1fb1bcd27de.tar.gz
core: add N2 and general gas component accessors
There were helper functions to access O2 and He component fractions. Add another one for N2. Indeed, this can be used in three cases, where N2 was deduced indirectly. Moreover, add a general accessor with a gas_component argument. This will be used by the filter code to filter for gas components. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/gas.c')
-rw-r--r--core/gas.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/core/gas.c b/core/gas.c
index 9f67d0b92..040f938f6 100644
--- a/core/gas.c
+++ b/core/gas.c
@@ -77,3 +77,20 @@ bool gasmix_is_air(struct gasmix gasmix)
int he = gasmix.he.permille;
return (he == 0) && (o2 == 0 || ((o2 >= O2_IN_AIR - 1) && (o2 <= O2_IN_AIR + 1)));
}
+
+static fraction_t make_fraction(int i)
+{
+ fraction_t res;
+ res.permille = i;
+ return res;
+}
+
+fraction_t get_gas_component_fraction(struct gasmix mix, enum gas_component component)
+{
+ switch (component) {
+ case O2: return make_fraction(get_o2(mix));
+ case N2: return make_fraction(get_n2(mix));
+ case HE: return make_fraction(get_he(mix));
+ default: return make_fraction(0);
+ }
+}