mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-13 10:10:33 +05:00
Handling gmsh global parameter for a gmsh ParallelMesh
This commit is contained in:
parent
a33b1ed60e
commit
b0b5c3242d
@ -60,19 +60,13 @@ smesh = smeshBuilder.New()
|
|||||||
print("Creating Parallel Mesh")
|
print("Creating Parallel Mesh")
|
||||||
par_mesh = smesh.ParallelMesh(rubik_cube, name="par_mesh", mesher3D="GMSH")
|
par_mesh = smesh.ParallelMesh(rubik_cube, name="par_mesh", mesher3D="GMSH")
|
||||||
|
|
||||||
print("Creating hypoehtesis for netgen")
|
print("Creating hypoehtesis for gmsh")
|
||||||
NETGEN_3D_Parameters_1 = smesh.CreateHypothesisByAverageLength( 'NETGEN_Parameters',
|
GMSH_3D_Parameters_1 = smesh.CreateHypothesis( 'GMSH_Parameters',
|
||||||
'NETGENEngine', 34.641, 0 )
|
'libGMSHEngine.so' )
|
||||||
|
GMSH_3D_Parameters_1.SetMaxSize(10)
|
||||||
|
GMSH_3D_Parameters_1.SetMinSize(0.141421)
|
||||||
print("Adding hypothesis")
|
print("Adding hypothesis")
|
||||||
par_mesh.AddGlobalHypothesis(NETGEN_3D_Parameters_1, mesher="GMSH" )
|
par_mesh.AddGlobalHypothesis(GMSH_3D_Parameters_1)
|
||||||
|
|
||||||
#Set here particular mesh parameters in 3D
|
|
||||||
for algo3d in par_mesh._algo3d:
|
|
||||||
param3d = algo3d.Parameters()
|
|
||||||
param3d.Set2DAlgo(0)
|
|
||||||
param3d.Set3DAlgo(0)
|
|
||||||
param3d.SetSmouthSteps(2)
|
|
||||||
param3d.SetSizeFactor(1.1)
|
|
||||||
|
|
||||||
print("Setting parallelism method")
|
print("Setting parallelism method")
|
||||||
par_mesh.SetParallelismMethod(smeshBuilder.MULTITHREAD)
|
par_mesh.SetParallelismMethod(smeshBuilder.MULTITHREAD)
|
||||||
|
@ -111,7 +111,6 @@ def get_runner(mesher):
|
|||||||
|
|
||||||
def run_local(args):
|
def run_local(args):
|
||||||
""" Simple Local run """
|
""" Simple Local run """
|
||||||
#TODO: Check on how to handle log for windows (through sp.check_output)
|
|
||||||
cmd = CMD_TEMPLATE.format(\
|
cmd = CMD_TEMPLATE.format(\
|
||||||
runner=get_runner(args.mesher),
|
runner=get_runner(args.mesher),
|
||||||
mesher=args.mesher,
|
mesher=args.mesher,
|
||||||
@ -122,8 +121,6 @@ def run_local(args):
|
|||||||
new_element_file=args.new_element_file,
|
new_element_file=args.new_element_file,
|
||||||
log_file=path.join(path.dirname(args.shape_file), "run.log"),
|
log_file=path.join(path.dirname(args.shape_file), "run.log"),
|
||||||
output_mesh_file=args.output_mesh_file)
|
output_mesh_file=args.output_mesh_file)
|
||||||
print("Executing:")
|
|
||||||
print(cmd)
|
|
||||||
sp.check_output(cmd, shell=True, cwd=path.dirname(args.shape_file))
|
sp.check_output(cmd, shell=True, cwd=path.dirname(args.shape_file))
|
||||||
|
|
||||||
def run_pylauncher(args):
|
def run_pylauncher(args):
|
||||||
|
@ -462,7 +462,7 @@ class smeshBuilder( SMESH._objref_SMESH_Gen, object ):
|
|||||||
obj,name = name,obj
|
obj,name = name,obj
|
||||||
return Mesh(self, self.geompyD, obj, name)
|
return Mesh(self, self.geompyD, obj, name)
|
||||||
|
|
||||||
def ParallelMesh(self, obj, name=0, split_geom=True, mesher2D="NETGEN", mesher3D="NETGEN"):
|
def ParallelMesh(self, obj, name=0, split_geom=True, mesher2D=None, mesher3D="NETGEN"):
|
||||||
"""
|
"""
|
||||||
Create a parallel mesh.
|
Create a parallel mesh.
|
||||||
|
|
||||||
@ -7550,6 +7550,32 @@ def _copy_gmsh_param(dim, local_param, global_param):
|
|||||||
if dim==3:
|
if dim==3:
|
||||||
local_param.SetMaxSize(global_param.GetMaxSize())
|
local_param.SetMaxSize(global_param.GetMaxSize())
|
||||||
local_param.SetMinSize(global_param.GetMinSize())
|
local_param.SetMinSize(global_param.GetMinSize())
|
||||||
|
local_param.Set3DAlgo(global_param.Get3DAlgo())
|
||||||
|
local_param.SetRecombineAll(global_param.GetRecombineAll())
|
||||||
|
local_param.SetSubdivAlgo(global_param.GetSubdivAlgo())
|
||||||
|
local_param.SetRemeshAlgo(global_param.GetRemeshAlgo())
|
||||||
|
local_param.SetRemeshPara(global_param.GetRemeshPara())
|
||||||
|
local_param.SetSmouthSteps(global_param.GetSmouthSteps())
|
||||||
|
local_param.SetSizeFactor(global_param.GetSizeFactor())
|
||||||
|
local_param.SetUseIncomplElem(global_param.GetUseIncomplElem())
|
||||||
|
local_param.SetMeshCurvatureSize(global_param.GetMeshCurvatureSize())
|
||||||
|
local_param.SetSecondOrder(global_param.GetSecondOrder())
|
||||||
|
local_param.SetIs2d(global_param.GetIs2d())
|
||||||
|
elif dim==2:
|
||||||
|
local_param.SetMaxSize(global_param.GetMaxSize())
|
||||||
|
local_param.SetMinSize(global_param.GetMinSize())
|
||||||
|
local_param.Set2DAlgo(global_param.Get2DAlgo())
|
||||||
|
local_param.SetRecomb2DAlgo(global_param.GetRecomb2DAlgo())
|
||||||
|
local_param.SetRecombineAll(global_param.GetRecombineAll())
|
||||||
|
local_param.SetSubdivAlgo(global_param.GetSubdivAlgo())
|
||||||
|
local_param.SetRemeshAlgo(global_param.GetRemeshAlgo())
|
||||||
|
local_param.SetRemeshPara(global_param.GetRemeshPara())
|
||||||
|
local_param.SetSmouthSteps(global_param.GetSmouthSteps())
|
||||||
|
local_param.SetSizeFactor(global_param.GetSizeFactor())
|
||||||
|
local_param.SetUseIncomplElem(global_param.GetUseIncomplElem())
|
||||||
|
local_param.SetMeshCurvatureSize(global_param.GetMeshCurvatureSize())
|
||||||
|
local_param.SetSecondOrder(global_param.GetSecondOrder())
|
||||||
|
local_param.SetIs2d(global_param.GetIs2d())
|
||||||
|
|
||||||
def _copy_netgen_param(dim, local_param, global_param):
|
def _copy_netgen_param(dim, local_param, global_param):
|
||||||
"""
|
"""
|
||||||
@ -7784,7 +7810,7 @@ class ParallelMesh(Mesh):
|
|||||||
"""
|
"""
|
||||||
Surcharge on Mesh for parallel computation of a mesh
|
Surcharge on Mesh for parallel computation of a mesh
|
||||||
"""
|
"""
|
||||||
def __init__(self, smeshpyD, geompyD, geom, split_geom=True, name=0, mesher2D="NETGEN", mesher3D="NETGEN"):
|
def __init__(self, smeshpyD, geompyD, geom, split_geom=True, name=0, mesher2D=None, mesher3D="NETGEN"):
|
||||||
"""
|
"""
|
||||||
Create a parallel mesh.
|
Create a parallel mesh.
|
||||||
|
|
||||||
@ -7818,13 +7844,17 @@ class ParallelMesh(Mesh):
|
|||||||
if split_geom:
|
if split_geom:
|
||||||
self._all_faces, self._solids = _split_geom(geompyD, geom_obj)
|
self._all_faces, self._solids = _split_geom(geompyD, geom_obj)
|
||||||
|
|
||||||
order = []
|
if mesher3D == "NETGEN":
|
||||||
|
|
||||||
if ( mesher2D == "NETGEN" ): #Default 2D mesher
|
|
||||||
self._algo2d = self.Triangle(geom=geom_obj, algo="NETGEN_2D")
|
self._algo2d = self.Triangle(geom=geom_obj, algo="NETGEN_2D")
|
||||||
|
elif mesher3D == "GMSH":
|
||||||
|
self._algo2d = self.Triangle(geom=geom_obj, algo="GMSH_2D")
|
||||||
|
else:
|
||||||
|
raise ValueError("mesher3D should be either NETGEN or GMSH")
|
||||||
|
|
||||||
if ( mesher2D != "NETGEN" ):
|
|
||||||
#Means that we want to mesh face of solids in parallel and not the volume
|
if mesher2D is not None:
|
||||||
|
#Means that we want to mesh face of solids in parallel and not
|
||||||
|
#the volume
|
||||||
self._algo2d = []
|
self._algo2d = []
|
||||||
#For the moment use AutomaticLength based on finesse
|
#For the moment use AutomaticLength based on finesse
|
||||||
self._algo1d = self.Segment().AutomaticLength(0.1)
|
self._algo1d = self.Segment().AutomaticLength(0.1)
|
||||||
@ -7846,7 +7876,6 @@ class ParallelMesh(Mesh):
|
|||||||
|
|
||||||
self._param = None
|
self._param = None
|
||||||
|
|
||||||
|
|
||||||
def GetNbSolids(self):
|
def GetNbSolids(self):
|
||||||
"""
|
"""
|
||||||
Return the number of 3D solids
|
Return the number of 3D solids
|
||||||
@ -7877,7 +7906,7 @@ class ParallelMesh(Mesh):
|
|||||||
raise Exception("You need to set Parallelism method first (SetParallelismMethod)")
|
raise Exception("You need to set Parallelism method first (SetParallelismMethod)")
|
||||||
return self._param
|
return self._param
|
||||||
|
|
||||||
def AddGlobalHypothesis(self, hyp, mesher="NETGEN"):
|
def AddGlobalHypothesis(self, hyp):
|
||||||
"""
|
"""
|
||||||
Split hypothesis to apply it to all the submeshes:
|
Split hypothesis to apply it to all the submeshes:
|
||||||
- the 1D+2D
|
- the 1D+2D
|
||||||
@ -7887,18 +7916,19 @@ class ParallelMesh(Mesh):
|
|||||||
hyp: a hypothesis to assign
|
hyp: a hypothesis to assign
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if not isinstance(hyp, NETGENPlugin._objref_NETGENPlugin_Hypothesis):
|
if isinstance(hyp, NETGENPlugin._objref_NETGENPlugin_Hypothesis):
|
||||||
raise ValueError("param must come from NETGENPlugin")
|
copy_param = _copy_netgen_param
|
||||||
|
elif isinstance(hyp, GMSHPlugin._objref_GMSHPlugin_Hypothesis):
|
||||||
|
copy_param = _copy_gmsh_param
|
||||||
|
else:
|
||||||
|
raise ValueError("param must come from NETGENPlugin or GMSHPlugin")
|
||||||
|
|
||||||
param2d = self._algo2d.Parameters()
|
param2d = self._algo2d.Parameters()
|
||||||
_copy_netgen_param(2, param2d, hyp)
|
copy_param(2, param2d, hyp)
|
||||||
|
|
||||||
for algo3d in self._algo3d:
|
for algo3d in self._algo3d:
|
||||||
param3d = algo3d.Parameters()
|
param3d = algo3d.Parameters()
|
||||||
if ( mesher == "NETGEN" ):
|
copy_param(3, param3d, hyp)
|
||||||
_copy_netgen_param(3, param3d, hyp)
|
|
||||||
elif( mesher == "GMSH" ):
|
|
||||||
_copy_gmsh_param(3, param3d, hyp)
|
|
||||||
|
|
||||||
|
|
||||||
pass # End of ParallelMesh
|
pass # End of ParallelMesh
|
||||||
|
Loading…
Reference in New Issue
Block a user