-
-
Notifications
You must be signed in to change notification settings - Fork 216
Unification of one-sided sub-entity integrals + ridge integrals #3900
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
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.
Nice code duplication removal!
The unification reads really well. One point to consider, for future design, given the increase in type of integral we are seeing: |
I think if we ever introduce "peak" integrals, they would effectively replace the vertex integrals, as we should always go down the "co-dimension" route (for the sake of mixed assembly support). |
Once we have the ridge integral which aligns with vertex integral for |
Something has gone very badly wrong in the DOLFINX design if this is the case. It should be relatively easy to rename an enum, or change the enum to a pair of integers, in DOLFINx without changing UFCx or FFCx. What specifically causes a 'cascade' into FFCx? |
This is being handled separately in: |
But what's the issue? I can't see it. If we have such tight coupling between DOLFINx and FFCx/UFCx there is a design mistake that needs to be fixed. |
Currently in DOLFINx we look things up by strings, and assume that they match with things in FFCx and UFL. |
fn, constants, | ||
md::mdspan(coeffs.data(), vertices.size() / shape1, cstride), cdofs_b); | ||
md::mdspan<const std::uint8_t, md::dextents<std::size_t, 2>> perms | ||
= (itg_type == fem::IntegralType::exterior_facet) |
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.
What are you checking here? If the IntegralType happens to be codim=1, i.e. if the entities we integrate over happen to be facets?
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.
This was initially an if statement, then a switch then moved back after Garth’s comment.
in general any integral of codim>0 needs permutations (except codim=tdim). At the time of writing, we only have facet permutations implemented.
It matters for mesh-submesh coupling, ie this PR does not introduce 3D-1D mixed problems, as I need ridge permutations, which is in another PR (#3904)
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.
Should the condition be what you said then, that codim > 0 (or better codim=1, and warning for codim > 1)? I don't mind either of the if, switch or ternary, I am asking about the logic.
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.
With what we currently have implemented, it should be equality.
if I get ridge permutations into DOLFINx, it will be an if codim>0. Garth asked to not implement for features that are not there yet, which is why I removed the switch and went for a tenary logic for what we support.
Co-authored-by: Michal Habera <[email protected]>
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.
I am happy with this PR, I only see minor potential for naming improvement, as after the PR we will have:
- assemble_entities
assembles over provided entities (regardless of their dim/codim) restricted to 0th adjacent cell, could as well be called assemble_entities_cell0?.
And two more specialized cases:
- assemble_cells
assembles over cells restricted to 0th (but the only) adjacent cell (itself), - assemble_interior_facets
assembles over facets (codim=1) with restriction being based on exactly first two adjacent cells.
If we'd like to unify the special cases, with some work we can use assemble_entities_cell0 to handle assemble_cells -- the only complication now I think is different data format of entities array, and also generalize assemble_interior_facets to assemble_entities_cell0cell1. This proposed naming is very explicit in what the function does.
This PR does not add any complexity, it actually exposes the shortcomings of the current design where the assumptions on: 1. what do we integrate over and 2. what adjacent entities is it restricted to, are simply buried in the code, not clear from the API.
@@ -156,16 +156,24 @@ void assemble_cells_matrix( | |||
} | |||
} | |||
|
|||
/// @brief Execute kernel over exterior facets and accumulate result in | |||
/// a matrix. | |||
/// @brief Execute kernel over entities of codimension > 1 and accumulate result |
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.
/// @brief Execute kernel over entities of codimension > 1 and accumulate result | |
/// @brief Execute kernel over entities of codimension ≥ 1 and accumulate result |
@@ -55,41 +55,50 @@ T assemble_cells(mdspan2_t x_dofmap, | |||
return value; | |||
} | |||
|
|||
/// Execute kernel over exterior facets and accumulate result | |||
/// @brief Execute kernel over entities of codimension > 1 and accumulate result |
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.
/// @brief Execute kernel over entities of codimension > 1 and accumulate result | |
/// @brief Execute kernel over entities of codimension ≥ 1 and accumulate result |
@@ -718,7 +718,16 @@ void assemble_cells( | |||
} | |||
} | |||
|
|||
/// @brief Execute kernel over cells and accumulate result in vector. | |||
/// @brief Execute kernel over entities of codimension > 1 and accumulate result |
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.
/// @brief Execute kernel over entities of codimension > 1 and accumulate result | |
/// @brief Execute kernel over entities of codimension ≥ 1 and accumulate result |
@@ -191,14 +199,14 @@ void assemble_cells_matrix( | |||
/// @param[in] perms Facet permutation integer. Empty if facet |
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.
/// @param[in] perms Facet permutation integer. Empty if facet | |
/// @param[in] perms Entity permutation integer. Empty if entity |
Glad to see the ridge integrals are coming their way! The unification makes real sense to me. In addition to the significant duplicated code removal, the "re-naming" of the assembly functions with I agree with @michalhabera 's point on moving assembly routines to "the codimension format". I think @jorgensd 's PR#3919 with a dedicated class This is a big step towards codimension > 1 :) |
New features
ufl.dr
) (tdim - 2) (for rank 0, 1 and 2-tensors)assemble_vector
for all exterior entity integrals.assemble_matrix
andapply_lifting
for vertex integralsContext
Any one-sided sub entity integral boils down to getting the correct (cell, local_entity_index), and assemble over these.
The lower level assembly routines (assemble_exterior_facet, assemble_vertex) does not really differ in this respect. It is only due to the fact that facets might require permutations that codes were not identical.
This became crystal clear when introducing ridge integrals.
Consequences
assemble_vertex
routines recently introduced are removed in favor of anassemble_exterior_facet
function, now renamed asassemble_exterior_entities
. This is also used for ridge integrals.Bugs encountered
Future work
Mixed dimensional support for codim-2.
For this to work, a few things have to be introduced: