Giter Site home page Giter Site logo

Comments (2)

dlilien avatar dlilien commented on September 25, 2024

To update, A = max_value(small_number, A) is not sufficient to fix this--it seems like it will put a floor on nodal values, but the function overall can take negative values at intermediate points (although maybe that is less of an issue depending on the function space of the velocity).

MWE follows--in this one, the problem is solved for vertical degree greater than 4, but that is not true in the general case.

import numpy as np
import icepack
from scipy.interpolate import RegularGridInterpolator
from matplotlib import pyplot as plt


res = 250
Lx = 1000
nx = Lx // res
mesh1d = firedrake.IntervalMesh(nx, Lx)
mesh = firedrake.ExtrudedMesh(mesh1d, layers=1)

x, ΞΆ = firedrake.SpatialCoordinate(mesh)

QT = firedrake.FunctionSpace(mesh, "CG", 2, vfamily="CG", vdegree=4)

meshT = QT.mesh()
element = QT.ufl_element()
MV = firedrake.VectorFunctionSpace(meshT, element)
coordsT = firedrake.interpolate(meshT.coordinates, MV).dat.data_ro[:]

T = firedrake.Function(QT)

z_T = np.linspace(0, 1, 101)
x_T = np.array([-1, Lx + 1])
T_z = 240.0 + (z_T - 0.66) ** 2.0 * 74.0

T_arr = np.repeat(T_z, 2).reshape((101, 2))
T.dat.data[:] = RegularGridInterpolator((x_T, z_T), T_arr.T)(coordsT)

cmT = firedrake.tripcolor(T, num_sample_points=100)
plt.colorbar(cmT, label='T')

A = firedrake.project(firedrake.max_value(icepack.rate_factor(T), 1.0e-8), QT)
cmA = firedrake.tripcolor(A, num_sample_points=100, vmin=-5, vmax=5, cmap='bwr')
plt.colorbar(cmA, label='A')

plt.show()

from icepack.

danshapero avatar danshapero commented on September 25, 2024

Thanks for catching this! I suspect the problem is happening because the temperature crosses the slope break at -10C. That could certainly cause the interpolated or projected fluidity field to do something wrong. We might be able to work around this by interpolating with Bernstein polynomials. I'll see what I can figure out and get back to you.

I've run into similar (but not as severe) problems before and it has me wondering if I should implement a 2- or multi-layer model. Clearly using a single layer and high-degree polynomials can cause problems like what you're seeing or other ringing artifacts.

from icepack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.