Given zero or more step functions, modifies any output functions among them to only output a subset (or a superset) of the cell, corresponding to the `meep::volume* v` (created by the `Volume` function).
(v, *step_funcs)
| 5209 | |
| 5210 | |
| 5211 | def in_volume(v, *step_funcs): |
| 5212 | """ |
| 5213 | Given zero or more step functions, modifies any output functions among them to only |
| 5214 | output a subset (or a superset) of the cell, corresponding to the `meep::volume* v` |
| 5215 | (created by the `Volume` function). |
| 5216 | """ |
| 5217 | closure = {"cur_eps": ""} |
| 5218 | |
| 5219 | def _in_volume(sim, todo): |
| 5220 | v_save = sim.output_volume |
| 5221 | eps_save = sim.last_eps_filename |
| 5222 | |
| 5223 | sim.output_volume = sim._fit_volume_to_simulation(v).swigobj |
| 5224 | |
| 5225 | if closure["cur_eps"]: |
| 5226 | sim.last_eps_filename = closure["cur_eps"] |
| 5227 | for func in step_funcs: |
| 5228 | _eval_step_func(sim, func, todo) |
| 5229 | |
| 5230 | closure["cur_eps"] = sim.last_eps_filename |
| 5231 | sim.output_volume = v_save |
| 5232 | if eps_save: |
| 5233 | sim.last_eps_filename = eps_save |
| 5234 | |
| 5235 | return _in_volume |
| 5236 | |
| 5237 | |
| 5238 | def in_point(pt, *step_funcs): |