def __init__(self, form, name, parameters): """A wrapper object for one or more FFC kernels compiled from a given :class:`~Form`. :arg form: the :class:`~Form` from which to compile the kernels. :arg name: a prefix to be applied to the compiled kernel names. This is primarily useful for debugging. :arg parameters: a dict of parameters to pass to the form compiler. """ if self._initialized: return incl = PreprocessNode('#include "firedrake_geometry.h"\n') inc = [path.dirname(__file__)] try: ffc_tree = ffc_compile_form(form, prefix=name, parameters=parameters) kernels = [] # need compute_form_data here to get preproc form integrals fd = compute_form_data(form) elements = fd.elements needs_orientations = self._needs_orientations(elements) for it, kernel in zip(fd.preprocessed_form.integrals(), ffc_tree): # Set optimization options opts = {} if it.integral_type() not in ['cell'] else default_parameters["coffee"] kernels.append((Kernel(Root([incl, kernel]), '%s_%s_integral_0_%s' % (name, it.integral_type(), it.subdomain_id()), opts, inc), needs_orientations)) self.kernels = tuple(kernels) self._empty = False except EmptyIntegrandError: # FFC noticed that the integrand was zero and simplified # it, catch this here and set a flag telling us to ignore # the kernel when returning it in compile_form self._empty = True self._initialized = True
def __init__(self, form, name): if self._initialized: return code = ffc_compile_form(form, prefix=name, parameters=ffc_parameters) form_data = form.form_data() self.kernels = tuple([Kernel(code, '%s_%s_integral_0_%s' % \ (name, ida.domain_type, ida.domain_id)) \ for ida in form_data.integral_data]) self._initialized = True
def __init__(self, form, name): if self._initialized: return incl = PreprocessNode('#include "pyop2_geometry.h"\n') ffc_tree = ffc_compile_form(form, prefix=name, parameters=ffc_parameters) ast = Root([incl] + [subtree for subtree in ffc_tree]) form_data = form.form_data() self.kernels = tuple([Kernel(ast, '%s_%s_integral_0_%s' % (name, ida.domain_type, ida.domain_id)) for ida in form_data.integral_data]) self._initialized = True
def __init__(self, form, name, parameters): """A wrapper object for one or more FFC kernels compiled from a given :class:`~ufl.classes.Form`. :arg form: the :class:`~ufl.classes.Form` from which to compile the kernels. :arg name: a prefix to be applied to the compiled kernel names. This is primarily useful for debugging. :arg parameters: a dict of parameters to pass to the form compiler. """ if self._initialized: return incl = [PreprocessNode('#include "firedrake_geometry.h"\n')] inc = [path.dirname(__file__)] try: ffc_tree = ffc_compile_form(form, prefix=name, parameters=parameters) if len(ffc_tree) == 0: raise EmptyIntegrandError kernels = [] # need compute_form_data here to get preproc form integrals fd = compute_form_data(form) elements = fd.unique_elements needs_orientations = self._needs_orientations(elements) for it, kernel in zip(fd.preprocessed_form.integrals(), ffc_tree): # Set optimization options opts = default_parameters["coffee"] _kernel = kernel if not parameters.get( "assemble_inverse", False) else _inverse(kernel) kernels.append((Kernel( Root(incl + [_kernel]), '%s_%s_integral_0_%s' % (name, it.integral_type(), it.subdomain_id()), opts, inc), needs_orientations)) self.kernels = tuple(kernels) self._empty = False except EmptyIntegrandError: # FFC noticed that the integrand was zero and simplified # it, catch this here and set a flag telling us to ignore # the kernel when returning it in compile_form self._empty = True self._initialized = True
def __init__(self, form, name): if self._initialized: return incl = PreprocessNode('#include "pyop2_geometry.h"\n') ffc_tree = ffc_compile_form(form, prefix=name, parameters=ffc_parameters) form_data = form.form_data() kernels = [] for ida, kernel in zip(form_data.integral_data, ffc_tree): # Set optimization options opts = {} if ida.domain_type not in ['cell'] else \ {'licm': False, 'tile': None, 'vect': None, 'ap': False} kernels.append(Kernel(Root([incl, kernel]), '%s_%s_integral_0_%s' % (name, ida.domain_type, ida.domain_id), opts)) self.kernels = tuple(kernels) self._initialized = True