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

Implement FacetNormals in constraints and Powerconstraints with varying implementation

parent 46ab4811
No related branches found
No related tags found
No related merge requests found
from dune.perftool.generation import (global_context,
from dune.perftool.generation import (get_counted_variable,
global_context,
include_file,
preamble,
)
......@@ -52,12 +53,10 @@ def assemble_constraints(name):
def name_bctype_function(element, is_dirichlet):
if isinstance(element, (VectorElement, TensorElement)):
subel = element.sub_elements()[0]
child = name_bctype_function(subel, is_dirichlet[:subel.value_size()])
name = "{}_pow{}bctype".format(child, element.num_sub_elements())
define_power_bctype_function(element, name, child)
return name
# Note: Previously, there was a separate code branch for VectorElement here,
# which was implemented through PDELabs Power constraints concept.
# However this completely fails if you have different constraints for
# the children of a VectorElement. We therefore omit this branch completely.
if isinstance(element, MixedElement):
k = 0
childs = []
......@@ -69,7 +68,7 @@ def name_bctype_function(element, is_dirichlet):
return name
else:
assert isinstance(element, (FiniteElement, TensorProductElement))
name = "{}_bctype".format(FEM_name_mangling(element).lower())
name = get_counted_variable("bctype")
define_bctype_function(element, is_dirichlet[0], name)
return name
......@@ -85,12 +84,6 @@ def define_bctype_function(element, is_dirichlet, name):
)
@preamble(section="constraints")
def define_power_bctype_function(element, name, subgfs):
include_file('dune/pdelab/constraints/common/constraintsparameters.hh', filetag='driver')
return "Dune::PDELab::PowerConstraintsParameters<decltype({}), {}> {}({});".format(subgfs, element.num_sub_elements(), name, subgfs)
@preamble(section="constraints")
def define_composite_bctype_function(element, is_dirichlet, name, subgfs):
include_file('dune/pdelab/constraints/common/constraintsparameters.hh', filetag='driver')
......
......@@ -22,6 +22,10 @@ class DriverUFL2PymbolicVisitor(UFL2LoopyVisitor):
ret = self._call(expr, False)
return set(self.preambles), ret
def facet_normal(self, o):
self.preambles.append("auto n=is.unitOuterNormal(xl);")
return prim.Variable("n")
def spatial_coordinate(self, o):
self.preambles.append("auto x=is.geometry().global(xl);")
return prim.Variable("x")
......
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