Skip to content

Commit

Permalink
Merge branch 'feature/connectivity'
Browse files Browse the repository at this point in the history
  • Loading branch information
HoBeZwe committed Jul 2, 2024
2 parents d279136 + 7be234b commit 1eec005
Show file tree
Hide file tree
Showing 28 changed files with 4,151 additions and 312 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ The following aspects are implemented (✓) and planned (⌛):
- ⌛ Degree elevation / reduction
- ⌛ Construction of common geometries

##### Connectivity
- ✓ Determine patch connectivity
- identify interfaces between patches
- introduce per patch local numbering for vertices and edges
- ✓ Virtual Bezier mesh connectivty (for FEM)
- introduce on each patch a virtual Bezier mesh
- determine adjacency information of mesh cells


## Citation
Expand Down
28 changes: 19 additions & 9 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,26 @@ makedocs(;
),
pages=[
"Introduction" => "index.md",
"Definitions" => Any["Bases" => "basis_def.md", "Curves" => "curves_def.md", "Surfaces" => "surfaces_def.md"],
"Fundamental Operations" => Any[
"Knot Insertion" => "knotInsertion.md",
"Knot Removal" => "knotRemoval.md",
"Degree Elevation" => "degreeElevation.md",
"Degree Reduction" => "degreeReduction.md",
"Definitions & Terminology" => Any[
"B-Spline Bases" => "basis_def.md",
"Manifolds" => Any["Curves" => "curves_def.md", "Surfaces" => "surfaces_def.md"],
"Fundamental Operations" => Any[
"Knot Insertion" => "knotInsertion.md",
"Knot Removal" => "knotRemoval.md",
"Degree Elevation" => "degreeElevation.md",
"Degree Reduction" => "degreeReduction.md",
],
"Connectivity" => Any["Patch Interfaces" => "interfaces.md", "Bezier Mesh" => "bezier.md"],
],
"Manual" => Any[
"Bases Evaluation" => "basis.md",
"Curves" => Any["Defining & Evaluating" => "curves.md", "Manipulating" => "curves_man.md"],
"Surfaces" => Any["Defining & Evaluating" => "surfaces.md", "Manipulating" => "surfaces_man.md"],
"Connectivity" => "meshes.md",
"Transformations" => "trafos.md",
"File I/O" => "fileio.md",
"Utils" => "utils.md",
],
"Manual" => Any["Bases" => "basis.md", "Curves" => "curves.md", "Surfaces" => "surfaces.md", "Transformations" => "trafos.md"],
"File I/O" => "fileio.md",
"Utils" => "utils.md",
"Contributing" => "contributing.md",
"API Reference" => "apiref.md",
],
Expand Down
1,703 changes: 1,703 additions & 0 deletions docs/src/assets/BezierCells.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
950 changes: 950 additions & 0 deletions docs/src/assets/RefSquare.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions docs/src/basis.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The considered
basis functions are defined by initializing corresponding structures. A naive evaluation method is available for all, an efficient evaluation only for B-splines and Curry-Schoenberg splines.

---
## Define Structures
## Defining Structures

B-spline, Curry-Schoenberg, and NURBS bases are defined by initializing a [`Bspline`](@ref Bspline), a [`CurrySchoenberg`](@ref CurrySchoenberg), or a [`NURB`](@ref NURB) structure, respectively.

Expand Down Expand Up @@ -67,7 +67,7 @@ Plots.plot(evalpoints, bspline, w=2,
Plots.plot!(evalpoints, nurb, w=2, label="NURB")
Plots.plot!(evalpoints, cspl, w=2, label="Curry-Schoenberg")
xlims!(0, 1) # hide
ylims!(0, 1) # hide
ylims!(0, 3) # hide
savefig("plotBspl.html"); nothing # hide
```

Expand Down Expand Up @@ -112,7 +112,7 @@ Plots.plot(evalpoints, bspline, w=2,
xlabel="𝑢",
ylabel="𝑁ᵢ,₂(𝑢)")
xlims!(0, 1) # hide
ylims!(0, 1) # hide
ylims!(0, 12) # hide
savefig("plotBspleff.html"); nothing # hide
```

Expand Down
40 changes: 20 additions & 20 deletions docs/src/basis_def.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# Bases
# B-Spline Bases

The considered
- B-spline,
Expand Down Expand Up @@ -29,68 +29,68 @@ where ``u_i \leq u_{i+1}``, i.e., the entries are sorted in ascending order, ``u
---
## Definitions

### [B-Splines](@id bspl)
#### [B-Splines](@id bspl)

The B-spline basis functions of degree ``p`` are defined as ``N_{i,p}`` on the knot vector ``U`` recursively, starting with the piecewise constant (``p=0``) [[1, p. 50]](@ref refs)
The B-spline basis functions of degree ``p`` are defined as ``B_{i,p}`` on the knot vector ``U`` recursively, starting with the piecewise constant (``p=0``) [[1, p. 50]](@ref refs)
```math
N_{i,0}(u) = \begin{cases} 1 & u_i \leq u < u_{i+1} \\ 0 & \text{otherwise}\end{cases}
B_{i,0}(u) = \begin{cases} 1 & u_i \leq u < u_{i+1} \\ 0 & \text{otherwise}\end{cases}
```
as well as for ``p>0``
```math
N_{i,p}(u) = \cfrac{u - u_i}{u_{i+p} - u_i} \, N_{i, p-1}(u) + \cfrac{u_{i+p+1} - u}{u_{i+p+1} - u_{i+1}} \, N_{i+1, p-1}(u) \,.
B_{i,p}(u) = \cfrac{u - u_i}{u_{i+p} - u_i} \, B_{i, p-1}(u) + \cfrac{u_{i+p+1} - u}{u_{i+p+1} - u_{i+1}} \, B_{i+1, p-1}(u) \,.
```
Whenever one of the contained quotients exhibits a division by 0, the quotient is defined to be 0 itself.

!!! note
The number of basis functions ``B`` is related to the length of the knot vector ``M`` and the polynomial degree ``p`` as
The number of basis functions ``N`` is related to the length of the knot vector ``M`` and the polynomial degree ``p`` as
```math
B = M - p - 1 \,.
N = M - p - 1 \,.
```

### [Curry-Schoenberg Splines](@id csspl)
#### [Curry-Schoenberg Splines](@id csspl)

The Curry-Schoenberg spline basis functions [[3, p. 88]](@ref refs)
```math
n_{i,p}(u) = \cfrac{p+1}{u_{i+p+1} - u_i} N_{i,p}(u)
b_{i,p}(u) = \cfrac{p+1}{u_{i+p+1} - u_i} B_{i,p}(u)
```
are defined as a normalized version of the B-splines.



### [NURBS](@id nurbs)
#### [NURBS](@id nurbs)

Introducing ``B`` weights ``w_i \in \mathbb{R}_+`` the rational B-spline basis functions [[1, p. 118]](@ref refs)
Introducing ``N`` weights ``w_i \in \mathbb{R}_+`` the rational B-spline basis functions [[1, p. 118]](@ref refs)
```math
R_{i, p}(u) = \cfrac{N_{i, p}(u) w_i}{\sum_{j=1}^B N_{j, p}(u) w_i}
R_{i, p}(u) = \cfrac{B_{i, p}(u) w_i}{\sum_{j=1}^N B_{j, p}(u) w_i}
```
are defined based on the B-spline basis ``N_{i, p}`` on the knot vector ``U``.
are defined based on the B-spline basis ``B_{i, p}`` on the knot vector ``U``.


---
## [Derivatives](@id derB)

### B-Splines
#### B-Splines

The ``k``-th derivative of the B-splines ``N_{i, p}`` can be computed as [[1, p. 61]](@ref refs)
The ``k``-th derivative of the B-splines ``B_{i, p}`` can be computed as [[1, p. 61]](@ref refs)
```math
N_{i,p}^{(k)}(u) = p \left( \cfrac{N_{i,p-1}^{(k-1)}}{u_{i+p} - u_i} - \cfrac{N_{i+1,p-1}^{(k-1)}}{u_{i+p+1} - u_{i+1}} \right) \,.
B_{i,p}^{(k)}(u) = p \left( \cfrac{B_{i,p-1}^{(k-1)}}{u_{i+p} - u_i} - \cfrac{B_{i+1,p-1}^{(k-1)}}{u_{i+p+1} - u_{i+1}} \right) \,.
```

!!! note
The [Curry-Schoenberg](@ref csspl) splines are related to the derivatives of the B-splines as
```math
N_{i,p}^{(1)}(u) = n_{i,p-1}(u) - n_{i+1,p-1}(u) \,.
B_{i,p}^{(1)}(u) = b_{i,p-1}(u) - b_{i+1,p-1}(u) \,.
```
As this is their common use, derivatives of the Curry-Schoenberg splines are not used/implemented in this package.


### NURBS
#### NURBS

The ``k``-th derivative of the NURBS basis functions ``R_{i, p}`` can be computed as [[2]](@ref refs)
```math
R_{i,p}^{(k)}(u) = \cfrac{w_i \, N_{i,p}^{(k)}(u) - \sum_{j=1}^k \begin{pmatrix} k \\j\end{pmatrix} W^{(j)}(u) R_{i,p}^{k-j}(u)}{W^{(0)}(u)}
R_{i,p}^{(k)}(u) = \cfrac{w_i \, B_{i,p}^{(k)}(u) - \sum_{j=1}^k \begin{pmatrix} k \\j\end{pmatrix} W^{(j)}(u) R_{i,p}^{k-j}(u)}{W^{(0)}(u)}
```
with
```math
W^{(k)}(u) = \sum_{i=1}^B N_{i, p}^{(k)}(u) w_i \,.
W^{(k)}(u) = \sum_{i=1}^N B_{i, p}^{(k)}(u) w_i \,.
```
33 changes: 33 additions & 0 deletions docs/src/bezier.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

# Bezier Mesh

For finite-element (FEM) applications of NURBS and B-splines it is often required to introduce a cell-structure on the NURBS surfaces that is largely independent of the surface description.
Especially, in isogeometric approaches B-splines are used to describe quantities such as currents or charges on the surface.
To this end, it is customary to introduce on each NURBS patch a virtual mesh induced by the knot vectors of the B-splines: the Bezier mesh.

!!! note
The Bezier mesh is independent of the knot vectors of the B-splines used to describe the surface.


---
## Per Patch Conventions

The local edges and corner points numbering as defined in the [`patch conventions`](@ref localNum) is passed on to the Bezier cells.
Moreover, the numbering of the cells follows
- starting at patch one, there is a consecutive number over all patches
- on each patch the numbering starts at ``u=v=0`` and is increased first along the ``v`` axes

```@raw html
<div align="center">
<img src="../assets/BezierCells.svg" width="400"/>
</div>
<br/>
```


---
## Adjacency Information

Most importantly, adjacency information about the Bezier cells is extraced: for a given Bezier cell, what other Bezier cells:
- have a common edge at which local edge numbers
- have a common corner point at which local corner numbers
123 changes: 2 additions & 121 deletions docs/src/curves.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Two type of curves are available:
Both are defined by initializing corresponding structures.

---
## Define Structures
## Defining Structures

NURBS and B-spline curves are defined by initializing a [`BsplineCurve`](@ref BsplineCurve) or a [`NURBScurve`](@ref NURBScurve) structure, respectively.

Expand Down Expand Up @@ -96,123 +96,4 @@ savefig(t, "cruve3Dder.html"); nothing # hide

```@raw html
<object data="../cruve3Dder.html" type="text/html" style="width:100%;height:50vh;"> </object>
```

---
## Refining a Curve

Based on the principles of [knot insertion](@ref knotInsert), a single knot can be inserted multiple times into a curve (without changing the points the curve describes) by the [`insertKnot`](@ref insertKnot) function.

```@example curves
NCurve2 = insertKnot(NCurve, 0.75, 2) # insert knot at 0.75 twice
C2 = NCurve2(evalpoints)
plotCurve3D(C2, controlPoints=NCurve2.controlPoints)
t = plotCurve3D(C2, controlPoints=NCurve2.controlPoints) # hide
savefig(t, "cruve3DInserted.html"); nothing # hide
```

```@raw html
<object data="../cruve3DInserted.html" type="text/html" style="width:100%;height:50vh;"> </object>
```

Several knots can be inserted by the [`refine`](@ref refine) function.

```@example curves
NCurve2 = refine(NCurve, [0.1, 0.2, 0.3, 0.8221]) # insert the array of knots
C2 = NCurve2(evalpoints)
plotCurve3D(C2, controlPoints=NCurve2.controlPoints)
t = plotCurve3D(C2, controlPoints=NCurve2.controlPoints) # hide
savefig(t, "cruve3Drefined.html"); nothing # hide
```

```@raw html
<object data="../cruve3Drefined.html" type="text/html" style="width:100%;height:50vh;"> </object>
```

!!! note
Refining a curve does not change the points in space described by the curve. Effectively, in the plots it can be seen that the number of control points is increased.
However, also underlying properties such as the differentiability are changed.


---
## Splitting a Curve

To split a curve into multiple separate curves the function [`split`](@ref NURBS.split) is provided which returns an array of curves.

```@example curves
cVec = split(NCurve, [0.2, 0.5]) # split at 0.2 and 0.5
# plot all three curves
data = PlotlyJS.GenericTrace[]
for (i, spC) in enumerate(cVec)
push!(data, plotCurve3D(spC(evalpoints), returnTrace=true, controlPoints=spC.controlPoints)...)
end
PlotlyJS.plot(data)
t = PlotlyJS.plot(data) # hide
savefig(t, "cruve3Dsplit.html"); nothing # hide
```

```@raw html
<object data="../cruve3Dsplit.html" type="text/html" style="width:100%;height:50vh;"> </object>
```

To equally split a curve into ``n`` curves as a second argument an integer can be provided:

```@example curves
cVec = split(NCurve, 4) # split into 4 curves
```


---
## Removing Knots from a Curve

Based on the principles of [knot removal](@ref knotRemoval), an interior knot can potentially be removed multiple times from a curve (without changing the points the curve describes) by the [`removeKnot`](@ref removeKnot) function.

```@example curves
p = 3
P1 = SVector(0.0, 0.0, 1.0)
P2 = SVector(0.0, 2.0, 0.0)
P3 = SVector(1.5, 3.0, 0.0)
P4 = SVector(3.0, 3.0, 0.0)
P5 = SVector(4.5, 3.0, 0.0)
P6 = SVector(6.0, 2.0, 0.0)
P7 = SVector(6.0, 0.0, 1.0)
cP = [P1, P2, P3, P4, P5, P6, P7]
kVec = Float64[0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2]
BCurve1 = BsplineCurve(Bspline(p, kVec), cP)
C1 = BCurve1(evalpoints)
BCurve2 = removeKnot(BCurve1, 0.5, 2) # remove knot at 0.5 twice
C2 = BCurve2(evalpoints)
# --- plot both curves
t1 = plotCurve3D(C1, controlPoints=BCurve1.controlPoints, returnTrace=true)
t2 = plotCurve3D(C2, controlPoints=BCurve2.controlPoints, returnTrace=true)
fig = make_subplots(
rows=1, cols=2,
specs=fill(Spec(kind="scene"), 1, 2)
)
add_trace!(fig, t1[1], row=1, col=1)
add_trace!(fig, t1[2], row=1, col=1)
add_trace!(fig, t2[1], row=1, col=2)
add_trace!(fig, t2[2], row=1, col=2)
fig
savefig(fig, "cruve3DRemoved.html"); nothing # hide
```

```@raw html
<object data="../cruve3DRemoved.html" type="text/html" style="width:100%;height:50vh;"> </object>
```

!!! note
Removing a knot from a curve is only possible when the continuity of the curve is sufficient at the knot.
A central part of the [`removeKnot`](@ref removeKnot) function is to verify if the knot can actually be removed.
If not, warnings are generated, indicating the encountered limitations.
```
Loading

0 comments on commit 1eec005

Please sign in to comment.