mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-01 03:14:29 +02:00
Surface tension added
This commit is contained in:
45
src/include/units/dimensions/surface_tension.h
Normal file
45
src/include/units/dimensions/surface_tension.h
Normal file
@@ -0,0 +1,45 @@
|
||||
// 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 <units/dimensions/si_base_dimensions.h>
|
||||
#include <units/dimensions/force.h>
|
||||
|
||||
namespace units {
|
||||
|
||||
struct surface_tension : derived_dimension<surface_tension, exp<force, 1>, exp<length, -1>> {};
|
||||
|
||||
template<typename T>
|
||||
concept SurfaceTension = QuantityOf<T, surface_tension>;
|
||||
|
||||
struct newton_per_metre : coherent_derived_unit<newton_per_metre, surface_tension> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// Nm
|
||||
constexpr auto operator""Npm(unsigned long long l) { return quantity<newton_per_metre, std::int64_t>(l); }
|
||||
constexpr auto operator""Npm(long double l) { return quantity<newton_per_metre, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units
|
@@ -90,6 +90,12 @@ TEST_CASE("operator<< on a quantity", "[text][ostream]")
|
||||
stream << 20.km / 2h;
|
||||
REQUIRE(stream.str() == "10 km/h");
|
||||
}
|
||||
|
||||
SECTION("surface tension")
|
||||
{
|
||||
stream << 20.N / 2m;
|
||||
REQUIRE(stream.str() == "10 N/m");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -34,6 +34,7 @@
|
||||
#include <units/dimensions/power.h>
|
||||
#include <units/dimensions/pressure.h>
|
||||
#include <units/dimensions/substance.h>
|
||||
#include <units/dimensions/surface_tension.h>
|
||||
#include <units/dimensions/temperature.h>
|
||||
#include <units/dimensions/time.h>
|
||||
#include <units/dimensions/velocity.h>
|
||||
@@ -184,4 +185,9 @@ namespace {
|
||||
static_assert(10km * 10km * 10km == 1000cub_km);
|
||||
static_assert(1cub_m == 1'000'000cub_cm);
|
||||
|
||||
|
||||
/* ************** DERIVED DIMENSIONS IN TERMS OF OTHER UNITS **************** */
|
||||
|
||||
static_assert(10N / 2m == 5Npm);
|
||||
|
||||
} // namespace
|
||||
|
Reference in New Issue
Block a user