this function should ordinarily not be called directly; instead it should be called via require_component, since only require_component knows what other field components need to be allocated in addition to c
| 478 | // since only require_component knows what other field components |
| 479 | // need to be allocated in addition to c |
| 480 | bool fields_chunk::alloc_f(component c) { |
| 481 | bool changed = false; |
| 482 | if (is_mine()) DOCMP { |
| 483 | if (!f[c][cmp]) { |
| 484 | changed = true; |
| 485 | if (is_magnetic(c)) { |
| 486 | /* initially, we just set H == B ... later on, we lazily allocate |
| 487 | H fields if needed (if mu != 1 or in PML) in update_eh */ |
| 488 | component bc = direction_component(Bx, component_direction(c)); |
| 489 | if (!f[bc][cmp]) { |
| 490 | f[bc][cmp] = new realnum[gv.ntot()]; |
| 491 | for (size_t i = 0; i < gv.ntot(); i++) |
| 492 | f[bc][cmp][i] = 0.0; |
| 493 | } |
| 494 | f[c][cmp] = f[bc][cmp]; |
| 495 | } |
| 496 | else { |
| 497 | f[c][cmp] = new realnum[gv.ntot()]; |
| 498 | for (size_t i = 0; i < gv.ntot(); i++) |
| 499 | f[c][cmp][i] = 0.0; |
| 500 | } |
| 501 | } |
| 502 | } |
| 503 | return changed; |
| 504 | } |
| 505 | |
| 506 | // allocate fields for components required by any source on any process |
| 507 | // ... this is needed after calling the low-level fields::add_srcdata |
no test coverage detected