# DiscreteDifferentialGeometry

The `DiscreteDifferentialGeometry`

Julia package defines Types and methods to implement Discrete Differential Geometry.

## Discrete Exterior Calculus

A concise description of the implemented operators follows. For learning Discrete Exterior Calculus we recommend the course available on-line (http://geometry.cs.cmu.edu/ddg).

The Discrete Exterior Calculus methods and Types supported by this package closely follow CMU's DDG course.

The intention is to extend this package to Discrete Geometric Algebra, any differences from DEC as currently taught in Computer Science will be due to this.

### Operators

The `๐`

and `โ`

operators interact with each other and elements of a simplical complex ( i.e. a mesh ) in a way illustrated by the following graph.

```
ฮฉแตข : k-form domain of the mesh. i.e. ฮฉโ represents verts, ฮฉโ edges, ฮฉโ faces
ฮฉโแตข : k-form dual domain of the mesh. i.e. ฮฉโโ represents dual verts, ฮฉโ dual edges, ฮฉโ dual faces
โแตข : hodge star operator
๐แตข : differential operator
ฮฉโ---๐โ-โฮฉโ----๐โ-โฮฉโ
โ โ โ
โโ|โโโป โโ|โโโป โโ|โโโป
โ โ โ
ฮฉโโโ-๐โ--ฮฉโโโ-๐โ---ฮฉโโ
```

The dual side of this graph are the simplex components of a one ring cell around each vertex of the primal mesh.
This cell connects the centres of each face (dual faces) via dual edges. To disambiguate, we use the word cell rather than dual from now on.
The ฮฉโโ cell is the circumcentric area around the vertex ฮฉโ.
The ฮฉโโ edges are perpendicular to the primal ฮฉโ edges.
The ฮฉโโ cell vertices are the centres of a primal ฮฉโ face.

The circumcentre is conceptually the correct ฮฉโโ centre, although in practice the barycentre may be used instead.

#### Discrete Differential

The method `๐`

implements the discrete differential operator on discrete k-forms or discrete differential forms.

Also called the exterior derivative.

You can enter this into julia with the character sequence "\itd[Tab]"

In the discrete setting, k-forms and differential forms are typically represented as matrices and vectors. Many of which you will recoginize as incidence matrices or simple column/row vectors corresponding to values at vertices/edges/faces.

#### Discrete Hodge Star

The method `โ`

implements the discrete hodge star on discrete k-forms or discrete differential forms.

You can enter this into julia with the character sequence "\star[Tab]"

### Discrete Codifferential

The method `ฮด`

implements the discrete codifferential.

```
ฮด = โ๐โ
```

You can enter this into julia with the character sequence "\delta[Tab]"

### Discrete Laplace Operator

The method `ฮ`

implements the discrete Laplace-Beltrami operator when applied to a triangle mesh.

You can enter this into julia with the character sequence "\Delta[Tab]"

By far the most important operator in DiscreteDifferentialGeometry.

```
ฮ = ฮด๐ + ๐ฮด
```

### Examples

Solve a simple poisson problem that doesn't involve boundary conditions. Simple heat diffusion.

```
julia> using DiscreteDifferentialGeometry, LinearAlgebra
# For triangle mesh topology
julia> using HalfEdges; using HalfEdges: loadmesh
# Load a mesh
julia> topo, P = loadmesh("resource/mesh/bunny.obj")
# Discrete Laplace-Beltrami operator
julia> L = ฮ(topo, P);
# Time step
julia> dt = 1.0/24.0;
# System matrix for implicit integration step applied to heat diffusion.
julia> A = array(L*dt) + I;
# Set up right hand side with some hot and cold spots
julia> b = zeros(nvertices(topo)); b[1000:1000:14000] = repeat([100.0,-100.0],7);
# Solve the system for new temperatures.
julia> bโฒ = A\b;
# Step it one more time to get a bit more diffusion
julia> bโฒ = A\bโฒ;
# Display the results
julia> using Makie; mesh(P, reduce(hcat, HalfEdges.facelist(topo))', color = bโฒ)
```

## Project Information

### Contributing

Please read CONTRIBUTING.md for details.

### Authors

**Michael Alexander Ewert**- Developer - Digital Domain

### License

This project is licensed under a modified Apache 2.0 license - see the LICENSE file for details