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

Interpolation to and from sub-meshes for co-dimension 0 #3114

Merged
merged 41 commits into from
Apr 23, 2024

Conversation

jorgensd
Copy link
Member

@jorgensd jorgensd commented Mar 24, 2024

A feature that is quite neat for post-processing, as one often only wants to visualize on a sub mesh.
Can also be used to avoid mixed-assembly in cases of iterative schemes:

  1. Solve on a parent mesh
  2. Move solution to sub mesh
  3. Solve equation on sub mesh
  4. Move solution back and repeat.

There is a slight API change in the C++ interface, as expressions need the associated mesh to be supplied.
In Python, the API only changes if you want to map between meshes.

@jorgensd jorgensd added the enhancement New feature or request label Mar 24, 2024
cpp/dolfinx/fem/Function.h Outdated Show resolved Hide resolved
cpp/dolfinx/fem/Function.h Outdated Show resolved Hide resolved
cpp/dolfinx/fem/Function.h Outdated Show resolved Hide resolved
cpp/dolfinx/fem/Function.h Outdated Show resolved Hide resolved
cpp/dolfinx/fem/Function.h Show resolved Hide resolved
cpp/dolfinx/fem/interpolate.h Outdated Show resolved Hide resolved
cpp/dolfinx/fem/interpolate.h Outdated Show resolved Hide resolved
python/dolfinx/wrappers/mesh.cpp Outdated Show resolved Hide resolved
python/test/unit/fem/test_interpolation.py Show resolved Hide resolved
python/test/unit/fem/test_interpolation.py Show resolved Hide resolved
@jorgensd
Copy link
Member Author

jorgensd commented Apr 8, 2024

@garth-wells i’ve tried to address your comments.

cpp/dolfinx/fem/Function.h Outdated Show resolved Hide resolved
@jorgensd jorgensd requested a review from jhale April 22, 2024 17:30
@jorgensd jorgensd changed the title Interpolation to and from sub-meshes Interpolation to and from sub-meshes for co-dimension 0 Apr 22, 2024
@jorgensd jorgensd added the backport? Suggest PR for backporting label Apr 22, 2024
@jorgensd
Copy link
Member Author

All tests now pass. I've tried to address all comments.

@jhale jhale enabled auto-merge April 23, 2024 06:58
@jhale jhale disabled auto-merge April 23, 2024 07:00
@jhale jhale enabled auto-merge April 23, 2024 07:05
@jhale jhale dismissed garth-wells’s stale review April 23, 2024 08:00

All comments through two rounds of review have been addressed.

@jhale jhale added this pull request to the merge queue Apr 23, 2024
Merged via the queue into main with commit d4003bb Apr 23, 2024
23 checks passed
@jhale jhale deleted the dokken/submesh_codim0_interpolation branch April 23, 2024 08:35
jhale added a commit that referenced this pull request Apr 24, 2024
* First attempt on submesh interpolation

* ADd some more conversion

* UPdate more interfaces

* Expose python arrays of mappings to C++.
Fixes for expression interpolation + tests

* Add more asserts to please mypy

* Fix C++ interface

* Set some default zero-spans in C++ + fix hyperelasticity demo

* Set atol depending on default floating type

* Use exact solution on submesh when interpolating back to avoid accumulation of round-off errors

* Use exact solution in mapping back due to same issue

* Less strict tolerance

* Apply suggestions from code review

Co-authored-by: Garth N. Wells <[email protected]>

* Add default arguments in C++ and add documentation to tests

* Fix submesh C++ wrapping

* Renaming + updating docstring

* Fix conversion of u

* More renaming

* Fix documentation

* Apply suggestions from code review

Remove empty comment

* Improve documentation

Co-authored-by: Joe Dean <[email protected]>

* Ruff format docstring

* Try less strict atol

* Modify test to avoid squaring functions

* Ruff formatting

* Scatter forward data

* Modify test again

* Try scaling down gradient

* Fix test

* clang-format

---------

Co-authored-by: Garth N. Wells <[email protected]>
Co-authored-by: Joe Dean <[email protected]>
Co-authored-by: Jack S. Hale <[email protected]>

# Map from parent to sub mesh

u_sub.interpolate(parent_expr, expr_mesh=mesh, cell_map=sub_to_parent)
Copy link
Member

Choose a reason for hiding this comment

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

The CI deadlock https://github.com/FEniCS/dolfinx/actions/runs/8838261829 is triggered by this line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport? Suggest PR for backporting enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants