Skip to content

Conversation

@marksidoro
Copy link
Contributor

@marksidoro marksidoro commented Jul 14, 2025

@sebproell

In the code below, the DealiiWrappers namespace is extended by functionality so that a finite element discretization can be set up using the dealii::FEValues objects. The code allows for assembling global FE matrices in a typical deal.II fashion while keeping the DOF layout compatible with 4C. The goal is to be able to assemble coupling blocks between 4C and deal.II based discretizations.

The main classes added are FEValuesContext (and FEFaceValuesContext), which are wrappers around an FEValues object, together with some functionality that handles the reindexing of the local shape functions so that the underlying finite element objects are compatible with the internal ones from 4C.

For this, currently already available parts of the namespace have been reworked, namely the Context class has been updated to provide some further utility, akin to what a dealii::DofHandler would provide. I have also updated the structure/namespaces in the element_conversion.hpp.

A helper class to handle the required deal.II mapping is implemented together with a function to set it up with an isogeometric mapping (currently only working for a single cell_type in the Discretization).

Besides that, there are some further quality of life functions, as well as tests computing an L2-projection, from a simple deal.II Vector directly onto a vector in 4C layout. The problem is solved using a deal.II solver interface and using deal.II matrices and vectors.

Next steps/limitations

  • Using this code, I have already successfully set up a small FSI toy problem which is based on the tutorial step-46 of the deal.II library using the code provided there for the Fluid part of the Domain, while using the Solid from 4C. That code will be merged next once this PR is through.
  • Currently, I have not tested this code in parallel yet.
  • The code is not tested yet for multiple different cell_types within the same discretization

@marksidoro marksidoro requested a review from sebproell July 14, 2025 15:55
@sebproell
Copy link
Member

@marksidoro Awesome, I will review this ASAP! In the meantime, could you clean up the commits a little? In the current form, they do not really help in reviewing, since they repeatedly change the same file. Also, could you split out the one commit that changes something in PackBuffer to a separate PR? I am not sure about that change, but this might be better discussed in a dedicated PR.

Copy link
Member

@sebproell sebproell left a comment

Choose a reason for hiding this comment

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

I had a high-level view over the code. This code is quite high quality, great job! The docs and tests are nice 👍

I will do a detailed review tomorrow and we can also discuss a few things in person.

One thing you can already do is to activate the development environment by calling utilities/set_updev_env.sh. I can see that the pre-commit hooks are not run on this state.

@marksidoro
Copy link
Contributor Author

@marksidoro Awesome, I will review this ASAP! In the meantime, could you clean up the commits a little? In the current form, they do not really help in reviewing, since they repeatedly change the same file. Also, could you split out the one commit that changes something in PackBuffer to a separate PR? I am not sure about that change, but this might be better discussed in a dedicated PR.

Thats a good idea. I moved it into its own PR #997

@marksidoro marksidoro force-pushed the update-deal-context-with-fe-capabilities branch 3 times, most recently from 0e36477 to e14e775 Compare July 15, 2025 12:30
Copy link
Member

@sebproell sebproell left a comment

Choose a reason for hiding this comment

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

First batch of comments (I reviewed from CLion, but it is lacking some features for code suggestions, so I will switch to GH now ;)

const std::span<const int>& reindex_scalar, std::vector<int>& reindexing);
} // namespace Internal

namespace FourCToDeal
Copy link
Member

Choose a reason for hiding this comment

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

Maybe the two namespaces are a bit much. How about just FourCToDealii and remove ConversionTools?

Copy link
Member

@sebproell sebproell left a comment

Choose a reason for hiding this comment

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

I know I am repeating myself, but anyway: this code is so nice! It was a real pleasure to review, and I think the PR is in very good shape already.

Comment on lines +188 to +236
return dealii::MappingFEField<dim, spacedim, VectorType>(
iso_dof_handler, position_vector, mask);
Copy link
Member

Choose a reason for hiding this comment

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

After reading through the code and the docs of MappingFEField, I am beginning to understand this. The iso_dof_handler is required, since you need to have a DoFHandler with dofs in all space dimensions, and this is not guaranteed for whichever DoFHandler we use for evaluation? So you create it here and create the according position vector. Idk, but maybe my thought process helps you in documenting this a bit clearer (or you can tell me where my assumptions are wrong).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are basically correct and I have now added some docs to the mapping class to explain its usage.

@marksidoro marksidoro force-pushed the update-deal-context-with-fe-capabilities branch 3 times, most recently from ba63f5a to 3d4649c Compare July 16, 2025 13:15
@marksidoro marksidoro self-assigned this Jul 16, 2025
@marksidoro marksidoro force-pushed the update-deal-context-with-fe-capabilities branch from 3d4649c to ea52227 Compare July 16, 2025 14:29
Copy link
Member

@amgebauer amgebauer left a comment

Choose a reason for hiding this comment

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

I have a few minor comments. Your added code is very readable! 👍

/**
* reinidexings of the shape functions from 4C to deal.II for different cell types.
*/
namespace FourCToDeal
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
namespace FourCToDeal
namespace FourCToDealii


} // namespace FourCToDeal

namespace DealToFourC
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
namespace DealToFourC
namespace DealiiToFourC

"FE_NAME<dim>(degree) within the '< >' brackets. If thats not the case use the "
"templated version of this function, where you can specify the dimension explicitly.",
finite_element_name);
return Core::FE::CellType::dis_none;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return Core::FE::CellType::dis_none;

Comment on lines +471 to +475
FOUR_C_THROW(
"The finite element name {} must contain a dimension (dim) in the form of "
"FE_NAME<dim>(degree) within the '< >' brackets. If thats not the case use the "
"templated version of this function, where you can specify the dimension explicitly.",
finite_element_name);
Copy link
Member

Choose a reason for hiding this comment

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

Why a runtime error and not a compile time error? Are there elements that we don't support?

Comment on lines +484 to +486
FOUR_C_THROW("Unsupported finite element type '{}' for dim = {} and spacedim = {}.",
finite_element_name, 1, 1);
return Core::FE::CellType::dis_none;
Copy link
Member

Choose a reason for hiding this comment

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

I think you don't need this here (you have it at the bottom already)

}
FOUR_C_THROW("Unsupported finite element type '{}' for dim = {} and spacedim = {}.",
finite_element_name, dim, spacedim);
return Core::FE::CellType::dis_none;
Copy link
Member

Choose a reason for hiding this comment

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

No need to return something if you throw

const Context<dim, spacedim>& context)
{
FOUR_C_ASSERT(context.n_finite_elements() == 1,
"Currently only supported for the case that there is only one finite element in the "
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"Currently only supported for the case that there is only one finite element in the "
"Currently only supported for the case that there is only one finite element type in the "

Is it one finite element or one finite element type?

@sebproell
Copy link
Member

@marksidoro Can you address the few comments, so we can proceed here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants