Skip to content

Commit 268593c

Browse files
Merge pull request #11 from gridap/P4est_wrapper
P4est wrapper
2 parents 1579110 + a71d00b commit 268593c

File tree

12 files changed

+102
-108
lines changed

12 files changed

+102
-108
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name = "p4est_wrapper"
1+
name = "P4est_wrapper"
22
uuid = "3743d7c0-8adf-11ea-380b-7d33b0ecc1da"
33
authors = ["Victor Sande <vsande@cimne.upc.edu>", "Alberto F. Martin <alberto.martin@monash.edu>"]
44
version = "0.1.0"

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
# p4est_wrapper
1+
# P4est_wrapper
22

33
Julia wrappers for p4est library ([Parallel AMR on Forests of Octrees](http://www.p4est.org/))
44

5-
[![Build Status](https://github.com/gridap/p4est_wrapper.jl/workflows/CI/badge.svg?branch=master)](https://github.com/gridap/p4est_wrapper.jl/actions)
6-
[![Codecov](https://codecov.io/gh/gridap/p4est_wrapper.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/gridap/p4est_wrapper.jl)
5+
[![Build Status](https://github.com/gridap/P4est_wrapper.jl/workflows/CI/badge.svg?branch=master)](https://github.com/gridap/P4est_wrapper.jl/actions)
6+
[![Codecov](https://codecov.io/gh/gridap/P4est_wrapper.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/gridap/P4est_wrapper.jl)
77

88

99
## Basic Usage
1010

1111
```julia
1212
using MPI
13-
using p4est_wrapper
13+
using P4est_wrapper
1414
using Test
1515

16-
sc_init(MPI.COMM_WORLD, Cint(true), Cint(true), C_NULL, p4est_wrapper.SC_LP_DEFAULT)
17-
p4est_init(C_NULL, p4est_wrapper.SC_LP_DEFAULT)
16+
sc_init(MPI.COMM_WORLD, Cint(true), Cint(true), C_NULL, P4est_wrapper.SC_LP_DEFAULT)
17+
p4est_init(C_NULL, P4est_wrapper.SC_LP_DEFAULT)
1818
unitsquare_connectivity = p4est_connectivity_new_unitsquare()
1919
unitsquare_forest = p4est_new(MPI.COMM_WORLD, unitsquare_connectivity, 0, C_NULL, C_NULL)
2020
...
@@ -28,38 +28,38 @@ MPI.Finalize()
2828

2929
## Installation
3030

31-
**p4est_wrapper.jl** itself is installed when you add and use it into another project.
31+
**P4est_wrapper.jl** itself is installed when you add and use it into another project.
3232

3333
Please, ensure that your system fulfill the requirements.
3434

3535
To include into your project form Julia REPL, use the following commands:
3636

3737
```
38-
pkg> add p4est_wrapper
39-
julia> using p4est_wrapper
38+
pkg> add P4est_wrapper
39+
julia> using P4est_wrapper
4040
```
4141

4242
If, for any reason, you need to manually build the project, write down the following commands in Julia REPL:
4343
```
44-
pkg> add p4est_wrapper
45-
pkg> build p4est_wrapper
46-
julia> using p4est_wrapper
44+
pkg> add P4est_wrapper
45+
pkg> build P4est_wrapper
46+
julia> using P4est_wrapper
4747
```
4848

4949
### Requirements
5050

5151
- `p4est >= 2.2`
5252
- `MPI`
5353

54-
`p4est_wrapper` julia package requires `p4est` library ([Parallel AMR on Forests of Octrees](http://www.p4est.org/)), and (optionally) `MPI` to work correctly.
54+
`P4est_wrapper` julia package requires `p4est` library ([Parallel AMR on Forests of Octrees](http://www.p4est.org/)), and (optionally) `MPI` to work correctly.
5555
- Latests versions of julia `MPI` use artifacts to locally install a MPI distribution. You should take care with the compatibility (version/vendor/distribution) between the parallel `p4est` and `MPI` libraries. If you want julia `MPI` library to wrap your local MPI library, you must export `JULIA_MPI_BINARY="system"` before installing the package.
56-
- Parallel `p4est` library can be manually installed in a custom path on your local machine. In order to succesfull describe your custom installation to be discovered by `p4est_wrapper`, you must export `P4EST_ROOT_DIR` environment variable pointing to the installation directory. If this environment variable is not available, and `julia >= 1.3`, `p4est_wrapper` will try to use [`P4est_jll` artifact](https://github.com/JuliaBinaryWrappers/P4est_jll.jl), but you should take into account that this artifact is not for parallel computations (MPI not enabled). Finally, in other case `p4est_wrapper` will try to find the `p4est` library in the usual linux user library directory (`/usr/lib`).
56+
- Parallel `p4est` library can be manually installed in a custom path on your local machine. In order to succesfull describe your custom installation to be discovered by `P4est_wrapper`, you must export `P4EST_ROOT_DIR` environment variable pointing to the installation directory. If this environment variable is not available, and `julia >= 1.3`, `P4est_wrapper` will try to use [`P4est_jll` artifact](https://github.com/JuliaBinaryWrappers/P4est_jll.jl), but you should take into account that this artifact is not for parallel computations (MPI not enabled). Finally, in other case `P4est_wrapper` will try to find the `p4est` library in the usual linux user library directory (`/usr/lib`).
5757

5858
#### Basic OpenMPI installation in debian based systems
5959

6060
`MPI` can be obtained from the default repositories of your Debian-based OS by means of `apt` tool.
6161

62-
Basic `MPI` installation in order to use it from `p4est_wrapper` julia package is as follows:
62+
Basic `MPI` installation in order to use it from `P4est_wrapper` julia package is as follows:
6363

6464
```
6565
apt-get update
@@ -102,8 +102,8 @@ Note: you need the following tools:
102102

103103
## Automated p4est wrapper generator
104104

105-
`p4est_wrapper` bindings are automatically generated by using [Clang](https://github.com/JuliaInterop/Clang.jl) package.
105+
`P4est_wrapper` bindings are automatically generated by using [Clang](https://github.com/JuliaInterop/Clang.jl) package.
106106

107-
To learn more about how it works, please read the README file at [gen directory](https://github.com/gridap/p4est_wrapper.jl/tree/master/gen).
107+
To learn more about how it works, please read the README file at [gen directory](https://github.com/gridap/P4est_wrapper.jl/tree/master/gen).
108108

109109

docs/make.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
using Documenter, p4est_wrapper
1+
using Documenter, P4est_wrapper
22

33
makedocs(;
4-
modules=[p4est_wrapper],
4+
modules=[P4est_wrapper],
55
format=Documenter.HTML(),
66
pages=[
77
"Home" => "index.md",
88
],
9-
repo="https://github.com/gridap/p4est_wrapper.jl/blob/{commit}{path}#L{line}",
10-
sitename="p4est_wrapper.jl",
9+
repo="https://github.com/gridap/P4est_wrapper.jl/blob/{commit}{path}#L{line}",
10+
sitename="P4est_wrapper.jl",
1111
authors="Víctor Sande <vsande@cimne.upc.edu>, Large Scale Scientific Computing",
1212
assets=String[],
1313
)
1414

1515
deploydocs(;
16-
repo="github.com/gridap/p4est_wrapper.jl",
16+
repo="github.com/gridap/P4est_wrapper.jl",
1717
)

docs/src/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# p4est_wrapper.jl
1+
# P4est_wrapper.jl
22

33
```@index
44
```
55

66
```@autodocs
7-
Modules = [p4est_wrapper]
7+
Modules = [P4est_wrapper]
88
```

src/p4est_wrapper.jl renamed to src/P4est_wrapper.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
module p4est_wrapper
1+
module P4est_wrapper
22

33
################################################################
44
# Check correct installation
55
################################################################
66
# Load in `deps.jl`, complaining if it does not exist
77
const depsjl_path = joinpath(@__DIR__, "..", "deps", "deps.jl")
88
if !isfile(depsjl_path)
9-
error("p4est_wrapper was not build properly. Please run Pkg.build(\"p4est.jl\").")
9+
error("P4est_wrapper was not build properly. Please run Pkg.build(\"p4est.jl\").")
1010
end
1111
include(depsjl_path)
1212
# Check if p4est library was found
1313
if(!P4EST_FOUND)
14-
error("p4est_wrapper was not build properly. Please run Pkg.build(\"p4est.jl\").")
14+
error("P4est_wrapper was not build properly. Please run Pkg.build(\"p4est.jl\").")
1515
end
1616

1717
# Use library path from build process
1818
const p4est_lib = P4EST_LIB
1919

2020
################################################################
21-
# Use dependencies
21+
# Use dependencies
2222
################################################################
2323
using Libdl
2424
using MPI
@@ -32,7 +32,7 @@ export Ctm, Ctime_t, Cclock_t
3232

3333
# Include P4EST bindings
3434

35-
# The following file fix and/or complete
35+
# The following file fix and/or complete
3636
# the automated generation of types and data structures
3737
include(joinpath(@__DIR__, "common_fixes.jl"))
3838

@@ -56,7 +56,7 @@ include(joinpath(@__DIR__, "api_fixes.jl"))
5656
# Export everything starting with ...
5757
################################################################
5858
foreach(names(@__MODULE__, all=true)) do s
59-
if startswith(string(s), "sc") || startswith(string(s), "p4est") || startswith(string(s), "p6est") || startswith(string(s), "p8est")
59+
if startswith(string(s), "sc") || startswith(string(s), "p4est") || startswith(string(s), "p6est") || startswith(string(s), "p8est")
6060
@eval export $s
6161
end
6262
end

test/example_1.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using MPI
2-
using p4est_wrapper
2+
using P4est_wrapper
33
using Test
44

55
# Initialize MPI if not initialized yet
@@ -38,17 +38,17 @@ const search_point_fn_c = @cfunction(search_point_fn, Cint, (Ptr{p4est_t}, p4est
3838
# Main program
3939
#############################################################################
4040

41-
mpicomm = p4est_wrapper.P4EST_ENABLE_MPI ? MPI.COMM_WORLD : Cint(0)
41+
mpicomm = P4est_wrapper.P4EST_ENABLE_MPI ? MPI.COMM_WORLD : Cint(0)
4242

4343
# Create a connectivity structure for the unit square.
44-
unitsquare_connectivity = p4est_connectivity_new_unitsquare()
44+
unitsquare_connectivity = p4est_connectivity_new_unitsquare()
4545
@test unitsquare_connectivity != C_NULL
4646

4747
# Create a new forest
48-
unitsquare_forest = p4est_new(mpicomm, unitsquare_connectivity, 0, C_NULL, C_NULL)
48+
unitsquare_forest = p4est_new(mpicomm, unitsquare_connectivity, 0, C_NULL, C_NULL)
4949
@test unitsquare_forest != C_NULL
5050

51-
# Register callback function to decide for refinement.
51+
# Register callback function to decide for refinement.
5252
p4est_refine(unitsquare_forest, 1, my_refine_c, C_NULL)
5353

5454
# Create a new sc_array
@@ -59,7 +59,7 @@ ptr_to_points_sc_array = sc_array_new_count(sizeof(point_t), 2)
5959
points_sc_array = ptr_to_points_sc_array[]
6060
@test points_sc_array.elem_count == 2 && points_sc_array.elem_size == sizeof(point_t)
6161

62-
# Obtain reference to first point_t
62+
# Obtain reference to first point_t
6363
ptr_to_points_array = Ptr{point_t}(sc_array_index(ptr_to_points_sc_array,0))
6464
@test ptr_to_points_array != C_NULL
6565

test/example_2.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using MPI
2-
using p4est_wrapper
2+
using P4est_wrapper
33
using Test
44

55
# Initialize MPI if not initialized yet
@@ -26,24 +26,24 @@ const my_refine_c = @cfunction(my_refine, Cint, (Ptr{p4est_t}, p4est_topidx_t, P
2626
# Main program
2727
#############################################################################
2828

29-
mpicomm = p4est_wrapper.P4EST_ENABLE_MPI ? MPI.COMM_WORLD : Cint(0)
29+
mpicomm = P4est_wrapper.P4EST_ENABLE_MPI ? MPI.COMM_WORLD : Cint(0)
3030

3131
# Create a connectivity structure for the unit square.
32-
unitsquare_connectivity = p4est_connectivity_new_unitsquare()
32+
unitsquare_connectivity = p4est_connectivity_new_unitsquare()
3333
@assert Bool(p4est_connectivity_is_valid(unitsquare_connectivity))
3434

3535
# Create a new forest
36-
unitsquare_forest = p4est_new(mpicomm, unitsquare_connectivity, sizeof(p4est_quadrant_t), C_NULL, C_NULL)
36+
unitsquare_forest = p4est_new(mpicomm, unitsquare_connectivity, sizeof(p4est_quadrant_t), C_NULL, C_NULL)
3737
@test unitsquare_forest != C_NULL
3838

39-
# Register callback function to decide for refinement.
39+
# Register callback function to decide for refinement.
4040
p4est_refine(unitsquare_forest, 1, my_refine_c, C_NULL)
4141

4242
# Equally partition the forest. The partition can be by element count or by a user-defined weight.
4343
p4est_partition(unitsquare_forest, 0, C_NULL);
4444

45-
# Build the ghost layer.
46-
ptr_to_p4est_ghost = p4est_ghost_new(unitsquare_forest, p4est_wrapper.P4EST_CONNECT_FULL)
45+
# Build the ghost layer.
46+
ptr_to_p4est_ghost = p4est_ghost_new(unitsquare_forest, P4est_wrapper.P4EST_CONNECT_FULL)
4747
p4est_ghost = ptr_to_p4est_ghost[]
4848

4949
# Obtain ghost quadrants
@@ -56,7 +56,7 @@ for i=1:p4est_ghost.mpisize
5656
quadrant = ptr_ghost_quadrants[j+1]
5757
piggy3 = quadrant.p.piggy3
5858
@test Bool(p4est_quadrant_is_valid(ptr_ghost_quadrants+(sizeof(p4est_quadrant_t)*j)))
59-
p4est_quadrant_print(p4est_wrapper.SC_LP_INFO, ptr_ghost_quadrants+(sizeof(p4est_quadrant_t)*j))
59+
p4est_quadrant_print(P4est_wrapper.SC_LP_INFO, ptr_ghost_quadrants+(sizeof(p4est_quadrant_t)*j))
6060
print("(i, j, local_num, which_tree) ($(i),$(j),$(piggy3.local_num),$(piggy3.which_tree)) \n")
6161
end
6262
end

test/example_3.jl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using MPI
2-
using p4est_wrapper
2+
using P4est_wrapper
33
using Test
44

55
# Initialize MPI if not initialized yet
@@ -27,8 +27,8 @@ const coarsen_flag = Cint(2)
2727
# back function to an array of ints with as many entries as forest quadrants. This call back function
2828
# initializes the quadrant->p.user_data void * pointer of all quadrants such that it
2929
# points to the corresponding entry in the global array mentioned in the previous sentence.
30-
function init_fn_callback_2d(forest_ptr::Ptr{p4est_t},
31-
which_tree::p4est_topidx_t,
30+
function init_fn_callback_2d(forest_ptr::Ptr{p4est_t},
31+
which_tree::p4est_topidx_t,
3232
quadrant_ptr::Ptr{p4est_quadrant_t})
3333
@assert which_tree == 0
3434
# Extract a reference to the first (and uniquely allowed) tree
@@ -45,8 +45,8 @@ end
4545

4646
const init_fn_callback_2d_c = @cfunction(init_fn_callback_2d, Cvoid, (Ptr{p4est_t}, p4est_topidx_t, Ptr{p4est_quadrant_t}))
4747

48-
function refine_callback_2d(::Ptr{p4est_t},
49-
which_tree::p4est_topidx_t,
48+
function refine_callback_2d(::Ptr{p4est_t},
49+
which_tree::p4est_topidx_t,
5050
quadrant_ptr::Ptr{p4est_quadrant_t})
5151
@assert which_tree == 0
5252
quadrant = quadrant_ptr[]
@@ -58,17 +58,17 @@ const refine_callback_2d_c = @cfunction(refine_callback_2d, Cint, (Ptr{p4est_t},
5858
# For each refined quadrant:
5959
# num_calls is even -> leave untouched all children
6060
# num_calls is odd -> mark all children for coarsening
61-
function refine_replace_callback_2d(forest_ptr::Ptr{p4est_t},
62-
which_tree::p4est_topidx_t,
63-
num_outgoing::Cint,
64-
outgoing_ptr::Ptr{Ptr{p4est_quadrant_t}},
65-
num_incoming::Cint,
61+
function refine_replace_callback_2d(forest_ptr::Ptr{p4est_t},
62+
which_tree::p4est_topidx_t,
63+
num_outgoing::Cint,
64+
outgoing_ptr::Ptr{Ptr{p4est_quadrant_t}},
65+
num_incoming::Cint,
6666
incoming_ptr::Ptr{Ptr{p4est_quadrant_t}})
6767
@assert which_tree == 0
6868
@assert num_outgoing == 1
69-
@assert num_incoming == p4est_wrapper.P4EST_CHILDREN
70-
incoming = unsafe_wrap(Array, incoming_ptr, p4est_wrapper.P4EST_CHILDREN)
71-
for quadrant_index = 1:p4est_wrapper.P4EST_CHILDREN
69+
@assert num_incoming == P4est_wrapper.P4EST_CHILDREN
70+
incoming = unsafe_wrap(Array, incoming_ptr, P4est_wrapper.P4EST_CHILDREN)
71+
for quadrant_index = 1:P4est_wrapper.P4EST_CHILDREN
7272
quadrant = incoming[quadrant_index][]
7373
if (num_calls % 2 == 0)
7474
unsafe_store!(Ptr{Cint}(quadrant.p.user_data), nothing_flag, 1)
@@ -87,8 +87,8 @@ function coarsen_callback_2d(forest_ptr::Ptr{p4est_t},
8787
quadrants_ptr::Ptr{Ptr{p4est_quadrant_t}})
8888
@assert which_tree == 0
8989
coarsen = Cint(1)
90-
quadrants = unsafe_wrap(Array, quadrants_ptr, p4est_wrapper.P4EST_CHILDREN)
91-
for quadrant_index = 1:p4est_wrapper.P4EST_CHILDREN
90+
quadrants = unsafe_wrap(Array, quadrants_ptr, P4est_wrapper.P4EST_CHILDREN)
91+
for quadrant_index = 1:P4est_wrapper.P4EST_CHILDREN
9292
quadrant = quadrants[quadrant_index][]
9393
coarsen = Cint(unsafe_wrap(Array, Ptr{Cint}(quadrant.p.user_data), 1)[] == coarsen_flag)
9494
if (!Bool(coarsen)) return coarsen end
@@ -119,9 +119,9 @@ end
119119
# Main program
120120
#############################################################################
121121

122-
mpicomm = p4est_wrapper.P4EST_ENABLE_MPI ? MPI.COMM_WORLD : Cint(0)
123-
sc_init(mpicomm, Cint(true), Cint(true), C_NULL, p4est_wrapper.SC_LP_DEFAULT)
124-
p4est_init(C_NULL, p4est_wrapper.SC_LP_DEFAULT)
122+
mpicomm = P4est_wrapper.P4EST_ENABLE_MPI ? MPI.COMM_WORLD : Cint(0)
123+
sc_init(mpicomm, Cint(true), Cint(true), C_NULL, P4est_wrapper.SC_LP_DEFAULT)
124+
p4est_init(C_NULL, P4est_wrapper.SC_LP_DEFAULT)
125125

126126
unitsquare_connectivity = p4est_connectivity_new_unitsquare()
127127
unitsquare_forest = p4est_new(mpicomm, unitsquare_connectivity, 0, C_NULL, C_NULL)

test/runtests.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
using MPI
2-
using p4est_wrapper
2+
using P4est_wrapper
33
using Test
44

55

66
# Skip tests if library was not properly loaded
7-
if p4est_wrapper.P4EST_FOUND
7+
if P4est_wrapper.P4EST_FOUND
88

99

1010
nprocs = min(Sys.CPU_THREADS, 2)
1111
dir = dirname(@__FILE__)
1212
julia = Base.julia_cmd()
1313
mpiexec = MPI.mpiexec_path
14-
@testset "Test SC bindings" begin
14+
@testset "Test SC bindings" begin
1515
cmd = `$mpiexec -n $nprocs --allow-run-as-root --tag-output $(julia) $(joinpath(dir, "test_sc_bindings.jl"))`
1616
@show cmd
1717
run(cmd)
1818
end
19-
@testset "Test P4EST bindings" begin
19+
@testset "Test P4EST bindings" begin
2020
cmd = `$mpiexec -n $nprocs --allow-run-as-root --tag-output $(julia) $(joinpath(dir, "test_p4est_bindings.jl"))`
2121
@show cmd
2222
run(cmd)
2323
end
24-
@testset "Test P8EST bindings" begin
24+
@testset "Test P8EST bindings" begin
2525
cmd = `$mpiexec -n $nprocs --allow-run-as-root --tag-output $(julia) $(joinpath(dir, "test_p8est_bindings.jl"))`
2626
@show cmd
2727
run(cmd)
2828
end
29-
@testset "Example 1" begin
29+
@testset "Example 1" begin
3030
cmd = `$mpiexec -n $nprocs --allow-run-as-root --tag-output $(julia) $(joinpath(dir, "example_1.jl"))`
3131
@show cmd
3232
run(cmd)
3333
end
34-
@testset "Example 2" begin
34+
@testset "Example 2" begin
3535
cmd = `$mpiexec -n $nprocs --allow-run-as-root --tag-output $(julia) $(joinpath(dir, "example_2.jl"))`
3636
@show cmd
3737
run(cmd)
3838
end
39-
@testset "Example 3" begin
39+
@testset "Example 3" begin
4040
cmd = `$mpiexec -n $nprocs --allow-run-as-root --tag-output $(julia) $(joinpath(dir, "example_3.jl"))`
4141
@show cmd
4242
run(cmd)

0 commit comments

Comments
 (0)