Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/source_cell/dom_force.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void DomainDecomposition::accumulate_ghost_forces(MDCell& cell)
{
throw std::runtime_error("Ghost force owner is outside the ghost communication stencil.");
}
send_buffers[static_cast<std::size_t>(peer - peer_ranks.begin())].push_back(record);
send_buffers[peer - peer_ranks.begin()].push_back(record);
}
atom.force.set(0.0, 0.0, 0.0);
}
Expand Down
14 changes: 7 additions & 7 deletions source/source_cell/dom_ghost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void DomainDecomposition::exchange_ghost_atoms(MDCell& cell)
const int index = (offset[0] + nlayer[0]) * span_y * span_z
+ (offset[1] + nlayer[1]) * span_z
+ (offset[2] + nlayer[2]);
slot_lookup[static_cast<std::size_t>(index)] = static_cast<int>(islot);
slot_lookup[index] = static_cast<int>(islot);
}

const auto collect_offsets = [&](const LocalAtom& atom, const int dim, std::vector<int>& offsets) {
Expand Down Expand Up @@ -124,11 +124,11 @@ void DomainDecomposition::exchange_ghost_atoms(MDCell& cell)
const int lookup_index = (dx + nlayer[0]) * span_y * span_z
+ (dy + nlayer[1]) * span_z
+ (dz + nlayer[2]);
const int slot_index = slot_lookup[static_cast<std::size_t>(lookup_index)];
const int slot_index = slot_lookup[lookup_index];
assert(slot_index >= 0);
const GhostExchangeSlot& slot = slots[static_cast<std::size_t>(slot_index)];
send_buffers[static_cast<std::size_t>(slot_index)].push_back(pack_atom(atom, slot.image_shift));
slots[static_cast<std::size_t>(slot_index)].send_atom_indices.push_back(static_cast<int>(iat));
const GhostExchangeSlot& slot = slots[slot_index];
send_buffers[slot_index].push_back(pack_atom(atom, slot.image_shift));
slots[slot_index].send_atom_indices.push_back(static_cast<int>(iat));
}
}
}
Expand All @@ -144,7 +144,7 @@ void DomainDecomposition::exchange_ghost_atoms(MDCell& cell)
slot.dynamic_image_shifts.reserve(slot.send_atom_indices.size());
for (const int index : slot.send_atom_indices)
{
const LocalAtom& atom = owned_atoms[static_cast<std::size_t>(index)];
const LocalAtom& atom = owned_atoms[index];
slot.previous_fracs.push_back({{atom.frac.x, atom.frac.y, atom.frac.z}});
slot.dynamic_image_shifts.push_back(slot.image_shift);
}
Expand Down Expand Up @@ -280,7 +280,7 @@ void DomainDecomposition::update_ghost_atom_positions(MDCell& cell)
std::vector<double> send_frac(6 * slot.send_atom_indices.size(), 0.0);
for (std::size_t i = 0; i < slot.send_atom_indices.size(); ++i)
{
const LocalAtom& atom = owned_atoms[static_cast<std::size_t>(slot.send_atom_indices[i])];
const LocalAtom& atom = owned_atoms[slot.send_atom_indices[i]];
const std::array<int, 3> image_shift = image_shift_for_update(
atom, slot.previous_fracs[i], slot.dynamic_image_shifts[i], slot);
slot.previous_fracs[i] = {{atom.frac.x, atom.frac.y, atom.frac.z}};
Expand Down
4 changes: 2 additions & 2 deletions source/source_cell/kernels/cuda/gpu_neighlist_device.cu
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ int build_device_impl(int nall,
if (status != 0) goto cleanup;
for (int bin = 0; bin < total_bins; ++bin)
{
bin_offsets[static_cast<std::size_t>(bin + 1)]
= bin_offsets[static_cast<std::size_t>(bin)] + bin_counts[static_cast<std::size_t>(bin)];
bin_offsets[bin + 1]
= bin_offsets[bin] + bin_counts[bin];
}
status = check_cuda(cudaMemcpy(d_bin_offsets, bin_offsets.data(),
sizeof(int) * (total_bins + 1), cudaMemcpyHostToDevice),
Expand Down
4 changes: 2 additions & 2 deletions source/source_cell/kernels/cuda/gpu_neighlist_host.cu
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ int build_impl(int nall,
if (status != 0) goto cleanup;
for (int bin = 0; bin < total_bins; ++bin)
{
bin_offsets[static_cast<std::size_t>(bin + 1)]
= bin_offsets[static_cast<std::size_t>(bin)] + bin_counts[static_cast<std::size_t>(bin)];
bin_offsets[bin + 1]
= bin_offsets[bin] + bin_counts[bin];
}
status = check_cuda(cudaMemcpy(d_bin_offsets, bin_offsets.data(), sizeof(int) * (total_bins + 1),
cudaMemcpyHostToDevice),
Expand Down
2 changes: 1 addition & 1 deletion source/source_cell/module_neighlist/bin_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void BinManager::build_atom_neighbors(

for (const ModuleNeighList::LocalAtomIndex binned_atom_index : bins_[nidx].get_atom_indices())
{
const NeighborAtom& natom = binned_atoms[static_cast<std::size_t>(binned_atom_index)];
const NeighborAtom& natom = binned_atoms[binned_atom_index];
double dx = atom.position_x - natom.position_x;
double dy = atom.position_y - natom.position_y;
double dz = atom.position_z - natom.position_z;
Expand Down
2 changes: 1 addition & 1 deletion source/source_cell/module_neighlist/neighbor_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class NeighborList
firstneigh_[i] = allocator_.allocate(numneigh_[i]);
for (int j = 0; j < numneigh_[i]; ++j)
{
firstneigh_[i][j] = neighbors[static_cast<std::size_t>(j)];
firstneigh_[i][j] = neighbors[j];
}
}

Expand Down
4 changes: 2 additions & 2 deletions source/source_cell/module_neighlist/neighbor_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ void NeighborSearch::filter_candidate_neighbors_(double cutoff, double lat0)
for (int i = 0; i < candidate_neighbor_list_.get_ncentral_atoms(); ++i)
{
active.clear();
const NeighborAtom& center = all_atoms_[static_cast<std::size_t>(i)];
const NeighborAtom& center = all_atoms_[i];
for (int j = 0; j < candidate_neighbor_list_.get_numneigh(i); ++j)
{
const int index = candidate_neighbor_list_.get_firstneigh(i)[j];
const NeighborAtom& neighbor = all_atoms_[static_cast<std::size_t>(index)];
const NeighborAtom& neighbor = all_atoms_[index];
const double dx = (center.position_x - neighbor.position_x) * lat0;
const double dy = (center.position_y - neighbor.position_y) * lat0;
const double dz = (center.position_z - neighbor.position_z) * lat0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ TEST_F(DomainDecompositionTest, GhostExchangePlanMatchesGhostLayout)
ASSERT_GE(owner, 0);
ASSERT_LT(owner, static_cast<int>(cell.owned_atoms().size()));
EXPECT_EQ(cell.ghost_atoms()[iat].type_index,
cell.owned_atoms()[static_cast<std::size_t>(owner)].type_index);
cell.owned_atoms()[owner].type_index);
}
}
else
Expand Down Expand Up @@ -160,7 +160,7 @@ TEST_F(DomainDecompositionTest, GhostExchangePlanMatchesGhostLayout)
+ iatom;
ASSERT_LT(ghost_index, cell.ghost_atoms().size());
EXPECT_EQ(cell.ghost_atoms()[ghost_index].type_index,
cell.owned_atoms()[static_cast<std::size_t>(owned_index)].type_index);
cell.owned_atoms()[owned_index].type_index);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ TEST(MdCellMigrateMpiTest, AtomCrossingDomainMigratesToNewOwner)

for (int i = 0; i < mdcell.owned_atoms().size(); ++i)
{
EXPECT_EQ(mdcell.owned_atoms()[static_cast<std::size_t>(i)].owner_rank, rank);
EXPECT_EQ(mdcell.owned_atoms()[i].owner_rank, rank);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ void initialize_test_ucell(UnitCell& ucell,
for (int it = 0; it < ntype; ++it)
{
ucell.atoms[it].type = it;
ucell.atoms[it].na = na[static_cast<std::size_t>(it)];
ucell.atoms[it].na = na[it];
ucell.atoms[it].tau.resize(static_cast<std::size_t>(ucell.atoms[it].na));
for (int ia = 0; ia < ucell.atoms[it].na; ++ia)
{
ucell.atoms[it].tau[static_cast<std::size_t>(ia)] = tau[iat++];
ucell.atoms[it].tau[ia] = tau[iat++];
}
ucell.nat += ucell.atoms[it].na;
}
Expand Down
2 changes: 1 addition & 1 deletion source/source_cell/print_cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ StruMeta make_stru_meta(const UnitCell& ucell)
metadata.species.resize(static_cast<std::size_t>(ucell.ntype));
for (int it = 0; it < ucell.ntype; ++it)
{
StruSpecies& species = metadata.species[static_cast<std::size_t>(it)];
StruSpecies& species = metadata.species[it];
if (static_cast<std::size_t>(it) < ucell.pseudo_fn.size()) species.pseudo_file = ucell.pseudo_fn[it];
if (static_cast<std::size_t>(it) < ucell.pseudo_type.size()) species.pseudo_type = ucell.pseudo_type[it];
if (static_cast<std::size_t>(it) < ucell.orbital_fn.size()) species.orbital_file = ucell.orbital_fn[it];
Expand Down
4 changes: 2 additions & 2 deletions source/source_io/module_parameter/read_inp_sys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ void ReadInput::item_system()
}
for (int i = 0; i < 3; ++i)
{
para.input.cell_replica[static_cast<std::size_t>(i)] = std::stoi(item.str_values[static_cast<std::size_t>(i)]);
para.input.cell_replica[i] = std::stoi(item.str_values[i]);
}
};
item.check_value = [](const Input_Item&, const Parameter& para) {
for (int i = 0; i < 3; ++i)
{
if (para.input.cell_replica[static_cast<std::size_t>(i)] <= 0)
if (para.input.cell_replica[i] <= 0)
{
ModuleBase::WARNING_QUIT("ReadInput", "cell_replica values must all be positive.");
}
Expand Down
6 changes: 3 additions & 3 deletions source/source_md/langevin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void Langevin::first_half(std::ofstream& ofs)

for (int i = 0; i < mdcell.owned_atoms().size(); ++i)
{
LocalAtom& atom = mdcell.owned_atoms()[static_cast<std::size_t>(i)];
LocalAtom& atom = mdcell.owned_atoms()[i];
for (int k = 0; k < 3; ++k)
{
if (atom.mbl[k]) atom.vel[k] += 0.5 * total_force[i][k] * md_dt / atom.mass;
Expand All @@ -62,7 +62,7 @@ void Langevin::second_half()
post_force();
for (int i = 0; i < mdcell.owned_atoms().size(); ++i)
{
LocalAtom& atom = mdcell.owned_atoms()[static_cast<std::size_t>(i)];
LocalAtom& atom = mdcell.owned_atoms()[i];
for (int k = 0; k < 3; ++k)
{
if (atom.mbl[k]) atom.vel[k] += 0.5 * total_force[i][k] * md_dt / atom.mass;
Expand Down Expand Up @@ -107,7 +107,7 @@ void Langevin::post_force()
{
random_value[k] = static_cast<double>(std::rand()) / RAND_MAX - 0.5;
}
const LocalAtom& atom = mdcell.owned_atoms()[static_cast<std::size_t>(i)];
const LocalAtom& atom = mdcell.owned_atoms()[i];
ModuleBase::Vector3<double> fictitious_force = -atom.mass * atom.vel / md_damp;
for (int j = 0; j < 3; ++j)
{
Expand Down
18 changes: 9 additions & 9 deletions source/source_md/md_func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@ void init_vel(MDCell& mdcell,
std::vector<int> offsets(static_cast<std::size_t>(unit.ntype + 1), 0);
for (int it = 0; it < unit.ntype; ++it)
{
offsets[static_cast<std::size_t>(it + 1)] = offsets[static_cast<std::size_t>(it)] + unit.atoms[it].na;
offsets[it + 1] = offsets[it] + unit.atoms[it].na;
}
for (LocalAtom& atom : mdcell.owned_atoms())
{
atom.vel = velocities[static_cast<std::size_t>(offsets[static_cast<std::size_t>(atom.type)] + atom.type_index)];
atom.vel = velocities[offsets[atom.type] + atom.type_index];
}
return;
}
Expand Down Expand Up @@ -337,16 +337,16 @@ void force_virial(ModuleESolver::ESolver* p_esolver,
static_cast<std::size_t>(ucell.ntype));
for (int it = 0; it < ucell.ntype; ++it)
{
backing_velocities[static_cast<std::size_t>(it)] = ucell.atoms[it].vel;
backing_velocities[it] = ucell.atoms[it].vel;
}
// The caller reports whether positions drifted in this run; the
// initial force evaluation (also of a restarted run) passes false so
// the charge-extrapolation history only advances after an MD drift.
mdcell.sync_backing_unitcell(positions_updated);
for (int it = 0; it < ucell.ntype; ++it)
{
std::copy(backing_velocities[static_cast<std::size_t>(it)].begin(),
backing_velocities[static_cast<std::size_t>(it)].end(),
std::copy(backing_velocities[it].begin(),
backing_velocities[it].end(),
ucell.atoms[it].vel.begin());
}
p_esolver->runner(ucell, istep); potential = 0.5 * p_esolver->cal_energy();
Expand Down Expand Up @@ -484,8 +484,8 @@ void dump_info(const int& step,
{
std::ostringstream row;
row << std::fixed << std::setprecision(12);
row << " " << type_offsets[static_cast<std::size_t>(atom.type)] + atom.type_index
<< " " << mdcell.type_labels()[static_cast<std::size_t>(atom.type)]
row << " " << type_offsets[atom.type] + atom.type_index
<< " " << mdcell.type_labels()[atom.type]
<< " " << atom.cart.x * unit_pos << " " << atom.cart.y * unit_pos << " " << atom.cart.z * unit_pos;
if (mdp.dump_force)
row << " " << atom.force.x * unit_force << " " << atom.force.y * unit_force << " " << atom.force.z * unit_force;
Expand All @@ -502,7 +502,7 @@ void dump_info(const int& step,
const std::size_t maximum_count = std::numeric_limits<int>::max();
for (const LocalAtom& atom : mdcell.owned_atoms())
{
const std::int64_t index = type_offsets[static_cast<std::size_t>(atom.type)] + atom.type_index;
const std::int64_t index = type_offsets[atom.type] + atom.type_index;
const LocalAtom* atom_pointer = &atom;
ordered_atoms.emplace_back(index, atom_pointer);
const std::string row = format_atom(atom);
Expand Down Expand Up @@ -653,7 +653,7 @@ std::int64_t global_dof(const MDCell& mdcell)
std::int64_t local_frozen[3] = {0, 0, 0};
for (int i = 0; i < mdcell.owned_atoms().size(); ++i)
{
const ModuleBase::Vector3<int>& mbl = mdcell.owned_atoms()[static_cast<std::size_t>(i)].mbl;
const ModuleBase::Vector3<int>& mbl = mdcell.owned_atoms()[i].mbl;
if (mbl.x == 0) ++local_frozen[0];
if (mbl.y == 0) ++local_frozen[1];
if (mbl.z == 0) ++local_frozen[2];
Expand Down
4 changes: 2 additions & 2 deletions source/source_md/module_lj/lj_forcefield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void LJ::compute(BaseCell& cell,

for (int local_i = 0; local_i < neighbor_list.get_ncentral_atoms(); ++local_i)
{
const NeighborAtom& center_atom = inside_atoms[static_cast<std::size_t>(local_i)];
const NeighborAtom& center_atom = inside_atoms[local_i];
const int it = center_atom.atom_type;
const int ia = center_atom.atom_index;
const int iat = atom_offsets[it] + ia;
Expand Down Expand Up @@ -149,7 +149,7 @@ void LJ::compute(BaseCell& cell,

for (int local_i = 0; local_i < neighbor_list.get_ncentral_atoms(); ++local_i)
{
LocalAtom& center_atom = owned_atoms[static_cast<std::size_t>(local_i)];
LocalAtom& center_atom = owned_atoms[local_i];
ModuleBase::Vector3<double> tau1(center_atom.cart.x, center_atom.cart.y, center_atom.cart.z);
for (int ad = 0; ad < neighbor_list.get_numneigh(local_i); ++ad)
{
Expand Down
Loading
Loading