|
3 | 3 | ################################################################################ |
4 | 4 |
|
5 | 5 | """ |
6 | | - integral(f, geometry[, rule]; diff_method=_default_diff_method(geometry, FP), FP=Float64) |
| 6 | + integral(f, geometry[, rule]; kwargs...) |
7 | 7 |
|
8 | 8 | Numerically integrate a given function `f(::Point)` over the domain defined by |
9 | 9 | a `geometry` using a particular numerical integration `rule` with floating point |
10 | 10 | precision of type `FP`. |
11 | 11 |
|
12 | 12 | # Arguments |
13 | 13 | - `f`: an integrand function, i.e. any callable with a method `f(::Meshes.Point)` |
14 | | -- `geometry`: some `Meshes.Geometry` that defines the integration domain |
| 14 | +- `geometry`: a Meshes `Geometry` or `Domain` that defines the integration domain |
15 | 15 | - `rule`: optionally, the `IntegrationRule` used for integration (by default |
16 | 16 | `GaussKronrod()` in 1D and `HAdaptiveCubature()` else) |
17 | 17 |
|
18 | 18 | # Keyword Arguments |
19 | | -- `diff_method::DifferentiationMethod = _default_diff_method(geometry, FP)`: the method to |
20 | | -use for calculating Jacobians that are used to calculate differential elements |
21 | | -- `FP = Float64`: the floating point precision desired. |
| 19 | +- `diff_method::DifferentiationMethod`: manually specifies the differentiation method use to |
| 20 | +calculate Jacobians within the integration domain. |
| 21 | +- `FP = Float64`: manually specifies the desired output floating point precision |
22 | 22 | """ |
23 | 23 | function integral end |
24 | 24 |
|
| 25 | +# Default integration rule to use if unspecified |
| 26 | +_defrule(geometry) = (Meshes.paramdim(geometry) == 1) ? GaussKronrod() : HAdaptiveCubature() |
| 27 | + |
25 | 28 | # If only f and geometry are specified, select default rule |
26 | 29 | function integral( |
27 | 30 | f, |
28 | 31 | geometry::Geometry, |
29 | | - rule::I = Meshes.paramdim(geometry) == 1 ? GaussKronrod() : HAdaptiveCubature(); |
| 32 | + rule::I = _defrule(geometry); |
30 | 33 | kwargs... |
31 | 34 | ) where {I <: IntegrationRule} |
32 | 35 | _integral(f, geometry, rule; kwargs...) |
|
35 | 38 | function integral( |
36 | 39 | f, |
37 | 40 | domain::Meshes.Domain, |
38 | | - rule::I = Meshes.paramdim(domain) == 1 ? GaussKronrod() : HAdaptiveCubature(); |
| 41 | + rule::I = _defrule(domain); |
39 | 42 | kwargs... |
40 | 43 | ) where {I <: IntegrationRule} |
41 | 44 | # Discretize the Domain into primitive geometries, sum the integrals over those |
42 | 45 | subintegral(geometry) = integral(f, geometry, rule; kwargs...) |
43 | | - subgeometries = Meshes.elements(Meshes.discretize(domain)) |> collect |
| 46 | + subgeometries = collect(Meshes.elements(Meshes.discretize(domain))) |
44 | 47 | return sum(subintegral, subgeometries) |
45 | 48 | end |
46 | 49 |
|
|
0 commit comments