Hello. I’m writing fix that changes box volume on demand.
Some of it in pseudo-code:
constructor():
no_change_box = 1;
restart_pbc = 1;
pre_exchange_migrate = 1;
pre_exchange():
domain->boxlo[0] -= delta; // delta can be negative
domain->boxhi[0] += delta;
...
if (domain->triclinic != 0) { domain->x2lamda(atom->nlocal); }
domain->reset_box();
if (domain->triclinic != 0) { domain->lamda2x(atom->nlocal); }
for (int i = 0; i < atom->nlocal; i++) { domain->remap(atom->x[i], atom->image[i]); }
if (domain->triclinic != 0) { domain->x2lamda(atom->nlocal); }
auto *irregular = new Irregular(lmp);
irregular->migrate_atoms(1);
delete irregular;
if (domain->triclinic != 0) { domain->lamda2x(atom->nlocal); }
After doing this segmentation fault happens on npair_bin.cpp:219
, more specifically at accessing inaccessible memory neighptr[n++]
.
What I do wrong? How can I fix that?
Some build information:
-- <<< Build configuration >>>
LAMMPS Version: 20240829 7231caae90-modified
Operating System: Linux Arch
CMake Version: 3.30.3
Build type: RelWithDebInfo
Install path: ~/venvs/3.8/lmpmy
Generator: Unix Makefiles using /usr/bin/make
-- Enabled packages: ADIOS;COMPRESS;PYTHON
-- <<< Compilers and Flags: >>>
-- C++ Compiler: /usr/bin/c++
Type: GNU
Version: 14.2.1
C++ Standard: 11
C++ Flags: -O2 -g -DNDEBUG
Defines: LAMMPS_BIGBIG;LAMMPS_MEMALIGN=64;LAMMPS_OMP_COMPAT=4;LAMMPS_CURL;LAMMPS_JPEG;LAMMPS_PNG;LAMMPS_GZIP;LAMMPS_FFMPEG;LMP_PYTHON;LAMMPS_ZSTD
-- Fortran Compiler: /usr/bin/f95
Type: GNU
Version: 14.2.1
Fortran Flags: -O2 -g
-- C compiler: /usr/bin/cc
Type: GNU
Version: 14.2.1
C Flags: -O2 -g -DNDEBUG
-- <<< Linker flags: >>>
-- Executable name: lmp_mpi
-- Shared library flags:
-- <<< MPI flags >>>
-- MPI_defines: MPICH_SKIP_MPICXX;OMPI_SKIP_MPICXX;_MPICC_H
-- MPI includes: /usr/include
-- MPI libraries: /usr/lib/libmpi.so;