Re: [Meep-discuss] Use of custom_src_time function
> > Probably, you would better look at generic src_time class. AFAIK, you > just have to override its dipole(time) function to whatever function > you need. I don't have a working c++ example and would be glad if > anyone provides it. I think providing a (*func) for custom_src_time should be enough (instead of overriding src_time) > > 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 > > (*func) (double t, void *), void *data, double st, double et). > > What information is passed as the second argument (void *data) to this > > function? The problem is using arbitrary values for space and time points - ie. non- separable source (each point in a line source have different values at different times. May be stored in a matrix x-t) Meep reference says this can be done by modifying sources after each time step. But couldn't find any example of it. Or else I would have hoped for a function like (*func)(double time, vec& p, *) accepted by custom_src_time so we can specify value at both x,t Really appreciate some help. Thanks Nizamov Shawkat writes: > > Probably, you would better look at generic src_time class. AFAIK, you > just have to override its dipole(time) function to whatever function > you need. I don't have a working c++ example and would be glad if > anyone provides it. > > wbr > Shawkat > > 2009/9/11, Chintha Handapangoda : > > Dear All, > > > > 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 > > (*func) (double t, void *), void *data, double st, double et). > > What information is passed as the second argument (void *data) to this > > function? > > > > Thanks very much. > > > > Chintha Handapangoda. > > > > > > > > > ___ meep-discuss mailing list meep-discuss@ab-initio.mit.edu http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss
Re: [Meep-discuss] Use of custom_src_time function
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 (*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
Re: [Meep-discuss] Use of custom_src_time function
Probably, you would better look at generic src_time class. AFAIK, you just have to override its dipole(time) function to whatever function you need. I don't have a working c++ example and would be glad if anyone provides it. wbr Shawkat 2009/9/11, Chintha Handapangoda : > Dear All, > > 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 > (*func) (double t, void *), void *data, double st, double et). > What information is passed as the second argument (void *data) to this > function? > > Thanks very much. > > Chintha Handapangoda. > > > > ___ meep-discuss mailing list meep-discuss@ab-initio.mit.edu http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss
[Meep-discuss] Use of custom_src_time function
Dear All, 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 (*func) (double t, void *), void *data, double st, double et). What information is passed as the second argument (void *data) to this function? Thanks very much. Chintha Handapangoda. ___ meep-discuss mailing list meep-discuss@ab-initio.mit.edu http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss