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.

Meshing Fails for Scaled Sheet

More
4 years 3 weeks ago #2535 by valhan
Hi everybody!

I have tried to mesh a sheet.
First I mesh it in meters, than in decimeters, than in centimeters and finally in millimeters.
It is quite simple in my opinion, however it does not work properly.
Meter, dm, cm work fine but mm fails.

What do I do wrong?

Cheers, Valentin
Code:
from netgen.csg import * def foo(scale = 1): thickness = 0.18 origin = Pnt(0, 0, 0) corner = Pnt(9*scale, 4*scale, thickness*scale) left = Plane (origin, Vec(-1,0,0) ) right = Plane (corner, Vec( 1,0,0) ) front = Plane (origin, Vec(0,-1,0) ) back = Plane (corner, Vec(0, 1,0) ) bot = Plane (origin, Vec(0,0,-1) ) top = Plane (corner, Vec(0,0, 1) ) cube = left * right * front * back * bot * top geo = CSGeometry() geo.Add (cube) mesh = geo.GenerateMesh(maxh=1) mesh.Save("cube.vol") if __name__ == "__main__": from ngsolve import * ngsglobals.msg_level = 0 print("it works with scale 1:") foo(1) print("it works with scale 0.1:") foo(0.1) print("it works with scale 0.01:") foo(0.01) print("it does not work with scale 0.001:") foo(0.001) # from ngsolve import * # mesh = Mesh("cube.vol") # import netgen.gui # Draw(mesh) print("done") # input()
More
4 years 3 weeks ago #2537 by valhan
Thanks to the information in the (personal) replies, I was able to fix the issue.

One suggested work-around would be to use the non-scaled model and fit the other parameters.
The proper solution redefines the bounding box of the mesh generator by
Code:
geo.SetBoundingBox(Pnt(-10*scale, -10*scale, -10*scale), Pnt(10*scale, 10*scale, 10*scale))

Under consideration of this adaption the original code works fine:
Code:
from netgen.csg import * def foo(scale = 1): thickness = 0.18 origin = Pnt(0, 0, 0) corner = Pnt(9*scale, 4*scale, thickness*scale) left = Plane (origin, Vec(-1,0,0) ) right = Plane (corner, Vec( 1,0,0) ) front = Plane (origin, Vec(0,-1,0) ) back = Plane (corner, Vec(0, 1,0) ) bot = Plane (origin, Vec(0,0,-1) ) top = Plane (corner, Vec(0,0, 1) ) cube = left * right * front * back * bot * top geo = CSGeometry() geo.Add (cube) geo.SetBoundingBox(Pnt(-10*scale, -10*scale, -10*scale), Pnt(10*scale, 10*scale, 10*scale)) mesh = geo.GenerateMesh(maxh=1) mesh.Save("cube.vol") if __name__ == "__main__": from ngsolve import * ngsglobals.msg_level = 0 print("it works with scale 1:") foo(1) print("it works with scale 0.1:") foo(0.1) print("it works with scale 0.01:") foo(0.01) print("it does not work with scale 0.001:") foo(0.001) # from ngsolve import * # mesh = Mesh("cube.vol") # import netgen.gui # Draw(mesh) print("done") # input()
Time to create page: 0.121 seconds