Refactor fields (and `flat.cc` in general)
Could optionally be done as part of !23 , or in a separate MR
Currently in flat.cc
there is a lot of repeated code, especially with the added fields, that as a first implementation were added as a completely separate line of functions from the rest.
The main steps I would do to refactor flat.cc
are:
- Remove
field_integrate
and just useintegrate
for both kinds of integration. - Do with
integrate
andreal_integrand
,real_modif_integrand
, etc. what is done in the fields functions, namely have a few flags that determines whether one wants the real or imag component for instance (as opposed to having 4 separate functions as now). See theif
statements infield_integrand_wrapper
for what I mean. An additional flag could choose whether to use an "impedance integrand" or a "field integrand" - One could probably unify
params
andfield_params
to one struct fairly easily. I would also anyway consider restructuring it a little, and adding smaller structs as members of theparams
struct, such as:
struct layers_params {
unsigned int N;
ap::template_1d_array< amp::campf<PRECISION> > eps1;
ap::template_1d_array< amp::campf<PRECISION> > mu1;
ap::template_1d_array< amp::campf<PRECISION> > nu2;
ap::template_1d_array< amp::campf<PRECISION> > eps1ratio;
ap::template_1d_array< amp::campf<PRECISION> > mu1ratio;
ap::template_1d_array< amp::campf<PRECISION> > nu2ratio;
ap::template_1d_array< amp::ampf<PRECISION> > b;
}
struct params {
...
layers_params upper_layer_params;
layers_params lower_layer_params;
...
}
I haven't looked much into it, but I would guess one could refactor etachi
and field_coefficients
a bit to reuse more code as well.