Parallel mesh computation with NETGEN_3D_PARAMETERS

Hello everyone,
I am trying to implement parallel meshing in salome using the example script.But I can’t find documentation regarding the function which is th only function as mentioned in script file:
For example I have a solid ‘Box_1’ on which I want to implement usual parameters oF netgen. I do the following;
smesh = smeshBuilder.New()
par_mesh = smesh.ParallelMesh(Box_1, name=“par_mesh”)

netgen parameters in script:
NETGEN_3D_Parameters_1 = smesh.CreateHypothesisByAverageLength( ‘NETGEN_Parameters’,‘NETGENEngine’, 34, 0 )
print(“Adding hypothesis”)
par_mesh.AddGlobalHypothesis(NETGEN_3D_Parameters_1)

I don’t understand all the arguements of this command.Neither is documentation available online on this command.

I want to implement usual NETGEN parameters on my mesh like the example below but it does not work.

NETGEN_1D_2D_3D = par_mesh.Tetrahedron(algo=smeshBuilder.NETGEN_1D2D3D)
NETGEN_3D_Parameters_1 = NETGEN_1D_2D_3D.Parameters()
NETGEN_3D_Parameters_1.SetMaxSize( 0.02 )
NETGEN_3D_Parameters_1.SetMinSize( 0.001 )
NETGEN_3D_Parameters_1.SetSecondOrder( 0 )
NETGEN_3D_Parameters_1.SetOptimize( 1 )
NETGEN_3D_Parameters_1.SetFineness( 2 )
NETGEN_3D_Parameters_1.SetChordalError( -1 )
NETGEN_3D_Parameters_1.SetChordalErrorEnabled( 0 )
NETGEN_3D_Parameters_1.SetUseSurfaceCurvature( 1 )
NETGEN_3D_Parameters_1.SetFuseEdges( 1 )
NETGEN_3D_Parameters_1.SetQuadAllowed( 0 )
NETGEN_3D_Parameters_1.SetCheckChartBoundary( 32 )

Please help.

regards
Anirudh Nehra

Hello anirudh,

The parallel mesh feature implemented in smesh is based on domain decomposition, so in order for you to see any performance, first you will required to pass a compound geometry that will be decomposed by the mesh algorithm into individual solids to mesh each solid in parallel, therefore, its pointless to pass a single box, see lines 28 to 50 of the example to understand how to create a compound box of individual boxes.

The method CreateHypothesisByAverageLength is a helper method to define a hypothesis, you can use the returned object from this method to setup the parameters you required, this is:

NETGEN_3D_Parameters_1 = smesh.CreateHypothesisByAverageLength( ‘NETGEN_Parameters’,‘NETGENEngine’, 34, 0 )
NETGEN_3D_Parameters_1.SetMaxSize( 0.02 )
NETGEN_3D_Parameters_1.SetMinSize( 0.001 )
NETGEN_3D_Parameters_1.SetSecondOrder( 0 )
NETGEN_3D_Parameters_1.SetOptimize( 1 )
NETGEN_3D_Parameters_1.SetFineness( 2 )
NETGEN_3D_Parameters_1.SetChordalError( -1 )
NETGEN_3D_Parameters_1.SetChordalErrorEnabled( 0 )
NETGEN_3D_Parameters_1.SetUseSurfaceCurvature( 1 )
NETGEN_3D_Parameters_1.SetFuseEdges( 1 )
NETGEN_3D_Parameters_1.SetQuadAllowed( 0 )
NETGEN_3D_Parameters_1.SetCheckChartBoundary( 32 )

par_mesh.AddGlobalHypothesis(NETGEN_3D_Parameters_1)

Note that all the individual solids that you passed to the mesh libraries will be meshed with the same parameters. Please note that you will require to define the parallelism setting too:

par_mesh.SetParallelismMethod(smeshBuilder.MULTITHREAD)
param = par_mesh.GetParallelismSettings()
param.SetNbThreads(6) #in this case run with 6 threads

Regards,
Cesar

Hi,
Very much thanks for the reply.
I have a few queries.
You said that the parallel mesh needs a compound of solids to be effective.
Could I use a partition of solids instead which is exploded into solids? And assign different parameters of the exploded solids?
The reason I want to use a partition is because I want a coherent mesh at contact boundary of exploded solids.
Also if the parallel mesh when computed again with a tweak of parameters creates a new mesh or modifies the old one?
Can we use the usual compute button in GUI to recompute a parallel mesh?
Does multithreading refer to threads or physical cores(the ones used by Code Aster MPI for example)

Thanks and regards
Anirudh Nehra

Hello,

Yes, I think you can pass the result from a partition operation, always that it would be possible to decompose it into individuals solids, the mesh will be compute in parallel on those solids.

Unfortunately you will not have fine grained control over the parameter set for each mesh in each solid, the hypothesis is applied globally to all solids.

The parallel mesh will take care of mesh coherence in common faces and edges.
If the parallel mesh is computed again after change of hypothesis parameters everything will be recomputed, there is not fine grained control over which part of the mesh/solid you want to recompute.

This feature is only available in TUI not in GUI yet. The multithread version uses std version of threads and the multinode option uses QProcess. So no MPI implementation (not sure if QProcess uses MPI behind, probably yes), nevertheless, in my understanding, you should be able to run in multiple nodes, but this is something that I have not try yet.

Regards,
Cesar

Hi Cesar,

…(parallel meshing) This feature is only available in TUI not in GUI yet.

When you say “not in GUI”, do you mean the GUI release; so even with the Python console ? If I wanted parallel smesh, I would have to recompile the GUI version with parallel enabled and would only be available via the Python console, yes ?

Many thanks,
Bob.

It means that there is no interface for the parallel meshing. You can do it in the python console

Hi Franco,

Thanks. There must be something wrong with my script or machine setup.
I adapted the meshing parallel example for my setup and the decomposition block setup and partitioning works just fine, but when I execute Compute() I only see one core in my machine being used; even though I have set nBThreads.

print(“Find imported STEP ‘brep_1’”)
brep_1 = salome.myStudy.FindObject(“brep_1”)
br1 = brep_1.GetObject()

Partition_1 = geompy.MakePartition([br1], [rubik_cube], , , geompy.ShapeType[“SOLID”], 0, , 0)
geompy.addToStudy(Partition_1, ‘Partition_1’)

smesh = smeshBuilder.New()
par_mesh = smesh.ParallelMesh(Partition_1, name=“par_mesh”)

NETGEN_3D_Parameters_1 = smesh.CreateHypothesisByAverageLength( ‘NETGEN_Parameters’, ‘NETGENEngine’, 0.001, 0 )
print(“Adding hypothesis”)
par_mesh.AddGlobalHypothesis(NETGEN_3D_Parameters_1)

par_mesh.SetParallelismMethod(smeshBuilder.MULTITHREAD)

param = par_mesh.GetParallelismSettings()
param.SetNbThreads(10)
salome.sg.updateObjBrowser()

Br, Bob.

Have you tested re running the original script to see if it’s your script or that it does not work? Also from memory it only works in Linux and not in windows.

Hi Franco,

Ahhh, I’m on Windows10 here at work. I’ll try my code out at home over the weekend on my Linux box and report back.

Thanks,
Bob.

If I remember correctly, it is mentioned in the guide script