0

I am working on a research project where I need to create meshes of fiber models to test some stuff later. For that, I'm trying to make an extrusion along a spline in gmsh python module and I don't what is the syntax for that to write the code. Is it even possible to do that in the gmsh python module or only just in the open cascade kernel in gmsh?

I was successfully able to generate an extrusion along a random spline in the open cascade kernel in gmsh but I want to replicate that in python to create fibers meshes of the real data. It would be greatly appreciated if anyone can help with that. I think all I'm having trouble with is what the syntax for that would be if it's even possible to do that in the gmsh python module.

But here is the code for extruding along a wire directly on gmsh:


SetFactory("OpenCASCADE");

//adding points
Point(1) = {-0, -0.1, 0, 1.0};
Point(2) = {0.4, -0.1, 0, 1.0};
Point(3) = {0.8, -0.1, 0, 1.0};
Point(4) = {1.3, -0.1, 0, 1.0};
Point(5) = {2.2, -0.5, 0, 1.0};
Point(6) = {2.8, -0, 0, 1.0};
Point(7) = {4.2, -0.9, 0, 1.0};
Point(8) = {6.5, 0.6, 0, 1.0};

//creating a spline
Spline(1) = {1, 2, 3, 4, 5, 6, 7, 8};
arc= newl; Spline(arc)={1,2,3,4,5,6,7,8};

//rotating the spline 90 degrees
Rotate {{0, 1, 0}, {0, 0, 0}, Pi/2} {Curve{arc};}

//creating a disk at the 1st point
Disk(1) = {0, -0.1, 0, 0.1};

//making the arc a wire
Wire(10) = arc;

//extruding surface{1} aka Disk(1) along wire
Try1() = Extrude { Surface{1}; } Using Wire {10};

//deleting initial points and spline
Recursive Delete {Curve{1};}
Recursive Delete {Point{2}; Point{3}; Point{4}; Point{5}; Point{6}; Point{7};}
 
Harsha 21
  • 1
  • 1

1 Answers1

0

I am probably facing similiar issues with the python api of gmsh. Can you add some more details on the error-messanges? Can you export a geometry with the python-script and show the geometry in the gmsh-gui?

I can create a 2d-mesh. But i am failing with the extrusion and the 3d-meshing.

enter image description here

3D-meshing output:

Info    : [  0%] Meshing curve 1 (Nurb)
Info    : [ 10%] Meshing curve 2 (Nurb)
Info    : [ 20%] Meshing curve 3 (Nurb)
Info    : [ 20%] Meshing curve 4 (Nurb)
Info    : [ 30%] Meshing curve 5 (Nurb)
Info    : [ 40%] Meshing curve 8 (Nurb)
Info    : [ 40%] Meshing curve 9 (Nurb)
Info    : [ 50%] Meshing curve 10 (Nurb)
Info    : [ 60%] Meshing curve 11 (Nurb)
Info    : [ 60%] Meshing curve 12 (Nurb)
Info    : [ 70%] Meshing curve 14 (Line)
Info    : [ 80%] Meshing curve 15 (Line)
Info    : [ 80%] Meshing curve 19 (Line)
Info    : [ 90%] Meshing curve 23 (Line)
Info    : [100%] Meshing curve 30 (Line)
Info    : Done meshing 1D (Wall 0.011256s, CPU 0.010587s)
Info    : Meshing 2D...
Info    : [  0%] Meshing surface 1 (Plane, Frontal-Delaunay)
Info    : [ 20%] Meshing surface 16 (Surface, Frontal-Delaunay)
Info    : [ 30%] Meshing surface 20 (Surface, Frontal-Delaunay)
Info    : [ 50%] Meshing surface 24 (Surface, Frontal-Delaunay)
Info    : [ 60%] Meshing surface 28 (Surface, Frontal-Delaunay)
Info    : [ 80%] Meshing surface 32 (Surface, Frontal-Delaunay)
Warning : Unknown entity of dimension 1 and tag 2 in physical group 1
Warning : Unknown entity of dimension 1 and tag 4 in physical group 2
Warning : Unknown entity of dimension 1 and tag 1 in physical group 3
Warning : Unknown entity of dimension 1 and tag 3 in physical group 4
Warning : Unknown entity of dimension 1 and tag 5 in physical group 5
Warning : Unknown entity of dimension 2 and tag 1 in physical group 6
Warning : Extrusion of periodic curves is not supported with the built-in kernel
Warning : Impossible to recover edge 1 1 (error tag -1)
Warning : Impossible to recover edge 4841 4841 (error tag -1)
Error   : Unable to recover the edge 5681 (1/41) on curve 1 (on surface 32)

tests/gmsh/test_ntrfc_turbo_cascade.py:6 (test_generate_turbocascade)
tmpdir = local('/tmp/pytest-of-many/pytest-214/test_generate_turbocascade0')

    def test_generate_turbocascade(tmpdir):
        from ntrfc.turbo.pointcloud_methods import extract_geo_paras
        from ntrfc.turbo.airfoil_generators.naca_airfoil_creator import naca
        from ntrfc.turbo.domaingen_cascade import cascade_2d_domain, cascade_3d_domain
        naca_code = "6510"
        angle = 41  # deg
        res = 420
        xs, ys = naca(naca_code, res, half_cosine_spacing=True)
        sorted_poly = pv.PolyData(np.stack([xs[:-1], ys[:-1], np.zeros(len(xs) - 1)]).T)
        sorted_poly.rotate_z(angle)
        alpha = 1
        X, Y = sorted_poly.points[::, 0], sorted_poly.points[::, 1]
        points = np.stack((X[:], Y[:], np.zeros(len(X)))).T
        pointspoly = pv.PolyData(points)
    
    
        sortedPoly, ind_vk, ind_hk, psPoly, ssPoly, per_y_upper, per_y_lower, inletPoly, outletPoly = cascade_2d_domain(pointspoly.points, -1, 2, 1,
                                                                                                        "m", 0.1, 1,
                                                                                                        verbose=False)
    
    
>       generate_turbocascade(sortedPoly,ind_vk, ind_hk, per_y_upper, per_y_lower,inletPoly, outletPoly, filename=f"{tmpdir}/domain3d.msh")

test_ntrfc_turbo_cascade.py:28: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../ntrfc/gmsh/turbo_cascade.py:88: in generate_turbocascade
    gmsh.model.mesh.generate()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

dim = 3

    @staticmethod
    def generate(dim=3):
        """
        gmsh.model.mesh.generate(dim=3)
    
        Generate a mesh of the current model, up to dimension `dim' (0, 1, 2 or 3).
        """
        ierr = c_int()
        lib.gmshModelMeshGenerate(
            c_int(dim),
            byref(ierr))
        if ierr.value != 0:
>           raise Exception(logger.getLastError())
E           Exception: Unable to recover the edge 5681 (1/41) on curve 1 (on surface 32)

/home/many/miniconda3/envs/NTRfC/lib/python3.10/site-packages/gmsh.py:1599: Exception

Gmsh is not showing any geometry-lines, only 1D-edges of the mesh. But the mesh includes a correct list of curves.

Sorry that I can't help directly.

Ma Ny
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 12 '22 at 22:28