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

The Δz_field test generates bad LocalGeometry objects #1827

Closed
charleskawczynski opened this issue Jun 18, 2024 · 1 comment · Fixed by #1830 · May be fixed by #1828
Closed

The Δz_field test generates bad LocalGeometry objects #1827

charleskawczynski opened this issue Jun 18, 2024 · 1 comment · Fixed by #1830 · May be fixed by #1828
Assignees
Labels
bug Something isn't working

Comments

@charleskawczynski
Copy link
Member

In particular, we get NaN/Inf in some of the metric terms

@charleskawczynski charleskawczynski added the bug Something isn't working label Jun 18, 2024
@charleskawczynski charleskawczynski self-assigned this Jun 18, 2024
@charleskawczynski
Copy link
Member Author

We can update it to:

@testset "Δz_field" begin
    FT = Float64
    context = ClimaComms.SingletonCommsContext()
    x = FT(1)
    y = FT(2)
    z = FT(3)
    lat, long = FT(4), FT(5)
    x1 = FT(1)
    x2 = FT(2)
    x3 = FT(3)
    coords = [
        Geometry.ZPoint(z),
        Geometry.XZPoint(x, z),
        Geometry.XYZPoint(x, y, z),
        Geometry.LatLongZPoint(lat, long, z),
        Geometry.Cartesian3Point(x3),
        Geometry.Cartesian13Point(x1, x3),
        Geometry.Cartesian123Point(x1, x2, x3),
    ]
    all_components = [
        SMatrix{1,1}(FT[1]),
        SMatrix{2,2}(FT[1 2; 3 4]),
        SMatrix{3,3}(FT[1 2 10; 4 5 6; 7 8 9]),
        SMatrix{3,3}(FT[1 2 10; 4 5 6; 7 8 9]),
        SMatrix{2,2}(FT[1 2; 3 4]),
        SMatrix{3,3}(FT[1 2 10; 4 5 6; 7 8 9])
    ]

    expected_dzs = [1.0, 4.0, 9.0, 9.0, 1.0, 2.0, 9.0]

    for (components, coord, expected_dz) in
        zip(all_components, coords, expected_dzs)
        CoordType = typeof(coord)
        AIdx = Geometry.coordinate_axis(CoordType)
        at = Geometry.AxisTensor(
            (Geometry.LocalAxis{AIdx}(), Geometry.CovariantAxis{AIdx}()),
            components,
        )
        local_geometry = Geometry.LocalGeometry(coord, FT(1.0), FT(1.0), at)
        space = Spaces.PointSpace(context, local_geometry)
        dz_computed = Array(parent(Fields.Δz_field(space)))
        @test length(dz_computed) == 1
        @test dz_computed[1] == expected_dz
    end
end

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
1 participant