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

Construction of FEInterfaceValues with two pointers #115

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fdrmrc
Copy link
Collaborator

@fdrmrc fdrmrc commented Mar 10, 2023

This PR allows to construct a FEInterfaceValues out of two pointers to already initialized FEValues objects. It's working for our application, but right now I'm not sure this is what you intended.
First, the only context I can imagine this is when one has two ImmersedQuadratures (and hence two different FEImmersedSurfaceValues on two neighboring cells) and needs to compute jumps, etc. The issue with this is that a FEImmersedSurfaceValues is an FEValuesBase, not a FEFaceValuesBase and as such we don't have reinit(cell,f)), so the two internal pointers have been changed to plain FEValuesBase.

Second, the reinit of FEInterfaceValues allows also for subfaces in principle, but this is not allowed with an FEImmersedSurfaceValues, so these two Asserts for subfaces

Assert(
internal_fe_subface_values,

Assert(
internal_fe_subface_values_neighbor,

are necessary in case one accidentally calls reinit with subfaces arguments using this constructor.

@luca-heltai

@@ -1546,13 +1554,13 @@ class FEInterfaceValues
const unsigned int fe_index = numbers::invalid_unsigned_int);

/**
* Return a reference to the FEFaceValues or FESubfaceValues object
* Return a reference to the FEValuesBase object
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you mention that this is typically an FEFaceValues or FESubfaceValues except in case of using the constructor that uses two FEValuesBase pointers?

* FEValuesBase like objects. This may occur when one has
*
*/
FEInterfaceValues(FEValuesBase<dim, spacedim> *const fe_values0,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why pointers instead of references?

/**
* Construct a new FEInterfaceValues on top of two already initialized
* FEValuesBase like objects. This may occur when one has
*
Copy link
Collaborator

Choose a reason for hiding this comment

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

please complete documentation

@@ -2203,14 +2211,14 @@ class FEInterfaceValues
* Pointer to internal_fe_face_values or internal_fe_subface_values,
* respectively as determined in reinit().
*/
FEFaceValuesBase<dim, spacedim> *fe_face_values;
FEValuesBase<dim, spacedim> *fe_face_values;
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you update the comment here as well (it can be one of three options now)


/**
* Pointer to internal_fe_face_values_neighbor,
* internal_fe_subface_values_neighbor, or nullptr, respectively
* as determined in reinit().
*/
FEFaceValuesBase<dim, spacedim> *fe_face_values_neighbor;
FEValuesBase<dim, spacedim> *fe_face_values_neighbor;
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

@@ -300,7 +300,7 @@ namespace Step12
ScratchData<dim> & scratch_data,
CopyData & copy_data) {
scratch_data.fe_interface_values.reinit(cell, face_no);
const FEFaceValuesBase<dim> &fe_face =
const FEValuesBase<dim> &fe_face =
Copy link
Collaborator

Choose a reason for hiding this comment

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

So this change is not backwards-compatible? Hrm.
One could also leave the old type and fail if one calls this function after using the new constructor. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unfortunately, yes. The main problem is that get_fe_face_values() is called internally to compute jumps, averages, etc. so it must be available also with the new cstr. At the same time, the name get_fe_face_values() is now misleading, as in the present PR it's not returning a FEFaceValuesBase anymore, so I agree one should use the old types.

To be more specific, everything boils down to the fact that fe_face_values and fe_face_values_neighbor now need to be of type FEValuesBase.

So far the only solution I see is to add two FEValuesBase* members that will be initialized in case one chooses the new constructor. This would propagate some asserts and if sentences to the code, though.

@luca-heltai
Copy link
Owner

In the long run, I think a better option would be (and this would also be applicable to another application we are working on with @lwy5515) to create a base class FECouplingValues, that internally stores pointers to FEvaluesBase and that does all the dof handling stuff (gathering of the indices, local to global, etc.), of which FEInterfaceValues is a derived class that knows that the FEValues passed to the base class are actually FEFaceValues, thus separating the concerns (i.e., the dof indices handling part would be done in the base class, while the jumps/averages/etc. (that require knowledge of normals/subfaces/etc.) are handled in the derived class.

What you are doing here is ok, but I think we should refactor things a bit.

I suggest we postpone this PR for a few days, until we discuss about this also with Martin.

@fdrmrc
Copy link
Collaborator Author

fdrmrc commented Mar 12, 2023

Sounds perfect to me!

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