File: discrete.cpp

package info (click to toggle)
gmsh 4.15.1%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,880 kB
  • sloc: cpp: 440,657; ansic: 114,930; f90: 15,611; python: 13,907; yacc: 7,438; java: 3,491; lisp: 3,206; lex: 633; perl: 571; makefile: 500; xml: 414; sh: 407; javascript: 113; modula3: 32
file content (30 lines) | stat: -rw-r--r-- 973 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <gmsh.h>

int main(int argc, char **argv)
{
  gmsh::initialize(argc, argv);

  gmsh::model::add("test");

  // add discrete surface with tag 1
  gmsh::model::addDiscreteEntity(2, 1);

  // add 4 mesh nodes
  gmsh::model::mesh::addNodes(2, 1, {1, 2, 3, 4}, // node tags: 1, 2, 3, and 4
                              {0., 0., 0., // coordinates of node 1
                               1., 0., 0., // coordinates of node 2
                               1., 1., 0., // ...
                               0., 1., 0.});

  // add 2 triangles
  gmsh::model::mesh::addElements(2, 1, {2}, // single type : 3-node triangle
                                 {{1, 2}}, // triangle tags: 1 and 2
                                 {{1, 2, 3, // triangle 1: nodes 1, 2, 3
                                   1, 3, 4}}); // triangle 2: nodes 1, 3, 4

  // export the mesh ; use explore.cpp to read and examine the mesh
  gmsh::write("test.msh");

  gmsh::finalize();
  return 0;
}