Boundary conditions - box part 2

Asked by Bruno Martins

Following the question solved yesterday, I discovered that I can define the boundaries using the mask but I can't define a constant on this mask.

Here is the code:

width=0.1
depth=0.1
p0=Point(0.0,0.0)
p1=Point(0.0,depth)
p2=Point(width,depth)
p3=Point(width,0.0)
l0=Line(p0,p1)
l1=Line(p1,p2)
l2=Line(p2,p3)
l3=Line(p3,p0)
c1=CurveLoop(l0,l1,l2,l3)
rec1=PlaneSurface(c1)
p4=Point(0.0,-0.01)
p5=Point(0.01,-0.01)
p6=Point(0.01,0.0)
l4=Line(p0,p4)
l5=Line(p4,p5)
l6=Line(p5,p6)
l7=Line(p6,p0)
c2=CurveLoop(l4,l5,l6,l7)
rec2=PlaneSurface(c2)
model=Design(dim=2,element_size=0.002)
model.addItems(PropertySet("rec1", rec1))
model.addItems(PropertySet("rec2", rec2))

gammaD=2.0*MaskFromBoundaryTag(domain,"rec2")+whereZero(x[1]-depth)
mypde=LinearPDE(domain)
mypde.setValue(A=kronecker(domain),D=(1/Ld**2),q=gammaD,r=-1.0*MaskFromBoundaryTag(domain,"rec2")+0.0*whereZero(x[1]-depth))
v0=mypde.getSolution()

I define the value -1 at the boundary of rec2. The problem is that this value doesn't show up in the solution. My solution v0 is a constant potential equal to 0.0 (the other boundary condition) over the entire domain (including even the boundaries of rec2). Concluding, I defined the mask at the boundary of rec2 but I can't define the constant value at the mask. Is there a specific function (something like setMaskValue) to do this?

Thank you.

Question information

Language:
English Edit question
Status:
Solved
For:
esys-escript Edit question
Assignee:
No assignee Edit question
Solved by:
Bruno Martins
Solved:
Last query:
Last reply:
Revision history for this message
Lutz Gross (l-gross) said :
#1

I guess should have had a closer look to your problem before. I assume you want to create a big rectangle
with a little extension as a combined domain and then fix the the solution just on the (outer) boundary of the
 extension??

Revision history for this message
Bruno Martins (bvc-martins) said :
#2

Yes that is correct. I have a big and a small rectangle together as a combined domain. I want to fix the solution just in the small rectangle (can be only outside or in the entire rectangle) so it acts as a boundary condition for the big rectangle. If I use MaskFromBoundaryTag I cannot define this fixed value (it's zero everywhere including on the boundaries themselves) and if I use MaskFromTag I define a fixed value inside and in the boundary of the small rectangle but it is not recognized as a boundary condition by the bigger rectangle when I solve the PDE.

Of course I can solve the problem using the * operator to combine conditions and select only the small rectangle by its boundaries but I would like to understand better how the mask works.

Revision history for this message
Lutz Gross (l-gross) said :
#3

Firstly, you need to create the two rectangle as a connected domain, i.e. the line where both subdomain touch
touch each other may be defined once only. So you need to shorten the l3 line segment to use p6 rather than
p0 as an endpoint and then you need to add l7 into the definition of rec1. Alternatively you can define the
domain as a single PlaneSurface.

Here comes solution 0:

width=0.1
depth=0.1
p0=Point(0.0,0.0)
p1=Point(0.0,depth)
p2=Point(width,depth)
p3=Point(width,0.0)
p4=Point(0.0,-0.01)
p5=Point(0.01,-0.01)
p6=Point(0.01,0.0)

l0=Line(p0,p1)
l1=Line(p1,p2)
l2=Line(p2,p3)
l3=Line(p3,p6)
l4=Line(p0,p4)
l5=Line(p4,p5)
l6=Line(p5,p6)
l7=Line(p6,p0)

c1=CurveLoop(l7,l0,l1,l2,l3)
rec1=PlaneSurface(c1)
c2=CurveLoop(l4,l5,l6,l7)
rec2=PlaneSurface(c2)

model=Design(dim=2,element_size=0.002)
model.addItems(rec1,rec2)
model.addItems(PropertySet("rec2", l4,l5,l6))

Notice that property set "rec2" uses *lines* (=boundary segments) l4, l5 and l6 only. This is important when you use MaskFromBoundaryTag.

PS: I should have spent a bit more time to understand your problem in more details.

Revision history for this message
Bruno Martins (bvc-martins) said :
#4

Nice, this worked very well. I understood well what was my previous mistake in the assignment of the loops. I think this is sufficient for what I need now.

Thank you very much.