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

Some initial work on symbolic parameter functions

parent b7b37755
No related branches found
No related tags found
No related merge requests found
......@@ -45,9 +45,9 @@ def read_ufl(uflfile):
try:
exec("from dune.perftool.ufl.execution import *\n" + uflcode, namespace)
except:
basename = os.path.splitext(os.path.basename(uflfile))[0]
basename = "{}_debug".format(basename)
pyname = "{}.py".format(basename)
name = splitext(basename(uflfile))[0]
name = "{}_debug".format(name)
pyname = "{}.py".format(name)
print(pyname)
pycode = "#!/usr/bin/env python\nfrom dune.perftool.ufl.execution import *\nset_level(DEBUG)\n" + uflcode
with file(pyname, "w") as f:
......
......@@ -23,6 +23,7 @@ from dune.perftool.pdelab.parameter import (cell_parameter_function,
intersection_parameter_function,
)
from dune.perftool.pdelab.quadrature import (pymbolic_quadrature_weight,
pymbolic_quadrature_position_in_cell,
quadrature_inames,
)
from dune.perftool.pdelab.spaces import (lfs_inames,
......@@ -84,6 +85,9 @@ class PDELabInterface(object):
# Geometry related generator functions
#
def pymbolic_spatial_coordinate(self, restriction):
return pymbolic_quadrature_position_in_cell(restriction)
def name_facet_jacobian_determinant(self):
return name_facet_jacobian_determinant()
......
......@@ -235,12 +235,18 @@ class UFL2LoopyVisitor(ModifiedTerminalTracker):
if isinstance(o.ufl_operands[0], JacobianDeterminant):
return self.call(o.ufl_operands[0])
else:
return Call('abs', self.call(o.ufl_operands[0]))
return Call(Variable('abs'), (self.call(o.ufl_operands[0]),))
def exp(self, o):
return Call(Variable('exp'), (self.call(o.ufl_operands[0]),))
#
# Handlers for geometric quantities
#
def spatial_coordinate(self, o):
return self.interface.pymbolic_spatial_coordinate(self.restriction)
def facet_normal(self, o):
# The normal must be restricted to be well-defined
assert self.restriction is not Restriction.NONE
......
f = Expression("Dune::FieldVector<double,2> c(0.5); c-= x; return 4.*(1.-c.two_norm2())*std::exp(-1.*c.two_norm2());")
#f = Expression("Dune::FieldVector<double,2> c(0.5); c-= x; return 4.*(1.-c.two_norm2())*std::exp(-1.*c.two_norm2());")
g = Expression("Dune::FieldVector<double,2> c(0.5); c-= x; return std::exp(-1.*c.two_norm2());")
cell = triangle
V = FiniteElement("CG", "triangle", 1, dirichlet_expression=g)
V = FiniteElement("CG", cell, 1, dirichlet_expression=g)
u = TrialFunction(V)
v = TestFunction(V)
x = SpatialCoordinate(cell)
f = exp(-1*(x[0]-0.5))
forms = [(inner(grad(u), grad(v)) - f*v)*dx]
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