X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=doc%2Fsalome%2Fgui%2FSMESH%2Fconstructing_meshes.htm;h=a643f436f5807f11ea580dee480bc93a5d4e10fd;hp=02059fa6b79a18616b79c61247c54b2cb26e5f5d;hb=9d11375af40826e967ab2c3bcb77d1f9d439c90c;hpb=4b8b3b4a281e64c16ceaa81647631c6e3bf1c730;ds=sidebyside diff --git a/doc/salome/gui/SMESH/constructing_meshes.htm b/doc/salome/gui/SMESH/constructing_meshes.htm index 02059fa6b..a643f436f 100755 --- a/doc/salome/gui/SMESH/constructing_meshes.htm +++ b/doc/salome/gui/SMESH/constructing_meshes.htm @@ -1,448 +1,448 @@ - - - - - -Constructing Meshes - - - - - - - - - - - -

Creating Meshes

- -

First of all see Example - of 3d mesh generation, which is an example of good python script style - for Mesh module.

- -

Other examples of python - scripts will be also updated soon to use smesh package instead of direct - usage of idl interface.

- -

Construction of a Mesh

- -

import - geompy

- -

import smesh

- -

 

- -

# create a box

- -

box = geompy.MakeBox(0., - 0., 0., 100., 200., 300.)

- -

idbox = geompy.addToStudy(box, - "box")

- -

 

- -

# create a mesh

- -

tetra = smesh.Mesh(box, - "MeshBox")

- -

 

- -

algo1D = tetra.Segment()

- -

algo1D.NumberOfSegments(7)

- -

 

- -

algo2D = tetra.Triangle()

- -

algo2D.MaxElementArea(800.)

- -

 

- -

algo3D = tetra.Tetrahedron(smesh.NETGEN)

- -

algo3D.MaxElementVolume(900.)

- -

 

- -

# compute the mesh

- -

ret = tetra.Compute()

- -

if ret == 0:

- -

    print - "problem when computing the mesh"

- -

else:

- -

    print - "mesh computed"

- -

    pass -

- -

 

- -

 

- -

Construction of a Submesh

- -

from - geompy import *

- -

import smesh

- -

 

- -

# create a box

- -

box = MakeBoxDXDYDZ(10., 10., 10.)

- -

addToStudy(box, "Box")

- -

 

- -

# select one edge of - the box for definition of a local hypothesis

- -

p5 = MakeVertex(5., 0., 0.)

- -

EdgeX = GetEdgeNearPoint(box, p5)

- -

addToStudyInFather(box, EdgeX, "Edge - [0,0,0 - 10,0,0]")

- -

 

- -

# create a hexahedral - mesh on the box

- -

quadra = smesh.Mesh(box, "Box : quadrangle - 2D mesh")

- -

 

- -

# create a regular - 1D algorithm for the faces

- -

algo1D = quadra.Segment()

- -

 

- -

# define "NumberOfSegments" - hypothesis to cut

- -

# all the edges in - a fixed number of segments

- -

algo1D.NumberOfSegments(4)

- -

 

- -

# create a quadrangle - 2D algorithm for the faces

- -

quadra.Quadrangle()

- -

 

- -

# construct a submesh - on the edge with a local hypothesis

- -

algo_local = quadra.Segment(EdgeX)

- -

 

- -

# define "Arithmetic1D" - hypothesis to cut the edge - in several segments with increasing arithmetic length

- -

algo_local.Arithmetic1D(1, 4)

- -

 

- -

# define "Propagation" - hypothesis that propagates all other hypotheses

- -

# on all edges of the - opposite side in case of quadrangular faces

- -

algo_local.Propagation()

- -

 

- -

# compute the mesh

- -

quadra.Compute()

- -

 

- -

Editing of a mesh

- -

import - geompy

- -

import smesh

- -

 

- -

def PrintMeshInfo(theMesh):

- -

    aMesh - = theMesh.GetMesh()

- -

    print - "Information about mesh:"

- -

    print - "Number of nodes       : - ", aMesh.NbNodes()

- -

    print - "Number of edges       : - ", aMesh.NbEdges()

- -

    print - "Number of faces       : - ", aMesh.NbFaces()

- -

    print - "Number of volumes     : - ", aMesh.NbVolumes()

- -

    pass

- -

 

- -

# create a box

- -

box = geompy.MakeBox(0., 0., 0., 20., - 20., 20.)

- -

geompy.addToStudy(box, "box")

- -

 

- -

# select one edge of - the box for definition of a local hypothesis

- -

subShapeList = geompy.SubShapeAll(box, - geompy.ShapeType["EDGE"])

- -

edge = subShapeList[0]

- -

name = geompy.SubShapeName(edge, box)

- -

geompy.addToStudyInFather(box, edge, name)

- -

 

- -

# create a mesh

- -

tria = smesh.Mesh(box, "Mesh 2D")

- -

algo1D = tria.Segment()

- -

hyp1 = algo1D.NumberOfSegments(3)

- -

algo2D = tria.Triangle()

- -

hyp2 = algo2D.MaxElementArea(10.)

- -

 

- -

# create a sub-mesh

- -

algo_local = tria.Segment(edge)

- -

hyp3 = algo_local.Arithmetic1D(1, 6)

- -

hyp4 = algo_local.Propagation()

- -

 

- -

# compute the mesh

- -

tria.Compute()

- -

PrintMeshInfo(tria)

- -

 

- -

# remove a local hypothesis

- -

mesh = tria.GetMesh()

- -

mesh.RemoveHypothesis(edge, hyp4)

- -

 

- -

# compute the mesh

- -

tria.Compute()

- -

PrintMeshInfo(tria)

- -

 

- -

# change the value - of the 2D hypothesis

- -

hyp2.SetMaxElementArea(2.)

- -

 

- -

# compute the mesh

- -

tria.Compute()

- -

PrintMeshInfo(tria)

- -

 

- -

Export of a Mesh

- -

import geompy

- -

import smesh

- -

 

- -

# create a box

- -

box = geompy.MakeBox(0., - 0., 0., 100., 200., 300.)

- -

idbox = geompy.addToStudy(box, - "box")

- -

 

- -

# create a mesh

- -

tetra = smesh.Mesh(box, - "MeshBox")

- -

 

- -

algo1D = tetra.Segment()

- -

algo1D.NumberOfSegments(7)

- -

 

- -

algo2D = tetra.Triangle()

- -

algo2D.MaxElementArea(800.)

- -

 

- -

algo3D = tetra.Tetrahedron(smesh.NETGEN)

- -

algo3D.MaxElementVolume(900.)

- -

 

- -

# compute the mesh

- -

tetra.Compute()

- -

 

- -

# export the mesh in a - MED file

- -

tetra.ExportMED("/tmp/meshMED.med", - 0)

- - - - + + + + + +Constructing Meshes + + + + + + + + + + + +

Creating Meshes

+ +

First of all see Example + of 3d mesh generation, which is an example of good python script style + for Mesh module.

+ +

Other examples of python + scripts will be also updated soon to use smesh package instead of direct + usage of idl interface.

+ +

Construction of a Mesh

+ +

import + geompy

+ +

import smesh

+ +

 

+ +

# create a box

+ +

box = geompy.MakeBox(0., + 0., 0., 100., 200., 300.)

+ +

idbox = geompy.addToStudy(box, + "box")

+ +

 

+ +

# create a mesh

+ +

tetra = smesh.Mesh(box, + "MeshBox")

+ +

 

+ +

algo1D = tetra.Segment()

+ +

algo1D.NumberOfSegments(7)

+ +

 

+ +

algo2D = tetra.Triangle()

+ +

algo2D.MaxElementArea(800.)

+ +

 

+ +

algo3D = tetra.Tetrahedron(smesh.NETGEN)

+ +

algo3D.MaxElementVolume(900.)

+ +

 

+ +

# compute the mesh

+ +

ret = tetra.Compute()

+ +

if ret == 0:

+ +

    print + "problem when computing the mesh"

+ +

else:

+ +

    print + "mesh computed"

+ +

    pass +

+ +

 

+ +

 

+ +

Construction of a Submesh

+ +

from + geompy import *

+ +

import smesh

+ +

 

+ +

# create a box

+ +

box = MakeBoxDXDYDZ(10., 10., 10.)

+ +

addToStudy(box, "Box")

+ +

 

+ +

# select one edge of + the box for definition of a local hypothesis

+ +

p5 = MakeVertex(5., 0., 0.)

+ +

EdgeX = GetEdgeNearPoint(box, p5)

+ +

addToStudyInFather(box, EdgeX, "Edge + [0,0,0 - 10,0,0]")

+ +

 

+ +

# create a hexahedral + mesh on the box

+ +

quadra = smesh.Mesh(box, "Box : quadrangle + 2D mesh")

+ +

 

+ +

# create a regular + 1D algorithm for the faces

+ +

algo1D = quadra.Segment()

+ +

 

+ +

# define "NumberOfSegments" + hypothesis to cut

+ +

# all the edges in + a fixed number of segments

+ +

algo1D.NumberOfSegments(4)

+ +

 

+ +

# create a quadrangle + 2D algorithm for the faces

+ +

quadra.Quadrangle()

+ +

 

+ +

# construct a submesh + on the edge with a local hypothesis

+ +

algo_local = quadra.Segment(EdgeX)

+ +

 

+ +

# define "Arithmetic1D" + hypothesis to cut the edge + in several segments with increasing arithmetic length

+ +

algo_local.Arithmetic1D(1, 4)

+ +

 

+ +

# define "Propagation" + hypothesis that propagates all other hypotheses

+ +

# on all edges of the + opposite side in case of quadrangular faces

+ +

algo_local.Propagation()

+ +

 

+ +

# compute the mesh

+ +

quadra.Compute()

+ +

 

+ +

Editing of a mesh

+ +

import + geompy

+ +

import smesh

+ +

 

+ +

def PrintMeshInfo(theMesh):

+ +

    aMesh + = theMesh.GetMesh()

+ +

    print + "Information about mesh:"

+ +

    print + "Number of nodes       : + ", aMesh.NbNodes()

+ +

    print + "Number of edges       : + ", aMesh.NbEdges()

+ +

    print + "Number of faces       : + ", aMesh.NbFaces()

+ +

    print + "Number of volumes     : + ", aMesh.NbVolumes()

+ +

    pass

+ +

 

+ +

# create a box

+ +

box = geompy.MakeBox(0., 0., 0., 20., + 20., 20.)

+ +

geompy.addToStudy(box, "box")

+ +

 

+ +

# select one edge of + the box for definition of a local hypothesis

+ +

subShapeList = geompy.SubShapeAll(box, + geompy.ShapeType["EDGE"])

+ +

edge = subShapeList[0]

+ +

name = geompy.SubShapeName(edge, box)

+ +

geompy.addToStudyInFather(box, edge, name)

+ +

 

+ +

# create a mesh

+ +

tria = smesh.Mesh(box, "Mesh 2D")

+ +

algo1D = tria.Segment()

+ +

hyp1 = algo1D.NumberOfSegments(3)

+ +

algo2D = tria.Triangle()

+ +

hyp2 = algo2D.MaxElementArea(10.)

+ +

 

+ +

# create a sub-mesh

+ +

algo_local = tria.Segment(edge)

+ +

hyp3 = algo_local.Arithmetic1D(1, 6)

+ +

hyp4 = algo_local.Propagation()

+ +

 

+ +

# compute the mesh

+ +

tria.Compute()

+ +

PrintMeshInfo(tria)

+ +

 

+ +

# remove a local hypothesis

+ +

mesh = tria.GetMesh()

+ +

mesh.RemoveHypothesis(edge, hyp4)

+ +

 

+ +

# compute the mesh

+ +

tria.Compute()

+ +

PrintMeshInfo(tria)

+ +

 

+ +

# change the value + of the 2D hypothesis

+ +

hyp2.SetMaxElementArea(2.)

+ +

 

+ +

# compute the mesh

+ +

tria.Compute()

+ +

PrintMeshInfo(tria)

+ +

 

+ +

Export of a Mesh

+ +

import geompy

+ +

import smesh

+ +

 

+ +

# create a box

+ +

box = geompy.MakeBox(0., + 0., 0., 100., 200., 300.)

+ +

idbox = geompy.addToStudy(box, + "box")

+ +

 

+ +

# create a mesh

+ +

tetra = smesh.Mesh(box, + "MeshBox")

+ +

 

+ +

algo1D = tetra.Segment()

+ +

algo1D.NumberOfSegments(7)

+ +

 

+ +

algo2D = tetra.Triangle()

+ +

algo2D.MaxElementArea(800.)

+ +

 

+ +

algo3D = tetra.Tetrahedron(smesh.NETGEN)

+ +

algo3D.MaxElementVolume(900.)

+ +

 

+ +

# compute the mesh

+ +

tetra.Compute()

+ +

 

+ +

# export the mesh in a + MED file

+ +

tetra.ExportMED("/tmp/meshMED.med", + 0)

+ + + +