Two domain mesh

Hi, after following the tutorial instructions and executing

mesh1=mesh.Materials("outer|inner")-mesh.Materials("inner")

I had no error, but when I am trying to Draw it with Draw(mesh1), I see the error
[color=purple]File “”, line 13
Draw(mesh1)
^
IndentationError: unexpected indent[/color]

similar error if I try another example using mesh.Points():

for p in mesh.Points(): x,y,z =p.p print ("x= ", x, "y= ", y) for el in mesh.Elemends2D(): print (el.vertices)
I see
[color=purple]File “”, line 22
for el in mesh.Elemends2D():
^
IndentationError: unexpected indent[/color]

I checked if the appropriate libraries are imported and I can not find the mistake. Could help me please? Do I miss something?

best wishes
Makis

Attachment: 1-Subdomains.py

Attachment: 2-NEG_mesh_bc.py

Hi Makis,

regarding your first question (I’m not working on ngsxfem):
You have to be aware of the type of your python object!

...
mesh = Mesh(geo.GenerateMesh(maxh=0.5))

Let’s say we have the mesh with two domains (as in the tutorial you linked, full code is attached). If you want to work with material/domains of you mesh, you have the use the NGSolve mesh. You can check the type with:

type(mesh)[/code] and the output is[code]<class 'ngsolve.comp.Mesh'>

Also use the python help function to find out which functions and members are available for your python object. This can be done by

help(mesh)

If you want to use one of your subdomains, you can use the “Material(…)” function. But this function does not return a mesh! It returns a “Region”, which can be used the define a finite element space on a subdomain. Again

type(mesh.Materials('inner'))

tells you the type of the object and python help shows details about this object.

For the second part of your first question you have to use the Netgen mesh. This is available as member of the NGSolve mesh.

type(mesh.ngmesh)

returns

<class 'netgen.libngpy._meshing.Mesh'>

If you now check the help of “mesh.ngmesh” you see the functions to get the points and elements you wanted to use.

for p in mesh.ngmesh.Points():
    x,y,z =p.p
    print ("x= ", x, "y= ", y)
for el in mesh.ngmesh.Elements2D():
    print (el.vertices)

Best regards,
Christoph

Attachment: twodommesh.py

Dear Christoph,
thank you for the detailed instructions!
with Kindest Regards
Makis