Skip to content
Snippets Groups Projects
Commit f84e5252 authored by Dominic Kempf's avatar Dominic Kempf
Browse files

Add the runtime_ufl from uflpdelab

it reserves the trial function as coefficient 0.
parent 5d9a7dd6
No related branches found
No related tags found
No related merge requests found
V = FiniteElement("CG", "triangle", 1) V = FiniteElement("CG", "triangle", 1)
k = Coefficient(V) u = TrialFunction(V)
u = Coefficient(V)
v = TestFunction(V) v = TestFunction(V)
forms = [inner(grad(u), grad(v))*dx] forms = [inner(grad(u), grad(v))*dx]
""" This module is loaded instead of ufl when executing .ufl files.
So, this module contains all our extensions and monkey patches to
UFL.
"""
import ufl
from ufl import *
from ufl.split_functions import split
class TrialFunction(ufl.Coefficient):
""" A coefficient that always takes the reserved index 0 """
def __init__(self, element, count=None):
if count and count is not 0:
raise ValueError("The trial function must be the coefficient of index 0 in uflpdelab")
ufl.Coefficient.__init__(self, element, count=0)
class Coefficient(ufl.Coefficient):
""" A coefficient that honors the reserved index 0. """
def __init__(self, element, count=None):
if count and count is 0:
raise ValueError("The coefficient of index 0 is reserved for the trial function in uflpdelab")
if not count and ufl.Coefficient._globalcount is 0:
count = 1
ufl.Coefficient.__init__(self, element, count)
def Coefficients(element):
return split(Coefficient(element))
def TrialFunctions(element):
return split(TrialFunction(element))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment