[Gmsh] Create mesh for 1D geometry

Max Orok morok at mevex.com
Thu Feb 6 21:22:08 CET 2020


Using the python api, building on Jeremy's nice example, but omitting
physical groups:

-----
import gmsh

delx = 0.5
xend = 20

gmsh.initialize()

point_a = gmsh.model.geo.addPoint(0.0, 0.0, 0.0, meshSize=delx)
point_b = gmsh.model.geo.addPoint(20.0, 0.0, 0.0, meshSize=delx)

line = gmsh.model.geo.addLine(point_a, point_b)

gmsh.model.geo.synchronize()

# make a 1d mesh
gmsh.model.mesh.generate(1)

# save the mesh as a NASTRAN bulk data file
gmsh.write("line.bdf")

gmsh.finalize()
-----

Sincerely,
Max

On Thu, Feb 6, 2020 at 1:25 PM Jeremy Theler <jeremy at seamplex.com> wrote:

> delx = 0.5;
> xend = 20;
> Point(1) = {0, 0, 0, delx};
> Point(2) = {xend, 0, 0, delx};
>
> Line(1) = {1, 2};
>
> Physical Point("left") = {1};
> Physical Point("right") = {2};
> Physical Line("bulk") = {1};
>
> On Thu, 2020-02-06 at 23:11 +0530, Deepa wrote:
> > >
> > > I am a beginner here.
> > >
> > > I'm looking for ways of creating a mesh for a 2D geometry. It's a
> > > straight line, the nodes have to be positioned along the x
> > > directions and all y-coordinates have to be zero.
> > >
> > > Example: 0 : delx : xend, where delx =0.5, xend = 20.
> > >
> > > I have to create the input file in a format that will be compatible
> > > for importing in COMSOL.
> > >
> > > Any suggestions on how to proceed will be really helpful
> > >
> > > Thanks,
> > > Deepa
> > >
> > >
> >
> > _______________________________________________
> > gmsh mailing list
> > gmsh at onelab.info
> >
> > http://onelab.info/mailman/listinfo/gmsh
> >
> >
>
>
> _______________________________________________
> gmsh mailing list
> gmsh at onelab.info
> http://onelab.info/mailman/listinfo/gmsh
>


-- 
Max Orok
Contractor
www.mevex.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://onelab.info/pipermail/gmsh/attachments/20200206/ec2dacf7/attachment.html>
-------------- next part --------------
import gmsh 

delx = 0.5
xend = 20

gmsh.initialize()

point_a = gmsh.model.geo.addPoint(0.0, 0.0, 0.0, meshSize=delx)
point_b = gmsh.model.geo.addPoint(20.0, 0.0, 0.0, meshSize=delx)

line = gmsh.model.geo.addLine(point_a, point_b)

gmsh.model.geo.synchronize()

# make a 1d mesh 
gmsh.model.mesh.generate(1)

# save the mesh as a NASTRAN bulk data file
gmsh.write("line.bdf")

gmsh.finalize()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: line.bdf
Type: application/octet-stream
Size: 4718 bytes
Desc: not available
URL: <http://onelab.info/pipermail/gmsh/attachments/20200206/ec2dacf7/attachment.bdf>


More information about the gmsh mailing list