@@ -23,8 +23,8 @@ FFT Gaussian simulation.
23
23
Fourier transform method](https://link.springer.com/article/10.1007/BF02769641)
24
24
"""
25
25
@simsolver FFTGS begin
26
- @param variogram = GaussianVariogram ()
27
- @param mean = 0.0
26
+ @param variogram = GaussianVariogram ()
27
+ @param mean = 0.0
28
28
@global threads = cpucores ()
29
29
@global rng = Random. GLOBAL_RNG
30
30
end
@@ -33,11 +33,12 @@ function preprocess(problem::SimulationProblem, solver::FFTGS)
33
33
hasdata (problem) && @error " conditional simulation is not implemented"
34
34
35
35
# retrieve problem info
36
- pdomain = domain (problem)
37
- dims = size (pdomain)
38
- nelms = nelements (pdomain)
39
- center = CartesianIndex (dims .÷ 2 )
40
- cindex = LinearIndices (dims)[center]
36
+ pdomain = domain (problem)
37
+ pgrid, _ = unview (pdomain)
38
+ dims = size (pgrid)
39
+ nelms = nelements (pgrid)
40
+ center = CartesianIndex (dims .÷ 2 )
41
+ cindex = LinearIndices (dims)[center]
41
42
42
43
# number of threads in FFTW
43
44
FFTW. set_num_threads (solver. threads)
@@ -63,8 +64,8 @@ function preprocess(problem::SimulationProblem, solver::FFTGS)
63
64
@assert isstationary (γ) " variogram model must be stationary"
64
65
65
66
# compute covariances between centroid and all points
66
- 𝒟c = [centroid (pdomain , cindex)]
67
- 𝒟p = [centroid (pdomain , eindex) for eindex in 1 : nelms]
67
+ 𝒟c = [centroid (pgrid , cindex)]
68
+ 𝒟p = [centroid (pgrid , eindex) for eindex in 1 : nelms]
68
69
covs = sill (γ) .- pairwise (γ, 𝒟c, 𝒟p)
69
70
C = reshape (covs, dims)
70
71
@@ -85,8 +86,9 @@ function solvesingle(problem::SimulationProblem, covars::NamedTuple, solver::FFT
85
86
rng = solver. rng
86
87
87
88
# retrieve problem info
88
- pdomain = domain (problem)
89
- dims = size (pdomain)
89
+ pdomain = domain (problem)
90
+ pgrid, inds = unview (pdomain)
91
+ dims = size (pgrid)
90
92
91
93
mactypeof = Dict (name (v) => mactype (v) for v in variables (problem))
92
94
@@ -108,7 +110,7 @@ function solvesingle(problem::SimulationProblem, covars::NamedTuple, solver::FFT
108
110
Z .= √ (sill (γ) / σ²) .* Z .+ μ
109
111
110
112
# flatten result
111
- var => vec (Z)
113
+ var => Z[inds]
112
114
end
113
115
114
116
Dict (varreal)
0 commit comments