/ / /
| 782 | /***************************************************************/ |
| 783 | /***************************************************************/ |
| 784 | std::vector<double> fields::get_array_metadata(const volume &where) { |
| 785 | if (where.dim == Dcyl) |
| 786 | meep::abort("get_array_metadata does not support cylindrical coordinates."); |
| 787 | |
| 788 | /* get extremal corners of subgrid and array of weights, collapsed if necessary */ |
| 789 | size_t dims[3]; |
| 790 | direction dirs[3]; |
| 791 | vec min_max_loc[2]; // extremal points in subgrid |
| 792 | get_array_slice_dimensions(where, dims, dirs, true, false, min_max_loc); |
| 793 | |
| 794 | realnum *weights = get_array_slice(where, NO_COMPONENT); |
| 795 | |
| 796 | /* get length and endpoints of x,y,z tics arrays */ |
| 797 | size_t nxyz[3] = {1, 1, 1}; |
| 798 | double xyzmin[3] = {0.0, 0.0, 0.0}, xyzmax[3] = {0.0, 0.0, 0.0}; |
| 799 | for (int nd = 0, rr = 0; nd < 3; ++nd) { |
| 800 | direction d = direction(nd); |
| 801 | if (where.in_direction(d) == 0.0) { |
| 802 | xyzmin[nd] = xyzmax[nd] = where.in_direction_min(d); |
| 803 | nxyz[nd] = 1; |
| 804 | } |
| 805 | else { |
| 806 | nxyz[nd] = dims[rr++]; |
| 807 | xyzmin[nd] = min_max_loc[0].in_direction(d); |
| 808 | xyzmax[nd] = min_max_loc[1].in_direction(d); |
| 809 | } |
| 810 | } |
| 811 | |
| 812 | /* pack all data into a single vector with each tics array preceded by its */ |
| 813 | /* length: [ NX, xtics[:], NY, ytics[:], NZ, ztics[:], weights[:] ] */ |
| 814 | std::vector<double> xyzw; |
| 815 | for (int nd = 0; nd < 3; nd++) { |
| 816 | xyzw.push_back((double)nxyz[nd]); |
| 817 | for (size_t n = 0; n < nxyz[nd]; n++) |
| 818 | xyzw.push_back(xyzmin[nd] + n * gv.inva); |
| 819 | } |
| 820 | for (unsigned nw = 0; nw < (nxyz[0] * nxyz[1] * nxyz[2]); nw++) |
| 821 | xyzw.push_back(weights[nw]); |
| 822 | |
| 823 | delete[] weights; |
| 824 | return xyzw; |
| 825 | |
| 826 | } // get_array_metadata |
| 827 | |
| 828 | } // namespace meep |