Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constrain scalar types with concept #2690

Merged
merged 10 commits into from
Jun 29, 2023
Merged

Constrain scalar types with concept #2690

merged 10 commits into from
Jun 29, 2023

Conversation

jhale
Copy link
Member

@jhale jhale commented Jun 28, 2023

This PR constrains T (which is usually used to denote a scalar related to the finite element coefficients) to be a real or complex floating point type. Let me know if this needs to be widened re: multi-precision support.

In terms of naming 'field' might be more mathematically correct than 'scalar'.

I wonder also if we should change all of the Mesh related Ts to Us throughout?

@jhale
Copy link
Member Author

jhale commented Jun 28, 2023

Looking at the diff I've used dolfinx::scalar in some places where instead I should have used std::floating_point so I will make these changes. This would support changing all mesh related T to U throughout.

@jhale jhale marked this pull request as ready for review June 28, 2023 14:51
@jhale jhale requested a review from garth-wells June 28, 2023 14:51
@@ -47,7 +47,7 @@ namespace dolfinx::fem
/// @param[in] V1 Nédélec (first kind) element and and dofmap for
/// corresponding space to interpolate into
/// @param[in] mat_set A functor that sets values in a matrix
template <typename T, std::floating_point U = dolfinx::scalar_value_type_t<T>>
template <dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_type_t<T>>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this constraint U to be the same scalar type as T? Is this necessary?

@garth-wells garth-wells added the enhancement New feature or request label Jun 28, 2023
Copy link
Member

@garth-wells garth-wells left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Tiny formatting comment.

cpp/dolfinx/fem/Constant.h Outdated Show resolved Hide resolved
cpp/dolfinx/fem/Constant.h Show resolved Hide resolved
@jhale jhale added this pull request to the merge queue Jun 29, 2023
Merged via the queue into main with commit 6034c26 Jun 29, 2023
@jhale jhale deleted the jhale/concept-for-T branch June 29, 2023 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants