Dear All,

I am trying to generate mesh using api functions  setElements and setNodes.
But encountering few problems.

Mesh should be generated on square region inside of each are boundary
lines(this structures looks similar to binary tree or simple biological
tree with root bounded to square boundary).

Proof of concept I have done using *geo *module:

gmsh::initialize();
model::add("square");
geo::addPoint(0, 0, 0, 0.1, 1);
geo::addPoint(0.5, 0, 0, 0.1, 2);
geo::addPoint(1, 0, 0, 0.1, 3);
geo::addPoint(1, 1, 0, 0.1, 4);
geo::addPoint(0, 1, 0, 0.1, 5);
geo::addPoint(0.5, 0.2, 0, 0.1, 6);
geo::addLine(1, 2, 1);
geo::addLine(2, 3, 2);
geo::addLine(3, 4, 3);
geo::addLine(4, 5, 4);
geo::addLine(5, 1, 5);
geo::addLine(2, 6, 6);
geo::addLine(6, 2, 7);
geo::addCurveLoop({1, 2, 3, 4, 5, 6, 7}, 1);
geo::addPlaneSurface({1}, 6);
geo::synchronize();
model::mesh::generate(2);

pay attention on these two lines its workaround to generate mesh properly

geo::addLine(2, 6, 6);
geo::addLine(6, 2, 7);

For me is more convenient to use setElements and setNodes, there is even
nice example discrete.cpp which creates "by hand" two mesh triangles.
I also tried to create(adopting the discrete.cpp sample)  "by hand" region
using line elements.
but it fails saying next:

*Error : Wrong type of element for Surface 1 *

I used next code:
model::addDiscreteEntity(2, 1);

msh::setNodes(2, 1,
 {1, 2, 3, 4},
{0., 0., 0., //node 1
1., 0., 0., //node 2
 1., 1., 0., //node 3
0., 1., 0.}); //node 4

msh::setElements(2, 1,
{1},//line element
{{1,2,3,4}},//line tags
{{1,2,2,3,3,4,4,1}}); //lines
model::mesh::generate(2);


Also I tried instead of line elements(1) to use point elements(15), error
was the same.
How to generate such mesh without using geo module?

With regards,
Oleg Kmechak
_______________________________________________
gmsh mailing list
gmsh@onelab.info
http://onelab.info/mailman/listinfo/gmsh

Reply via email to