Skip to content

Instantly share code, notes, and snippets.

View w1th0utnam3's full-sized avatar

Fabian Löschner w1th0utnam3

View GitHub Profile
@w1th0utnam3
w1th0utnam3 / gsoc18.md
Last active May 18, 2018 16:52
FEniCS GSOC18 application

Maximizing performance on modern architectures with data-level parallelism

Abstract

In the solution process of problems discretized using FEM, the assembly of element level tensors to the global matrix often contributes a significant amount of computational time relative to the overall process. The goal of this GSoC 2018 project is to improve the performance of the FEniCS framework in the assembly phase. To achieve this, the FEniCS Form Compiler (FFC) should be enhanced such that the generated code can fully utilize data-level

@w1th0utnam3
w1th0utnam3 / Dockerfile
Last active May 18, 2018 13:14
DolfinX and Loopy
# Dockerfile to build the FEniCS-X development libraries
# with support for Loopy and Intel OpenCL drivers
#
# Authors:
# Jack S. Hale <[email protected]>
# Lizao Li <[email protected]>
# Garth N. Wells <[email protected]>
# Jan Blechta <[email protected]>
# Fabian Löschner <[email protected]>
@w1th0utnam3
w1th0utnam3 / poisson_example_numba.py
Last active June 3, 2018 11:49
FEniCS Poisson example with Numba kernel
import dolfin
import dolfin.cpp
from dolfin import *
from dolfin.la import PETScMatrix, PETScVector, PETScKrylovSolver
from dolfin.jit.jit import ffc_jit
import numba as nb
import numpy as np
import time
@w1th0utnam3
w1th0utnam3 / poisson_example_cffi.py
Created June 4, 2018 21:33
FEniCS Poisson example with C/CFFI kernel
import dolfin
import dolfin.cpp
from dolfin import *
from dolfin.la import PETScMatrix, PETScVector, PETScKrylovSolver
from dolfin.jit.jit import ffc_jit
import numba as nb
import numpy as np
import cffi
@w1th0utnam3
w1th0utnam3 / ffc_tabulate_tensor.c
Created June 17, 2018 13:18
tabulate_tensor function generated by FFC with default parameters for Laplace with P2(Tetrahedron) elements
void tabulate_tensor_A(
double* restrict A,
const double* const* w,
const double* restrict coordinate_dofs,
int cell_orientation)
{
// Precomputed values of basis functions and precomputations
// FE* dimensions: [entities][points][dofs]
// PI* dimensions: [entities][dofs][dofs] or [entities][dofs]
// PM* dimensions: [entities][dofs][dofs]
@w1th0utnam3
w1th0utnam3 / neohookean.py
Last active June 27, 2018 13:44
Generate Neo-Hookean force & force Jacobian functions using FEniCS
from ufl import *
import ffc.compiler
# Define cell type we solve on
cell = tetrahedron
d = cell.geometric_dimension()
# The finite element function space
element = VectorElement("Lagrange", cell, 1, dim=d)
@w1th0utnam3
w1th0utnam3 / gpu_passthrough.md
Created September 11, 2018 08:48
KVM/libvirt/QEMU Windows VM with GPU passthrough on Ubuntu host
@w1th0utnam3
w1th0utnam3 / rust_electron.md
Last active January 29, 2024 23:17
Building a Rust/Electron app
@w1th0utnam3
w1th0utnam3 / error.rs
Created March 13, 2020 13:19
Glium 0.23.0 bug: thread 'main' panicked at 'already mutably borrowed: BorrowError'
use glutin::event_loop::{ControlFlow, EventLoop};
use glutin::window::WindowBuilder;
fn main() {
let el = EventLoop::new();
let wb = WindowBuilder::new();
let windowed_context = glutin::ContextBuilder::new()
.build_windowed(wb, &el)
.unwrap();
@w1th0utnam3
w1th0utnam3 / draw_loglog_slope.py
Created August 26, 2020 15:38
A helper function for Matplotlib to draw "convergence triangles" into loglog plots.
import matplotlib as mpl
def draw_loglog_slope(fig, ax, origin, width_inches, slope, inverted=False, color=None, polygon_kwargs=None, label=True, labelcolor=None, label_kwargs=None, zorder=None):
"""
This function draws slopes or "convergence triangles" into loglog plots.
@param fig: The figure
@param ax: The axes object to draw to
@param origin: The 2D origin (usually lower-left corner) coordinate of the triangle
@param width_inches: The width in inches of the triangle