On Sep 11, 2009, at 1:09 AM, Chintha Handapangoda wrote:
I am trying to simulate a two dimensional photonic crystal with a square lattice composed of cylinders, using the C++ interface to meep. My source is in the form of discrete values in both spatial and time domains (stored in an array). I tried to use the "custom_src_time" function defined in the meep.hpp header file but came across the following problem:

The function is defined in meep.hpp as custom_src_time(complex<double> (*func) (double t, void *), void *data, double st, double et). What information is passed as the second argument (void *data) to this function?

That is up to you: the void *data is just a pointer to any arbitrary data that you want to store in the class's void*data member, which is then passed along to your func(t, data) function. (Typically, this is a pointer to some data structure needed by your function, which is then typecast back to the appropriate pointer type inside your func. If you don't need extra data, you can just pass NULL.)

(Having an extra void* argument to callback functions is a standard trick in C to allow re-entrant callback functions, without needing to use global variables to pass additional data needed by the callback function.)

(The other alternative, if your custom source needs additional data, is to define your own subclass of src_time with whatever data members it needs.)

(In a proper functional language like Scheme, such things are not needed because they have lexical scoping.)

Steven


_______________________________________________
meep-discuss mailing list
meep-discuss@ab-initio.mit.edu
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss

Reply via email to