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.

Can not change Mesh size.

More
4 years 9 months ago #1733 by OCCUser
Hello,
I load my geometry using LoadOCCGeometry and when I am trying to mesh it I have the same number of elements for different values of maxh parameter.
Code:
from netgen.NgOCC import * geo = LoadOCCGeometry("brick.step") mp = MeshingParameters(maxh=1, grading=0.3) ngmesh = geo.GenerateMesh(mp=mp)
Output: 17 elements were created
Code:
from netgen.NgOCC import * geo = LoadOCCGeometry("brick.step") mp = MeshingParameters(maxh=0.1, grading=0.3) ngmesh = geo.GenerateMesh(mp=mp)
Output: 17 elements were created
Code:
ngmesh = geo.GenerateMesh(maxh=0.1, segmentsperedge=20)
Tried with segments meshing - > 17 elements were created.

Do you have experience with this? Is it a bug of python interface?
Thanks
More
4 years 8 months ago #1744 by christopher
Hi,
you are right, the meshing parameters from Python were ignored for the occ geometry. This is fixed in the upcoming nightly release. We have included some further changes/improvements/syntactic sugar:

The occ module should now be included using netgen.occ, geometries constructed by the constructor taking the filename as argument.
Code:
from netgen.occ import * geo = OCCGeometry("brick.step")
This constructor now understands .brep, .iges, .step and .stp files.
One can now use meshing parameters as given in the gui, by the helper variable meshsize:
Code:
geo.GenerateMesh(meshsize.very_fine)
you can give additional meshsize parameters as kwargs as well:
Code:
geo.GenerateMesh(meshsize.coarse, maxh=0.2)
There is a docstring about available meshing and optimization parameters if you query GenerateMesh for its help:
Code:
help(geo.GenerateMesh)

Hope that helps and let us know if you run into problems.

Best
Christopher
The following user(s) said Thank You: OCCUser
More
4 years 8 months ago #1761 by OCCUser
Replied by OCCUser on topic Can not change Mesh size.
Thanks a lot, now it works good :)
Could you, please, tell me if netgen has MPI support. Can I create mesh in parallel?
More
4 years 8 months ago #1762 by joachim
Replied by joachim on topic Can not change Mesh size.
Hi,
no, you cannot generate a mesh mpi-parallel. But you can distribute a mesh for parallel computations, and also refine a mesh in parallel.

Here is a simple example for that::
Code:
from ngsolve import * from netgen.csg import unit_cube import netgen.meshing if mpi_world.rank == 0: ngmesh = unit_cube.GenerateMesh(maxh=0.2).Distribute(mpi_world) else: ngmesh = netgen.meshing.Mesh.Receive(mpi_world) for l in range(2): ngmesh.Refine() mesh = Mesh(ngmesh) fes = H1(mesh, order=3) print ("ndof-local =", fes.ndof, "ndof-global =", fes.ndofglobal)

Joachim
More
4 years 8 months ago - 4 years 8 months ago #1784 by OCCUser
Replied by OCCUser on topic Can not change Mesh size.
Hello joachim,
Could you please tell me if RestrictH() method works with occ geometries?
I try to run the code like this(Cube properties 10x10x10, starting point (0,0,0) ):
Code:
from netgen.occ import * from netgen.meshing import MeshingParameters mp = MeshingParameters() n = 100 for i in range(n+1): loc_h = 10/n mp.RestrictH(x=0,y=i*loc_h,z=0,h=loc_h) geo = OCCGeometry("cube.step") mesh = geo.GenerateMesh(mp=mp) mesh.Export("output.msh", "Gmsh2 Format")

But it does not mesh my edge. When I use CS Geometry it works good.
Could you please help me?
Thanks
Last edit: 4 years 8 months ago by OCCUser.
More
4 years 7 months ago - 4 years 7 months ago #1818 by christopher
Fixed in github.com/NGSolve/netgen/commit/13c17ad...768f001776390b343fa8
Will be in coming nightly release
Thanks for reporting

Best
Christopher
Last edit: 4 years 7 months ago by christopher.
Time to create page: 0.184 seconds