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.

Set Meshing Options with Python?

More
3 years 4 months ago #3326 by christopher
first step = perfstepsstart
last step = perfstepsend
in python
and you can set the message level with
ngsolve.ngsglobals.msg_level = 0

Best
Christopher
More
3 years 4 months ago #3327 by mariopa
thx very much!

i will try as soon as possible...
More
3 years 3 months ago #3423 by mariopa
Hello,

I just tried the following python script:

from netgen.occ import *
geo = OCCGeometry("//STI01/STIWA/mail/ParM/ng/projects/parm/abc/Schuettblech.stp")
mesh = geo.GenerateMesh(meshsize.very_coarse, perfstepsstart=MESHCONST_ANALYSE, perfstepsend=MESHCONST_OPTSURFACE, curvaturesafety=5)
Draw(Mesh(mesh))
mesh.Export("//.................stl", 'STL Format')

does not work :-( --> 'MESHCONST_ANALYSE' is not defined

what I did wrong?

(should) load python file '\\STI01\STIWA\mail\ParM\ng\projects\parm\abc\tmp.py'
Traceback (most recent call last):
File "<string>", line 2, in <module>
FileNotFoundError: [WinError 3] Das System kann den angegebenen Pfad nicht finden: 'C:\\STI01\\STIWA\\mail\\ParM\ng\\projects'
Number of colours in STEP File: 1
Colour [1] = LIGHTBLUE3 : (0.654902,0.760784,0.788235)
Highest entry in topology hierarchy:
1 solid(s)
Traceback (most recent call last):
File "<string>", line 3, in <module>
NameError: name 'MESHCONST_ANALYSE' is not defined
Finished executing \\....................py
Preparing visualization (deflection = 0.01) ... done
More
3 years 3 months ago #3424 by cwinters
Hi,

having a look at the code, I found a python enum "MeshingStep":
Code:
py::enum_<MESHING_STEP>(m,"MeshingStep") .value("ANALYSE", MESHCONST_ANALYSE) .value("MESHEDGES", MESHCONST_MESHEDGES) .value("MESHSURFACE", MESHCONST_OPTSURFACE) .value("MESHVOLUME", MESHCONST_OPTVOLUME) ;

So just use
Code:
from netgen.meshing import MeshingStep mesh = geo.GenerateMesh(meshsize.very_coarse, perfstepsstart=MeshingStep.ANALYSE, perfstepsend=MeshingStep.MESHSURFACE, curvaturesafety=5)
to generate the mesh.

Best,
Christoph
More
3 years 3 months ago #3425 by mariopa
thanks very much!

and is there a enum for MESHCONST_OPTSURFACE and MESHCONST_OPTVOLUME too?

regards, mario
More
3 years 3 months ago #3426 by cwinters
The enum "MeshingStep" contains all these options (ANALYSE, MESHEDGES, MESHSURFACE, MESHVOLUME). I copied the export to python in my last post.
Time to create page: 0.133 seconds