Skip to content

Comments

Feature/ale#2244

Open
arash-mp wants to merge 30 commits intoExtremeFLOW:developfrom
arash-mp:feature/ALE
Open

Feature/ale#2244
arash-mp wants to merge 30 commits intoExtremeFLOW:developfrom
arash-mp:feature/ALE

Conversation

@arash-mp
Copy link

@arash-mp arash-mp commented Jan 2, 2026

Summary

This PR implements the Arbitrary Lagrangian-Eulerian (ALE) formulation to support moving mesh simulations in Neko. It introduces a new "ale_manager" to handle grid velocities and mesh deformation, modifies "fluid_pnpn" to include grid velocity terms, and updates the IO and checkpoints to support ALE simulations.

Key Changes

Core & Solver

  • New Module: Added "src/ale/" containing "ale_manager.f90" (handles mesh motion logic) and core definitions.
  • Solver Update: Modified "fluid_pnpn.f90" and "rhs_maker" to incorporate ALE advection terms (fluid velocity relative to mesh velocity).
  • BC type: Implements a new "moving_boundary" boundary condition (field_moving.f90).

IO & Checkpointing

  • Updated "checkpoint.f90" and "chkp_file.f90" to save/restart simulations with moving meshes.

Examples

  • Added two new examples in "examples/":
    • "ocyl_cylinder3D": A cylinder hinged from the top and oscillate like a pendulum.
    • "ocyl_ellipse3D": A moving ellipse that simultaneously rotates around its axis.

ToDo:

  • GPU implementation (Currently CPU only).
  • OIFS time-integration support.

References:

Implementation is based on:
1- Fischer, P., Schmitt, M. and Tomboulides, A., 2017. Recent developments in spectral element simulations of moving-domain problems. Recent progress and modern challenges in applied mathematics, modeling and computational science, pp.213-244.
2- Ho, L.W., 1989. A Legendre spectral element method for simulation of incompressible unsteady viscous free-surface flows (Doctoral dissertation, Massachusetts Institute of Technology).

ocyl_ellipse_example

Comment on lines 167 to 172
case ("moving_boundary")
if (.not. neko_registry%field_exists('wm_x')) then
call neko_error("'moving_boundary' found in the BC list&
&, but ALE is not active! Set 'ale_active = true' in &
&case file.")
end if
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just an initial comment. This moving_boundary is just a no-slip condition underneath, right? Your new bc just does a masked copy of the mesh velocity. What I don't fully understand is how the setup of the motion in the ALE is coupled to the selection of the boundary that moves. If it is the boundary that moves, is it not more logical to prescribe the motion in the JSON dictionary for the bc? What if you have more than one moving_boundary in the current setup, does it work?

Copy link
Author

Choose a reason for hiding this comment

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

The "moving_boundary" is similar to a Dirichlet boundary condition, but it is also used to mark boundaries that are allowed to move.

In the current implementation, a single mesh-velocity field is defined over the entire domain, assigning a velocity to every grid point. THen, the filed is multiplied by a scalar field called phi. So, we need to identify the moving_boundary regions for constructing the correct phi field.

The field phi takes values between 0 and 1. It is equal to 1 on boundaries marked as moving_boundary and 0 on all other non-periodic boundaries. When the mesh-velocity field is multiplied by phi, only the boundaries marked as moving are assigned the prescribed velocity, while all other boundaries remain fixed. Also, this method presereve the mesh quality near the wall, so mesh deformation happes mostly away from the wall.

In ale_manager, the subroutine solve_base_displacement computes the phi field by solving a Laplace equation once during initialization (in practive, we can recompute it also every N iterations, if needed). This results in a smooth spatial transition of phi from the moving boundaries into the interior of the domain.

  • We can have multiple moving boundaries at the same time. The Laplace solution provides a smooth blending of motion throughout the domain. However, in the current implementation, all moving objects share the same prescribed velocity. With some hack (like defining the base mesh velocity based on coordinates to allow different object mvoe with different velocities) we can overcome this, but ofc not the best solution.
    I will think about better ways to do this also.
    Also, tbh, for most practical cases I think one would have 1 moving object, but it's good to make it more flexible for several moving objects for sure.

Copy link
Author

Choose a reason for hiding this comment

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

Also, at moving_boundary, we need to set the fluid velocity vector equal to mesh velcoity (to have no-slip BC). that's what masked_copy does here. It's like enforcing the kinematics boundary condition.

Copy link
Author

Choose a reason for hiding this comment

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

Also one way (maybe naiive, should think more about it) for generalization into several moving objects is using super position, such that we find 1 phi field for each moving body, such that phi=1 only on that body and 0 on other moving bodies, then we sum them up. and then I can set seperate motion for any number of bodies in JSON.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for the clarification, Arash, now I understand much better! I think it is totally fine to leave the mesh motion working as you say for this initial PR. For the boundary conditions, it feels like a better way would be not introducing a new condition, but rather having a moving : true / false keyword added to ordinary boundary conditions and letting them handle that situation. In the beginning we can just add this to the no_slip condition. But later on it is probably nice if other conditions can also handle a moving boudnary, and adding a movng_* for each sounds not very practical. I am not 100% sure, but it seems this can be done rather easily, or? The only thing you need is to fetch the grid velocity inside the bc. Think about it, and I will also take a bit of a look.

Copy link
Author

Choose a reason for hiding this comment

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

I see the point. I think it's straight forward to do this. Will give it a shot today.

Copy link
Collaborator

Choose a reason for hiding this comment

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

What we do now for no-slip is

allocate(zero_dirichlet_t::object)

in the bc factory. I don't think we should add anything to zero_dirichlet_t. That type is anyway mostly meant as a utility for masks etc. I think what you can do is rename the new bc you added here to no_slip, and allocate that one instead of the zero_dirichlet. Then, you pretty much do exactly the same as what you already do in the moving_boundary currently, but just add treatment of the ordinary no-slip when there is no mesh movement.

@njansson
Copy link
Collaborator

njansson commented Feb 3, 2026

Great stuff, I think it would be good to try to get this merged as soon as possible before it starts to lag behind develop too much

timofeymukha added a commit that referenced this pull request Feb 4, 2026
Added an option to print out the mesh every time.

I am having problems on deciding how to do this. Generally I would like
that one can control what is written when the write method is called,
but that is not the way we do things in Neko, so for the moment it is
just like this.

I guess if one creates a file_t in the user file, it is possible to
control if the mesh is written by directly modifying the attribute in
the object, so at least that's something.

This is based on what @arash-mp will also add in #2244.

---------

Co-authored-by: Timofey Mukha <timofey.mukha@protonmail.com>
Co-authored-by: Victor Baconnet <baconnet@kth.se>
@adperezm
Copy link
Collaborator

@arash-mp, is this one ready for review? Also check the failing tests.

@arash-mp arash-mp requested a review from adperezm February 11, 2026 13:07
@arash-mp
Copy link
Author

arash-mp commented Feb 11, 2026

@arash-mp, is this one ready for review? Also check the failing tests.

@adperezm Yes it's ready.
GPU part still is not done, and the failing tests I should check and ask how to fix them:D
But I think it's good to start reviewing it as it may take a lot of time!

loretet pushed a commit that referenced this pull request Feb 18, 2026
Added an option to print out the mesh every time.

I am having problems on deciding how to do this. Generally I would like
that one can control what is written when the write method is called,
but that is not the way we do things in Neko, so for the moment it is
just like this.

I guess if one creates a file_t in the user file, it is possible to
control if the mesh is written by directly modifying the attribute in
the object, so at least that's something.

This is based on what @arash-mp will also add in #2244.

---------

Co-authored-by: Timofey Mukha <timofey.mukha@protonmail.com>
Co-authored-by: Victor Baconnet <baconnet@kth.se>
@njansson njansson moved this from 📋 Todo to 🏗 In progress in Neko v1.1.0 release Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🏗 In progress

Development

Successfully merging this pull request may close these issues.

4 participants