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

Function fields_to_array

src/cw_fields.cpp:25–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23namespace meep {
24
25static void fields_to_array(const fields &f, complex<realnum> *x) {
26 size_t ix = 0;
27 for (int i = 0; i < f.num_chunks; i++)
28 if (f.chunks[i]->is_mine()) FOR_COMPONENTS(c) {
29 if (is_D(c) || is_B(c)) {
30 realnum *fr, *fi;
31#define COPY_FROM_FIELD(fld) \
32 if ((fr = f.chunks[i]->fld[0]) && (fi = f.chunks[i]->fld[1])) \
33 LOOP_OVER_VOL_OWNED(f.chunks[i]->gv, c, idx) \
34 x[ix++] = complex<double>(fr[idx], fi[idx]);
35 COPY_FROM_FIELD(f[c]);
36 COPY_FROM_FIELD(f_u[c]);
37 COPY_FROM_FIELD(f_cond[c]);
38 COPY_FROM_FIELD(f_bfast[c]);
39 component c2 = field_type_component(is_D(c) ? E_stuff : H_stuff, c);
40 COPY_FROM_FIELD(f_w[c2]);
41 if (f.chunks[i]->f_w[c2][0]) COPY_FROM_FIELD(f[c2]);
42#undef COPY_FROM_FIELD
43 }
44 }
45}
46
47static void array_to_fields(const complex<realnum> *x, fields &f) {
48 size_t ix = 0;

Callers 2

fieldopFunction · 0.85
solve_cwMethod · 0.85

Calls 5

is_DFunction · 0.85
is_BFunction · 0.85
field_type_componentFunction · 0.85
FOR_COMPONENTSFunction · 0.70
is_mineMethod · 0.45

Tested by

no test coverage detected