/ precisely one of fun, rfun, should be non-NULL */ /
| 605 | /* precisely one of fun, rfun, should be non-NULL */ |
| 606 | /**********************************************************************/ |
| 607 | void *fields::do_get_array_slice(const volume &where, std::vector<component> components, |
| 608 | field_function fun, field_rfunction rfun, void *fun_data, |
| 609 | void *vslice, double frequency, bool snap) { |
| 610 | am_now_working_on(FieldOutput); |
| 611 | |
| 612 | /***************************************************************/ |
| 613 | /* call get_array_slice_dimensions to get slice dimensions and */ |
| 614 | /* partially initialze an array_slice_data struct */ |
| 615 | /***************************************************************/ |
| 616 | size_t dims[3]; |
| 617 | direction dirs[3]; |
| 618 | array_slice_data data; |
| 619 | int rank = get_array_slice_dimensions(where, dims, dirs, false, snap, 0, &data); |
| 620 | size_t slice_size = data.slice_size; |
| 621 | bool complex_data = (rfun == 0); |
| 622 | int elem_size = complex_data ? 2 : 1; |
| 623 | void *vslice_uncollapsed; |
| 624 | |
| 625 | vslice_uncollapsed = |
| 626 | memset(new realnum[slice_size * elem_size], 0, slice_size * elem_size * sizeof(realnum)); |
| 627 | |
| 628 | data.vslice = vslice_uncollapsed; |
| 629 | data.snap = snap; |
| 630 | data.fun = fun; |
| 631 | data.rfun = rfun; |
| 632 | data.fun_data = fun_data; |
| 633 | data.components = components; |
| 634 | data.frequency = frequency; |
| 635 | int num_components = components.size(); |
| 636 | data.cS = new component[num_components]; |
| 637 | data.ph = new complex<double>[num_components]; |
| 638 | data.fields = new complex<realnum>[num_components]; |
| 639 | data.offsets = new ptrdiff_t[2 * num_components]; |
| 640 | memset(data.offsets, 0, 2 * num_components * sizeof(ptrdiff_t)); |
| 641 | data.empty_dim[0] = data.empty_dim[1] = data.empty_dim[2] = data.empty_dim[3] = |
| 642 | data.empty_dim[4] = false; |
| 643 | LOOP_OVER_DIRECTIONS(where.dim, d) { data.empty_dim[d] = where.in_direction(d) == 0; } |
| 644 | |
| 645 | /* compute inverse-epsilon directions for computing Dielectric fields */ |
| 646 | data.ninveps = 0; |
| 647 | bool needs_dielectric = false; |
| 648 | for (int i = 0; i < num_components; ++i) |
| 649 | if (components[i] == Dielectric) { |
| 650 | needs_dielectric = true; |
| 651 | break; |
| 652 | } |
| 653 | if (needs_dielectric) FOR_ELECTRIC_COMPONENTS(c) if (gv.has_field(c)) { |
| 654 | if (data.ninveps == 3) meep::abort("more than 3 field components??"); |
| 655 | data.inveps_cs[data.ninveps] = c; |
| 656 | data.inveps_ds[data.ninveps] = component_direction(c); |
| 657 | ++data.ninveps; |
| 658 | } |
| 659 | |
| 660 | /* compute inverse-mu directions for computing Permeability fields */ |
| 661 | data.ninvmu = 0; |
| 662 | bool needs_permeability = false; |
| 663 | for (int i = 0; i < num_components; ++i) |
| 664 | if (components[i] == Permeability) { |
nothing calls this directly
no test coverage detected