question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nonzero natural conditions in 1-D

See original GitHub issue

I can’t figure out how to impose nonzero natural conditions on a one-dimensional problem.

Essential conditions are easy, same as in higher dimensions.

Consider u’’ = 0 with u(0) = 0 and u’(1) = 1 so that the exact solution is u = x.

I can solve this as trivially two-dimensional problem (∇v, ∇u) = [v, n . ∇u]|(x=1) = [v, 1]|(x=1):

m = MeshQuad.init_tensor(*(np.linspace(0., 1.),)*2)
e = ElementQuad1()
ib = InteriorBasis(m, e)
fb = FacetBasis(m, e)


@linear_form
def boundary_flux(v, dv, w):
    return v * (w.x[0] == 1.)


n = m.p.shape[-1]
L = asm(laplace, ib)
b = asm(boundary_flux, fb)
u, D = ib.find_dofs(lambda x, y: x == 0.)
I = ib.dofnum.complement_dofs(D)  # noqa E741
u = np.zeros_like(b)
u[I] = solve(*condense(L, b, I=I)) # noqa E741

but trying the same thing with the minimal modifications to drop the dimension from two to one

m = MeshLine(np.linspace(0., 1.))
e = ElementLineP1()

fails at FacetBasis with

NotImplementedError: The given mesh type is not supported!

I think that this is merely the proximate cause, raised by get_quadrature, but on inspection MeshLine appears incomplete, lacking attributes facets, t2f, f2t.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
kinnalacommented, Aug 16, 2018

I sort of saw these challenges when I reimplemented the 1D support but forgot to do anything about it. Let us try to find a fix so that the implementation is as similar as in higher dimensions.

0reactions
kinnalacommented, Aug 24, 2018

Closing this after adding some 1D tests.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Heat Equation with Non-Zero Temperature Boundaries
In this section we take a quick look at solving the heat equation in which the boundary conditions are fixed, non-zero temperature.
Read more >
Heat equation with non-zero boundary condition
I have the following PDE with initial+boundary conditions: Ut=−Uxx. U(x,0)=0 for x>0 , U(0,t)=1 , U(1,t)=0.
Read more >
Nonzero Neumann boundary condition - YouTube
Course materials: https://learning-modules.mit.edu/class/index.html?uuid=/course/16/fa17/16.920.
Read more >
Weak form with nonzero Dirichlet boundary condition - YouTube
Course materials: https://learning-modules.mit.edu/class/index.html?uuid=/course/16/fa17/16.920.
Read more >
Traveling waves for some nonlocal 1D Gross-Pitaevskii ...
The nonzero boundary condition (1) arises as a background density. This model appears naturally in several areas of quantum physics, for ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found