Skip to content

Commit 7f27628

Browse files
committed
define image and quadgen functions
1 parent e8ae1a2 commit 7f27628

1 file changed

Lines changed: 36 additions & 10 deletions

File tree

src/Integration/quadrule.jl

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
"""
2-
abstract type AbstractQuadratureRule{D<:AbstractReferenceShape}
2+
abstract type AbstractQuadratureRule{D}
33
44
A quadrature rule for integrating a function over the domain `D`.
55
6-
An instance `q` of `AbstractQuadratureRule{D}` is expected to implement the
7-
following methods:
6+
Calling `q()` returns the nodes `x` and weights `w` for performing integration
7+
over `domain(q)`.
88
9-
- `q()` : return the nodes `x` and weights `w` of the quadrature rule on the
10-
reference domain `D`. For performance reasons, the result should depend only
11-
on the type of `q`.
9+
Calling `q(el)` returns the nodes and weights for integrating over `el`.
1210
"""
1311
abstract type AbstractQuadratureRule{D} end
1412

@@ -19,6 +17,15 @@ Given a function-like object `f: Ω → R`, return `Ω`.
1917
"""
2018
domain(q::AbstractQuadratureRule{D}) where {D} = D()
2119

20+
"""
21+
image(f)
22+
23+
Given a function-like object `f: Ω → R`, return `R`.
24+
"""
25+
function image(f)
26+
abstractmethod(f)
27+
end
28+
2229
"""
2330
qnodes(Y)
2431
@@ -33,12 +40,30 @@ Return the quadrature weights associated with `Y`.
3340
"""
3441
qweights(q::AbstractQuadratureRule) = q()[2]
3542

43+
function (q::AbstractQuadratureRule)()
44+
abstractmethod(q)
45+
end
46+
47+
function (q::AbstractQuadratureRule)(el::AbstractElement)
48+
msg = "reference domain of quadrature rule and element must match"
49+
@assert domain(q) == domain(el) msg
50+
X̂,Ŵ = q()
51+
X = map(el,X̂)
52+
W = map(X̂,Ŵ) do x̂,ŵ
53+
jac = jacobian(el,x̂)
54+
μ = sqrt(det(jac'*jac))
55+
μ*
56+
end
57+
X,W
58+
end
59+
3660
"""
37-
(q::AbstractQuadratureRule)()
61+
quadgen(el,q::AbstractQuadratureRule)
3862
39-
Return the quadrature nodes `x` and weights `w` on the `domain(q)`.
63+
Return a set of points and weights for integrating over `el` based on the
64+
quadrature rule `q`.
4065
"""
41-
function (q::AbstractQuadratureRule)() end
66+
quadgen(el::AbstractElement,q::AbstractQuadratureRule) = q(el)
4267

4368
"""
4469
integrate(f,q::AbstractQuadrature)
@@ -175,6 +200,8 @@ struct Gauss{D,N} <: AbstractQuadratureRule{D}
175200
# of nodes. This ensures you don't instantiate quadratures which are not
176201
# tabulated.
177202
function Gauss(;domain,order)
203+
domain == :triangle && (domain=ReferenceTriangle())
204+
domain == :tetrehedron && (domain=ReferenceTetrahedron())
178205
if domain isa ReferenceTriangle
179206
msg = "quadrature of order $order not available for ReferenceTriangle"
180207
haskey(TRIANGLE_GAUSS_ORDER_TO_NPTS,order) || error(msg)
@@ -266,7 +293,6 @@ function qrule_for_reference_shape(ref,order)
266293
end
267294
end
268295

269-
abstract type NestedQuadratureRule{D} <: AbstractQuadratureRule{D} end
270296
"""
271297
struct CustomQuadratureRule{D,N,T} <: AbstractQuadratureRule{D}
272298

0 commit comments

Comments
 (0)