// File: /workspace/github_cpp_makefile_star2_O2/npaster[P]gmsh_tools/main.cc
// Function: main
int main(int argc, char** argv)
{
  if (argc < 2)
    {
      cout << "Please, enter the name of your mesh .. " << endl;
      return 0;
    }

  gmsh::Gmesh mesh;
  const string name_mesh(argv[1]);
  mesh.readGmesh(name_mesh);

  mesh.getInfo();
  cout << endl;

  mesh.writeGmesh("test.msh", 2);

  gmsh::Gmesh mesh2(mesh);

  mesh2.convertInDiscontinuousMesh();

  std::vector<gmsh::Node> newNodes;

  for(size_t i=0; i< mesh2.getNumberofNodes(); i++){
     std::array<double, 3> newcoor = {{1.0*(rand() % 10), 1.0*(rand() % 10), 0.0}};
     gmsh::Node tmpNode(newcoor, i, 0);
     newNodes.push_back(tmpNode);
 }

  mesh2.computeDeformed(newNodes);

  mesh2.writeGmesh("test2.msh", 2);

  gmsh::NodeData data;

  data.changeNbComposante(1);

  std::vector<gmsh::Node> v_node= mesh2.getNodes();

  for (size_t i = 0; i < v_node.size(); i++) {
     std::vector<double> value = {1.0 + (rand() % 10)} ;
     std::array<double, 3> coor = {{0.1*(rand() % 10), 0.1*(rand() % 10), 0.0}};
     gmsh::Node nodetmp(coor, v_node.size() +1 +i, 1 );
     gmsh::Data dat(v_node.size() +1 +i , value);
     data.addData(v_node[i].getIndex(), value );
     //data.addSubData(dat, nodetmp);
  }

  data.saveNodeData("result5.msh", mesh2);

  gmsh::ElementData data2;

  data2.changeNbComposante(1);

  std::vector<gmsh::Triangle> v= mesh.getTriangles();

  for (size_t i = 0; i < v.size(); i++) {
     std::vector<double> value = {1.0 + i} ;
     data2.addData(v[i].getIndex(), value );
  }



  data2.saveElementData("result4.msh", mesh);

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3d8, %rsp            # imm = 0x3D8
cmpl $0x1, %edi
jg 0xc305
movq 0x7cec(%rip), %rdi      # 0x13fd8
leaq 0x1b0d(%rip), %rsi      # 0xde00
callq 0x21c0
movq %rax, %rdi
callq 0x20f0
jmp 0xc7c3
movq %rsi, %rbx
leaq -0x3f8(%rbp), %rdi
callq 0x2fb4
movq 0x8(%rbx), %rsi
leaq -0x1c8(%rbp), %rdi
leaq -0x310(%rbp), %rdx
callq 0x20b0
leaq -0x1a8(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0x21f0
leaq -0x3f8(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x4f36
leaq -0x1a8(%rbp), %rdi
callq 0x20d0
leaq -0x3f8(%rbp), %rdi
callq 0x70c8
movq 0x7c68(%rip), %rdi      # 0x13fd8
callq 0x20f0
leaq 0x1aac(%rip), %rsi      # 0xde28
leaq -0x188(%rbp), %rdi
leaq -0x310(%rbp), %rdx
callq 0x20b0
leaq -0x3f8(%rbp), %rdi
leaq -0x188(%rbp), %rsi
pushq $0x2
popq %rdx
callq 0x7030
leaq -0x188(%rbp), %rdi
callq 0x20d0
leaq -0x310(%rbp), %rdi
leaq -0x3f8(%rbp), %rsi
callq 0xb992
leaq -0x310(%rbp), %rdi
callq 0x7cae
xorpd %xmm0, %xmm0
leaq -0xc0(%rbp), %rax
movapd %xmm0, (%rax)
andq $0x0, 0x10(%rax)
xorl %r14d, %r14d
leaq -0x310(%rbp), %r15
pushq $0xa
popq %rbx
leaq -0x228(%rbp), %r12
leaq -0x108(%rbp), %r13
movq %r15, %rdi
callq 0x3808
cmpq %rax, %r14
jae 0xc460
callq 0x2070
cltd
idivl %ebx
cvtsi2sd %edx, %xmm0
movsd %xmm0, -0x108(%rbp)
callq 0x2070
cltd
idivl %ebx
cvtsi2sd %edx, %xmm0
movsd %xmm0, -0x100(%rbp)
andq $0x0, -0xf8(%rbp)
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x24c2
leaq -0xc0(%rbp), %rdi
movq %r12, %rsi
callq 0x8354
incq %r14
jmp 0xc3ff
leaq -0x310(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x7cdc
leaq 0x19b7(%rip), %rsi      # 0xde31
leaq -0x168(%rbp), %rdi
leaq -0x228(%rbp), %rdx
callq 0x20b0
leaq -0x310(%rbp), %rdi
leaq -0x168(%rbp), %rsi
pushq $0x2
popq %rdx
callq 0x7030
leaq -0x168(%rbp), %rdi
callq 0x20d0
leaq -0x228(%rbp), %rdi
callq 0xa7c0
leaq -0x228(%rbp), %rdi
pushq $0x1
popq %r13
movq %r13, %rsi
callq 0xa738
leaq -0x48(%rbp), %rdi
leaq -0x310(%rbp), %rsi
callq 0x383e
xorl %r14d, %r14d
pushq $0x28
popq %r15
leaq -0xa8(%rbp), %r12
leaq -0x108(%rbp), %rsi
leaq -0x1(%r13), %rcx
movq -0x40(%rbp), %rax
subq -0x48(%rbp), %rax
cqto
idivq %r15
cmpq %rax, %rcx
jae 0xc61d
movq %r13, -0x78(%rbp)
movq %r14, -0x70(%rbp)
movq %r15, %r13
movq %rsi, %r14
callq 0x2070
cltd
idivl %ebx
incl %edx
cvtsi2sd %edx, %xmm0
movsd %xmm0, -0x108(%rbp)
movq %r12, %rdi
movq %r14, %rsi
movl %ebx, %r15d
pushq $0x1
popq %r12
movq %r12, %rdx
leaq -0x68(%rbp), %rcx
callq 0xc922
callq 0x2070
cltd
idivl %r15d
cvtsi2sd %edx, %xmm0
movsd 0x1899(%rip), %xmm1     # 0xddf8
mulsd %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
callq 0x2070
cltd
movl %r15d, %ebx
idivl %r15d
cvtsi2sd %edx, %xmm0
mulsd 0x1875(%rip), %xmm0     # 0xddf8
movsd %xmm0, -0x88(%rbp)
andq $0x0, -0x80(%rbp)
movq -0x40(%rbp), %rax
subq -0x48(%rbp), %rax
cqto
movq %r13, %r15
idivq %r13
movq -0x78(%rbp), %r13
leaq (%rax,%r13), %rdx
movq %r14, %rdi
leaq -0x90(%rbp), %rsi
movq %r12, %rcx
callq 0x24c2
movq -0x40(%rbp), %rax
subq -0x48(%rbp), %rax
cqto
idivq %r15
leaq (%rax,%r13), %rsi
leaq -0x68(%rbp), %rdi
leaq -0xa8(%rbp), %r12
movq %r12, %rdx
callq 0xa430
movq -0x70(%rbp), %r14
movq -0x48(%rbp), %rdi
addq %r14, %rdi
callq 0x2616
leaq -0x228(%rbp), %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0xa76a
leaq -0x60(%rbp), %rdi
callq 0xbbec
movq %r12, %rdi
callq 0xbbec
incq %r13
addq $0x28, %r14
jmp 0xc4ec
leaq 0x1817(%rip), %rsi      # 0xde3b
leaq -0x148(%rbp), %rdi
leaq -0x108(%rbp), %rdx
callq 0x20b0
leaq -0x228(%rbp), %rdi
leaq -0x148(%rbp), %rsi
leaq -0x310(%rbp), %rdx
callq 0xad42
leaq -0x148(%rbp), %rdi
callq 0x20d0
leaq -0x108(%rbp), %rdi
callq 0xa604
leaq -0x108(%rbp), %rdi
pushq $0x1
popq %rsi
callq 0xa738
leaq -0x68(%rbp), %rdi
leaq -0x3f8(%rbp), %rsi
callq 0x3892
xorl %r14d, %r14d
leaq -0xa8(%rbp), %rbx
leaq -0x29(%rbp), %r12
leaq -0x108(%rbp), %r13
xorl %r15d, %r15d
movq -0x60(%rbp), %rax
subq -0x68(%rbp), %rax
cqto
pushq $0x38
popq %rcx
idivq %rcx
cmpq %rax, %r15
jae 0xc729
movq %r15, %xmm0
punpckldq 0x170e(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1716(%rip), %xmm0     # 0xdde0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
addsd 0x1712(%rip), %xmm1     # 0xddf0
movsd %xmm1, -0x90(%rbp)
movq %rbx, %rdi
leaq -0x90(%rbp), %rsi
pushq $0x1
popq %rdx
movq %r12, %rcx
callq 0xc922
movq -0x68(%rbp), %rdi
addq %r14, %rdi
callq 0x26bc
movq %r13, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0xa76a
movq %rbx, %rdi
callq 0xbbec
incq %r15
addq $0x38, %r14
jmp 0xc6a0
leaq 0x1717(%rip), %rsi      # 0xde47
leaq -0x128(%rbp), %rdi
leaq -0xa8(%rbp), %rdx
callq 0x20b0
leaq -0x108(%rbp), %rdi
leaq -0x128(%rbp), %rsi
leaq -0x3f8(%rbp), %rdx
callq 0xb230
leaq -0x128(%rbp), %rdi
callq 0x20d0
leaq -0x68(%rbp), %rdi
callq 0x7f84
leaq -0x108(%rbp), %rdi
callq 0xb932
leaq -0x48(%rbp), %rdi
callq 0x8722
leaq -0x228(%rbp), %rdi
callq 0xc958
leaq -0xc0(%rbp), %rdi
callq 0x8722
leaq -0x310(%rbp), %rdi
callq 0xbaea
leaq -0x1c8(%rbp), %rdi
callq 0x20d0
leaq -0x3f8(%rbp), %rdi
callq 0xbaea
xorl %eax, %eax
addq $0x3d8, %rsp            # imm = 0x3D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x128(%rbp), %rdi
callq 0x20d0
jmp 0xc8a0
jmp 0xc87e
jmp 0xc7f2
movq %rax, %rbx
jmp 0xc8a9
jmp 0xc88a
movq %rax, %rbx
leaq -0x148(%rbp), %rdi
callq 0x20d0
jmp 0xc8cf
jmp 0xc88a
jmp 0xc817
movq %rax, %rbx
jmp 0xc8d8
jmp 0xc8e6
movq %rax, %rbx
leaq -0x168(%rbp), %rdi
callq 0x20d0
jmp 0xc8e9
jmp 0xc8e6
jmp 0xc8e6
movq %rax, %rbx
jmp 0xc8f5
jmp 0xc876
movq %rax, %rbx
leaq -0x188(%rbp), %rdi
jmp 0xc864
jmp 0xc876
movq %rax, %rbx
leaq -0x1a8(%rbp), %rdi
callq 0x20d0
jmp 0xc901
movq %rax, %rbx
jmp 0xc90d
movq %rax, %rbx
jmp 0xc901
movq %rax, %rbx
jmp 0xc8a0
jmp 0xc885
movq %rax, %rbx
jmp 0xc8c3
movq %rax, %rbx
jmp 0xc8cf
jmp 0xc8e6
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0xbbec
leaq -0x68(%rbp), %rdi
callq 0x7f84
leaq -0x108(%rbp), %rdi
callq 0xb932
jmp 0xc8cf
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0xbbec
leaq -0xa8(%rbp), %rdi
callq 0xbbec
leaq -0x48(%rbp), %rdi
callq 0x8722
leaq -0x228(%rbp), %rdi
callq 0xc958
jmp 0xc8e9
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
callq 0x8722
leaq -0x310(%rbp), %rdi
callq 0xbaea
leaq -0x1c8(%rbp), %rdi
callq 0x20d0
leaq -0x3f8(%rbp), %rdi
callq 0xbaea
movq %rbx, %rdi
callq 0x22a0
nop