• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

FEniCS / ffcx / 19801120260

30 Nov 2025 03:36PM UTC coverage: 73.753% (-4.2%) from 77.933%
19801120260

Pull #803

github

schnellerhase
passing compiles?
Pull Request #803: Add `C++` backend

0 of 272 new or added lines in 10 files covered. (0.0%)

3740 of 5071 relevant lines covered (73.75%)

0.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/ffcx/codegeneration/cpp/integrals.py
1
# Copyright (C) 2015-2021 Martin Sandve Alnæs, Michal Habera, Igor Baratta
2
#
3
# This file is part of FFCx. (https://www.fenicsproject.org)
4
#
5
# SPDX-License-Identifier:    LGPL-3.0-or-later
6
"""Integral generation."""
7

NEW
8
import logging
×
9

NEW
10
import basix
×
11

NEW
12
from ffcx.codegeneration.backend import FFCXBackend
×
NEW
13
from ffcx.codegeneration.cpp import integrals_template as ufcx_integrals
×
NEW
14
from ffcx.codegeneration.cpp.cpp_implementation import CppFormatter
×
NEW
15
from ffcx.codegeneration.integral_generator import IntegralGenerator
×
NEW
16
from ffcx.ir.representation import IntegralIR
×
17

NEW
18
logger = logging.getLogger("ffcx")
×
19

20

NEW
21
def generator(ir: IntegralIR, domain: basix.CellType, options):
×
22
    """Generate C++ code for an integral."""
NEW
23
    logger.info("Generating code for integral:")
×
NEW
24
    logger.info(f"--- type: {ir.expression.integral_type}")
×
NEW
25
    logger.info(f"--- name: {ir.expression.name}")
×
26

NEW
27
    factory_name = ir.expression.name
×
28

29
    # Format declaration
NEW
30
    declaration = ufcx_integrals.declaration.format(factory_name=factory_name)
×
31

32
    # Create FFCx C backend
NEW
33
    backend = FFCXBackend(ir, options)
×
34

35
    # Configure kernel generator
NEW
36
    ig = IntegralGenerator(ir, backend)
×
37

38
    # Generate code ast for the tabulate_tensor body
NEW
39
    parts = ig.generate(domain)
×
40

41
    # Format code as string
NEW
42
    CF = CppFormatter(options["scalar_type"])
×
NEW
43
    body = CF.c_format(parts)
×
44

45
    # Generate generic FFCx code snippets and add specific parts
NEW
46
    code = {}
×
NEW
47
    code["class_type"] = ir.expression.integral_type + "_integral"
×
NEW
48
    code["name"] = ir.expression.name
×
49

NEW
50
    vals = ", ".join("true" if i else "false" for i in ir.enabled_coefficients)
×
NEW
51
    code["enabled_coefficients"] = f"{{{vals}}}"
×
52

NEW
53
    code["additional_includes_set"] = set()  # FIXME: Get this out of code[]
×
NEW
54
    code["tabulate_tensor"] = body
×
55

NEW
56
    implementation = ufcx_integrals.factory.format(
×
57
        factory_name=factory_name,
58
        enabled_coefficients=code["enabled_coefficients"],
59
        tabulate_tensor=code["tabulate_tensor"],
60
        needs_facet_permutations="true" if ir.expression.needs_facet_permutations else "false",
61
        scalar_type=options["scalar_type"],
62
        geom_type=options["scalar_type"],
63
        np_scalar_type=options["scalar_type"],
64
        coordinate_element=ir.expression.coordinate_element_hash,
65
    )
66

NEW
67
    return declaration + implementation, ""
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc