Skip to content

EnhancedMeshVariable.clone() drops its arguments, breaking six shipped examples #498

Description

@lmoresi

EnhancedMeshVariable.clone is declared as clone(self) and calls self._base_var.clone(), but the underlying MeshVariable.clone requires (name, varsymbol):

src/underworld3/discretisation/enhanced_variables.py:466
    def clone(self):
        """Clone the variable."""
        return self._base_var.clone()

src/underworld3/discretisation/discretisation_mesh_variables.py:577
    def clone(self, name, varsymbol):

So it is broken in both directions: passing the arguments callers actually use raises TypeError: clone() takes 1 positional argument but 3 were given, and the no-argument form the wrapper offers would fail inside the base for a missing argument.

Every in-tree caller uses the two-argument form:

  • docs/examples/fluid_mechanics/advanced/Ex_Stokes_Cartesian_SolC.py:141,142
  • docs/examples/utilities/advanced/Ex_Darcy_1D_benchmark.py:89,90
  • docs/examples/utilities/advanced/Ex_Darcy_3D_flow_x_axis.py:90,91
  • docs/examples/utilities/advanced/Ex_Darcy_3D_flow_z_axis.py:92,93
  • docs/examples/utilities/advanced/Ex_Darcy_3D_Loop_Mesh_Fault.py:218,219

Each of those examples aborts at that line, so none of them runs to completion. No test covers clone at all, which is how it stayed broken.

Found while replacing the Underworld2 shell-out in the SolC example with uw.analytic.SolC — the example turned out never to have run, which is also how a mismatched body force survived in it.

Fix is to forward the arguments and add a test. Doing that in the analytic-suite branch since it blocks verifying that work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions