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

Hard-to-debug error when LinearAlgebra.cdot and MatrixFields.cdot are both imported #1774

Open
Sbozzolo opened this issue Jun 3, 2024 · 0 comments · May be fixed by #1771
Open

Hard-to-debug error when LinearAlgebra.cdot and MatrixFields.cdot are both imported #1774

Sbozzolo opened this issue Jun 3, 2024 · 0 comments · May be fixed by #1771
Assignees
Labels
bug Something isn't working

Comments

@Sbozzolo
Copy link
Member

Sbozzolo commented Jun 3, 2024

    n_elem_z = 2

    domain = Domains.IntervalDomain(Geometry.ZPoint(0.0), Geometry.ZPoint(1.0), boundary_names = (:bottom, :top))
    mesh = Meshes.IntervalMesh(domain, nelems = 2)
    space = Spaces.FaceFiniteDifferenceSpace(mesh)

    diverg = Operators.DivergenceC2F(; bottom = Operators.SetDivergence(0.0), top = Operators.SetDivergence(0.0))
    grad = Operators.GradientF2C()

    diverg_matrix = MatrixFields.operator_matrix(diverg)
    grad_matrix = MatrixFields.operator_matrix(grad)

    name = @name(u)
    jacobian = MatrixFields.FieldMatrix(
        (@name(u), @name(u)) => similar(zeros(space), ClimaCore.MatrixFields.TridiagonalMatrixRow{Float64}),
    )

    @. jacobian[name, name] = diverg_matrix()  grad_matrix() - (I,)

The error here is "Broadcasted spaces are not the same". The real issue is that cdot is not the correct function.

Tracking this problem down took a couple of hours of debugging, but it is something we can easily catch in ClimaCore (there is no instance where users want to use LinearAlgebra.dot when working with MatrixFields).

@Sbozzolo Sbozzolo added the bug Something isn't working label Jun 3, 2024
@Sbozzolo Sbozzolo linked a pull request Jun 3, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants