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

Fix mountain test through specification of initial wind #31

Merged
merged 3 commits into from
Nov 26, 2024

Conversation

tommbendall
Copy link
Collaborator

The mountain_nonhydrostatic test is currently broken, as it calls the remove_initial_w routine which no longer works, giving the error message:

Traceback (most recent call last):
  File "/home/thomas/firedrake/src/gusto/case_studies/case_studies/compressible_euler/mountain_nonhydrostatic.py", line 283, in <module>
    mountain_nonhydrostatic(**vars(args))
  File "/home/thomas/firedrake/src/gusto/case_studies/case_studies/compressible_euler/mountain_nonhydrostatic.py", line 224, in mountain_nonhydrostatic
    remove_initial_w(u0)
  File "/home/thomas/firedrake/src/gusto/gusto/initialisation/hydrostatic_initialisation.py", line 232, in remove_initial_w
    bc.apply(u)
  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/thomas/firedrake/src/firedrake/firedrake/adjoint_utils/dirichletbc.py", line 32, in wrapper
    ret = apply(self, *args, **kwargs)
  File "/home/thomas/firedrake/src/firedrake/firedrake/bcs.py", line 448, in apply
    r = r.sub(idx)
  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/thomas/firedrake/src/firedrake/firedrake/function.py", line 349, in sub
    return self._components[i]
  File "/usr/lib/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/home/thomas/firedrake/src/firedrake/firedrake/function.py", line 333, in _components
    return tuple(type(self)(self.function_space().sub(i), self.topological.sub(i))
  File "/home/thomas/firedrake/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/thomas/firedrake/src/firedrake/firedrake/functionspaceimpl.py", line 187, in sub
    raise IndexError("Invalid component %d, not in [0, %d)" % (i, bound))
IndexError: Invalid component 1, not in [0, 1)

This PR fixes that by simply not calling the remove_initial_w routine. Instead we enforce the no-normal flow boundary conditions through the initial projection of the wind.

The final state demonstrates that this still gives the correct initial condition:
mountain_trial_final

@tommbendall tommbendall added bug Pull requests or issues to relating to something not working case study Pull requests or issues relating to adding or amending a case study labels Nov 22, 2024
Copy link
Collaborator

@jshipton jshipton left a comment

Choose a reason for hiding this comment

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

Great - thanks @tommbendall !

@jshipton jshipton merged commit 7a6a26b into main Nov 26, 2024
3 checks passed
@jshipton jshipton deleted the TBendall/FixMountainRemoveW branch November 26, 2024 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Pull requests or issues to relating to something not working case study Pull requests or issues relating to adding or amending a case study
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants