Discussion:
[Meep-discuss] Problem on modifying fields through chunk loop function with Meep C++
Li Tao
2018-10-29 23:36:39 UTC
Permalink
Dear meep users,


I want to directly modify both the E and B fields at every time step. Adding sources or potentials seems to be not enough for my implementation because I want to make sure after each time step, the Poynting vector of the added fields have a specific direction. After reading the documentations and source code, it seems I need to use the chunk loop function, see follows:

void my_chunkloop(fields_chunk *fc, int ichunk, component cgrid,
ivec is, ivec ie, vec s0, vec s1, vec e0, vec e1,
double dV0, double dV1,
ivec shift, complex<double> shift_phase,
const symmetry &S, int sn, void *data_)
{
(void) s0; (void) s1; (void) e0; (void) e1; (void) dV0; (void) dV1;
(void) shift_phase; (void) data_;

// loop over all grid points in chunk
LOOP_OVER_IVECS(fc->gv, is, ie, idx)
{
double *x = fc->f[meep::Ex][0];
x[idx] = 0.0; // everything is good if I delete this line
}
}

If I do not delete the line "x[idx] = 0.0;", the following runtime error will appear (in Ubuntu 18.04)

[XX:13747] *** Process received signal ***
[XX:13747] Signal: Segmentation fault (11)
[XX:13747] Signal code: Address not mapped (1)
[XX:13747] Failing at address: 0x8
[XX:13747] [ 0] /lib/x86_64-linux-gnu/libc.so.6(+0x3ef20)[0x7f7477467f20]
[XX:13747] [ 1] ./tls(+0x2544)[0x556b33f7c544]
[XX:13747] [ 2] /usr/local/lib/libmeep.so.11(_ZN4meep6fields14loop_in_chunksEPFvPNS_12fields_chunkEiNS_9componentENS_4ivecES4_NS_3vecES5_S5_S5_ddS4_St7complexIdERKNS_8symmetryEiPvESB_RKNS_6volumeES3_bb+0x31ff)[0x7f7478c9327f]
[XX:13747] [ 3] ./tls(+0x1e67)[0x556b33f7be67]
[XX:13747] [ 4] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7f747744ab97]
[XX:13747] [ 5] ./tls(+0x200a)[0x556b33f7c00a]
[XX:13747] *** End of error message ***
Segmentation fault (core dumped)

Could anyone tell me what's wrong with this chunk loop function? If chunk loop function does not work, is there any other method to directly modify the EM field with meep?


Thanks a lot!

Tao

Loading...