Skip to content

Commit f00eb75

Browse files
authored
Merge pull request #168 from YichengDWu/UnionDomain
Union domain
2 parents f25698d + b546f5d commit f00eb75

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/compact/NeuralPDE/pinnsampler.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ function sample(d::DomainSets.GenericSphere{StaticArraysCore.SVector{2, T}, T},
109109
return data
110110
end
111111

112+
function sample(d::DomainSets.UnitCircle, points::Int, alg::QuasiMonteCarlo.SamplingAlgorithm)
113+
θ = sample(points, [0.0], [2π], alg)
114+
data = [cos.(θ); sin.(θ)]
115+
return data
116+
end
117+
118+
112119
function sample(d::DomainSets.GenericSphere{StaticArraysCore.SVector{3, T}, T}, points::Int, alg::QuasiMonteCarlo.SamplingAlgorithm) where {T}
113120
(; center, radius) = d
114121
r = sample(points, [-1,-1], [1,1], alg)
@@ -130,6 +137,11 @@ function sample(d::SetdiffDomain{S, <:Tuple{<:Rectangle, F}}, points::Int, alg::
130137
return data[:, idx]
131138
end
132139

140+
function sample(d::UnionDomain, points::Int, alg::QuasiMonteCarlo.SamplingAlgorithm) where {S, F}
141+
data = mapreduce(x -> sample(x, points, alg), hcat, d.domains)
142+
return data
143+
end
144+
133145
function sample(d::Rectangle, points::Int, sampling_alg::QuasiMonteCarlo.SamplingAlgorithm)
134146
bounds = get_bounds(d)
135147
return sample(points, bounds[1], bounds[2], sampling_alg)
@@ -148,6 +160,7 @@ function sample(points::Int, lb::AbstractVector, ub::AbstractVector, ::SobolSamp
148160
return sobolsample(points, lb, ub)
149161
end
150162

163+
151164
function sobolsample(n::Int, lb, ub)
152165
s = cached_sobolseq(n, lb, ub)
153166
return reduce(hcat, [Sobol.next!(s) for i in 1:n])

0 commit comments

Comments
 (0)