From d872b62a08768929c845559ac696403061d3b25b Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Wed, 17 Apr 2019 13:50:41 -0400 Subject: [PATCH] run clang-format --- python/typemap_utils.cpp | 4 +- src/anisotropic_averaging.cpp | 4 +- src/array_slice.cpp | 147 +++++++++++++++++----------------- src/dft.cpp | 71 ++++++++-------- src/meep.hpp | 40 ++++----- src/meep/vec.hpp | 6 +- src/meepgeom.cpp | 6 +- src/monitor.cpp | 9 ++- src/near2far.cpp | 21 ++--- tests/array-metadata.cpp | 2 +- tests/cylindrical.cpp | 4 +- 11 files changed, 157 insertions(+), 157 deletions(-) diff --git a/python/typemap_utils.cpp b/python/typemap_utils.cpp index af093874d..dc0b2e253 100644 --- a/python/typemap_utils.cpp +++ b/python/typemap_utils.cpp @@ -407,9 +407,7 @@ static int pymaterial_to_material(PyObject *po, material_type *mt) { PyObject *eps = PyObject_GetAttrString(po, "eps"); PyObject *py_do_averaging = PyObject_GetAttrString(po, "do_averaging"); bool do_averaging = false; - if (py_do_averaging) { - do_averaging = PyObject_IsTrue(py_do_averaging); - } + if (py_do_averaging) { do_averaging = PyObject_IsTrue(py_do_averaging); } if (eps && eps == Py_True) { md = make_user_material(py_epsilon_func_wrap, po, do_averaging); } else { diff --git a/src/anisotropic_averaging.cpp b/src/anisotropic_averaging.cpp index 0fb433862..f10364439 100644 --- a/src/anisotropic_averaging.cpp +++ b/src/anisotropic_averaging.cpp @@ -56,9 +56,7 @@ vec material_function::normal_vector(field_type ft, const volume &v) { double chi1p1_val = chi1p1(ft, pt); if (i > 0 && i < min_iters) { - if (chi1p1_val != chi1p1_prev) { - break_early = false; - } + if (chi1p1_val != chi1p1_prev) { break_early = false; } if (i == min_iters - 1 && break_early) { // Don't average regions where epsilon is uniform return zero_vec(v.dim); diff --git a/src/array_slice.cpp b/src/array_slice.cpp index c08ec55e8..47bb510b1 100644 --- a/src/array_slice.cpp +++ b/src/array_slice.cpp @@ -123,14 +123,14 @@ static void get_array_slice_dimensions_chunkloop(fields_chunk *fc, int ichnk, co data->num_chunks++; if (data->min_max_loc) { - vec rshift(shift * (0.5 * fc->gv.inva)); - LOOP_OVER_IVECS(fc->gv, is, ie, idx) { - IVEC_LOOP_LOC(fc->gv, loc); - loc = S.transform(loc, sn) + rshift; - data->min_max_loc[0] = min(loc, data->min_max_loc[0]); - data->min_max_loc[1] = max(loc, data->min_max_loc[1]); - } - } + vec rshift(shift * (0.5 * fc->gv.inva)); + LOOP_OVER_IVECS(fc->gv, is, ie, idx) { + IVEC_LOOP_LOC(fc->gv, loc); + loc = S.transform(loc, sn) + rshift; + data->min_max_loc[0] = min(loc, data->min_max_loc[0]); + data->min_max_loc[1] = max(loc, data->min_max_loc[1]); + } + } } /*****************************************************************/ @@ -167,13 +167,13 @@ void fill_chunk_source_slice(fields_chunk *fc, array_slice_data *data) { ivec iloc = fc->gv.iloc(Dielectric, chunk_index); bool skip = false; LOOP_OVER_DIRECTIONS(iloc.dim, d) { - if(iloc.in_direction(d) < slice_imin.in_direction(d) || - iloc.in_direction(d) > slice_imax.in_direction(d)) { + if (iloc.in_direction(d) < slice_imin.in_direction(d) || + iloc.in_direction(d) > slice_imax.in_direction(d)) { skip = true; break; } } - if (skip) continue; // source point outside slice + if (skip) continue; // source point outside slice ivec slice_offset = iloc - slice_imin; ptrdiff_t slice_index = 0; if (has_direction(dim, Z)) slice_index += slice_offset.in_direction(Z) / 2; @@ -312,9 +312,8 @@ static void get_array_slice_chunkloop(fields_chunk *fc, int ichnk, component cgr for (int i = 0; i < num_components; ++i) { // special case for fetching grid point coordinates and weights if (cS[i] == NO_COMPONENT) { - fields[i] = IVEC_LOOP_WEIGHT(s0, s1, e0, e1, dV0 + dV1 * loop_i2); - } - else if (cS[i] == Dielectric) { + fields[i] = IVEC_LOOP_WEIGHT(s0, s1, e0, e1, dV0 + dV1 * loop_i2); + } else if (cS[i] == Dielectric) { double tr = 0.0; for (int k = 0; k < data->ninveps; ++k) { const realnum *ie = fc->s->chi1inv[iecs[k]][ieds[k]]; @@ -375,8 +374,7 @@ static void get_array_slice_chunkloop(fields_chunk *fc, int ichnk, component cgr /* get_array_slice. */ /***************************************************************/ int fields::get_array_slice_dimensions(const volume &where, size_t dims[3], direction dirs[3], - bool collapse_empty_dimensions, - bool snap_empty_dimensions, + bool collapse_empty_dimensions, bool snap_empty_dimensions, vec *min_max_loc, void *caller_data) { am_now_working_on(FieldOutput); @@ -391,25 +389,24 @@ int fields::get_array_slice_dimensions(const volume &where, size_t dims[3], dire data->min_max_loc = min_max_loc; vec *min_loc = 0, *max_loc = 0; - if (min_max_loc) - { min_loc = min_max_loc + 0; - max_loc = min_max_loc + 1; - LOOP_OVER_DIRECTIONS(gv.dim,d) { - min_loc->set_direction(d,+infinity); - max_loc->set_direction(d,-infinity); - } + if (min_max_loc) { + min_loc = min_max_loc + 0; + max_loc = min_max_loc + 1; + LOOP_OVER_DIRECTIONS(gv.dim, d) { + min_loc->set_direction(d, +infinity); + max_loc->set_direction(d, -infinity); } + } bool use_symmetry = true; - loop_in_chunks(get_array_slice_dimensions_chunkloop, (void *)data, where, Centered, - use_symmetry, snap_empty_dimensions); + loop_in_chunks(get_array_slice_dimensions_chunkloop, (void *)data, where, Centered, use_symmetry, + snap_empty_dimensions); data->min_corner = -max_to_all(-data->min_corner); // i.e., min_to_all data->max_corner = max_to_all(data->max_corner); - if (min_max_loc) - LOOP_OVER_DIRECTIONS(gv.dim,d) { - min_loc->set_direction(d, -1.0*max_to_all(-1.0*min_loc->in_direction(d))); - max_loc->set_direction(d, max_to_all( max_loc->in_direction(d))); + if (min_max_loc) LOOP_OVER_DIRECTIONS(gv.dim, d) { + min_loc->set_direction(d, -1.0 * max_to_all(-1.0 * min_loc->in_direction(d))); + max_loc->set_direction(d, max_to_all(max_loc->in_direction(d))); } data->num_chunks = sum_to_all(data->num_chunks); if (data->num_chunks == 0 || !(data->min_corner <= data->max_corner)) @@ -617,7 +614,8 @@ bool increment(size_t *n, size_t *nMax, int rank) { } // data_size = 1,2 for real,complex-valued array -double *collapse_array(double *array, int *rank, size_t dims[3], direction dirs[3], volume where, int data_size=1) { +double *collapse_array(double *array, int *rank, size_t dims[3], direction dirs[3], volume where, + int data_size = 1) { /*--------------------------------------------------------------*/ /*- detect empty dimensions and compute rank and strides for */ @@ -629,13 +627,13 @@ double *collapse_array(double *array, int *rank, size_t dims[3], direction dirs[ int reduced_rank = 0; size_t reduced_dims[3], reduced_stride[3] = {1, 1, 1}; direction reduced_dirs[3]; - for(int r=0; r fields::get_array_metadata(const volume &where, - bool collapse_empty_dimensions, +std::vector fields::get_array_metadata(const volume &where, bool collapse_empty_dimensions, bool snap_empty_dimensions) { /* get extremal corners of subgrid and array of weights, collapsed if necessary */ size_t dims[3]; direction dirs[3]; - vec min_max_loc[2]; // extremal points in subgrid + vec min_max_loc[2]; // extremal points in subgrid int rank = get_array_slice_dimensions(where, dims, dirs, false /*collapse_empty_dimensions*/, snap_empty_dimensions, min_max_loc); - int full_rank=rank; + int full_rank = rank; direction full_dirs[3]; - for(int fr=0; fr xyzw; - for(int nd=0; nd<3; nd++) - { xyzw.push_back( (double)nxyz[nd] ); - for(size_t n=0; ngv.inva)); int chunk_idx = 0; cdouble integral = 0.0; - component c_conjugate = (component)(ic_conjugate>=0 ? ic_conjugate : -ic_conjugate); + component c_conjugate = (component)(ic_conjugate >= 0 ? ic_conjugate : -ic_conjugate); LOOP_OVER_IVECS(fc->gv, is, ie, idx) { IVEC_LOOP_LOC(fc->gv, loc); loc = S.transform(loc, sn) + rshift; double w = IVEC_LOOP_WEIGHT(s0, s1, e0, e1, dV0 + dV1 * loop_i2); double interp_w = retain_interp_weights ? IVEC_LOOP_WEIGHT(s0i, s1i, e0i, e1i, 1.0) : 1.0; - cdouble dft_val = ( c_conjugate==NO_COMPONENT ? w - : c_conjugate==Dielectric ? parent->get_eps(loc) - : c_conjugate==Permeability ? parent->get_mu(loc) - : dft[Nomega * (chunk_idx++) + num_freq] / stored_weight - ); + cdouble dft_val = (c_conjugate == NO_COMPONENT + ? w + : c_conjugate == Dielectric + ? parent->get_eps(loc) + : c_conjugate == Permeability + ? parent->get_mu(loc) + : dft[Nomega * (chunk_idx++) + num_freq] / stored_weight); if (include_dV_and_interp_weights) dft_val /= (sqrt_dV_and_interp_weights ? sqrt(w) : w); cdouble mode1val = 0.0, mode2val = 0.0; @@ -845,19 +846,19 @@ cdouble dft_chunk::process_dft_component(int rank, direction *ds, ivec min_corne /***************************************************************/ cdouble fields::process_dft_component(dft_chunk **chunklists, int num_chunklists, int num_freq, component c, const char *HDF5FileName, cdouble **pfield_array, - int *array_rank, size_t *array_dims, direction *array_dirs, void *mode1_data, - void *mode2_data, component c_conjugate, + int *array_rank, size_t *array_dims, direction *array_dirs, + void *mode1_data, void *mode2_data, component c_conjugate, bool *first_component, bool retain_interp_weights) { /***************************************************************/ /***************************************************************/ /***************************************************************/ - int ic_conjugate = (int) c_conjugate; - if (component_index(c)==-1) - { ic_conjugate = -((int)c); - num_chunklists=1; - c=chunklists[0]->c; - } + int ic_conjugate = (int)c_conjugate; + if (component_index(c) == -1) { + ic_conjugate = -((int)c); + num_chunklists = 1; + c = chunklists[0]->c; + } /***************************************************************/ /* get statistics on the volume slice **************************/ @@ -940,9 +941,9 @@ cdouble fields::process_dft_component(dft_chunk **chunklists, int num_chunklists for (int ncl = 0; ncl < num_chunklists; ncl++) for (dft_chunk *chunk = chunklists[ncl]; chunk; chunk = chunk->next_in_dft) if (chunk->c == c) - overlap += - chunk->process_dft_component(rank, ds, min_corner, max_corner, num_freq, file, buffer, - reim, field_array, mode1_data, mode2_data, ic_conjugate, retain_interp_weights, this); + overlap += chunk->process_dft_component(rank, ds, min_corner, max_corner, num_freq, file, + buffer, reim, field_array, mode1_data, mode2_data, + ic_conjugate, retain_interp_weights, this); if (HDF5FileName) { file->done_writing_chunks(); @@ -981,7 +982,8 @@ cdouble fields::process_dft_component(dft_chunk **chunklists, int num_chunklists /***************************************************************/ cdouble *collapse_array(cdouble *array, int *rank, size_t dims[3], direction dirs[3], volume where); -cdouble *fields::get_dft_array(dft_flux flux, component c, int num_freq, int *rank, size_t dims[3]) { +cdouble *fields::get_dft_array(dft_flux flux, component c, int num_freq, int *rank, + size_t dims[3]) { dft_chunk *chunklists[2]; chunklists[0] = flux.E; chunklists[1] = flux.H; @@ -991,7 +993,8 @@ cdouble *fields::get_dft_array(dft_flux flux, component c, int num_freq, int *ra return collapse_array(array, rank, dims, dirs, flux.where); } -cdouble *fields::get_dft_array(dft_force force, component c, int num_freq, int *rank, size_t dims[3]) { +cdouble *fields::get_dft_array(dft_force force, component c, int num_freq, int *rank, + size_t dims[3]) { dft_chunk *chunklists[3]; chunklists[0] = force.offdiag1; chunklists[1] = force.offdiag2; @@ -1002,7 +1005,8 @@ cdouble *fields::get_dft_array(dft_force force, component c, int num_freq, int * return collapse_array(array, rank, dims, dirs, force.where); } -cdouble *fields::get_dft_array(dft_near2far n2f, component c, int num_freq, int *rank, size_t dims[3]) { +cdouble *fields::get_dft_array(dft_near2far n2f, component c, int num_freq, int *rank, + size_t dims[3]) { dft_chunk *chunklists[1]; chunklists[0] = n2f.F; cdouble *array; @@ -1011,7 +1015,8 @@ cdouble *fields::get_dft_array(dft_near2far n2f, component c, int num_freq, int return collapse_array(array, rank, dims, dirs, n2f.where); } -cdouble *fields::get_dft_array(dft_fields fdft, component c, int num_freq, int *rank, size_t dims[3]) { +cdouble *fields::get_dft_array(dft_fields fdft, component c, int num_freq, int *rank, + size_t dims[3]) { dft_chunk *chunklists[1]; chunklists[0] = fdft.chunks; cdouble *array; @@ -1041,8 +1046,7 @@ void fields::output_dft_components(dft_chunk **chunklists, int num_chunklists, v // in which case those processes will think NumFreqs==0. bool have_empty_dims = false; LOOP_OVER_DIRECTIONS(dft_volume.dim, d) - if (dft_volume.in_direction(d)!=0.0) - have_empty_dims = true; + if (dft_volume.in_direction(d) != 0.0) have_empty_dims = true; h5file *file = 0; if (have_empty_dims && am_master()) { @@ -1056,18 +1060,19 @@ void fields::output_dft_components(dft_chunk **chunklists, int num_chunklists, v for (int num_freq = 0; num_freq < NumFreqs; num_freq++) FOR_E_AND_H(c) { if (!have_empty_dims) { - process_dft_component(chunklists, num_chunklists, num_freq, c, HDF5FileName, 0, 0, 0, 0, 0, 0, - Ex, &first_component); + process_dft_component(chunklists, num_chunklists, num_freq, c, HDF5FileName, 0, 0, 0, 0, 0, + 0, Ex, &first_component); } else { cdouble *array = 0; int rank; size_t dims[3]; direction dirs[3]; - process_dft_component(chunklists, num_chunklists, num_freq, c, 0, &array, &rank, dims, dirs); + process_dft_component(chunklists, num_chunklists, num_freq, c, 0, &array, &rank, dims, + dirs); if (rank > 0 && am_master()) { array = collapse_array(array, &rank, dims, dirs, dft_volume); if (rank == 0) abort("%s:%i: internal error", __FILE__, __LINE__); - size_t array_size = dims[0] * (rank>=2 ? dims[1] * (rank==3 ? dims[2] : 1) : 1); + size_t array_size = dims[0] * (rank >= 2 ? dims[1] * (rank == 3 ? dims[2] : 1) : 1); double *real_array = new double[array_size]; if (!real_array) abort("%s:%i:out of memory(%lu)", __FILE__, __LINE__, array_size); for (int reim = 0; reim < 2; reim++) { diff --git a/src/meep.hpp b/src/meep.hpp index f4e2543cf..c781facdf 100644 --- a/src/meep.hpp +++ b/src/meep.hpp @@ -719,8 +719,8 @@ class structure { void load_chunk_layout(const std::vector &gvs, boundary_region &br); // monitor.cpp - double get_chi1inv(component, direction, const ivec &origloc, bool parallel=true) const; - double get_chi1inv(component, direction, const vec &loc, bool parallel=true) const; + double get_chi1inv(component, direction, const ivec &origloc, bool parallel = true) const; + double get_chi1inv(component, direction, const vec &loc, bool parallel = true) const; double get_inveps(component c, direction d, const ivec &origloc) const { return get_chi1inv(c, d, origloc); } @@ -943,7 +943,8 @@ class dft_chunk { ivec max_corner, int num_freq, h5file *file, double *buffer, int reim, std::complex *field_array, void *mode1_data, - void *mode2_data, int ic_conjugate, bool retain_interp_weights, fields *parent); + void *mode2_data, int ic_conjugate, + bool retain_interp_weights, fields *parent); void operator-=(const dft_chunk &chunk); @@ -998,7 +999,7 @@ class dft_chunk { ivec is, ie; vec s0, s1, e0, e1; double dV0, dV1; - bool empty_dim[5]; // which directions correspond to empty dimensions in original volume + bool empty_dim[5]; // which directions correspond to empty dimensions in original volume std::complex scale; // scale factor * phase from shift and symmetry ivec shift; symmetry S; @@ -1118,8 +1119,8 @@ class dft_near2far { /* fourier tranforms of tangential E and H field components in a medium with the given scalar eps and mu */ dft_near2far(dft_chunk *F, double fmin, double fmax, int Nf, double eps, double mu, - const volume &where_, const direction periodic_d_[2], - const int periodic_n_[2], const double periodic_k_[2], const double period_[2]); + const volume &where_, const direction periodic_d_[2], const int periodic_n_[2], + const double periodic_k_[2], const double period_[2]); dft_near2far(const dft_near2far &f); /* return an array (Ex,Ey,Ez,Hx,Hy,Hz) x Nfreq of the far fields at x */ @@ -1557,11 +1558,11 @@ class fields { field_function fun, field_rfunction rfun, void *fun_data, void *vslice, component source_slice_component = Ex, bool get_source_slice = false); - /* fetch and return coordinates and integration weights of grid points covered by an array slice, */ - /* packed into a vector with format [NX, xtics[:], NY, ytics[:], NZ, ztics[:], weights[:] ] */ - std::vector get_array_metadata(const volume &where, - bool collapse_empty_dimensions=true, - bool snap_empty_dimensions=false); + /* fetch and return coordinates and integration weights of grid points covered by an array slice, + */ + /* packed into a vector with format [NX, xtics[:], NY, ytics[:], NZ, ztics[:], weights[:] ] */ + std::vector get_array_metadata(const volume &where, bool collapse_empty_dimensions = true, + bool snap_empty_dimensions = false); // step.cpp methods: double last_step_output_wall_time; @@ -1691,9 +1692,10 @@ class fields { std::complex process_dft_component(dft_chunk **chunklists, int num_chunklists, int num_freq, component c, const char *HDF5FileName, std::complex **field_array = 0, int *rank = 0, - size_t *dims = 0, direction *dirs=0, void *mode1_data = 0, - void *mode2_data = 0, component c_conjugate = Ex, - bool *first_component = 0, bool retain_interp_weights=true); + size_t *dims = 0, direction *dirs = 0, + void *mode1_data = 0, void *mode2_data = 0, + component c_conjugate = Ex, bool *first_component = 0, + bool retain_interp_weights = true); // output DFT fields to HDF5 file void output_dft_components(dft_chunk **chunklists, int num_chunklists, volume dft_volume, @@ -1730,9 +1732,9 @@ class fields { // near2far.cpp dft_near2far add_dft_near2far(const volume_list *where, double freq_min, double freq_max, - int Nfreq, int Nperiods=1); + int Nfreq, int Nperiods = 1); // monitor.cpp - double get_chi1inv(component, direction, const vec &loc, bool parallel=true) const; + double get_chi1inv(component, direction, const vec &loc, bool parallel = true) const; double get_inveps(component c, direction d, const vec &loc) const { return get_chi1inv(c, d, loc); } @@ -1742,7 +1744,7 @@ class fields { monitor_point *get_new_point(const vec &, monitor_point *p = NULL) const; std::complex get_field(int c, const vec &loc) const; - std::complex get_field(component c, const vec &loc, bool parallel=true) const; + std::complex get_field(component c, const vec &loc, bool parallel = true) const; double get_field(derived_component c, const vec &loc) const; // energy_and_flux.cpp @@ -1821,8 +1823,8 @@ class fields { public: // monitor.cpp - std::complex get_field(component c, const ivec &iloc, bool parallel=true) const; - double get_chi1inv(component, direction, const ivec &iloc, bool parallel=true) const; + std::complex get_field(component c, const ivec &iloc, bool parallel = true) const; + double get_chi1inv(component, direction, const ivec &iloc, bool parallel = true) const; // boundaries.cpp bool locate_component_point(component *, ivec *, std::complex *) const; }; diff --git a/src/meep/vec.hpp b/src/meep/vec.hpp index 4f743430b..697c59770 100644 --- a/src/meep/vec.hpp +++ b/src/meep/vec.hpp @@ -385,8 +385,8 @@ inline direction component_direction(component c) { case Hp: case Dp: case Bp: return P; - case Dielectric: - case Permeability: + case Dielectric: + case Permeability: case NO_COMPONENT: return NO_DIRECTION; } return X; // This code is never reached... @@ -420,7 +420,7 @@ inline component direction_component(component c, direction d) { start_point = Dx; else if (is_B(c)) start_point = Bx; - else if (d == NO_DIRECTION && component_direction(c)==d) + else if (d == NO_DIRECTION && component_direction(c) == d) return c; else abort("unknown field component %d", c); diff --git a/src/meepgeom.cpp b/src/meepgeom.cpp index 0f67d74ea..3c2ad82dd 100644 --- a/src/meepgeom.cpp +++ b/src/meepgeom.cpp @@ -686,12 +686,12 @@ void geom_epsilon::eff_chi1inv_row(meep::component c, double chi1inv_row[3], con double tol, int maxeval) { symmetric_matrix meps_inv; bool fallback; - eff_chi1inv_matrix(c, &meps_inv, v, tol, maxeval, fallback);; + eff_chi1inv_matrix(c, &meps_inv, v, tol, maxeval, fallback); + ; if (fallback) { fallback_chi1inv_row(c, chi1inv_row, v, tol, maxeval); - } - else { + } else { switch (component_direction(c)) { case meep::X: case meep::R: diff --git a/src/monitor.cpp b/src/monitor.cpp index 729a111f8..68a3089ef 100644 --- a/src/monitor.cpp +++ b/src/monitor.cpp @@ -147,7 +147,7 @@ complex fields::get_field(component c, const ivec &origloc, bool paralle for (int i = 0; i < num_chunks; i++) if (chunks[i]->gv.owns(S.transform(iloc, sn))) { complex val = S.phase_shift(c, sn) * kphase * - chunks[i]->get_field(S.transform(c, sn), S.transform(iloc, sn)); + chunks[i]->get_field(S.transform(c, sn), S.transform(iloc, sn)); return parallel ? sum_to_all(val) : val; } return 0.0; @@ -178,7 +178,7 @@ double fields::get_chi1inv(component c, direction d, const ivec &origloc, bool p double fields_chunk::get_chi1inv(component c, direction d, const ivec &iloc) const { if (is_mine()) return s->chi1inv[c][d] ? s->chi1inv[c][d][gv.index(c, iloc)] - : (d == component_direction(c) ? 1.0 : 0); + : (d == component_direction(c) ? 1.0 : 0); return 0.0; } @@ -222,7 +222,7 @@ double structure::get_chi1inv(component c, direction d, const ivec &origloc, boo if (chunks[i]->gv.owns(S.transform(iloc, sn))) { signed_direction ds = S.transform(d, sn); double val = chunks[i]->get_chi1inv(S.transform(c, sn), ds.d, S.transform(iloc, sn)) * - (ds.flipped ^ S.transform(component_direction(c), sn).flipped ? -1 : 1); + (ds.flipped ^ S.transform(component_direction(c), sn).flipped ? -1 : 1); return parallel ? sum_to_all(val) : val; } return 0.0; @@ -230,7 +230,8 @@ double structure::get_chi1inv(component c, direction d, const ivec &origloc, boo double structure_chunk::get_chi1inv(component c, direction d, const ivec &iloc) const { if (is_mine()) - return chi1inv[c][d] ? chi1inv[c][d][gv.index(c, iloc)] : (d == component_direction(c) ? 1.0 : 0); + return chi1inv[c][d] ? chi1inv[c][d][gv.index(c, iloc)] + : (d == component_direction(c) ? 1.0 : 0); return 0.0; } diff --git a/src/near2far.cpp b/src/near2far.cpp index 576e3d70c..01ecbeb63 100644 --- a/src/near2far.cpp +++ b/src/near2far.cpp @@ -31,7 +31,8 @@ namespace meep { dft_near2far::dft_near2far(dft_chunk *F_, double fmin, double fmax, int Nf, double eps_, double mu_, const volume &where_, const direction periodic_d_[2], - const int periodic_n_[2], const double periodic_k_[2], const double period_[2]) + const int periodic_n_[2], const double periodic_k_[2], + const double period_[2]) : Nfreq(Nf), F(F_), eps(eps_), mu(mu_), where(where_) { if (Nf <= 1) fmin = fmax = (fmin + fmax) * 0.5; freq_min = fmin; @@ -258,12 +259,12 @@ void dft_near2far::farfield_lowlevel(std::complex *EH, const vec &x) { vec xs(x0); for (int i0 = -periodic_n[0]; i0 <= periodic_n[0]; ++i0) { if (periodic_d[0] != NO_DIRECTION) - xs.set_direction(periodic_d[0], x0.in_direction(periodic_d[0]) + i0*period[0]); - double phase0 = i0*periodic_k[0]; + xs.set_direction(periodic_d[0], x0.in_direction(periodic_d[0]) + i0 * period[0]); + double phase0 = i0 * periodic_k[0]; for (int i1 = -periodic_n[1]; i1 <= periodic_n[1]; ++i1) { if (periodic_d[1] != NO_DIRECTION) - xs.set_direction(periodic_d[1], x0.in_direction(periodic_d[1]) + i1*period[1]); - double phase = phase0 + i1*periodic_k[1]; + xs.set_direction(periodic_d[1], x0.in_direction(periodic_d[1]) + i1 * period[1]); + double phase = phase0 + i1 * periodic_k[1]; std::complex cphase = std::polar(1.0, phase); green(EH6, x, freq, eps, mu, xs, c0, f->dft[Nfreq * idx_dft + i]); for (int j = 0; j < 6; ++j) @@ -498,13 +499,13 @@ dft_near2far fields::add_dft_near2far(const volume_list *where, double freq_min, if (Nperiods > 1) { for (int i = 0; i < 2; ++i) { double user_width = user_volume.num_direction(fd[i]) / a; - if (has_direction(v.dim, fd[i]) && - boundaries[High][fd[i]] == Periodic && boundaries[Low][fd[i]] == Periodic && + if (has_direction(v.dim, fd[i]) && boundaries[High][fd[i]] == Periodic && + boundaries[Low][fd[i]] == Periodic && float(w->v.in_direction(fd[i])) >= float(user_width)) { periodic_d[i] = fd[i]; periodic_n[i] = Nperiods; period[i] = user_width; - periodic_k[i] = 2*pi*real(k[fd[i]]) * period[i]; + periodic_k[i] = 2 * pi * real(k[fd[i]]) * period[i]; } } } @@ -524,8 +525,8 @@ dft_near2far fields::add_dft_near2far(const volume_list *where, double freq_min, } } - return dft_near2far(F, freq_min, freq_max, Nfreq, eps, mu, everywhere, - periodic_d, periodic_n, periodic_k, period); + return dft_near2far(F, freq_min, freq_max, Nfreq, eps, mu, everywhere, periodic_d, periodic_n, + periodic_k, period); } } // namespace meep diff --git a/tests/array-metadata.cpp b/tests/array-metadata.cpp index 2cb88bed1..3c22b0c18 100644 --- a/tests/array-metadata.cpp +++ b/tests/array-metadata.cpp @@ -83,7 +83,7 @@ bool test_array_metadata(meep::fields &f, const volume &where, bool collapse_emp size_t nxyz[3], nw = 1; vector tics[3], weights; for (int i = 0; i < 3; ++i) { - nxyz[i] = (size_t) xyzw[offset++]; + nxyz[i] = (size_t)xyzw[offset++]; nw *= nxyz[i]; for (size_t j = 0; j < nxyz[i]; ++j) tics[i].push_back(xyzw[offset++]); diff --git a/tests/cylindrical.cpp b/tests/cylindrical.cpp index 7ce8a54ee..7c74c1709 100644 --- a/tests/cylindrical.cpp +++ b/tests/cylindrical.cpp @@ -152,9 +152,7 @@ int test_simple_metallic(double eps(const vec &), int splitting, const char *myd return 1; } -static bool issmall(std::complex x) { - return abs(x) < 1e-16; -} +static bool issmall(std::complex x) { return abs(x) < 1e-16; } int test_r_equals_zero(double eps(const vec &), const char *mydirname) { double a = 10.0;