diff --git a/test/PeriodicModels.jl b/test/PeriodicModels.jl index 1358da3..02bf63b 100644 --- a/test/PeriodicModels.jl +++ b/test/PeriodicModels.jl @@ -1,3 +1,4 @@ +module PeriodicModelsTests using Test using Gridap, Gridap.Geometry, Gridap.Adaptivity, Gridap.ReferenceFEs @@ -34,7 +35,7 @@ function same_model(m1::DiscreteModel{Dc},m2) where Dc return A && B end -function run(ranks,Dc,isperiodic) +function driver(ranks,Dc,isperiodic) nc = (Dc==2) ? (3,3) : (3,3,3) domain = (Dc==2) ? (0,3,0,3) : (0,3,0,3,0,3) good_cmodel = CartesianDiscreteModel(domain,nc;isperiodic=isperiodic) @@ -50,18 +51,21 @@ function run(ranks,Dc,isperiodic) @test same_model(good_fmodel,fmodel) end -ranks = with_mpi() do distribute - distribute(LinearIndices((1,))) -end +function run(distribute) + np = MPI.Comm_size(MPI.COMM_WORLD) + ranks = distribute(LinearIndices((np,))) -for isperiodic in [(true,true),(true,false),(false,true)] - run(ranks,2,isperiodic) -end + for isperiodic in [(true,true),(true,false),(false,true)] + driver(ranks,2,isperiodic) + end -for isperiodic in [ - (true,true,true), - (false,true,true),(true,false,true),(true,true,false), - (false,false,true),(true,false,false),(false,true,false) - ] - run(ranks,3,isperiodic) + for isperiodic in [ + (true,true,true), + (false,true,true),(true,false,true),(true,true,false), + (false,false,true),(true,false,false),(false,true,false) + ] + driver(ranks,3,isperiodic) + end end + +end # module \ No newline at end of file diff --git a/test/mpi/PeriodicModels.jl b/test/mpi/PeriodicModels.jl new file mode 100644 index 0000000..86ee67d --- /dev/null +++ b/test/mpi/PeriodicModels.jl @@ -0,0 +1,15 @@ +using MPI +using PartitionedArrays + +include("../PeriodicModels.jl") +import .PeriodicModelsTests as TestModule + +if !MPI.Initialized() + MPI.Init() +end + +with_mpi() do distribute + TestModule.run(distribute) +end + +MPI.Finalize() diff --git a/test/runtests.jl b/test/runtests.jl index 8a3f799..0ab5e93 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -47,6 +47,9 @@ function run_tests(testdir) elseif f in ["PoissonNonConformingOctreeModelsTests.jl"] np = [1,2,4] extra_args = "" + elseif f in ["PeriodicModels.jl"] + np = [1] + extra_args = "" else np = [nprocs] extra_args = ""