Skip to content

Commit

Permalink
Merge branch 'main' into dokken/3D-1D
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgensd committed Feb 23, 2025
2 parents 997f60c + c78d7ea commit 54b1708
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 169 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/dolfinx-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ on:
description: "UFL branch or tag"
default: "main"
type: string
# Weekly build on Mondays at 8 am
schedule:
- cron: "0 8 * * 1"

jobs:
build:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ on:
- main
workflow_dispatch:

# Weekly build on Mondays at 8 am
schedule:
- cron: "0 8 * * 1"

jobs:
build:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -54,7 +58,7 @@ jobs:
- name: Install dependencies (non-Python, Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get install -y graphviz libgraphviz-dev ninja-build pkg-config
sudo apt-get install -y graphviz libgraphviz-dev ninja-build pkg-config libblas-dev liblapack-dev
- name: Install dependencies (non-Python, macOS)
if: runner.os == 'macOS'
run: brew install ninja
Expand Down
15 changes: 0 additions & 15 deletions demo/MixedGradient.py

This file was deleted.

26 changes: 0 additions & 26 deletions demo/TraceElement.py

This file was deleted.

19 changes: 2 additions & 17 deletions demo/test_demos.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@ def test_demo(file, scalar_type):
# Skip complex demos on win32
pytest.skip(reason="_Complex not supported on Windows")

if file in [
"MixedGradient",
"TraceElement", # HDiv Trace
"MixedElasticity", # VectorElement of BDM
"RestrictedElement",
"_TensorProductElement",
]:
# Skip demos that use elements not yet implemented in Basix
pytest.skip(reason="Element not yet implemented in Basix")

if "complex" in scalar_type and file in [
"BiharmonicHHJ",
"BiharmonicRegge",
Expand All @@ -48,7 +38,7 @@ def test_demo(file, scalar_type):
assert os.system(f"cd {demo_dir} && ffcx {opts} {file}.py") == 0
assert (
os.system(
f"cd {demo_dir} && " f'cl.exe /I "../ffcx/codegeneration" {extra_flags} /c {file}.c'
f'cd {demo_dir} && cl.exe /I "../ffcx/codegeneration" {extra_flags} /c {file}.c'
)
) == 0
assert (
Expand All @@ -65,11 +55,6 @@ def test_demo(file, scalar_type):
)
assert os.system(f"cd {demo_dir} && ffcx {opts} {file}.py") == 0
assert (
os.system(
f"cd {demo_dir} && "
f"{cc} -I../ffcx/codegeneration "
f"{extra_flags} "
f"-c {file}.c"
)
os.system(f"cd {demo_dir} && {cc} -I../ffcx/codegeneration {extra_flags} -c {file}.c")
== 0
)
2 changes: 2 additions & 0 deletions ffcx/codegeneration/C/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ def generator(ir: ExpressionIR, options):
d["constant_names_init"] = ""
d["constant_names"] = "NULL"

d["coordinate_element_hash"] = f"UINT64_C({ir.expression.coordinate_element_hash})"

# Check that no keys are redundant or have been missed
from string import Formatter

Expand Down
1 change: 1 addition & 0 deletions ffcx/codegeneration/C/expressions_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
.value_shape = {value_shape},
.num_components = {num_components},
.rank = {rank},
.coordinate_element_hash = {coordinate_element_hash},
}};
// Alias name
Expand Down
5 changes: 2 additions & 3 deletions ffcx/codegeneration/C/integrals.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ def generator(ir: IntegralIR, options):
f".tabulate_tensor_{np_scalar_type} = tabulate_tensor_{factory_name},"
)

element_hash = 0 if ir.coordinate_element_hash is None else ir.coordinate_element_hash

assert ir.expression.coordinate_element_hash is not None
implementation = ufcx_integrals.factory.format(
factory_name=factory_name,
enabled_coefficients=code["enabled_coefficients"],
Expand All @@ -84,7 +83,7 @@ def generator(ir: IntegralIR, options):
needs_facet_permutations="true" if ir.expression.needs_facet_permutations else "false",
scalar_type=dtype_to_c_type(options["scalar_type"]),
geom_type=dtype_to_c_type(dtype_to_scalar_dtype(options["scalar_type"])),
coordinate_element_hash=f"UINT64_C({element_hash})",
coordinate_element_hash=f"UINT64_C({ir.expression.coordinate_element_hash})",
tabulate_tensor_float32=code["tabulate_tensor_float32"],
tabulate_tensor_float64=code["tabulate_tensor_float64"],
tabulate_tensor_complex64=code["tabulate_tensor_complex64"],
Expand Down
43 changes: 24 additions & 19 deletions ffcx/codegeneration/ufcx.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
#define UFCX_VERSION_RELEASE 0

#if UFCX_VERSION_RELEASE
#define UFCX_VERSION \
#define UFCX_VERSION \
UFCX_VERSION_MAJOR "." UFCX_VERSION_MINOR "." UFCX_VERSION_MAINTENANCE
#else
#define UFCX_VERSION \
UFCX_VERSION_MAJOR "." UFCX_VERSION_MINOR "." UFCX_VERSION_MAINTENANCE ".dev0"
#define UFCX_VERSION \
UFCX_VERSION_MAJOR "." UFCX_VERSION_MINOR "." UFCX_VERSION_MAINTENANCE ".de" \
"v0"
#endif

#include <stdbool.h>
Expand Down Expand Up @@ -86,8 +87,8 @@ extern "C"
/// null pointer can be passed. For interior facets the array will have size 2
/// (one permutation for each cell adjacent to the facet).
typedef void(ufcx_tabulate_tensor_float32)(
float* restrict A, const float* restrict w,
const float* restrict c, const float* restrict coordinate_dofs,
float* restrict A, const float* restrict w, const float* restrict c,
const float* restrict coordinate_dofs,
const int* restrict entity_local_index,
const uint8_t* restrict quadrature_permutation);

Expand All @@ -96,8 +97,8 @@ extern "C"
///
/// @see ufcx_tabulate_tensor_single
typedef void(ufcx_tabulate_tensor_float64)(
double* restrict A, const double* restrict w,
const double* restrict c, const double* restrict coordinate_dofs,
double* restrict A, const double* restrict w, const double* restrict c,
const double* restrict coordinate_dofs,
const int* restrict entity_local_index,
const uint8_t* restrict quadrature_permutation);

Expand Down Expand Up @@ -136,19 +137,19 @@ extern "C"
#endif // __STDC_NO_COMPLEX__
bool needs_facet_permutations;

/// Get the hash of the coordinate element associated with the geometry of the mesh.
/// Hash of the coordinate element associated with the geometry of the mesh.
uint64_t coordinate_element_hash;
} ufcx_integral;

typedef struct ufcx_expression
{
/// Evaluate expression into tensor A with compiled evaluation points
/// Evaluate expression into tensor A with compiled evaluation
/// points.
///
/// @param[out] A
/// Dimensions: A[num_points][num_components][num_argument_dofs]
/// @param[out] A Dimensions:
/// `A[num_points][num_components][num_argument_dofs]`
///
/// @see ufcx_tabulate_tensor
///
ufcx_tabulate_tensor_float32* tabulate_tensor_float32;
ufcx_tabulate_tensor_float64* tabulate_tensor_float64;
#ifndef __STDC_NO_COMPLEX__
Expand Down Expand Up @@ -178,7 +179,7 @@ extern "C"
int entity_dimension;

/// Coordinates of evaluations points. Dimensions:
/// points[num_points][entity_dimension]
/// `points[num_points][entity_dimension]`
const double* points;

/// Shape of expression. Dimension: value_shape[num_components]
Expand All @@ -190,6 +191,9 @@ extern "C"
/// Rank, i.e. number of arguments
int rank;

/// Hash of the coordinate element associated with the geometry of
/// the mesh.
uint64_t coordinate_element_hash;
} ufcx_expression;

/// This class defines the interface for the assembly of the global
Expand All @@ -203,9 +207,9 @@ extern "C"
///
/// A = a(V1, V2, ..., Vr, w1, w2, ..., wn),
///
/// where each argument Vj represents the application to the
/// sequence of basis functions of Vj and w1, w2, ..., wn are given
/// fixed functions (coefficients).
/// where each argument Vj represents the application to the sequence
/// of basis functions of Vj and w1, w2, ..., wn are given fixed
/// functions (coefficients).
typedef struct ufcx_form
{
/// String identifying the form
Expand All @@ -229,8 +233,8 @@ extern "C"
/// List of names of constants
const char** constant_name_map;

/// Get the hash of the finite element for the i-th argument function, where 0 <=
/// i < r + n.
/// Get the hash of the finite element for the i-th argument
/// function, where 0 <= i < r + n.
///
/// @param i Argument number if 0 <= i < r Coefficient number j = i
/// - r if r + j <= i < r + n
Expand All @@ -242,7 +246,8 @@ extern "C"
/// IDs for each integral in form_integrals list
int* form_integral_ids;

/// Offsets for cell, interior facet and exterior facet integrals in form_integrals list
/// Offsets for cell, interior facet and exterior facet integrals in
/// form_integrals list
int* form_integral_offsets;

} ufcx_form;
Expand Down
Loading

0 comments on commit 54b1708

Please sign in to comment.