diff --git a/ffcx/codegeneration/basix_custom_element_template.py b/ffcx/codegeneration/C/basix_custom_element_template.py similarity index 100% rename from ffcx/codegeneration/basix_custom_element_template.py rename to ffcx/codegeneration/C/basix_custom_element_template.py diff --git a/ffcx/codegeneration/C/dofmap.py b/ffcx/codegeneration/C/dofmap.py index 606623bd3..5f5d4cdf9 100644 --- a/ffcx/codegeneration/C/dofmap.py +++ b/ffcx/codegeneration/C/dofmap.py @@ -29,8 +29,6 @@ def generator(ir, options): d["num_element_support_dofs"] = ir.num_element_support_dofs d["num_sub_dofmaps"] = ir.num_sub_dofmaps - import ffcx.codegeneration.C.cnodes as L - flattened_entity_dofs = [] entity_dof_offsets = [0] for dim in ir.entity_dofs: @@ -39,19 +37,13 @@ def generator(ir, options): flattened_entity_dofs.append(v) entity_dof_offsets.append(len(flattened_entity_dofs)) d["entity_dofs"] = f"entity_dofs_{ir.name}" - d["entity_dofs_init"] = L.ArrayDecl( - "int", - f"entity_dofs_{ir.name}", - values=flattened_entity_dofs, - sizes=len(flattened_entity_dofs), - ) + values = ", ".join(str(i) for i in flattened_entity_dofs) + sizes = len(flattened_entity_dofs) + d["entity_dofs_init"] = f"int entity_dofs_{ir.name}[{sizes}] = {{{values}}};" d["entity_dof_offsets"] = f"entity_dof_offsets_{ir.name}" - d["entity_dof_offsets_init"] = L.ArrayDecl( - "int", - f"entity_dof_offsets_{ir.name}", - values=entity_dof_offsets, - sizes=len(entity_dof_offsets), - ) + values = ", ".join(str(i) for i in entity_dof_offsets) + sizes = len(entity_dof_offsets) + d["entity_dof_offsets_init"] = f"int entity_dof_offsets_{ir.name}[{sizes}] = {{{values}}};" # Closure flattened_entity_closure_dofs = [] @@ -62,19 +54,13 @@ def generator(ir, options): flattened_entity_closure_dofs.append(v) entity_closure_dof_offsets.append(len(flattened_entity_closure_dofs)) d["entity_closure_dofs"] = f"entity_closure_dofs_{ir.name}" - d["entity_closure_dofs_init"] = L.ArrayDecl( - "int", - f"entity_closure_dofs_{ir.name}", - values=flattened_entity_closure_dofs, - sizes=len(flattened_entity_closure_dofs), - ) + values = ", ".join(str(i) for i in flattened_entity_closure_dofs) + sizes = len(flattened_entity_closure_dofs) + d["entity_closure_dofs_init"] = f"int entity_closure_dofs_{ir.name}[{sizes}] = {{{values}}};" d["entity_closure_dof_offsets"] = f"entity_closure_dof_offsets_{ir.name}" - d["entity_closure_dof_offsets_init"] = L.ArrayDecl( - "int", - f"entity_closure_dof_offsets_{ir.name}", - values=entity_closure_dof_offsets, - sizes=len(entity_closure_dof_offsets), - ) + values = ", ".join(str(i) for i in entity_closure_dof_offsets) + sizes = len(entity_dof_offsets) + d["entity_closure_dof_offsets_init"] = f"int entity_closure_dof_offsets_{ir.name}[{sizes}] = {{{values}}};" d["block_size"] = ir.block_size diff --git a/ffcx/codegeneration/C/finite_element.py b/ffcx/codegeneration/C/finite_element.py index ff1c7ac94..6c5a09b61 100644 --- a/ffcx/codegeneration/C/finite_element.py +++ b/ffcx/codegeneration/C/finite_element.py @@ -10,7 +10,7 @@ import logging -import ffcx.codegeneration.basix_custom_element_template as ufcx_basix_custom_finite_element +import ffcx.codegeneration.C.basix_custom_element_template as ufcx_basix_custom_finite_element import ffcx.codegeneration.C.finite_element_template as ufcx_finite_element import ufl @@ -63,30 +63,29 @@ def generator(ir, options): else: d["basix_cell"] = int(ir.basix_cell) - import ffcx.codegeneration.C.cnodes as L - if len(ir.value_shape) > 0: d["value_shape"] = f"value_shape_{ir.name}" - d["value_shape_init"] = L.ArrayDecl( - "int", f"value_shape_{ir.name}", values=ir.value_shape, sizes=len(ir.value_shape)) + values = ", ".join(str(i) for i in ir.values_shape) + sizes = len(ir.value_shape) + d["value_shape_init"] = f"int value_shape_{ir.name}[{sizes}] = {{{values}}};" else: d["value_shape"] = "NULL" d["value_shape_init"] = "" if len(ir.reference_value_shape) > 0: d["reference_value_shape"] = f"reference_value_shape_{ir.name}" - d["reference_value_shape_init"] = L.ArrayDecl( - "int", f"reference_value_shape_{ir.name}", - values=ir.reference_value_shape, sizes=len(ir.reference_value_shape)) + values = ", ".join(str(i) for i in ir.reference_value_shape) + sizes = len(ir.reference_value_shape) + d["reference_value_shape_init"] = "int reference_value_shape_{ir.name}[{sizes}] = {{{values}}};" else: d["reference_value_shape"] = "NULL" d["reference_value_shape_init"] = "" if len(ir.sub_elements) > 0: d["sub_elements"] = f"sub_elements_{ir.name}" - d["sub_elements_init"] = L.ArrayDecl( - "ufcx_finite_element*", f"sub_elements_{ir.name}", - values=[L.AddressOf(L.Symbol(el)) for el in ir.sub_elements], sizes=len(ir.sub_elements)) + values = ", ".join(f"&{el}" for el in ir.sub_elements) + sizes = len(ir.sub_elements) + d["sub_elements_init"] = f"ufcx_finite_element* sub_elements_{ir.name}[{sizes}] = {{{values}}};" else: d["sub_elements"] = "NULL" d["sub_elements_init"] = "" @@ -126,14 +125,12 @@ def generate_custom_element(name, ir): d["highest_degree"] = ir.highest_degree d["discontinuous"] = "true" if ir.discontinuous else "false" d["interpolation_nderivs"] = ir.interpolation_nderivs - - import ffcx.codegeneration.C.cnodes as L - d["value_shape_length"] = len(ir.value_shape) if len(ir.value_shape) > 0: d["value_shape"] = f"value_shape_{name}" - d["value_shape_init"] = L.ArrayDecl( - "int", f"value_shape_{name}", values=ir.value_shape, sizes=len(ir.value_shape)) + values = ", ".join(str(i) for i in ir.value_shape) + sizes = len(ir.value_shape) + d["value_shape_init"] = f"int value_shape_{name}[{sizes}] = {{{values}}};" else: d["value_shape"] = "NULL" d["value_shape_init"] = ""