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

Bubble shear on the fly adapt demo #145

Merged
merged 14 commits into from
Sep 17, 2024
Merged

Bubble shear on the fly adapt demo #145

merged 14 commits into from
Sep 17, 2024

Conversation

ddundo
Copy link
Member

@ddundo ddundo commented Aug 13, 2024

Closes #55. Closes #144.

@ddundo
Copy link
Member Author

ddundo commented Aug 13, 2024

Still a few small things to sort out before ready for full review.

@stephankramer further to our discussion, could you please check that the run_simulation function looks good? No need to take a look at anything else :) I'd just like to have a solid problem and solver setup that I would then use in generating training data - where I would vary initial condition and velocity field. I'd keep everything else the same. So before doing that I'd like to make sure this looks good.

@ddundo ddundo added the documentation Improvements or additions to documentation label Sep 12, 2024
@ddundo ddundo self-assigned this Sep 12, 2024
@ddundo ddundo requested a review from jwallwork23 September 12, 2024 11:46
@ddundo
Copy link
Member Author

ddundo commented Sep 12, 2024

Hey @jwallwork23, could you please review when you have a bit of time?

I had to comment out the rank check in RiemannianMetric as otherwise RiemannianMetric.sub() raises the following error:

Traceback (most recent call last):
  File "/home/ubuntu/software/firedrake-may24/src/animate/demos/bubble_shear.py", line 424, in <module>
    mesh = adapt_metric_advection(mesh, t0, t1, c)
  File "/home/ubuntu/software/firedrake-may24/src/animate/demos/bubble_shear.py", line 393, in adapt_metric_advection
    m_.assign(metric_.sub(2 * i + j))
  File "petsc4py/PETSc/Log.pyx", line 188, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
  File "petsc4py/PETSc/Log.pyx", line 189, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
  File "/home/ubuntu/software/firedrake-may24/src/firedrake/firedrake/function.py", line 349, in sub
    return self._components[i]
  File "/home/ubuntu/software/firedrake-may24/src/PyOP2/pyop2/utils.py", line 62, in __get__
    obj.__dict__[self.__name__] = result = self.fget(obj)
  File "/home/ubuntu/software/firedrake-may24/src/firedrake/firedrake/function.py", line 333, in _components
    return tuple(type(self)(self.function_space().sub(i), self.topological.sub(i))
  File "/home/ubuntu/software/firedrake-may24/src/firedrake/firedrake/function.py", line 333, in <genexpr>
    return tuple(type(self)(self.function_space().sub(i), self.topological.sub(i))
  File "petsc4py/PETSc/Log.pyx", line 188, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
  File "petsc4py/PETSc/Log.pyx", line 189, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
  File "/home/ubuntu/software/firedrake-may24/src/animate/animate/metric.py", line 89, in __init__
    raise ValueError(
ValueError: Riemannian metric should be matrix-valued, not rank-1 tensor-valued.

Do you see a nice workaround please? If it's not obvious, I'll keep digging :) other than that it should be good I think

@ddundo ddundo marked this pull request as ready for review September 12, 2024 11:50
@ddundo ddundo mentioned this pull request Sep 12, 2024
@jwallwork23
Copy link
Member

Could you not just try interpolating metric_[i,j] rather than assigning a sub-component? It's not as efficient as assignment but generating a sub-component of a metric would take a bit of work by the looks of it.

@jwallwork23
Copy link
Member

Alternatively, just have a solver that acts on the full metric rather than a solver for each of it's components?

animate/metric.py Outdated Show resolved Hide resolved
@ddundo ddundo force-pushed the 55_on_the_fly branch 2 times, most recently from c54e073 to 81ce258 Compare September 15, 2024 11:53
@ddundo ddundo requested a review from jwallwork23 September 15, 2024 12:07
Copy link
Member

@jwallwork23 jwallwork23 left a comment

Choose a reason for hiding this comment

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

This is amazing, thanks @ddundo! Quite a few comments but mostly fairly minor.

Please can you create a linked mesh-adaptation-docs PR to add the new demo to animate/index.rst?

demos/bubble_shear.py Outdated Show resolved Hide resolved
# #########################################
#
# In this demo we consider the 2-dimensional version of the mesh adaptation experiment
# presented in :cite:<Barral:2016>. The problem comprises a bubble of tracer
Copy link
Member

Choose a reason for hiding this comment

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

Citation doesn't work because it's inconsistent with the one in demo_references.bib.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, I see now it's supposed to have backslashes instead of brackets! Fixed in 6111ca5

Copy link
Member Author

Choose a reason for hiding this comment

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

Btw I always get errors for citations locally, e.g. /data3/mesh-adaptation-docs/docs/source/demos/solid_body_rotation.py.rst:21: WARNING: could not find bibtex key "LeVeque:1996" so I ignored this :)

Copy link
Member

Choose a reason for hiding this comment

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

Are you saying that the citations never render for you in Sphinx? They work fine for me.

Copy link
Member

Choose a reason for hiding this comment

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

Oh actually I do get the same warnings, although the citations render in the HTML.

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried it on the new docker image now. I get the same warnings and the citations don't render in html (i.e. they just appear as empty brackets []). I guess you're doing this on the docker image and following the same instructions as in the mesh-adaptation-docs readme?

Copy link
Member

Choose a reason for hiding this comment

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

I don't tend to use the Docker image locally, no. I'm using a local build. Navigating to ${VIRTUAL_ENV}/src/mesh-adaptation-docs/docs and running make html.

Copy link
Member

Choose a reason for hiding this comment

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

Please open an issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

demos/bubble_shear.py Outdated Show resolved Hide resolved
demos/bubble_shear.py Outdated Show resolved Hide resolved
demos/bubble_shear.py Outdated Show resolved Hide resolved
demos/bubble_shear.py Show resolved Hide resolved
demos/bubble_shear.py Outdated Show resolved Hide resolved
demos/bubble_shear.py Outdated Show resolved Hide resolved
demos/bubble_shear.py Show resolved Hide resolved
demos/bubble_shear.py Outdated Show resolved Hide resolved
@ddundo ddundo requested a review from jwallwork23 September 16, 2024 14:37
@ddundo
Copy link
Member Author

ddundo commented Sep 16, 2024

Thanks a lot for the detailed review @jwallwork23! I'm sorry for doing such a terrible job at self-reviewing :) hopefully all is good now!

Copy link
Member

@jwallwork23 jwallwork23 left a comment

Choose a reason for hiding this comment

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

Thanks @ddundo, just some minor comments and suggestions now.

@ddundo
Copy link
Member Author

ddundo commented Sep 17, 2024

Thanks again @jwallwork23! Addressed the final comments so will merge now.

(Cancelled the workflow since it's just text updates)

@ddundo ddundo merged commit d52f046 into main Sep 17, 2024
1 check failed
@ddundo ddundo deleted the 55_on_the_fly branch September 17, 2024 07:28
ddundo added a commit to mesh-adaptation/docs that referenced this pull request Sep 17, 2024
@jwallwork23 jwallwork23 mentioned this pull request Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Metric advection demo Time-dependent adaptation demo
2 participants