mesh-adaptation / goalie

Goal-oriented error estimation and mesh adaptation for finite element problems solved using Firedrake
Other
2 stars 0 forks source link

Mixed steady/unsteady #164

Open ddundo opened 5 months ago

ddundo commented 5 months ago

This closes all issues connected to having multiple fields - in particular, when some were of "steady" type and others unsteady.

  1. Closes #152: added a mantle convection demo (taken from Davies, Kramer et al. 2022)
  2. Closes #153
ddundo commented 3 months ago

Using transfer_method="project" in the demo raises this:

Traceback (most recent call last):
  File "/home/ubuntu/software/firedrake-may24/src/goalie/demos/mantle_convection.py", line 222, in <module>
    solutions, indicators = mesh_seq.indicate_errors()
  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/goalie/goalie/go_mesh_seq.py", line 159, in indicate_errors
    self.solve_adjoint(**solver_kwargs)
  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/goalie/goalie/adjoint.py", line 426, in solve_adjoint
    checkpoints = self.get_checkpoints(
  File "/home/ubuntu/software/firedrake-may24/src/pyadjoint/pyadjoint/tape.py", line 110, in wrapper
    return function(*args, **kwargs)
  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/goalie/goalie/adjoint.py", line 175, in get_checkpoints
    checkpoints = super().get_checkpoints(
  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/goalie/goalie/mesh_seq.py", line 595, in get_checkpoints
    checkpoints.append(next(solver_gen))
  File "/home/ubuntu/software/firedrake-may24/src/goalie/goalie/mesh_seq.py", line 553, in _solve_forward
    {
  File "/home/ubuntu/software/firedrake-may24/src/goalie/goalie/mesh_seq.py", line 554, in <dictcomp>
    field: self._transfer(
  File "/home/ubuntu/software/firedrake-may24/src/goalie/goalie/mesh_seq.py", line 345, in _transfer
    return transfer(source, target_space, self._transfer_method, **transfer_kwargs)
  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/interpolation.py", line 74, in transfer
    return _transfer_forward(source, target, transfer_method, **kwargs)
  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/interpolation.py", line 188, in _transfer_forward
    t.project(s, **kwargs)
  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/adjoint_utils/function.py", line 48, in wrapper
    output = project(self, b, *args, **kwargs)
  File "/home/ubuntu/software/firedrake-may24/src/firedrake/firedrake/function.py", line 363, in project
    return projection.project(b, self, *args, **kwargs)
  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/adjoint_utils/projection.py", line 34, in wrapper
    output = project(*args, **kwargs)
  File "/home/ubuntu/software/firedrake-may24/src/firedrake/firedrake/projection.py", line 79, in project
    use_slate_for_inverse=use_slate_for_inverse).project()
  File "/home/ubuntu/software/firedrake-may24/src/firedrake/firedrake/projection.py", line 182, in project
    self.apply_massinv(self.target, self.rhs)
  File "/home/ubuntu/software/firedrake-may24/src/firedrake/firedrake/projection.py", line 241, in rhs
    self.mixed_mass.mult(u, v)
  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/projection.py", line 235, in mixed_mass
    return assemble_mixed_mass_matrix(self.source.function_space(),
  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/supermeshing.py", line 192, in assemble_mixed_mass_matrix
    V_S_A = FunctionSpace(reference_mesh, V_A.ufl_element())
  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/functionspace.py", line 104, in FunctionSpace
    element = make_scalar_element(mesh, family, degree, vfamily, vdegree, variant)
  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/functionspace.py", line 56, in make_scalar_element
    return family.reconstruct(cell=cell)
  File "/home/ubuntu/software/firedrake-may24/src/FInAT/finat/ufl/finiteelement.py", line 214, in reconstruct
    return FiniteElement(family, cell, degree, quad_scheme=quad_scheme, variant=variant)
  File "/home/ubuntu/software/firedrake-may24/src/FInAT/finat/ufl/finiteelement.py", line 145, in __init__
    ) = canonical_element_description(family, cell, degree, form_degree)
  File "/home/ubuntu/software/firedrake-may24/src/FInAT/finat/ufl/elementlist.py", line 453, in canonical_element_description
    raise ValueError(f"Cellname '{cellname}' invalid for '{family}' finite element.")
ValueError: Cellname 'triangle' invalid for 'Q' finite element.

The error is not raised with transfer_method="interpolate", which is what I originally used when I first started this demo - but now it's not possible due to https://github.com/mesh-adaptation/animate/issues/113.

@jwallwork23 @stephankramer do you know why this is raised please? The demo should be ready to go once this is fixed :)

Edit: Sorry, I figured it out :) thanks anyway!