-
-
Notifications
You must be signed in to change notification settings - Fork 209
Refactor dolfinx::fem::Form
to use local indexing of forms, rather than integral ids
#3740
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
base: main
Are you sure you want to change the base?
Conversation
Can you add some gentle background to the PR description? |
I've added an example to the description of the PR. |
@garth-wells any further comments? |
Yes, will add comments asap. |
/// `integrals[IntegralType, domain ID, kernel index]` returns the | ||
/// integral (`integral_data`) of type `IntegralType` over domain `ID` | ||
/// with kernel index `kernel index`. | ||
/// `integrals[IntegralType, i, kernel index]` returns the `i`th integral |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear what the "i
th integral" means.
/// | ||
/// @param[in] type Integral type. | ||
/// @return List of IDs for given integral type. | ||
std::vector<int> integral_ids(IntegralType type) const | ||
/// @param[in] kernel_idx Index of the kernel (we may have multiple |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be helpful to add a more in-depth discussion/explanation to to the body of the docs.
{ | ||
std::vector<int> ids; | ||
int count = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be replaced by std::count_if
?
@@ -512,21 +502,21 @@ class Form | |||
/// `entities0[i]` point to the same mesh entity, but with respect to | |||
/// different mesh views. | |||
/// | |||
/// @param type Integral type. | |||
/// @param rank Argument index, e.g. `0` for the test function space, `1` | |||
/// @param[in] type Integral type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doc is just a repeat of the type. Does it need more explanation?
As shown in: #3735, there are many UFL forms (especially in the case of mixed quadrature rules), where the
subdomain_id
is not mapped 1-1 with an integration kernel.This PR refactors the Form class, to rather use the local indexing from the generated code (where integrals have been grouped) as the lookup key for the integral.
Only a minor change occurs in the user-interface, as
Form::subdomain_ids
no longer maps to the UFL subdomain_ids.However, this is currently only used for internal looping, as the integral_idx -> subdomain_id mapping happens within the
create_form_factory
function.This allows for different quadrature degrees in different parts of a form.
Example:
This generates two different integration kernels in FFCx, with the integral information as:
As seen in the latter line here,
form_integral_ids_form_*
is not a list of unique integers.In the main branch of DOLFINx, we assume that this id is unique, which is the root cause of #3735.