TerrainGen coverage


terraingen/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
4 / 4
100.0%
Branches:
-
-%
Functions:
2 / 2
100.0%

distribution/production_surface.h
Line Branch Exec Source
1 /// @file
2 /// @brief The crater density of a surface of a given age: a production function times a chronology.
3 #pragma once
4
5 #include "terraingen/distribution/size_frequency.h"
6
7 #include <functional>
8 #include <memory>
9
10 namespace terraingen {
11
12 /// N(>=1 km) per m^2 on a surface `ageGyr` old, such as `NeukumLunarChronology`.
13 using Chronology = std::function<double(double ageGyr)>;
14
15 /// The cumulative crater density on a surface of a given age: a production function scaled
16 /// so that N(>=1 km) follows a chronology, N(D, T) = Phi(D) * N1(T) / Phi(1 km).
17 ///
18 /// This is the population with no erosion; small craters exceed equilibrium on old surfaces.
19 class ProductionSurface final : public SizeFrequencyDistribution {
20 public:
21 /// The surface `ageGyr` Gyr old.
22 /// @param production A `ProductionRate` distribution defined at 1 km. The surface takes its
23 /// valid range and extrapolation setting.
24 /// @param chronology N(>=1 km) per m^2 for the age, which may reject ages out of its range.
25 /// @throws std::invalid_argument if `production` is null or not a production rate, or
26 /// `chronology` is empty.
27 /// @throws std::domain_error if the age is out of range or `production` is not defined at 1 km.
28 ProductionSurface(std::shared_ptr<const SizeFrequencyDistribution> production, double ageGyr,
29 const Chronology& chronology);
30
31 /// The `ProductionRate` distribution the surface scales.
32 2 const SizeFrequencyDistribution& Production() const {
33 2 return *production_;
34 }
35
36 /// The surface age in Gyr.
37 2 double AgeGyr() const {
38 2 return ageGyr_;
39 }
40
41 protected:
42 double CumulativeAt(double diameter) const override;
43 double IncrementalAt(double diameter) const override;
44 double InvertCumulative(double target, double dMin, double dMax) const override;
45
46 private:
47 std::shared_ptr<const SizeFrequencyDistribution> production_;
48 double ageGyr_;
49 double scale_;
50 };
51
52 } // namespace terraingen
53