Forum Message

 

 

We have moved the forum to https://forum.ngsolve.org . This is an archived version of the topics until 05/05/23. All the topics were moved to the new forum and conversations can be continued there. This forum is just kept as legacy to not invalidate old links. If you want to continue a conversation just look for the topic in the new forum.

Notice

The forum is in read only mode.

Two domain mesh

More
6 years 5 months ago - 6 years 5 months ago #241 by Karatza
Two domain mesh was created by Karatza
Hi, after following the tutorial instructions and executing
Code:
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
File "<string>", line 13
Draw(mesh1)
^
IndentationError: unexpected indent


similar error if I try another example using mesh.Points():
Code:
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
File "<string>", line 22
for el in mesh.Elemends2D():
^
IndentationError: unexpected indent


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
Last edit: 6 years 5 months ago by Karatza. Reason: better performance
More
6 years 5 months ago #246 by cwinters
Hi Makis,

regarding your first question (I'm not working on ngsxfem):
You have to be aware of the type of your python object!
Code:
... 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:
Code:
type(mesh)
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
Code:
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
Code:
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.
Code:
type(mesh.ngmesh)
returns
Code:
<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.
Code:
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
Attachments:
The following user(s) said Thank You: Karatza
More
6 years 5 months ago - 6 years 5 months ago #248 by Karatza
Replied by Karatza on topic 2 mesh's substraction
Dear Christoph,
thank you for the detailed instructions!
with Kindest Regards
Makis
Last edit: 6 years 5 months ago by Karatza.
Time to create page: 0.126 seconds