Boundary conditions - box

Asked by Bruno Martins

I am generating a domain using the following piece of 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(rec1)
model.addItems(rec2)
model.setMeshFileName("domain.msh")
domain=MakeDomain(model)

The domain consists of two parts: a big square (rec1) and a small square (rec2) that touches its bottom. I want to apply a fixed value for all nodes of the small square (boundaries and inside) so it will be a boundary condition for the big square. How can I do this?

Can I do something like this: gammaD=whereNegative(x[0]-0.01)+whereNegative(x[1])? Is there a way to define the boundary conditions using the PlaneSurface label: gammaD=rec2 ?

Thank you,

Bruno.

Question information

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

There is a little helper for this, see
http://esys.esscc.uq.edu.au/esys13/3.2.1/epydoc/esys.escript.pdetools-module.html#MaskFromBoundaryTag

In your case this could be used in the form:

from esys.escript.pdetools import MaskFromBoundaryTag
gammaD=MaskFromBoundaryTag(domain, "rec2")

Note: In general, tagging of nodes in gmsh/pycad is a bit of a tricky business as in essence
the geometry definition is face based. Therefore it is easy to define tags for faces but as nodes can be on
several faces it is not obvious how this translates to nodes. Actually escript supports node tagging.

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

I understand the problem and the solution is pretty clear. Nevertheless I am still getting an error message:

gammaD=MaskFromBoundaryTag(domain,"rec2")
  File "escript/py_src/pdetools.py", line 1895, in MaskFromBoundaryTag
RuntimeError: DataException: Error - unknown tag in setTaggedValueByName.

Here is the test code:

gammaD=MaskFromBoundaryTag(domain,"rec2")
mypde=LinearPDE(domain)
mypde.setValue(A=kronecker(domain),D=(1/Ld**2),q=gammaD,r=2*MaskFromBoundaryTag(domain,"rec2"))
v0=mypde.getSolution()

It seems that I must set the name of the using function setTaggedValueByName. Am I right? Is this function included in the pdetools package? I didn't find.

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

Sorry, you need to through in the PropertySet object to assign a tag:

model=Design(dim=2,element_size=0.002)
model.addItems(PropertySet("rec1", rec1) )
model.addItems(PropertySet("rec2", rec2))
model.setMeshFileName("domain.msh")

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

Thanks Lutz Gross, that solved my question.