def __init__(self, form, name, parameters, number_map): """A wrapper object for one or more TSFC 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. :arg number_map: a map from local coefficient numbers to global ones (useful for split forms). """ if self._initialized: return tree = tsfc_compile_form(form, prefix=name, parameters=parameters) kernels = [] for kernel in tree: # Set optimization options opts = default_parameters["coffee"] ast = kernel.ast ast = ast if not parameters.get("assemble_inverse", False) else _inverse(ast) # Unwind coefficient numbering numbers = tuple(number_map[c] for c in kernel.coefficient_numbers) kernels.append(KernelInfo(kernel=Kernel(ast, ast.name, opts=opts), integral_type=kernel.integral_type, oriented=kernel.oriented, subdomain_id=kernel.subdomain_id, domain_number=kernel.domain_number, coefficient_map=numbers, needs_cell_facets=False)) self.kernels = tuple(kernels) self._initialized = True
def __init__(self, form, name, parameters, number_map): """A wrapper object for one or more TSFC 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. :arg number_map: a map from local coefficient numbers to global ones (useful for split forms). """ if self._initialized: return tree = tsfc_compile_form(form, prefix=name, parameters=parameters) kernels = [] for kernel in tree: # Set optimization options opts = default_parameters["coffee"] ast = kernel.ast ast = ast if not parameters.get("assemble_inverse", False) else _inverse(ast) # Unwind coefficient numbering numbers = tuple(number_map[c] for c in kernel.coefficient_numbers) kernels.append( KernelInfo(kernel=Kernel(ast, ast.name, opts=opts), integral_type=kernel.integral_type, oriented=kernel.oriented, subdomain_id=kernel.subdomain_id, domain_number=kernel.domain_number, coefficient_map=numbers, needs_cell_facets=False, pass_layer_arg=False, needs_cell_sizes=kernel.needs_cell_sizes)) self.kernels = tuple(kernels) self._initialized = True
def __init__(self, form, name, parameters, number_map, interface, coffee=False, diagonal=False): """A wrapper object for one or more TSFC 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. :arg number_map: a map from local coefficient numbers to the split global coefficient numbers. :arg interface: the KernelBuilder interface for TSFC (may be None) """ if self._initialized: return tree = tsfc_compile_form(form, prefix=name, parameters=parameters, interface=interface, coffee=coffee, diagonal=diagonal) kernels = [] for kernel in tree: # Set optimization options opts = default_parameters["coffee"] ast = kernel.ast # Unwind coefficient numbering numbers = tuple(number_map[c] for c in kernel.coefficient_numbers) kernels.append(KernelInfo(kernel=Kernel(ast, kernel.name, opts=opts, requires_zeroed_output_arguments=True, flop_count=kernel.flop_count), integral_type=kernel.integral_type, oriented=kernel.oriented, subdomain_id=kernel.subdomain_id, domain_number=kernel.domain_number, coefficient_map=numbers, needs_cell_facets=False, pass_layer_arg=False, needs_cell_sizes=kernel.needs_cell_sizes)) self.kernels = tuple(kernels) self._initialized = True