Skip to content

Commit

Permalink
Merge pull request #5 from gismo/develop
Browse files Browse the repository at this point in the history
Add new features, preparing v.25.1.0
  • Loading branch information
hverhelst authored Jan 9, 2025
2 parents e54d61c + 15c1be3 commit 421233d
Show file tree
Hide file tree
Showing 30 changed files with 1,993 additions and 450 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name = "Gismo"
uuid = "f019f137-166b-4455-b646-ee200b009b83"
authors = ["Hugo Verhelst <hugoverhelst1995@gmail.com>"]
version = "0.1.0"
version = "25.1.0"

[deps]
gismo_jll = "c3015cfb-32aa-504c-ba3d-5541e7ecaf35"

[compat]
gismo_jll = "24.8.0"
gismo_jll = "25.1.0"
julia = "1.9"

[extras]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ The Gismo.jl package can be directly downloaded from Julia's package management
```
] add Gismo
```
This command fetches the dependency [`gismo_jll`](LINK) contaning pre-compiled library files, and it fetches the current repository which calls `gismo_jll`.
This command fetches the dependency [`gismo_jll`](https://github.com/JuliaBinaryWrappers/gismo_jll.jl) contaning pre-compiled library files, and it fetches the current repository which calls `gismo_jll`.

### Enabling Gismo.jl locally
Alternatively, one can use a local build of G+Smo as a back-end for the Julia bindings. This requires the [`gsCInterface`](LINK) module to be compiled, and the Gismo.jl package to be fetched as a submodule in G+Smo.
Alternatively, one can use a local build of G+Smo as a back-end for the Julia bindings. This requires the [`gsCInterface`](https://github.com/gismo/gsCInterface) module to be compiled, and the Gismo.jl package to be fetched as a submodule in G+Smo.

#### a. Fetching and compiling the required G+Smo submodules
Enable the `gsCInterface` and the `Gismo.jl` modules inside G+Smo
Expand Down
18 changes: 13 additions & 5 deletions cmake/Gismo.jl.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,25 @@ module Gismo
# Forward declaration of structs
include("Declarations.jl")

# Load gsMatrix
include("gsMatrix.jl")

# Load gsCore
include("gsCore.jl")

# Load gsNurbs
include("gsNurbs.jl")
# Load gsMatrix
include("gsMatrix.jl")

# Load gsAssembler
include("gsAssembler.jl")

# Load gsHSplines
include("gsHSplines.jl")

# Load gsIO
include("gsIO.jl")

# Load gsMatrix
include("gsModeling.jl")

# Load gsNurbs
include("gsNurbs.jl")

end #module
8 changes: 6 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ DocMeta.setdocmeta!(Gismo,
# List of subsection pages
SUBSECTION_PAGES = [
"gsCore.md",
"gsNurbs.md",
"gsHSplines.md"
"gsAssembler.md",
"gsHSplines.md",
"gsIO.md",
"gsMatrix.md",
"gsModeling.md",
"gsNurbs.md"
]

makedocs(
Expand Down
10 changes: 10 additions & 0 deletions docs/src/gsAssembler.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# gsAssembler

The methods in `gsAssembler` contain methods used for assembly.

## Function Documentation
```@autodocs
Modules = [Gismo]
Pages = ["src/gsAssembler.jl"]
Order = [:function, :type]
```
6 changes: 2 additions & 4 deletions docs/src/gsCore.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# gsCore

The methods in `gsCore` contain basis, geometry and function methods.

## Function Documentation
```@autodocs
Modules = [Gismo]
Pages = ["src/gsCore.jl"]
Order = [:function, :type]
```

```@contents
Pages = Main.SUBSECTION_PAGES
```
2 changes: 2 additions & 0 deletions docs/src/gsHSplines.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# gsHSplines

The methods in `gsHSplines` contain methods for hierarchical splines.

## Function Documentation
```@autodocs
Modules = [Gismo]
Expand Down
10 changes: 10 additions & 0 deletions docs/src/gsIO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# gsIO

The methods in `gsIO` contain G+Smo's methods for input and output.

## Function Documentation
```@autodocs
Modules = [Gismo]
Pages = ["src/gsIO.jl"]
Order = [:function, :type]
```
6 changes: 2 additions & 4 deletions docs/src/gsMatrix.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# gsMatrix

The methods in `gsMatrix` are an interface to G+Smo's linear algebra, supported by `Eigen`.

## Function Documentation
```@autodocs
Modules = [Gismo]
Pages = ["src/gsMatrix.jl"]
Order = [:function, :type]
```

```@contents
Pages = Main.SUBSECTION_PAGES
```
10 changes: 10 additions & 0 deletions docs/src/gsModeling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# gsModeling

The methods in `gsModeling` contain methods for geometric modelling, such as fitting.

## Function Documentation
```@autodocs
Modules = [Gismo]
Pages = ["src/gsModeling.jl"]
Order = [:function, :type]
```
2 changes: 2 additions & 0 deletions docs/src/gsNurbs.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# gsNurbs

The methods in `gsNurbs` contain methods related to NURBS and B-splines.

## Function Documentation
```@autodocs
Modules = [Gismo]
Expand Down
48 changes: 46 additions & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,52 @@
Julia interface for the Geometry + Simulation modules (G+Smo)

## Installation instructions
# Gismo.jl: Geometry + Simulation Modules meet Julia
The Gismo.jl package provides an interface to the [Geometry + Simulation Modules](https://github.com/gismo/gismo) inside Julia.

## Getting started
We provide a hand full of examples in the `examples` directory, which can be run after [installation](#installation) of the package.

## Installation
There are two ways to install Gismo.jl: via Julia's package manager, or by linking it to a local build of G+Smo.

### Via `Pkg`
The Gismo.jl package can be directly downloaded from Julia's package management system `Pkg` using
```
] add Gismo
```
This command fetches the dependency [`gismo_jll`](https://github.com/JuliaBinaryWrappers/gismo_jll.jl) contaning pre-compiled library files, and it fetches the current repository which calls `gismo_jll`.

### Enabling Gismo.jl locally
Alternatively, one can use a local build of G+Smo as a back-end for the Julia bindings. This requires the [`gsCInterface`](https://github.com/gismo/gsCInterface) module to be compiled, and the Gismo.jl package to be fetched as a submodule in G+Smo.

#### a. Fetching and compiling the required G+Smo submodules
Enable the `gsCInterface` and the `Gismo.jl` modules inside G+Smo
```
cd path/to/gismo/build
cmake . -DGISMO_OPTIONAL="<OTHER OPTIONAL MODULES>;gsCInterface;Gismo.jl" \
-DGISMO_JL_DEVELOP=ON
```
And compile everything
```
make gismo
```
#### b. Link libgismo to Gismo.jl
In the file `Gismo.jl/src/Gismo.jl`, the shared library should be included as follows:
```
libgismo = "path/to/gismo/build/lib/libgismo"
```

#### c. Install Gismo.jl in Julia
Add the local package Gismo.jl to Julia's development packages
```
cd path/to/gismo/
cd optional
julia -e 'using Pkg; Pkg.develop(path="Gismo.jl")'
```

## Structure of the package
The package is structured according to the `src/` folder in `gismo`'s C++ library. That is, for every directory `dir` in `src/dir`, `Gismo.jl/src` contains a `jl` file.

## Function Documentation
```@docs
```

16 changes: 8 additions & 8 deletions examples/BSpline_example.jl
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
using Plots
using Gismo
import Gismo.size

KV = Gismo.KnotVector([0.,0.,0.,1.,1.,1.])
BB = Gismo.BSplineBasis(KV)
Gismo.uniformRefine(BB)
Gismo.uniformRefine(BB)
KV = KnotVector([0.,0.,0.,1.,1.,1.])
BB = BSplineBasis(KV)
uniformRefine!(BB)
uniformRefine!(BB)

# Create a matrix of random coefficients
coefs = rand(Gismo.size(BB),2)
coefs = rand(size(BB),2)
# Create a BSpline geometry
B = Gismo.BSpline(BB,coefs)
B = BSpline(BB,coefs)

# Create a matrix of linearly spaced evaluation points
points1D = zeros(1,100)
points1D[1,:] = range(0,stop=1,length=100)
ev = Gismo.asMatrix(Gismo.eval(B,points1D))
ev = asMatrix(val(B,points1D))

# Plot the geometry
plot(ev[1,:],ev[2,:],legend=false)
plot!(coefs[:,1],coefs[:,2],legend=false)
plot!(coefs[:,1],coefs[:,2],legend=false,seriestype=:scatter)
gui()


21 changes: 21 additions & 0 deletions examples/OptionList_example.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Gismo

options = Dict([("a",1), ("b",1.1), ("c", true), ("d", "one")])
println(options)
gsOptionList = OptionList(options)
println(gsOptionList)

Gismo.setInt(gsOptionList,"a",2)
Gismo.setReal(gsOptionList,"b",2.0)
Gismo.setSwitch(gsOptionList,"c",false)
Gismo.setString(gsOptionList,"d","two")
println(gsOptionList)

int::Int = Gismo.getInt(gsOptionList,"a")
println("Integer read from option list: ",int)
double::Float64 = Gismo.getReal(gsOptionList,"b")
println("Double read from option list: ",double)
bool::Bool = Gismo.getSwitch(gsOptionList,"c")
println("Bool read from option list: ",bool)
string::Cstring = Gismo.getString(gsOptionList,"d")
println("String read from option list: ",string)
15 changes: 15 additions & 0 deletions examples/QuadRule_example.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Gismo

# Gauss quadrature rule (1D)
rule1D = GaussRule(Cint(2))
nodes,weights = mapTo(rule1D,0.0,1.0)
println("Gauss nodes: ",asMatrix(nodes))
println("Gauss nodes: ",asVector(weights))

# Lobatto quadrature rule (2D)
rule2D = LobattoRule(Cint(2),Array{Cint}([3,3]))
low = Vector{Float64}([0.0,0.0])
upp = Vector{Float64}([1.0,1.0])
nodes,weights = mapTo(rule2D,low,upp)
println("Lobatto nodes: ",asMatrix(nodes))
println("Lobatto weights: ",asVector(weights))
25 changes: 13 additions & 12 deletions examples/THBSpline_example.jl
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
using Plots
using Gismo
import Gismo.size

KV = Gismo.KnotVector([0.,0.,0.,1.,1.,1.])
TBB = Gismo.TensorBSplineBasis(KV,KV)
print("The size of the basis is: ",Gismo.size(TBB),"\n")
Gismo.uniformRefine(TBB)
print("The size of the basis is: ",Gismo.size(TBB),"\n")
THB = Gismo.THBSplineBasis(TBB)
boxes = Vector{Int32}([1,0,0,2,2])
Gismo.refineElements(THB,boxes)
KV = KnotVector([0.,0.,0.,1.,1.,1.])
TBB = TensorBSplineBasis(KV,KV)
print("The size of the basis is: ",size(TBB),"\n")
uniformRefine!(TBB)
print("The size of the basis is: ",size(TBB),"\n")
THB = THBSplineBasis(TBB)
boxes = Vector{Int}([1,0,0,2,2])
refineElements!(THB,boxes)

print("The size of the basis is: ",Gismo.size(THB),"\n")
print("The size of the basis is: ",size(THB),"\n")

# Create a matrix of random coefficients
coefs = rand(Gismo.size(TBB),3)
coefs = rand(size(TBB),3)
# Create a BSpline geometry
TB = Gismo.TensorBSpline(TBB,coefs)
TB = TensorBSpline(TBB,coefs)

# Create a matrix of linearly spaced evaluation points
N = 10
Expand All @@ -26,7 +27,7 @@ points2D = zeros(2,N*N)
points2D[1,:] = repeat(points1D, N)
points2D[2,:] = repeat(points1D, inner=N)

ev = Gismo.asMatrix(Gismo.eval(TB,points2D))
ev = asMatrix(val(TB,points2D))

# Plot the geometry
surface!(ev[1,:],ev[2,:],ev[3,:],legend=false)
Expand Down
19 changes: 11 additions & 8 deletions examples/TensorBSpline_example.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
using Plots
using Gismo
import Gismo.size

KV = Gismo.KnotVector([0.,0.,0.,1.,1.,1.])
TBB = Gismo.TensorBSplineBasis(KV,KV)
print("The size of the basis is: ",Gismo.size(TBB),"\n")
Gismo.uniformRefine(TBB)
print("The size of the basis is: ",Gismo.size(TBB),"\n")
KV = KnotVector([0.,0.,0.,1.,1.,1.])
TBB = TensorBSplineBasis(KV,KV)
print("The size of the basis is: ",size(TBB),"\n")
uniformRefine!(TBB)
print("The size of the basis is: ",size(TBB),"\n")

# Create a matrix of random coefficients
coefs = rand(Gismo.size(TBB),3)
coefs = rand(size(TBB),3)
# Create a BSpline geometry
TB = Gismo.TensorBSpline(TBB,coefs)
TB = TensorBSpline(TBB,coefs)

Gismo.size(KV)

# Create a matrix of linearly spaced evaluation points
N = 10
Expand All @@ -21,7 +24,7 @@ points2D = zeros(2,N*N)
points2D[1,:] = repeat(points1D, N)
points2D[2,:] = repeat(points1D, inner=N)

ev = Gismo.asMatrix(Gismo.eval(TB,points2D))
ev = asMatrix(val(TB,points2D))

# Plot the geometry
surface!(ev[1,:],ev[2,:],ev[3,:],legend=false)
Expand Down
Loading

0 comments on commit 421233d

Please sign in to comment.