Merge branch 'maintenance' of github.com:lammps/lammps into maintenance

This commit is contained in:
Axel Kohlmeyer
2025-06-27 14:51:47 -04:00
6 changed files with 65 additions and 20 deletions

View File

@ -3224,6 +3224,7 @@ CONTAINS
TYPE(c_ptr) :: c_id, c_caller
TYPE(c_funptr) :: c_callback
INTEGER :: i, this_fix
TYPE(fix_external_data), DIMENSION(:), ALLOCATABLE :: tmp_ext_data
c_id = f2c_string(id)
IF (ALLOCATED(ext_data)) THEN
@ -3235,9 +3236,13 @@ CONTAINS
END IF
END DO
IF (this_fix > SIZE(ext_data)) THEN
! reallocates ext_data; this requires us to re-bind "caller" on the C
! reallocate ext_data in a pre-fortran 2008 compatible way.
ALLOCATE(tmp_ext_data(this_fix))
tmp_ext_data(1:this_fix-1) = ext_data(1:this_fix-1)
tmp_ext_data(this_fix) = fix_external_data()
CALL move_alloc(tmp_ext_data, ext_data)
! this requires us to re-bind "caller" on the C
! side to the new data structure, which likely moved to a new address
ext_data = [ext_data, fix_external_data()] ! extends ext_data by 1
CALL rebind_external_callback_data()
END IF
ELSE

View File

@ -701,6 +701,8 @@ void FixPour::pre_exchange()
atom->nangles += (bigint) onemols[imol]->nangles * ninserted_mols;
atom->ndihedrals += (bigint) onemols[imol]->ndihedrals * ninserted_mols;
atom->nimpropers += (bigint) onemols[imol]->nimpropers * ninserted_mols;
// body particle molecule template must contain only one atom
atom->nbodies += (bigint) onemols[imol]->bodyflag * ninserted_mols;
}
if (maxtag_all >= MAXTAGINT) error->all(FLERR, "New atom IDs exceed maximum allowed ID");
}

View File

@ -83,14 +83,26 @@ void PairMLIAPKokkos<DeviceType>::compute(int eflag, int vflag)
error->all(FLERR, "Incompatible model and descriptor element count");
ev_init(eflag, vflag, 0);
if (eflag_atom && (int)k_eatom.h_view.extent(0) < maxeatom) {
memoryKK->destroy_kokkos(k_eatom,eatom);
memoryKK->create_kokkos(k_eatom,eatom,maxeatom,"pair:eatom");
if (eflag_atom) {
if ((int)k_eatom.h_view.extent(0) < maxeatom) {
memoryKK->destroy_kokkos(k_eatom,eatom);
memoryKK->create_kokkos(k_eatom,eatom,maxeatom,"pair:eatom");
} else {
Kokkos::deep_copy(k_eatom.template view<DeviceType>(),0);
k_eatom.modify<DeviceType>();
k_eatom.sync_host();
}
}
if (vflag_atom && (int)k_vatom.h_view.extent(0) < maxeatom) {
memoryKK->destroy_kokkos(k_vatom,vatom);
memoryKK->create_kokkos(k_vatom,vatom,maxeatom,6,"pair:eatom");
if (vflag_atom) {
if ((int)k_vatom.h_view.extent(0) < maxeatom) {
memoryKK->destroy_kokkos(k_vatom,vatom);
memoryKK->create_kokkos(k_vatom,vatom,maxeatom,6,"pair:eatom");
} else {
Kokkos::deep_copy(k_vatom.template view<DeviceType>(),0);
k_vatom.modify<DeviceType>();
k_vatom.sync_host();
}
}
data->generate_neighdata(list, eflag, vflag);

View File

@ -614,6 +614,8 @@ void FixDeposit::pre_exchange()
atom->nangles += onemols[imol]->nangles;
atom->ndihedrals += onemols[imol]->ndihedrals;
atom->nimpropers += onemols[imol]->nimpropers;
// body particle molecule template must contain only one atom
atom->nbodies += (bigint) onemols[imol]->bodyflag;
}
maxtag_all += natom;
if (maxtag_all >= MAXTAGINT)

View File

@ -1461,30 +1461,44 @@ void Molecule::nspecial_read(int flag, char *line)
{
if (flag == 0) maxspecial = 0;
for (int i = 0; i < natoms; ++i) count[i] = 0;
for (int i = 0; i < natoms; i++) {
readline(line);
int c1, c2, c3;
int c0, c1, c2, c3;
try {
ValueTokenizer values(utils::trim_comment(line));
if (values.count() != 4)
error->all(FLERR, "Invalid line in Special Bond Counts section of molecule file: {}", line);
values.next_int();
c1 = values.next_tagint();
c2 = values.next_tagint();
c3 = values.next_tagint();
c0 = values.next_int();
c1 = values.next_int();
c2 = values.next_int();
c3 = values.next_int();
} catch (TokenizerException &e) {
error->all(FLERR, "Invalid line in Special Bond Counts section of molecule file: {}\n{}",
e.what(), line);
}
if (flag) {
int iatom = c0 - 1;
if (iatom < 0 || iatom >= natoms)
error->all(FLERR, "Invalid atom index in Special Bond Counts section of molecule file");
count[iatom]++;
nspecial[i][0] = c1;
nspecial[i][1] = c1 + c2;
nspecial[i][2] = c1 + c2 + c3;
} else
} else {
maxspecial = MAX(maxspecial, c1 + c2 + c3);
}
}
// check
if (flag) {
for (int i = 0; i < natoms; i++) {
if (count[i] == 0)
error->all(FLERR, "Atom {} missing in Special Bond Counts section of molecule file", i + 1);
}
}
}
@ -1494,6 +1508,7 @@ void Molecule::nspecial_read(int flag, char *line)
void Molecule::special_read(char *line)
{
for (int i = 0; i < natoms; ++i) count[i] = 0;
try {
for (int i = 0; i < natoms; i++) {
readline(line);
@ -1504,18 +1519,27 @@ void Molecule::special_read(char *line)
if (nwords != nspecial[i][2] + 1)
error->all(FLERR, "Molecule file special list does not match special count");
values.next_int(); // ignore
int iatom = values.next_int() - 1;
if (iatom < 0 || iatom >= natoms)
error->all(FLERR, "Invalid atom index {} in Special Bonds section of molecule file", iatom);
for (int m = 1; m < nwords; m++) {
special[i][m - 1] = values.next_tagint();
if (special[i][m - 1] <= 0 || special[i][m - 1] > natoms || special[i][m - 1] == i + 1)
error->all(FLERR, "Invalid atom index in Special Bonds section of molecule file");
int ival = values.next_tagint();
if ((ival <= 0) || (ival > natoms) || (ival == iatom + 1))
error->all(FLERR, "Invalid atom index {} in Special Bonds section of molecule file",
ival);
special[iatom][m - 1] = ival;
}
count[iatom]++;
}
} catch (TokenizerException &e) {
error->all(FLERR, "Invalid line in Special Bonds section of molecule file: {}\n{}", e.what(),
line);
}
for (int i = 0; i < natoms; i++) {
if (count[i] == 0)
error->all(FLERR, "Atom {} missing in Special Bonds section of molecule file", i + 1);
}
}
/* ----------------------------------------------------------------------

View File

@ -7,8 +7,8 @@ has_mpi4py=False
try:
from mpi4py import __version__ as mpi4py_version
# tested to work with mpi4py versions 2 and 3
has_mpi4py = mpi4py_version.split('.')[0] in ['2','3']
# tested to work with mpi4py versions 2, 3, and 4
has_mpi4py = mpi4py_version.split('.')[0] in ['2','3','4']
except:
pass