This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

How to apply a specific boundary condition on a point in a rectangular domain

0 votes

Hello,
I want to put a wave source on a point on the left edge of a rectangular domain. In the previous step I modeled a wave in a rectangular domain with Dirichlet boundary condition on the boundaries and a Gaussian impulse at the center of the domain at t=0 (initial condition). This is my code:


from dolfin import *
import numpy as np
c=1500
mesh = RectangleMesh(Point(-2,-1), Point(2,1),200,100)
V=FunctionSpace(mesh, "Lagrange", 1)

Time variables

dt = 0.000013; t = 0; T = 0.0004
init="exp(-10(x[0]x[0]+ x[1]*x[1]))"
g = Expression(init,t=0)

Previous and current solution

u1= interpolate(g, V)
u0= interpolate(g, V)

Variational problem at each time

u = TrialFunction(V)
v = TestFunction(V)
a = uvdx + dtdtccinner(grad(u), grad(v))dx
L = 2
u1vdx-u0vdx
bc = DirichletBC(V, 0,"on_boundary")
u=Function(V)
while t <= T:
g.t=t
solve(a == L, u, bc)
u0.assign(u1)
u1.assign(u)
t += dt
plot(u, interactive=True)


Now I want to put a wave source at the center of the left edge of the domain with an equation like U=Sin(10*t) in which "t" varies from 0 to "T". Could you please help me and tell me how I can define such a boundary condition? Thanks in advance for your help.

asked Dec 15, 2015 by jafar FEniCS Novice (670 points)

1 Answer

0 votes

Are you talking about a delta source term with intensity varying in time according to U, i.e., in physics notations,
f(x,t) = U(t) delta(x-x_s),
where x_s is the location of your source?
If that is what you want, you can look at the method dolfin.PointSource (disclaimer: needs some work-around in parallel).

answered Dec 18, 2015 by BC FEniCS Novice (790 points)

Thanks for your respond. I have asked a new question with details explaining exactly what my question is. Please take a look at here:
http://fenicsproject.org/qa/8883/wave-propagation-from-a-source-point

Hello Jafar,

May I ask why have you hidden the question you gave the link for?

http://fenicsproject.org/qa/8883/wave-propagation-from-a-source-point

I don't think it is fair to hide questions after you get answer to them, so that only you can keep the answer to yourself.

It is my humble request - please unhide the question so the solution can be known to all. It is important to also contribute to this forum, not only take from it.

...