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

Update interpolate #78

Merged
merged 5 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions demos/cahnhilliard/demo_cahnhilliard.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ For simplicity, we'll use a direct solver at each time step.
Boilerplate imports::

from firedrake import *
from firedrake.pyplot import tripcolor
import numpy as np
import os
from irksome import Dt, GaussLegendre, MeshConstant, TimeStepper
Expand Down
3 changes: 2 additions & 1 deletion demos/demo_nitsche_heat.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
# MMS works on symbolic differentiation of true solution, not weak form
rhs = expand_derivatives(diff(uexact, t)) - div(grad(uexact))

u = interpolate(uexact, V)
u = Function(V)
u.interpolate(uexact)

# define the variational form once outside the loop
h = CellSize(msh)
Expand Down
3 changes: 2 additions & 1 deletion demos/heat/demo_heat.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ This defines the right-hand side using the method of manufactured solutions::
We define the initial condition for the fully discrete problem, which
will get overwritten at each time step::

u = interpolate(uexact, V)
u = Function(V)
u.interpolate(uexact)

Now, we will define the semidiscrete variational problem using
standard UFL notation, augmented by the ``Dt`` operator from Irksome::
Expand Down
3 changes: 2 additions & 1 deletion demos/heat/demo_heat_dirk.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ This defines the right-hand side using the method of manufactured solutions::
We define the initial condition for the fully discrete problem, which
will get overwritten at each time step::

u = interpolate(uexact, V)
u = Function(V)
u.interpolate(uexact)

Now, we will define the semidiscrete variational problem using
standard UFL notation, augmented by the ``Dt`` operator from Irksome::
Expand Down
3 changes: 2 additions & 1 deletion demos/lowlevel/demo_lowlevel_homogbc.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ Continuing::

rhs = expand_derivatives(diff(uexact, t)) - div(grad(uexact))

u = interpolate(uexact, V)
u = Function(V)
u.interpolate(uexact)

v = TestFunction(V)
F = inner(Dt(u), v)*dx + inner(grad(u), grad(v))*dx - inner(rhs, v)*dx
Expand Down
3 changes: 2 additions & 1 deletion demos/lowlevel/demo_lowlevel_inhomogbc.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Imports::
uexact = exp(-t) * cos(pi * x) * sin(pi * y)
rhs = expand_derivatives(diff(uexact, t)) - div(grad(uexact))

u = interpolate(uexact, V)
u = Function(V)
u.interpolate(uexact)

v = TestFunction(V)
F = inner(Dt(u), v)*dx + inner(grad(u), grad(v))*dx - inner(rhs, v)*dx
Expand Down
129 changes: 0 additions & 129 deletions demos/navier_stokes/navier_stokes_demo.py
rckirby marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.

130 changes: 0 additions & 130 deletions demos/navier_stokes/nse_steady_demo.py

This file was deleted.

3 changes: 2 additions & 1 deletion demos/preconditioning/demo_heat_mg.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ are just as for the regular heat equation demo::
uexact = B * atan(t)*(pi / 2.0 - atan(S * (R - t)))
rhs = expand_derivatives(diff(uexact, t)) - div(grad(uexact))

u = interpolate(uexact, V)
u = Function(V)
u.interpolate(uexact)
v = TestFunction(V)
F = inner(Dt(u), v)*dx + inner(grad(u), grad(v))*dx - inner(rhs, v)*dx
bc = DirichletBC(V, 0, "on_boundary")
Expand Down
4 changes: 2 additions & 2 deletions demos/preconditioning/demo_heat_pc.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ Common set-up for the problem::

uexact = B * atan(t)*(pi / 2.0 - atan(S * (R - t)))
rhs = expand_derivatives(diff(uexact, t)) - div(grad(uexact))
u = interpolate(uexact, V)

u = Function(V)
u.interpolate(uexact)
v = TestFunction(V)
F = inner(Dt(u), v)*dx + inner(grad(u), grad(v))*dx - inner(rhs, v)*dx

Expand Down
3 changes: 2 additions & 1 deletion demos/preconditioning/demo_heat_rana.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ Common set-up for the problem::

uexact = B * atan(t)*(pi / 2.0 - atan(S * (R - t)))
rhs = expand_derivatives(diff(uexact, t)) - div(grad(uexact))
u = interpolate(uexact, V)
u = Function(V)
u.interpolate(uexact)

v = TestFunction(V)
F = inner(Dt(u), v)*dx + inner(grad(u), grad(v))*dx - inner(rhs, v) * dx
Expand Down
7 changes: 4 additions & 3 deletions irksome/dirk_stepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from firedrake import Constant, DirichletBC, Function
from firedrake import NonlinearVariationalProblem as NLVP
from firedrake import NonlinearVariationalSolver as NLVS
from firedrake import interpolate, split
from firedrake import assemble, split, project
from firedrake.__future__ import interpolate
from ufl.constantvalue import as_ufl

from .deriv import TimeDerivative
Expand Down Expand Up @@ -110,10 +111,10 @@ def getFormDIRK(F, butch, t, dt, u0, bcs=None):
bcarg = as_ufl(bc._original_arg)
bcarg_stage = replace(bcarg, {t: t+c*dt})
try:
gdat = interpolate(bcarg, Vbc)
gdat = assemble(interpolate(bcarg, Vbc))
gmethod = lambda gd, gc: gd.interpolate(gc)
except: # noqa: E722
gdat = interpolate(bcarg, Vbc)
gdat = assemble(project(bcarg, Vbc))
gmethod = lambda gd, gc: gd.project(gc)

new_bc = DirichletBC(Vbc, gdat, bc.sub_domain)
Expand Down
Loading
Loading