From e5b2c6b477ae517419c6f7be813a43c095838ee5 Mon Sep 17 00:00:00 2001 From: jingang Date: Fri, 14 Jun 2019 19:59:27 -0400 Subject: [PATCH] &name[0] -> name.data() --- src/initialize.cpp | 2 +- src/lattice.cpp | 6 +++--- src/mesh.cpp | 28 ++++++++++++++-------------- src/tallies/filter_legendre.cpp | 2 +- src/tallies/filter_mesh.cpp | 2 +- src/tallies/filter_sph_harm.cpp | 4 ++-- src/tallies/filter_sptl_legendre.cpp | 2 +- src/tallies/filter_zernike.cpp | 4 ++-- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/initialize.cpp b/src/initialize.cpp index fd524a2de9..8331c30b5d 100644 --- a/src/initialize.cpp +++ b/src/initialize.cpp @@ -102,7 +102,7 @@ void initialize_mpi(MPI_Comm intracomm) // Create bank datatype Particle::Bank b; MPI_Aint disp[6]; - MPI_Get_address(&b.r, &disp[0]); + MPI_Get_address(c&b.r, &disp[0]); MPI_Get_address(&b.u, &disp[1]); MPI_Get_address(&b.E, &disp[2]); MPI_Get_address(&b.wgt, &disp[3]); diff --git a/src/lattice.cpp b/src/lattice.cpp index 5e679042ad..42e15013d4 100644 --- a/src/lattice.cpp +++ b/src/lattice.cpp @@ -401,7 +401,7 @@ RectLattice::to_hdf5_inner(hid_t lat_group) const } hsize_t dims[3] {nz, ny, nx}; - write_int(lat_group, 3, dims, "universes", &out[0], false); + write_int(lat_group, 3, dims, "universes", out.data(), false); } else { hsize_t nx {static_cast(n_cells_[0])}; @@ -417,7 +417,7 @@ RectLattice::to_hdf5_inner(hid_t lat_group) const } hsize_t dims[3] {1, ny, nx}; - write_int(lat_group, 3, dims, "universes", &out[0], false); + write_int(lat_group, 3, dims, "universes", out.data(), false); } } @@ -897,7 +897,7 @@ HexLattice::to_hdf5_inner(hid_t lat_group) const } hsize_t dims[3] {nz, ny, nx}; - write_int(lat_group, 3, dims, "universes", &out[0], false); + write_int(lat_group, 3, dims, "universes", out.data(), false); } //============================================================================== diff --git a/src/mesh.cpp b/src/mesh.cpp index 075e58de24..01ad329b7a 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -183,11 +183,11 @@ int RegularMesh::get_bin(Position r) const // Determine indices std::vector ijk(n_dimension_); bool in_mesh; - get_indices(r, &ijk[0], &in_mesh); + get_indices(r, ijk.data(), &in_mesh); if (!in_mesh) return -1; // Convert indices to bin - return get_bin_from_indices(&ijk[0]); + return get_bin_from_indices(ijk.data()); } int RegularMesh::get_bin_from_indices(const int* ijk) const @@ -497,9 +497,9 @@ void RegularMesh::bins_crossed(const Particle* p, std::vector& bins, int n = n_dimension_; std::vector ijk0(n), ijk1(n); bool start_in_mesh; - get_indices(r0, &ijk0[0], &start_in_mesh); + get_indices(r0, ijk0.data(), &start_in_mesh); bool end_in_mesh; - get_indices(r1, &ijk1[0], &end_in_mesh); + get_indices(r1, ijk1.data(), &end_in_mesh); // Reset coordinates and check for a mesh intersection if necessary. if (start_in_mesh) { @@ -509,7 +509,7 @@ void RegularMesh::bins_crossed(const Particle* p, std::vector& bins, // The initial coords do not lie in the mesh. Check to see if the particle // eventually intersects the mesh and compute the relevant coords and // indices. - if (!intersects(r0, r1, &ijk0[0])) return; + if (!intersects(r0, r1, ijk0.data())) return; } r1 = r; @@ -521,7 +521,7 @@ void RegularMesh::bins_crossed(const Particle* p, std::vector& bins, // The track ends in this cell. Use the particle end location rather // than the mesh surface and stop iterating. double distance = (r1 - r0).norm(); - bins.push_back(get_bin_from_indices(&ijk0[0])); + bins.push_back(get_bin_from_indices(ijk0.data())); lengths.push_back(distance / total_distance); break; } @@ -543,7 +543,7 @@ void RegularMesh::bins_crossed(const Particle* p, std::vector& bins, // Pick the closest mesh surface and append this traversal to the output. auto j = std::min_element(d.begin(), d.end()) - d.begin(); double distance = d[j]; - bins.push_back(get_bin_from_indices(&ijk0[0])); + bins.push_back(get_bin_from_indices(ijk0.data())); lengths.push_back(distance / total_distance); // Translate to the oncoming mesh surface. @@ -584,15 +584,15 @@ void RegularMesh::surface_bins_crossed(const Particle* p, int n = n_dimension_; std::vector ijk0(n), ijk1(n); bool start_in_mesh; - get_indices(r0, &ijk0[0], &start_in_mesh); + get_indices(r0, ijk0.data(), &start_in_mesh); bool end_in_mesh; - get_indices(r1, &ijk1[0], &end_in_mesh); + get_indices(r1, ijk1.data(), &end_in_mesh); // Check if the track intersects any part of the mesh. if (!start_in_mesh) { Position r0_copy = r0; std::vector ijk0_copy(ijk0); - if (!intersects(r0_copy, r1, &ijk0_copy[0])) return; + if (!intersects(r0_copy, r1, ijk0_copy.data())) return; } // ======================================================================== @@ -650,7 +650,7 @@ void RegularMesh::surface_bins_crossed(const Particle* p, // Outward current on i max surface if (in_mesh) { int i_surf = 4*i + 3; - int i_mesh = get_bin_from_indices(&ijk0[0]); + int i_mesh = get_bin_from_indices(ijk0.data()); int i_bin = 4*n*i_mesh + i_surf - 1; bins.push_back(i_bin); @@ -671,7 +671,7 @@ void RegularMesh::surface_bins_crossed(const Particle* p, // i min surface if (in_mesh) { int i_surf = 4*i + 2; - int i_mesh = get_bin_from_indices(&ijk0[0]); + int i_mesh = get_bin_from_indices(ijk0.data()); int i_bin = 4*n*i_mesh + i_surf - 1; bins.push_back(i_bin); @@ -683,7 +683,7 @@ void RegularMesh::surface_bins_crossed(const Particle* p, // Outward current on i min surface if (in_mesh) { int i_surf = 4*i + 1; - int i_mesh = get_bin_from_indices(&ijk0[0]); + int i_mesh = get_bin_from_indices(ijk0.data()); int i_bin = 4*n*i_mesh + i_surf - 1; bins.push_back(i_bin); @@ -704,7 +704,7 @@ void RegularMesh::surface_bins_crossed(const Particle* p, // i max surface if (in_mesh) { int i_surf = 4*i + 4; - int i_mesh = get_bin_from_indices(&ijk0[0]); + int i_mesh = get_bin_from_indices(ijk0.data()); int i_bin = 4*n*i_mesh + i_surf - 1; bins.push_back(i_bin); diff --git a/src/tallies/filter_legendre.cpp b/src/tallies/filter_legendre.cpp index 0446cb2955..6fa041c76b 100644 --- a/src/tallies/filter_legendre.cpp +++ b/src/tallies/filter_legendre.cpp @@ -19,7 +19,7 @@ LegendreFilter::get_all_bins(const Particle* p, int estimator, FilterMatch& match) const { std::vector wgt(n_bins_); - calc_pn_c(order_, p->mu_, &wgt[0]); + calc_pn_c(order_, p->mu_, wgt.data()); for (int i = 0; i < n_bins_; i++) { match.bins_.push_back(i); match.weights_.push_back(wgt[i]); diff --git a/src/tallies/filter_mesh.cpp b/src/tallies/filter_mesh.cpp index c62578b47e..babc4b6e61 100644 --- a/src/tallies/filter_mesh.cpp +++ b/src/tallies/filter_mesh.cpp @@ -59,7 +59,7 @@ MeshFilter::text_label(int bin) const int n_dim = mesh.n_dimension_; std::vector ijk(n_dim); - mesh.get_indices_from_bin(bin, &ijk[0]); + mesh.get_indices_from_bin(bin, ijk.data()); std::stringstream out; out << "Mesh Index (" << ijk[0]; diff --git a/src/tallies/filter_sph_harm.cpp b/src/tallies/filter_sph_harm.cpp index bbb34b16cc..0b3a371187 100644 --- a/src/tallies/filter_sph_harm.cpp +++ b/src/tallies/filter_sph_harm.cpp @@ -37,14 +37,14 @@ SphericalHarmonicsFilter::get_all_bins(const Particle* p, int estimator, // Determine cosine term for scatter expansion if necessary std::vector wgt(order_ + 1); if (cosine_ == SphericalHarmonicsCosine::scatter) { - calc_pn_c(order_, p->mu_, &wgt[0]); + calc_pn_c(order_, p->mu_, wgt.data()); } else { for (int i = 0; i < order_ + 1; i++) wgt[i] = 1; } // Find the Rn,m values std::vector rn(n_bins_); - calc_rn(order_, p->u_last_, &rn[0]); + calc_rn(order_, p->u_last_, rn.data()); int j = 0; for (int n = 0; n < order_ + 1; n++) { diff --git a/src/tallies/filter_sptl_legendre.cpp b/src/tallies/filter_sptl_legendre.cpp index 6727bfed10..6562ff01c7 100644 --- a/src/tallies/filter_sptl_legendre.cpp +++ b/src/tallies/filter_sptl_legendre.cpp @@ -51,7 +51,7 @@ SpatialLegendreFilter::get_all_bins(const Particle* p, int estimator, // Compute and return the Legendre weights. std::vector wgt(order_ + 1); - calc_pn_c(order_, x_norm, &wgt[0]); + calc_pn_c(order_, x_norm, wgt.data()); for (int i = 0; i < order_ + 1; i++) { match.bins_.push_back(i); match.weights_.push_back(wgt[i]); diff --git a/src/tallies/filter_zernike.cpp b/src/tallies/filter_zernike.cpp index 9ab7b4bcda..125bfada89 100644 --- a/src/tallies/filter_zernike.cpp +++ b/src/tallies/filter_zernike.cpp @@ -37,7 +37,7 @@ ZernikeFilter::get_all_bins(const Particle* p, int estimator, if (r <= 1.0) { // Compute and return the Zernike weights. std::vector zn(n_bins_); - calc_zn(order_, r, theta, &zn[0]); + calc_zn(order_, r, theta, zn.data()); for (int i = 0; i < n_bins_; i++) { match.bins_.push_back(i); match.weights_.push_back(zn[i]); @@ -94,7 +94,7 @@ ZernikeRadialFilter::get_all_bins(const Particle* p, int estimator, if (r <= 1.0) { // Compute and return the Zernike weights. std::vector zn(n_bins_); - calc_zn_rad(order_, r, &zn[0]); + calc_zn_rad(order_, r, zn.data()); for (int i = 0; i < n_bins_; i++) { match.bins_.push_back(i); match.weights_.push_back(zn[i]);