Commit a5bab802 authored by Stephan Rave's avatar Stephan Rave
Browse files

[fenics] remove ufl patch

parent f3576303
......@@ -24,43 +24,6 @@ from pymor.vectorarrays.list import CopyOnWriteVector, ComplexifiedVector, Compl
from pymor.vectorarrays.numpy import NumpyVectorSpace
@defaults('doit')
def patch_ufl(doit=True):
"""Monkey patch ufl.algorithms.estimate_total_polynomial_degree.
Catches `TypeError`, which can be called by certain UFL expressions, and returns
`default_degree`.
This is needed, for instance, when using :mod:`pymor.discretizers.fenics` on a
:func:`~pymor.analyticalproblems.thermalblock.thermal_block_problem`.
"""
if not doit:
return
import ufl
real_estimate_total_polynomial_degree = ufl.algorithms.estimate_total_polynomial_degree
def estimate_total_polynomial_degree_wrapper(e, default_degree=1, element_replace_map={}):
try:
return real_estimate_total_polynomial_degree(e, default_degree=default_degree,
element_replace_map=element_replace_map)
except TypeError:
return default_degree
ufl.algorithms.estimate_degrees.estimate_total_polynomial_degree = estimate_total_polynomial_degree_wrapper
ufl.algorithms.estimate_total_polynomial_degree = estimate_total_polynomial_degree_wrapper
# use sys.modules for monkey patching since compute_form_data is at the same time function
# and sub-module
import sys
sys.modules['ufl.algorithms.compute_form_data'].estimate_total_polynomial_degree \
= estimate_total_polynomial_degree_wrapper
patch_ufl()
@unpicklable
class FenicsVector(CopyOnWriteVector):
"""Wraps a FEniCS vector to make it usable with ListVectorArray."""
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment