Skip to content

Commit

Permalink
Add __call__-interpolation for operands
Browse files Browse the repository at this point in the history
  • Loading branch information
kburns committed May 12, 2021
1 parent e1541b9 commit 2489221
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
19 changes: 19 additions & 0 deletions dedalus/core/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,25 @@ def __rpow__(self, other):
from .operators import Power
return Power(other, self)

def __call__(self, *args, **kw):
"""Create Interpolation operator with this operand."""
return self.interp(*args, **kw)

def diff(self, *args, **kw):
"""Create Differentiation operator with this operand."""
from .operators import differentiate
return differentiate(self, *args, **kw)

def integ(self, *args, **kw):
"""Create Integration operator with this operand."""
from .operators import integrate
return integrate(self, *args, **kw)

def interp(self, *args, **kw):
"""Create Interpolation operator with this operand."""
from .operators import interpolate
return interpolate(self, *args, **kw)

@staticmethod
def parse(string, namespace, domain):
"""Build operand from a string expression."""
Expand Down
4 changes: 2 additions & 2 deletions examples/bvp/2d_poisson/poisson.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
problem = de.LBVP(domain, variables=['u','uy'])
problem.add_equation("dx(dx(u)) + dy(uy) = -10 * sin(x/2)**2 * (y - y**2)")
problem.add_equation("uy - dy(u) = 0")
problem.add_bc("left(u) = left(sin(8*x))")
problem.add_bc("right(uy) = 0")
problem.add_bc("u(y='left') = sin(8*x)")
problem.add_bc("uy(y='right') = 0")

# Build solver
solver = problem.build_solver()
Expand Down
14 changes: 7 additions & 7 deletions examples/ivp/2d_rayleigh_benard/rayleigh_benard.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@
problem.add_equation("bz - dz(b) = 0")
problem.add_equation("uz - dz(u) = 0")
problem.add_equation("wz - dz(w) = 0")
problem.add_bc("left(b) = 0")
problem.add_bc("left(u) = 0")
problem.add_bc("left(w) = 0")
problem.add_bc("right(b) = 0")
problem.add_bc("right(u) = 0")
problem.add_bc("right(w) = 0", condition="(nx != 0)")
problem.add_bc("right(p) = 0", condition="(nx == 0)")
problem.add_bc("b(z='left') = 0")
problem.add_bc("u(z='left') = 0")
problem.add_bc("w(z='left') = 0")
problem.add_bc("b(z='right') = 0")
problem.add_bc("u(z='right') = 0")
problem.add_bc("w(z='right') = 0", condition="(nx != 0)")
problem.add_bc("integ(p) = 0", condition="(nx == 0)")

# Build solver
solver = problem.build_solver(de.timesteppers.RK222)
Expand Down

0 comments on commit 2489221

Please sign in to comment.