Skip to content

There are differences between * and in MatrixFields #2293

@charleskawczynski

Description

@charleskawczynski

Here is a reproducer:

using ClimaComms
using LinearAlgebra
ClimaComms.@import_required_backends
using ClimaCore.CommonSpaces
using ClimaCore: Operators, Fields, MatrixFields, Geometry, Spaces
FT = Float64;
space = ExtrudedCubedSphereSpace(FT;
    z_elem = 10,
    z_min = 0,
    z_max = 1,
    radius = 10,
    h_elem = 10,
    n_quad_points = 4,
    staggering = CellCenter()
);
interpc2f_op = Operators.InterpolateC2F(
    bottom = Operators.Extrapolate(),
    top = Operators.Extrapolate(),
);
divf2c_op = Operators.DivergenceF2C();
divf2c_matrix = MatrixFields.operator_matrix(divf2c_op);
gradc2f_op = Operators.GradientC2F(
    top = Operators.SetGradient(Geometry.WVector(FT(0))),
    bottom = Operators.SetGradient(Geometry.WVector(FT(0))),
);
gradc2f_matrix = MatrixFields.operator_matrix(gradc2f_op);

K = Fields.Field(FT, space);
ϑ = Fields.Field(FT, space);
F = Fields.Field(FT, Spaces.face_space(space));
L = Fields.Field(FT, Spaces.face_space(space));

topBC_op = Operators.SetBoundaryOperator(
    top = Operators.SetValue(F),
    bottom = Operators.SetValue(
        Geometry.Covariant3Vector(zero(FT)),
    ),
);
# works
@. (divf2c_matrix() * (
    MatrixFields.DiagonalMatrixRow(
        interpc2f_op(K),
    ) * gradc2f_matrix())) - (I,)

# breaks
@. (divf2c_matrix()  (
    MatrixFields.DiagonalMatrixRow(
        interpc2f_op(K),
    )  gradc2f_matrix())) - (I,)

The error is ERROR: Broacasted spaces are not the same.. cc @dennisYatunin

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions