forked from lijiext/lammps
replace variable length arrays in fix gcmc with new/delete
This commit is contained in:
parent
0a835c499a
commit
477d9feb5c
|
@ -1349,7 +1349,7 @@ void FixGCMC::attempt_molecule_insertion()
|
||||||
MathExtra::quat_to_mat(quat,rotmat);
|
MathExtra::quat_to_mat(quat,rotmat);
|
||||||
|
|
||||||
double insertion_energy = 0.0;
|
double insertion_energy = 0.0;
|
||||||
bool procflag[natoms_per_molecule];
|
bool *procflag = new bool[natoms_per_molecule];
|
||||||
|
|
||||||
for (int i = 0; i < natoms_per_molecule; i++) {
|
for (int i = 0; i < natoms_per_molecule; i++) {
|
||||||
MathExtra::matvec(rotmat,onemols[imol]->x[i],molcoords[i]);
|
MathExtra::matvec(rotmat,onemols[imol]->x[i],molcoords[i]);
|
||||||
|
@ -1472,6 +1472,7 @@ void FixGCMC::attempt_molecule_insertion()
|
||||||
update_gas_atoms_list();
|
update_gas_atoms_list();
|
||||||
ninsertion_successes += 1.0;
|
ninsertion_successes += 1.0;
|
||||||
}
|
}
|
||||||
|
delete[] procflag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
@ -1934,7 +1935,7 @@ void FixGCMC::attempt_molecule_deletion_full()
|
||||||
grow_molecule_arrays(nmolq);
|
grow_molecule_arrays(nmolq);
|
||||||
|
|
||||||
int m = 0;
|
int m = 0;
|
||||||
int tmpmask[atom->nlocal];
|
int *tmpmask = new int[atom->nlocal];
|
||||||
for (int i = 0; i < atom->nlocal; i++) {
|
for (int i = 0; i < atom->nlocal; i++) {
|
||||||
if (atom->molecule[i] == deletion_molecule) {
|
if (atom->molecule[i] == deletion_molecule) {
|
||||||
tmpmask[i] = atom->mask[i];
|
tmpmask[i] = atom->mask[i];
|
||||||
|
@ -1982,6 +1983,7 @@ void FixGCMC::attempt_molecule_deletion_full()
|
||||||
if (force->kspace) force->kspace->qsum_qsq();
|
if (force->kspace) force->kspace->qsum_qsq();
|
||||||
}
|
}
|
||||||
update_gas_atoms_list();
|
update_gas_atoms_list();
|
||||||
|
delete[] tmpmask;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
@ -2426,9 +2428,9 @@ void FixGCMC::update_gas_atoms_list()
|
||||||
for (int i = 0; i < nlocal; i++) maxmol = MAX(maxmol,molecule[i]);
|
for (int i = 0; i < nlocal; i++) maxmol = MAX(maxmol,molecule[i]);
|
||||||
tagint maxmol_all;
|
tagint maxmol_all;
|
||||||
MPI_Allreduce(&maxmol,&maxmol_all,1,MPI_LMP_TAGINT,MPI_MAX,world);
|
MPI_Allreduce(&maxmol,&maxmol_all,1,MPI_LMP_TAGINT,MPI_MAX,world);
|
||||||
double comx[maxmol_all];
|
double *comx = new double[maxmol_all];
|
||||||
double comy[maxmol_all];
|
double *comy = new double[maxmol_all];
|
||||||
double comz[maxmol_all];
|
double *comz = new double[maxmol_all];
|
||||||
for (int imolecule = 0; imolecule < maxmol_all; imolecule++) {
|
for (int imolecule = 0; imolecule < maxmol_all; imolecule++) {
|
||||||
for (int i = 0; i < nlocal; i++) {
|
for (int i = 0; i < nlocal; i++) {
|
||||||
if (molecule[i] == imolecule) {
|
if (molecule[i] == imolecule) {
|
||||||
|
@ -2458,7 +2460,9 @@ void FixGCMC::update_gas_atoms_list()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
delete[] comx;
|
||||||
|
delete[] comy;
|
||||||
|
delete[] comz;
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < nlocal; i++) {
|
for (int i = 0; i < nlocal; i++) {
|
||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
|
|
Loading…
Reference in New Issue