mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
34730b898b
commit
23da23a534
3 changed files with 26 additions and 3 deletions
17
core/gas.c
17
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue