Skip to content

Commit b9c3572

Browse files
author
Jeremy E Kozdon
committed
Call DMSetUp! inside DMDACreateXd
1 parent df96fb0 commit b9c3572

4 files changed

Lines changed: 13 additions & 13 deletions

File tree

examples/ksp/ex50.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,6 @@ function main(petsclib; comm = MPI.COMM_WORLD, options...)
163163
opts...,
164164
)
165165

166-
PETSc.DMSetUp!(da)
167-
168166
ksp = PETSc.KSP(da; opts...)
169167

170168
PETSc.KSPSetComputeRHS!(ksp, rhs!)

src/dm.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@ mutable struct DM{PetscLib} <: AbstractDM{PetscLib}
99
end
1010

1111
"""
12-
DMSetUp!(da::DM)
12+
DMSetUp!(da::DM, opts=da.opts)
1313
1414
# External Links
15+
$(_doc_external("DM/DMSetFromOptions"))
1516
$(_doc_external("DM/DMSetUp"))
1617
"""
1718
function DMSetUp! end
1819

19-
@for_petsc function DMSetUp!(da::DM{$PetscLib})
20-
with(da.opts) do
20+
@for_petsc function DMSetUp!(da::DM{$PetscLib}, opts::Options=da.opts)
21+
with(opts) do
2122
@chk ccall(
2223
(:DMSetFromOptions, $petsc_library),
2324
PetscErrorCode,

src/dmda.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ end
2222
dof_per_node,
2323
stencil_width,
2424
points_per_proc::Union{Nothing, Vector{PetscInt}};
25+
dmsetup=true,
2526
options...
2627
)
2728
2829
Creates a 1-D distributed array with the options specified using keyword
2930
arguments.
3031
32+
If keyword argument `dmsetup == true` then `DMSetUp!` is also called.
33+
3134
# External Links
3235
$(_doc_external("DMDA/DMDACreate1d"))
3336
"""
@@ -41,6 +44,7 @@ function DMDACreate1d end
4144
dof_per_node,
4245
stencil_width,
4346
points_per_proc::Union{Nothing, Vector{$PetscInt}};
47+
dmsetup=true,
4448
options...,
4549
)
4650
opts = Options($petsclib, options...)
@@ -73,6 +77,7 @@ function DMDACreate1d end
7377
da,
7478
)
7579
end
80+
dmsetup && DMSetUp!(da)
7681
# We can only let the garbage collect finalize when we do not need to
7782
# worry about MPI (since garbage collection is asyncronous)
7883
if comm == MPI.COMM_SELF
@@ -121,6 +126,7 @@ function DMDACreate2d end
121126
stencil_width,
122127
points_per_proc_x::Union{Nothing, Vector{$PetscInt}},
123128
points_per_proc_y::Union{Nothing, Vector{$PetscInt}};
129+
dmsetup=true,
124130
options...,
125131
)
126132
opts = Options($petsclib, options...)
@@ -171,6 +177,7 @@ function DMDACreate2d end
171177
da,
172178
)
173179
end
180+
dmsetup && DMSetUp!(da)
174181
# We can only let the garbage collect finalize when we do not need to
175182
# worry about MPI (since garbage collection is asyncronous)
176183
if comm == MPI.COMM_SELF
@@ -228,6 +235,7 @@ function DMDACreate3d end
228235
points_per_proc_x::Union{Nothing, Vector{$PetscInt}},
229236
points_per_proc_y::Union{Nothing, Vector{$PetscInt}},
230237
points_per_proc_z::Union{Nothing, Vector{$PetscInt}};
238+
dmsetup=true,
231239
options...,
232240
)
233241
opts = Options($petsclib, options...)
@@ -292,6 +300,7 @@ function DMDACreate3d end
292300
da,
293301
)
294302
end
303+
dmsetup && DMSetUp!(da)
295304
# We can only let the garbage collect finalize when we do not need to
296305
# worry about MPI (since garbage collection is asyncronous)
297306
if comm == MPI.COMM_SELF

test/dmda.jl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ PETSc.initialize()
4141
stencil_width,
4242
points_per_proc,
4343
)
44-
PETSc.DMSetUp!(da)
4544

4645
@test PETSc.gettype(da) == "da"
4746
@test PETSc.DMGetDimension(da) == 1
@@ -83,7 +82,6 @@ PETSc.initialize()
8382
nothing;
8483
da_refine = da_refine,
8584
)
86-
PETSc.DMSetUp!(da)
8785
@test PETSc.gettype(da) == "da"
8886
@test PETSc.DMGetDimension(da) == 1
8987

@@ -157,7 +155,6 @@ end
157155
nothing,
158156
nothing,
159157
)
160-
PETSc.DMSetUp!(da)
161158
@test PETSc.gettype(da) == "da"
162159
@test PETSc.DMGetDimension(da) == 2
163160

@@ -189,7 +186,6 @@ end
189186
nothing;
190187
da_refine = da_refine,
191188
)
192-
PETSc.DMSetUp!(da)
193189
@test PETSc.gettype(da) == "da"
194190
@test PETSc.DMGetDimension(da) == 2
195191

@@ -271,7 +267,6 @@ end
271267
nothing,
272268
nothing,
273269
)
274-
PETSc.DMSetUp!(da)
275270
@test PETSc.gettype(da) == "da"
276271
@test PETSc.DMGetDimension(da) == 3
277272

@@ -308,7 +303,6 @@ end
308303
nothing;
309304
da_refine = da_refine,
310305
)
311-
PETSc.DMSetUp!(da)
312306
@test PETSc.gettype(da) == "da"
313307
@test PETSc.DMGetDimension(da) == 3
314308

@@ -369,7 +363,6 @@ end
369363
stencil_width,
370364
points_per_proc,
371365
)
372-
PETSc.DMSetUp!(da)
373366
mat = PETSc.DMCreateMatrix(da)
374367

375368
# Build the 1-D Laplacian FD matrix
@@ -426,7 +419,6 @@ end
426419
stencil_width,
427420
points_per_proc,
428421
)
429-
PETSc.DMSetUp!(da)
430422

431423
corners = PETSc.DMDAGetCorners(da)
432424

0 commit comments

Comments
 (0)