MCPcopy Create free account
hub / github.com/NanoComp/meep / alloc_f

Method alloc_f

src/fields.cpp:480–504  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

478// since only require_component knows what other field components
479// need to be allocated in addition to c
480bool 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

Callers 1

FOR_COMPONENTSFunction · 0.80

Calls 5

ifFunction · 0.85
is_magneticFunction · 0.85
direction_componentFunction · 0.85
component_directionFunction · 0.85
ntotMethod · 0.80

Tested by

no test coverage detected