Yunsong,ZHAO wrote:

Dear meep users:

I tried the example program in C++ Tutorial but I got a segmentation fault.

gdb result:

" Program received signal SIGSEGV, Segmentation fault.

 0x08049dcd   in meep::boundary_region::~boundary_region()"

I am a newbie here. Have you ever met this problem? What is the most probable reason and how to handle it?

 Thank you very much!

By the way, the example program :

#include <meep.hpp>

using namespace meep;

double eps(const vec &p) {

  if (p.x() < 2 && p.y() < 3)

    return 12.0;

  return 1.0;

}

int main(int argc, char **argv) {

  initialize mpi(argc, argv); // do this even for non-MPI Meep

  double resolution = 20; // pixels per distance

  volume v = vol2d(5,10, resolution); // 5x10 2d cell

  structure s(v, eps, pml(1.0));

  fields f(&s);

  f.output_hdf5(Dielectric, v.surroundings());

  double freq = 0.3, fwidth = 0.1;

  gaussian_src_time src(freq, fwidth);

  f.add_point_source(Ey, src, vec(1.1, 2.3));

  while (f.time() < f.last_source_time()) {

    f.step();

  }

  f.output_hdf5(Hz, v.surroundings());

  return 0;

}

Sincerely,

Zhaoys

------------------------------------------------------------------------

_______________________________________________
meep-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss
Hi, YunSong,

Segmentation fault normally occurs when your program accesses a piece of memory which does not belong to it. Try this program, you will understand it:
int main(){
       int * a=0;
       a[0]=1;
       return 0;
}

Back to this topic, meep::boundary_region::~boundary_region() wants to release some resources as a destructor which may delete some unaccessible things. However, in this case, it may not be meep's fault. Another possibility is that the compiler over-optimizes the codes. Try to enable the debug flag and gdb it again. At least, the codes you provide work well in my project.

Yours,
Zheng
_______________________________________________
meep-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss

Reply via email to