moose icon indicating copy to clipboard operation
moose copied to clipboard

Need a callback in FEProblemBase for performing extra work after displaced mesh is updated

Open YaqiWang opened this issue 8 months ago • 1 comments

Motivation

We have an object constructed from the displaced mesh that should be reintialized after the displaced mesh is updated by DisplacedProblem::updateMesh. Currently, we have to put this reinitialization in several places so that we can have the object in synchronization with the mesh before its operation. This is not ideal. I am think to have a virtual function in FEProblemBase named as onDisplacedMeshUpdate, so that it can be called within DisplacedProblem::updateMesh. We can perform an optimization by letting UpdateDisplacedMeshThread in updateMesh to return a flag indicating whether the mesh is indeed changed or not and call onDisplacedMeshUpdate when mesh is indeed changed. With this, I can add my object reinitialization in onDisplacedMeshUpdate and do not need to worry about its synchronization.

Design

My proposed design is described in the Motivation.

Impact

This will make synchronization of objects depending on the displaced mesh sound.

YaqiWang avatar Jun 25 '25 00:06 YaqiWang

why does the object need to be reinitialized after the displaced mesh is updated?

lindsayad avatar Jun 25 '25 17:06 lindsayad

and why can't you use the MeshChangedInterface? Does that interface work only for objects?

GiudGiud avatar Jun 26 '25 02:06 GiudGiud

why does the object need to be reinitialized after the displaced mesh is updated?

The test user object does not, but in Griffin, the sweeper is built on the displaced mesh. When the displaced mesh is updated, we need to reinit the sweeper to reflect the node displacement.

YaqiWang avatar Jun 26 '25 02:06 YaqiWang

and why can't you use the MeshChangedInterface? Does that interface work only for objects?

That is designed for mesh adaptation. Updating the displaced mesh is not considered as a mesh change, i.e. not trigger meshChanged.

YaqiWang avatar Jun 26 '25 02:06 YaqiWang

should we have a meshDisplacedInterface then?

GiudGiud avatar Jun 26 '25 11:06 GiudGiud

the advantage of interface with a similar design as meshChangedInterface is that it becomes a real moose capability, objects can be made to "do something if mesh displaces". Whereas a simple call back that does nothing by default, and is only essentially implemented in a Griffin executioner, does not really bring new opportunities for users. It also opens the door for Griffin and another app to implement that callback differently and be even more incompatible in a multi-system setup

GiudGiud avatar Jun 26 '25 14:06 GiudGiud

becomes a real moose capability

I think I like this idea. But it will be a much more significant change in framework. If the moose team wants it, I can give a try and update the PR.

YaqiWang avatar Jun 26 '25 15:06 YaqiWang

we need to reinit the sweeper to reflect the node displacement

the sweeper depends on the node locations?

lindsayad avatar Jun 26 '25 16:06 lindsayad

That is designed for mesh adaptation

It's not just for mesh adaptation. It's used for things like subdomain ID changes as well

lindsayad avatar Jun 26 '25 16:06 lindsayad

we need to reinit the sweeper to reflect the node displacement

the sweeper depends on the node locations?

Yes.

YaqiWang avatar Jun 26 '25 20:06 YaqiWang