tum-pbs / PhiFlow

A differentiable PDE solving framework for machine learning
MIT License
1.43k stars 193 forks source link

`.upsample2x` transposes 2d fields spatially #72

Closed danmackinlay closed 2 years ago

danmackinlay commented 2 years ago

If we generate a random field and upsample we see that the resulting fields are transposed (if you can't see it, look at the two darker blue dots)

Screen Shot 2022-07-22 at 15 23 53

MRE

from phi.flow import *
from phi import math, field

math.seed(59)

p = CenteredGrid(
    Noise(
        batch(batch=1),
        scale=0.1,
        smoothness=3),
    x=64,
    y=64,
    bounds=Box(
        x=1.0,
        y=1.0
    )
)

half_p = field.downsample2x(p)
double_p = field.upsample2x(p)
vis.plot([
        p,
        half_p,
        field.upsample2x(half_p),
        double_p,
        field.downsample2x(double_p)
    ],
    show_color_bar=False)
holl- commented 2 years ago

The upsample function changed the dimension order in a previous version. Upgrading to the latest version should fix it.

pip uninstall phiflow
pip install --upgrade --quiet git+https://github.com/tum-pbs/PhiFlow@2.2-develop
holl- commented 2 years ago

I added the fix to develop as well, so it will be part of 2.1.4, to be released soon.