Skip to content
Merged
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
19 changes: 12 additions & 7 deletions source/lmp/pppm_dplr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ PPPMDPLR::PPPMDPLR(LAMMPS* lmp)

/* ---------------------------------------------------------------------- */

void PPPMDPLR::clear_fele() {
int nlocal = atom->nlocal;
fele.resize(static_cast<size_t>(nlocal) * 3);
fill(fele.begin(), fele.end(), 0.0);
}

/* ---------------------------------------------------------------------- */

void PPPMDPLR::init() {
// DPLR PPPM requires newton on, b/c it computes forces on ghost atoms

Expand All @@ -57,10 +65,8 @@ void PPPMDPLR::init() {

PPPM::init();

int nlocal = atom->nlocal;
// cout << " ninit pppm/dplr ---------------------- " << nlocal << endl;
fele.resize(static_cast<size_t>(nlocal) * 3);
fill(fele.begin(), fele.end(), 0.0);
clear_fele();
}

/* ----------------------------------------------------------------------
Expand Down Expand Up @@ -89,6 +95,7 @@ void PPPMDPLR::compute(int eflag, int vflag) {
// return if there are no charges

if (qsqsum == 0.0) {
clear_fele();
return;
}

Expand Down Expand Up @@ -296,8 +303,7 @@ void PPPMDPLR::fieldforce_ik() {
int nghost = atom->nghost;
int nall = nlocal + nghost;

fele.resize(static_cast<size_t>(nlocal) * 3);
fill(fele.begin(), fele.end(), 0.0);
clear_fele();

for (i = 0; i < nlocal; i++) {
nx = part2grid[i][0];
Expand Down Expand Up @@ -372,8 +378,7 @@ void PPPMDPLR::fieldforce_ad() {
int nghost = atom->nghost;
int nall = nlocal + nghost;

fele.resize(static_cast<size_t>(nlocal) * 3);
fill(fele.begin(), fele.end(), 0.0);
clear_fele();

for (i = 0; i < nlocal; i++) {
nx = part2grid[i][0];
Expand Down
1 change: 1 addition & 0 deletions source/lmp/pppm_dplr.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class PPPMDPLR : public PPPM {
void fieldforce_ad() override;

private:
void clear_fele();
std::vector<double> fele;
};

Expand Down
Loading