def ComputeMesh(MEFISTO2=False):
    an1DHypothesis = StdMeshers_Arithmetic1D(0,0,aMeshGen)
    #print dir(an1DHypothesis)
    #print an1DHypothesis.SaveTo()
    
    an1DHypothesis.SetLength(1.,False)
    an1DHypothesis.SetLength(2.,True)
    an1DAlgo = StdMeshers_Regular_1D(1,0,aMeshGen)
    
    if MEFISTO2:
    #2D
        a2dHypothseis = StdMeshers_TrianglePreference(2,0,aMeshGen) #define the boundary
        a2dAlgo = StdMeshers_MEFISTO_2D(3,0,aMeshGen)
    else:
        a2dHypothseis = StdMeshers_QuadranglePreference(2,0,aMeshGen)
        a2dAlgo = StdMeshers_Quadrangle_2D(3,0,aMeshGen)
 
   
    #Calculate mesh
    aMesh.ShapeToMesh(aShape)
    
    #Assign hyptothesis to mesh
    aMesh.AddHypothesis(aShape,0)
    aMesh.AddHypothesis(aShape,1)
    aMesh.AddHypothesis(aShape,2)
    aMesh.AddHypothesis(aShape,3)
    
    #Compute the data
    aMeshGen.Compute(aMesh,aMesh.GetShapeToMesh())
Пример #2
0
    def test_LocalEdgeLength(self):
        """
        Test a mesh on a box with a local edge length enforced on one edge.
        """
        box = BRepPrimAPI_MakeBox(10, 10, 10).Solid()
        edge = TopExp_Explorer(box, TopAbs_EDGE).Current()

        gen = SMESH_Gen()
        mesh = gen.CreateMesh(0, True)

        hyp3d = NETGENPlugin_SimpleHypothesis_3D(0, 0, gen)
        hyp3d.SetLocalLength(1.0)
        NETGENPlugin_NETGEN_2D3D(1, 0, gen)

        hyp1d = StdMeshers_LocalLength(2, 0, gen)
        hyp1d.SetLength(0.1)
        StdMeshers_Regular_1D(3, 0, gen)

        mesh.ShapeToMesh(box)
        mesh.AddHypothesis(box, 0)
        mesh.AddHypothesis(box, 1)
        mesh.AddHypothesis(edge, 2)
        mesh.AddHypothesis(edge, 3)

        success = gen.Compute(mesh, box)
        self.assertTrue(success)

        self.assertEqual(mesh.NbTetras(), 31547)
        self.assertEqual(mesh.NbNodes(), 6205)
aShape = BRepAlgoAPI_Cut(box, sphere).Shape()
print('Done.')

# Create the Mesh
print('Creating mesh ...', end='')
aMeshGen = SMESH_Gen()
aMesh = aMeshGen.CreateMesh(0, True)
print('Done.')

print('Adding hypothesis and algorithms ...', end='')
# 1D
an1DHypothesis = StdMeshers_Arithmetic1D(0, 0,
                                         aMeshGen)  #discretization of the wire
an1DHypothesis.SetLength(5., False)  #the smallest distance between 2 points
an1DHypothesis.SetLength(10., True)  # the longest distance between 2 points
an1DAlgo = StdMeshers_Regular_1D(1, 0, aMeshGen)  # interpolation

# 2D
a2dHypothseis = StdMeshers_QuadranglePreference(2, 0,
                                                aMeshGen)  #define the boundary
a2dAlgo = StdMeshers_Quadrangle_2D(3, 0, aMeshGen)  # the 2D mesh

# 3D: Just uncomment the line to use the volumic mesher you want
a3dHypothesis = StdMeshers_Prism_3D(4, 0, aMeshGen)  #OK

#Calculate mesh
aMesh.ShapeToMesh(aShape)

#Assign hyptothesis to mesh
aMesh.AddHypothesis(aShape, 0)
aMesh.AddHypothesis(aShape, 1)
Пример #4
0
 def __init__(self, gen):
     hyp = StdMeshers_Regular_1D(gen.new_id(), -1, gen.object)
     super(Regular1D, self).__init__(hyp)