Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Martinheida patch 3 #20

Merged
merged 19 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
# Für nightly-Tests Fehler nur als Warnung behandeln
continue-on-error: ${{ matrix.version == 'nightly' }}
strategy:
fail-fast: false
matrix:
version:
- '1.7'
- '1.9'
- 'nightly'
os:
- ubuntu-latest
Expand Down
7 changes: 5 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "HighVoronoi"
uuid = "1d30c219-805f-47bd-9cb8-33f291c94a4c"
authors = ["Martin Heida"]
version = "1.3.1"
version = "1.4.0"

[deps]
Crayons = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
Expand All @@ -19,21 +19,24 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
DoubleFloats = "497a8b3b-efae-58df-a0af-a86822472b78"


[compat]
julia = "1.7"
Crayons = "4.1"
GLPK = "1.1"
IterTools = "1.4"
IterativeSolvers = "0.9.2"
JLD2 = "0.4.31"
JLD2 = ">=0.4.31, <0.5.12"
NearestNeighbors = "0.4.13"
Polyhedra = "0.7.6"
SpecialFunctions = "1,2"
StaticArrays = "1.5"
Plots = "1.30"
Distances = "0.10.11"
ProgressMeter = "1.10"
DoubleFloats = "1.0"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# HighVoronoi.jl
A Julia Package for parallelized computing of high dimensional (i.e. any dimension >= 2) Voronoi Meshes and setting up Finite Volume computations on these Meshes
# HighVoronoi.jl new version 1.4.0
A Julia Package for parallelized computing of high dimensional (i.e. any dimension >= 2) Euclidean and Spherical Voronoi Meshes and setting up Finite Volume computations on these Meshes. Also allows parallelized convex hull computation.

[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://martinheida.github.io/HighVoronoi.jl/stable/)
[![Dev(broken)](https://img.shields.io/badge/docs-dev-blue.svg)](https://martinheida.github.io/HighVoronoi.jl/dev/)
Expand All @@ -9,4 +9,5 @@ A Julia Package for parallelized computing of high dimensional (i.e. any dimensi

Refer to the manual for detailed information on how to use.

The new version 1.4.0 provides spherical meshes and convex hull computation.
The new version 1.3.0 has improved performance due to new internal data structure and parallelization.
4 changes: 3 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ makedocs(;
),
pages=[
"Home" => "index.md",
"Convex Hulls" => "man/convexhull.md",
"Manual Voronoi" => Any[
"Examples Voronoi Generation" => "man/short.md",
"man/workflowmesh.md",
"man/geometry.md",
"man/sphere.md",
"man/raycast.md",
"man/multithread.md",
"man/database.md",
Expand Down Expand Up @@ -50,6 +52,6 @@ makedocs(;
deploydocs(;
repo="github.com/martinheida/HighVoronoi.jl",
devbranch="main",
devurl = "v1.3.0",#"v1.0.2",
devurl = "v1.4.0",#"v1.0.2",
# versions = ["stable" => "v^", "v#.#.#",],
)
7 changes: 6 additions & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@
CurrentModule = HighVoronoi
```

# HighVoronoi 1.3.0: $N\log N$ complexity Parallel Computed Voronoi Grids in $\mathbb{R}^d$
# HighVoronoi 1.4.0: $N\log N$ complexity Parallel Computed Voronoi Grids in $\mathbb{R}^d$ and on $\mathbb{S}^d$

Documentation for [HighVoronoi](https://github.com/martinheida/HighVoronoi.jl). Voronoi mesh generation in arbitrary dimensions + Finite Volume setup, also for vertices with $d+k$, $k>1$ generators.

- [QUICK START on VORONOI generation: Click here](@ref quickVG) / [The ABSTRACT WORKFLOW is here](@ref workflowgeometry)
- [QUICK START on FINITE VOLUME methods: Click here](@ref QuickFV) / [The ABSTRACT WORKFLOW is here](@ref workflowfv)
- [Toy file for testing numerical solver](@ref toyfile)

### News to version 1.4.0:

- [Parallelized computation of convex hulls](@ref convexhull) based on the raycast algorithm (no volumes / integrals)
- [Parallelized computation of Voronoi diagrams on spheres](@ref voronoisphere), including volumes and integrals (spheres are the only non-euclidian geometry where the raycast algorithm can be applied)

### News to version 1.3.0:

- Parallelized compuation of Voronoi Diagrams, volumes and integrals
Expand Down
13 changes: 13 additions & 0 deletions docs/src/man/convexhull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

# [Convex Hull](@id convexhull)

Use the following to compute the convex hull of the `VoronoiNodes` `xs`:

```@julia
cv = ConvexHull(xs,"computing convex hull: "; nthreads=Threads.nthreads(), method = RCOriginal)
```

- Note that only the following methods are available: `RCOriginal`, `RCNonGeneral`. Again, `RCOriginal` is faster and for nodes in general position (that means there are only $d$ points in $\mathbb{R}^d$ that generate one surface element) while `RCNonGeneral` can be used for nodes in non-general position.
- `nthreads` will be initialized with `Threads.nthreads()` by default. If you want less threads, provide a positive `Int64`. You can set the string to ` "" ` in order to have only a progress bar.
- `length(cv)` will give you the number of surface elements
- `cv[i]` will then give you `(sig,r,u)` where `sig` is a list of generating nodes, `r` is a point on the plane equidistant to all `sig` and `u` is the outer normal of that plane.
70 changes: 70 additions & 0 deletions docs/src/man/sphere.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

# [Voronoi diagrams on spheres](@id voronoisphere)

## Simple example and explanation

You can generate a partition of the full sphere as follows:

```@julia
A=randn(3,400)
for k in 1:400
A[:,k] .= normalize(A[:,k])
end
vs = VoronoiSphere(VoronoiNodes(A), integrate=true, integrator=VI_FAST_POLYGON)
vd = VoronoiData(vs)
println(sum(vd.volume))
```
In the above example, the output should be close to $4\pi$, but will be lower by a systemic error (see following comments for a fix).


Some comments:
- `VI_MONTECARLO` may not be very accurate. You either need a high number of rays or you may be better of with `VI_FAST_POLYGON` and alike
- `VoronoiSphere` supports all commands of `VoronoiGeometry` except for the following: `periodic_grid`, `improving`
- `VoronoiSphere` comes with the additional commands:
- `total_area`: provide a `Float64` if you know the total area. This is helpful as it will correct the surface integral of functions according to a scaling factor that arises from computed area vs. provided `total_area`.
- `transformations`: provide a list of maps that will copy the given nodes and identify the copies with the originals at the stage of `VoronoiData` computation. Application: In 4 dimensions, the upper half of the $\mathbb{S}^3$ with "periodic boundary conditions" is equivalent to the $SO(3)$. See the following example.
- `center`: if you know the center of the sphere, you can provide it. Otherwise, `HighVoronoi` will try to figure out the center from the data.
- `systematic_error=0.0001`: This parameter adjusts an unavoidable error at the interface integrals. a value of `0.0001` means a systematic error of `0.01`%. If you set it to zero, it will crash.

## Advanced examples

The area of the upper half of the sphere using periodic boundary conditions:

```@julia

A=randn(3,400)
for k in 1:400
A[:,k] .= normalize(A[:,k])
if A[1,k] < 0.0
A[1,k] = -A[1,k]
end
end
vs = VoronoiSphere(VoronoiNodes(A),transformations=(x->-x,), integrate=true, integrator=VI_FAST_POLYGON)
vd = VoronoiData(vs)
println(sum(vd.volume))

```

The area of the upper half of the sphere using a mirror of the original points. In this case, if cell 1 has neighbor 1 ( use `vd.neighbors[1]` ), this segment will be part of the 2-dimensional boundary of the upper hull.

```@julia
using LinearAlgebra

A = randn(3,400)
for k in 1:400
A[:,k] .= normalize(A[:,k])
if A[1,k] < 0.0
A[1,k] = -A[1,k]
end
end

function mirror(x)
return diagm( [-1.0, 1.0, 1.0] ) * x
end

vs = VoronoiSphere(VoronoiNodes(A),transformations=(x->mirror(x),), integrate=true, integrator=VI_FAST_POLYGON)
vd = VoronoiData(vs)
println(sum(vd.volume))

```

2 changes: 1 addition & 1 deletion src/FVmesh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ end
@inline Base.getproperty(cd::SerialMesh, prop::Symbol) = dyncast_get(cd,Val(prop))
@inline @generated dyncast_get(cd::SerialMesh, ::Val{:length}) = :(getfield(cd,:data)[1])
@inline @generated dyncast_get(cd::SerialMesh, d::Val{S}) where S = :( getfield(cd, S))
@inline @generated dyncast_get(cd::SerialMesh, d::Val{:boundary_Vertices}) where S = :( getfield(cd, :meshes)[1].mesh.boundary_Vertices)
@inline @generated dyncast_get(cd::SerialMesh, d::Val{:boundary_Vertices}) = :( getfield(cd, :meshes)[1].mesh.boundary_Vertices)


@inline Base.setproperty!(cd::SerialMesh, prop::Symbol, val) = dyncast_set(cd,Val(prop),val)
Expand Down
10 changes: 9 additions & 1 deletion src/HighVoronoi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ using ProgressMeter
#using Cthulhu
using Base.Threads
using Base.Threads: Atomic, atomic_cas!
using DoubleFloats
#using LoggingExtras


#using Traceur
Expand Down Expand Up @@ -183,6 +185,9 @@ include("parallelintegral.jl")
include("voronoidomain.jl")
include("serialdomain.jl")
include("geometry.jl") # VoronoiGeometry
include("sphericalmeshview.jl")
include("sphere.jl")
include("sphericalpublicview.jl")
include("voronoidata.jl")
include("discretefunctions.jl")
include("substitute.jl") # refinement by substitution
Expand Down Expand Up @@ -228,7 +233,7 @@ include("l1projection_new.jl")
include("R-projection.jl")
include("finitevolume.jl")
include("statistics.jl")
#include("chull.jl")
include("chull.jl")
# What will be exported:
export DensityRange
export VoronoiNodes
Expand All @@ -241,6 +246,8 @@ export Voronoi_Integral
export VoronoiData
export CompactVoronoiData
export VoronoiFV
export ConvexHull
export VoronoiSphere

export refine!
export refine
Expand Down Expand Up @@ -292,6 +299,7 @@ export RaycastParameter
export RCOriginal
export RCCombined
export RCNonGeneral
export RCNonGeneralHP
export MultiThread
export SingleThread
export AutoThread
Expand Down
Loading
Loading