[Gmsh] Running mainsimple.cpp

rahulsn at iitk.ac.in rahulsn at iitk.ac.in
Wed Jun 13 14:51:58 CEST 2012


Dear All,

   My problem is concerned with the running of the program mainsimple.cpp
given in the utils folder. I have built the Gmsh library and i am using
this to compile the c++ program. The problem is it's not running after
compiling and it stops after giving the error "Segmentation Fault". If
anybody has solved this  kind of problem, please tell me if i am
missing something. I am attaching the program and error with this mail.

Thanks,
Rahul

MainSimple.cpp:

#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <stdio.h>
#include <omp.h>
#include <cstdlib>
#include "Gmsh.h"
#include "GModel.h"
#include "MElement.h"
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main(int argc, char **argv)
{
  GmshInitialize(argc, argv);
  GModel *m = new GModel();
  m->readGEO("/home/rahul/test_1.geo");
  cerr << "written Geometry file" << endl;
  m->writeGEO("test_4.geo");
  int i;
  m->mesh(3);
  cerr<<"meshing done"<<endl;
  for(GModel::riter it = m->firstRegion(); it != m->lastRegion(); ++it){
    GRegion *r = *it;
    printf("volume %d contains %d elements:\n", r->tag(),
r->getNumMeshElements());
    for(unsigned int i = 0; i < r->getNumMeshElements(); i++)
      printf(" %d", r->getMeshElement(i)->getNum());
    printf("\n");
  }
  m->writeMSH("test.msh");
  m->writeUNV("test.unv");
  delete m;
  GmshFinalize();

Compiled this program using:

g++ -o output_1 mainSimple.cpp -L /home/rahul/gmsh-2.5.0-source/build/ -lGmsh

Error:

written Geometry file
Segmentation fault (core dumped)