On May 17, 2010, at 10:42 AM, Mikkel Heuck wrote:
I am, however, in doubt about the "field_function" and also the
"*integrand_data_". The "field_function" apparently has the following
syntax (taken from the meep.hpp source code file):
typedef complex<double> (*field_function)(const complex<double>
*fields,
const vec &loc,
void *integrand_data_);
Does the pointer "*fields" refer to all the components Ex, Ey, Ez, Hx,
... of the fields, so that if I wanted to compute Ex*Ex I would write
fields[0]*fields[0]?
Regarding the "*integrand_data_" I have not been able to figure out,
what it refers to?
fields is a pointer to an array of all the field components you
requested. So, if the components array that you passed to
fields::integrate was {Ex,Ey,Hz}, then fields[0] contains the Ex value
at that point, fields[1] contains Ey, and fields[2] contains Ez.
integrand_data is a pointer to anything you want. Whatever pointer
you pass to fields::integrate for this parameter (typecast to void*)
gets passed to your function. The fields::integrate function itself
does nothing with this pointer except to pass it through to your
function. This is a standard technique in C/C++ to allow you to pass
arbitrary user data through to callback functions in a re-entrant way.
See also the documentation for the Scheme equivalent of the same thing:
http://ab-initio.mit.edu/wiki/index.php/Meep_field-function_examples
(Pass-through pointers like integrand_data are not needed in languages
like Scheme with true lexical scoping and closures.)
Steven
_______________________________________________
meep-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss