refactor: si_quantities.h added to improve compile-times

This commit is contained in:
Mateusz Pusz
2024-01-26 15:53:18 +01:00
parent 12c7a43d7d
commit e0f9048e4b
11 changed files with 67 additions and 35 deletions

View File

@@ -43,6 +43,7 @@ add_mp_units_module(
include/mp-units/systems/isq/electromagnetism.h include/mp-units/systems/isq/electromagnetism.h
include/mp-units/systems/isq/isq.h include/mp-units/systems/isq/isq.h
include/mp-units/systems/isq/mechanics.h include/mp-units/systems/isq/mechanics.h
include/mp-units/systems/isq/si_quantities.h
include/mp-units/systems/isq/space_and_time.h include/mp-units/systems/isq/space_and_time.h
include/mp-units/systems/isq/thermodynamics.h include/mp-units/systems/isq/thermodynamics.h
include/mp-units/systems/isq_angle/isq_angle.h include/mp-units/systems/isq_angle/isq_angle.h

View File

@@ -22,7 +22,8 @@
#pragma once #pragma once
#include <mp-units/systems/si/si.h> #include <mp-units/systems/si/constants.h>
#include <mp-units/systems/si/units.h>
#include <mp-units/unit.h> #include <mp-units/unit.h>
template<> template<>
@@ -52,8 +53,6 @@ inline constexpr struct speed_of_light : decltype(si::si2019::speed_of_light_in_
namespace unit_symbols { namespace unit_symbols {
using si::unit_symbols::eV;
inline constexpr auto qeV = si::quecto<electronvolt>; inline constexpr auto qeV = si::quecto<electronvolt>;
inline constexpr auto reV = si::ronto<electronvolt>; inline constexpr auto reV = si::ronto<electronvolt>;
inline constexpr auto yeV = si::yocto<electronvolt>; inline constexpr auto yeV = si::yocto<electronvolt>;
@@ -66,6 +65,7 @@ inline constexpr auto ueV = si::micro<electronvolt>;
inline constexpr auto meV = si::milli<electronvolt>; inline constexpr auto meV = si::milli<electronvolt>;
inline constexpr auto ceV = si::centi<electronvolt>; inline constexpr auto ceV = si::centi<electronvolt>;
inline constexpr auto deV = si::deci<electronvolt>; inline constexpr auto deV = si::deci<electronvolt>;
inline constexpr auto eV = electronvolt;
inline constexpr auto daeV = si::deca<electronvolt>; inline constexpr auto daeV = si::deca<electronvolt>;
inline constexpr auto heV = si::hecto<electronvolt>; inline constexpr auto heV = si::hecto<electronvolt>;
inline constexpr auto keV = si::kilo<electronvolt>; inline constexpr auto keV = si::kilo<electronvolt>;

View File

@@ -22,7 +22,8 @@
#pragma once #pragma once
#include <mp-units/systems/si/si.h> #include <mp-units/systems/si/constants.h>
#include <mp-units/systems/si/units.h>
#include <mp-units/unit.h> #include <mp-units/unit.h>
namespace mp_units::international { namespace mp_units::international {

View File

@@ -23,16 +23,9 @@
#pragma once #pragma once
#include <mp-units/quantity_spec.h> #include <mp-units/quantity_spec.h>
#include <mp-units/systems/isq/base_quantities.h> #include <mp-units/systems/isq/si_quantities.h>
#include <mp-units/systems/isq/mechanics.h>
#include <mp-units/systems/isq/space_and_time.h>
namespace mp_units::isq { namespace mp_units::isq {
// TODO Add all the remaining ISQ definitions
QUANTITY_SPEC(activity, inverse(duration));
QUANTITY_SPEC(absorbed_dose, energy / mass);
QUANTITY_SPEC(ionizing_radiation_quality_factor, dimensionless);
QUANTITY_SPEC(dose_equivalent, absorbed_dose* ionizing_radiation_quality_factor);
} // namespace mp_units::isq } // namespace mp_units::isq

View File

@@ -43,6 +43,7 @@ inline constexpr struct dim_luminous_intensity : base_dimension<"J"> {} dim_lumi
QUANTITY_SPEC(length, dim_length); QUANTITY_SPEC(length, dim_length);
QUANTITY_SPEC(mass, dim_mass); QUANTITY_SPEC(mass, dim_mass);
QUANTITY_SPEC(time, dim_time); QUANTITY_SPEC(time, dim_time);
inline constexpr auto duration = time;
QUANTITY_SPEC(electric_current, dim_electric_current); QUANTITY_SPEC(electric_current, dim_electric_current);
QUANTITY_SPEC(thermodynamic_temperature, dim_thermodynamic_temperature); QUANTITY_SPEC(thermodynamic_temperature, dim_thermodynamic_temperature);
QUANTITY_SPEC(amount_of_substance, dim_amount_of_substance); QUANTITY_SPEC(amount_of_substance, dim_amount_of_substance);

View File

@@ -27,6 +27,7 @@
#include <mp-units/systems/isq/base_quantities.h> #include <mp-units/systems/isq/base_quantities.h>
#include <mp-units/systems/isq/electromagnetism.h> #include <mp-units/systems/isq/electromagnetism.h>
#include <mp-units/systems/isq/mechanics.h> #include <mp-units/systems/isq/mechanics.h>
#include <mp-units/systems/isq/si_quantities.h>
#include <mp-units/systems/isq/space_and_time.h> #include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/isq/thermodynamics.h> #include <mp-units/systems/isq/thermodynamics.h>
// IWYU pragma: end_exports // IWYU pragma: end_exports

View File

@@ -23,7 +23,7 @@
#pragma once #pragma once
#include <mp-units/quantity_spec.h> #include <mp-units/quantity_spec.h>
#include <mp-units/systems/isq/base_quantities.h> #include <mp-units/systems/isq/si_quantities.h>
#include <mp-units/systems/isq/space_and_time.h> #include <mp-units/systems/isq/space_and_time.h>
namespace mp_units::isq { namespace mp_units::isq {
@@ -88,7 +88,6 @@ QUANTITY_SPEC(kinematic_viscosity, dynamic_viscosity / mass_density);
QUANTITY_SPEC(surface_tension, force / length, quantity_character::scalar); // TODO what is a correct equation here? QUANTITY_SPEC(surface_tension, force / length, quantity_character::scalar); // TODO what is a correct equation here?
QUANTITY_SPEC(power, mass* pow<2>(length) / pow<3>(time)); // not in ISO 80000 QUANTITY_SPEC(power, mass* pow<2>(length) / pow<3>(time)); // not in ISO 80000
QUANTITY_SPEC(mechanical_power, power, force* velocity, quantity_character::scalar); QUANTITY_SPEC(mechanical_power, power, force* velocity, quantity_character::scalar);
QUANTITY_SPEC(energy, mass* pow<2>(length) / pow<2>(time)); // differs from ISO 80000 (defined in thermodynamics)
QUANTITY_SPEC(mechanical_energy, energy); // differs from ISO 80000 QUANTITY_SPEC(mechanical_energy, energy); // differs from ISO 80000
QUANTITY_SPEC(potential_energy, mechanical_energy); // differs from ISO 80000 QUANTITY_SPEC(potential_energy, mechanical_energy); // differs from ISO 80000
QUANTITY_SPEC(kinetic_energy, mechanical_energy, mass* pow<2>(speed)); // differs from ISO 80000 QUANTITY_SPEC(kinetic_energy, mechanical_energy, mass* pow<2>(speed)); // differs from ISO 80000

View File

@@ -0,0 +1,52 @@
// The MIT License (MIT)
//
// Copyright (c) 2018 Mateusz Pusz
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#pragma once
#include <mp-units/quantity_spec.h>
#include <mp-units/systems/isq/base_quantities.h>
namespace mp_units::isq {
// space and time
QUANTITY_SPEC(width, length);
inline constexpr auto breadth = width;
QUANTITY_SPEC(radius, width); // differs from ISO 80000
QUANTITY_SPEC(path_length, length);
inline constexpr auto arc_length = path_length;
QUANTITY_SPEC(area, pow<2>(length));
QUANTITY_SPEC(angular_measure, dimensionless, arc_length / radius, is_kind);
QUANTITY_SPEC(solid_angular_measure, dimensionless, area / pow<2>(radius), is_kind);
QUANTITY_SPEC(period_duration, duration);
inline constexpr auto period = period_duration;
QUANTITY_SPEC(frequency, inverse(period_duration));
// mechanics
QUANTITY_SPEC(energy, mass* pow<2>(length) / pow<2>(time)); // differs from ISO 80000 (defined in thermodynamics)
// atomic_and_nuclear_physics
QUANTITY_SPEC(activity, inverse(duration));
QUANTITY_SPEC(absorbed_dose, energy / mass);
QUANTITY_SPEC(ionizing_radiation_quality_factor, dimensionless);
QUANTITY_SPEC(dose_equivalent, absorbed_dose* ionizing_radiation_quality_factor);
} // namespace mp_units::isq

View File

@@ -23,45 +23,33 @@
#pragma once #pragma once
#include <mp-units/quantity_spec.h> #include <mp-units/quantity_spec.h>
#include <mp-units/systems/isq/base_quantities.h> #include <mp-units/systems/isq/si_quantities.h>
namespace mp_units::isq { namespace mp_units::isq {
QUANTITY_SPEC(width, length);
inline constexpr auto breadth = width;
QUANTITY_SPEC(height, length); QUANTITY_SPEC(height, length);
inline constexpr auto depth = height; inline constexpr auto depth = height;
inline constexpr auto altitude = height; inline constexpr auto altitude = height;
QUANTITY_SPEC(thickness, width); QUANTITY_SPEC(thickness, width);
QUANTITY_SPEC(diameter, width); QUANTITY_SPEC(diameter, width);
QUANTITY_SPEC(radius, width); // differs from ISO 80000
QUANTITY_SPEC(path_length, length);
inline constexpr auto arc_length = path_length;
QUANTITY_SPEC(distance, path_length); QUANTITY_SPEC(distance, path_length);
QUANTITY_SPEC(radial_distance, distance); QUANTITY_SPEC(radial_distance, distance);
QUANTITY_SPEC(position_vector, length, quantity_character::vector); QUANTITY_SPEC(position_vector, length, quantity_character::vector);
QUANTITY_SPEC(displacement, length, quantity_character::vector); QUANTITY_SPEC(displacement, length, quantity_character::vector);
QUANTITY_SPEC(radius_of_curvature, radius); QUANTITY_SPEC(radius_of_curvature, radius);
QUANTITY_SPEC(curvature, inverse(radius_of_curvature)); QUANTITY_SPEC(curvature, inverse(radius_of_curvature));
QUANTITY_SPEC(area, pow<2>(length));
QUANTITY_SPEC(volume, pow<3>(length)); QUANTITY_SPEC(volume, pow<3>(length));
QUANTITY_SPEC(angular_measure, dimensionless, arc_length / radius, is_kind);
QUANTITY_SPEC(rotational_displacement, angular_measure, path_length / radius); QUANTITY_SPEC(rotational_displacement, angular_measure, path_length / radius);
inline constexpr auto angular_displacement = rotational_displacement; inline constexpr auto angular_displacement = rotational_displacement;
QUANTITY_SPEC(phase_angle, angular_measure); QUANTITY_SPEC(phase_angle, angular_measure);
QUANTITY_SPEC(solid_angular_measure, dimensionless, area / pow<2>(radius), is_kind);
inline constexpr auto duration = time;
QUANTITY_SPEC(speed, length / time); // differs from ISO 80000 QUANTITY_SPEC(speed, length / time); // differs from ISO 80000
QUANTITY_SPEC(velocity, speed, position_vector / duration); // vector // differs from ISO 80000 QUANTITY_SPEC(velocity, speed, position_vector / duration); // vector // differs from ISO 80000
QUANTITY_SPEC(acceleration, velocity / duration); // vector QUANTITY_SPEC(acceleration, velocity / duration); // vector
QUANTITY_SPEC(acceleration_of_free_fall, acceleration); // not in ISO 80000 QUANTITY_SPEC(acceleration_of_free_fall, acceleration); // not in ISO 80000
QUANTITY_SPEC(angular_velocity, angular_displacement / duration, quantity_character::vector); QUANTITY_SPEC(angular_velocity, angular_displacement / duration, quantity_character::vector);
QUANTITY_SPEC(angular_acceleration, angular_velocity / duration); QUANTITY_SPEC(angular_acceleration, angular_velocity / duration);
QUANTITY_SPEC(period_duration, duration);
inline constexpr auto period = period_duration;
QUANTITY_SPEC(time_constant, duration); QUANTITY_SPEC(time_constant, duration);
QUANTITY_SPEC(rotation, dimensionless); QUANTITY_SPEC(rotation, dimensionless);
QUANTITY_SPEC(frequency, inverse(period_duration));
QUANTITY_SPEC(rotational_frequency, rotation / duration); QUANTITY_SPEC(rotational_frequency, rotation / duration);
QUANTITY_SPEC(angular_frequency, phase_angle / duration); QUANTITY_SPEC(angular_frequency, phase_angle / duration);
QUANTITY_SPEC(wavelength, length); QUANTITY_SPEC(wavelength, length);

View File

@@ -23,9 +23,7 @@
#pragma once #pragma once
#include <mp-units/quantity_spec.h> #include <mp-units/quantity_spec.h>
#include <mp-units/systems/isq/base_quantities.h> #include <mp-units/systems/isq/si_quantities.h>
#include <mp-units/systems/isq/mechanics.h>
#include <mp-units/systems/isq/space_and_time.h>
namespace mp_units::isq { namespace mp_units::isq {

View File

@@ -23,9 +23,7 @@
#pragma once #pragma once
#include <mp-units/quantity_point.h> #include <mp-units/quantity_point.h>
#include <mp-units/systems/isq/atomic_and_nuclear_physics.h> #include <mp-units/systems/isq/si_quantities.h>
#include <mp-units/systems/isq/base_quantities.h>
#include <mp-units/systems/isq/space_and_time.h>
#include <mp-units/systems/si/prefixes.h> #include <mp-units/systems/si/prefixes.h>
#include <mp-units/unit.h> #include <mp-units/unit.h>