Skip to content

Instantly share code, notes, and snippets.

View meg-simula's full-sized avatar

Marie E Rognes meg-simula

View GitHub Profile
@meg-simula
meg-simula / knp_model_a.py
Created February 20, 2023 05:35
FEniCS-based solver for the 2018 Solbraa-Bergersen Ionic Electrodiffusion-scheme
# FEniCS-based solver for the 2018 Solbraa-Bergersen Ionic Electrodiffusion-scheme
#
# Marie E. Rognes (meg@simula.no)
#
# Feb 17 2023
import numpy
from dolfin import *
def set_initial_conditions(x):
@meg-simula
meg-simula / refine_mesh_locally.py
Created June 30, 2021 11:09
Utility functions in FEniCS and test script for refining and inspecting meshes with large cell size variations.
# Utility functions in FEniCS and test script for refining and
# inspecting meshes with large cell size variations.
from dolfin import *
def mark_large_cells(mesh, tolerance):
# Initialize mesh function (markers) that defines whether to
# refine a cell or not
d = mesh.topology().dim()
markers = MeshFunction("bool", mesh, d)
@meg-simula
meg-simula / mixed_domain_outline.ipynb
Created March 8, 2017 12:03
Developer notes on mixed domain FEniCS functionality from Atlanta 29.02.2017
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@meg-simula
meg-simula / basic_elastostatics.py
Last active October 12, 2015 07:34
Basic elastostatics -- settling of a block
from fenics import *
# Define the elastic body
mesh = UnitSquareMesh(20, 20)
V = VectorFunctionSpace(mesh, "CG", 1)
u = TrialFunction(V)
v = TestFunction(V)
# Set the
mu = Constant(10.0)
@meg-simula
meg-simula / oblig1.py
Created September 2, 2015 06:57
MEK2500 Fall 2015: Source code associated with mandatory assignment 1
# Copyright (C) 2015 Marie E. Rognes
#
# Run this file with python oblig1.py
import pylab
import numpy
from numpy import linalg
# Define parameters
L = 10
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@meg-simula
meg-simula / Holzapfel.py
Last active August 29, 2015 14:02
Demo illustrating "challenging forms" based on the Holzapfel-Ogden hyperelasticity model
"""
Demo illustrating "challenging forms" based on the Holzapfel-Ogden
hyperelasticity model for modelling cardiac ventricular tissue.
Original implementation by Gabriel Balaban, modified by Marie
E. Rognes (meg@simula.no)
"""
from dolfin import *
@meg-simula
meg-simula / rognes.css
Created February 5, 2014 14:31
Stylesheet template for simple homepage
body {
background-color:#bf2c2c;
font-family: Verdana, sans-serif;
font-size:100%;
color:#111;
}
main {
@meg-simula
meg-simula / install_fenics.sh
Last active September 17, 2021 10:59
Simple script for installing FEniCS from source
# Marie's simple FEniCS dev setup:
#
# 1. Use dorsal to install dependencies: CGAL, PETSC, (TRILINOS)),
# SLEPc in some directory (mine is ~/local/fenics-dependencies).
#
# 2. Modify the paths immediately below in accordance with your setup.
#
# 3. Run this script in one of two ways:
#
# ./install_fenics.sh install # To install from scratch