From 8b89c330e6ce94d69b05ec1d5e317c3d77ec44b7 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 10 Jan 2024 15:32:02 -0500 Subject: [PATCH] make removed DOF computation large system compatible --- src/EFF/fix_langevin_eff.cpp | 4 ++-- src/KOKKOS/fix_shake_kokkos.cpp | 10 +++++----- src/KOKKOS/fix_shake_kokkos.h | 4 +--- src/LATBOLTZ/fix_lb_fluid.cpp | 6 +++--- src/LATBOLTZ/fix_lb_fluid.h | 2 +- src/MANIFOLD/fix_nve_manifold_rattle.cpp | 10 +++++----- src/MANIFOLD/fix_nve_manifold_rattle.h | 2 +- src/POEMS/fix_poems.cpp | 10 +++++----- src/POEMS/fix_poems.h | 2 +- src/RIGID/fix_rigid.cpp | 4 ++-- src/RIGID/fix_rigid.h | 2 +- src/RIGID/fix_rigid_small.cpp | 8 ++++---- src/RIGID/fix_rigid_small.h | 2 +- src/RIGID/fix_shake.cpp | 8 ++++---- src/RIGID/fix_shake.h | 2 +- src/compute.cpp | 2 +- src/fix.h | 2 +- 17 files changed, 39 insertions(+), 41 deletions(-) diff --git a/src/EFF/fix_langevin_eff.cpp b/src/EFF/fix_langevin_eff.cpp index 8c255e4348..a25b6ac837 100644 --- a/src/EFF/fix_langevin_eff.cpp +++ b/src/EFF/fix_langevin_eff.cpp @@ -137,7 +137,7 @@ void FixLangevinEff::post_force_no_tally() dof = domain->dimension * particles; fix_dof = 0; for (int i = 0; i < modify->nfix; i++) - fix_dof += modify->fix[i]->dof(igroup); + fix_dof += (int)modify->fix[i]->dof(igroup); // extra_dof = domain->dimension dof -= domain->dimension + fix_dof; @@ -306,7 +306,7 @@ void FixLangevinEff::post_force_tally() dof = domain->dimension * particles; fix_dof = 0; for (int i = 0; i < modify->nfix; i++) - fix_dof += modify->fix[i]->dof(igroup); + fix_dof += (int)modify->fix[i]->dof(igroup); // extra_dof = domain->dimension dof -= domain->dimension + fix_dof; diff --git a/src/KOKKOS/fix_shake_kokkos.cpp b/src/KOKKOS/fix_shake_kokkos.cpp index dd6de8f9ec..c31e38a05e 100644 --- a/src/KOKKOS/fix_shake_kokkos.cpp +++ b/src/KOKKOS/fix_shake_kokkos.cpp @@ -525,7 +525,7 @@ void FixShakeKokkos::operator()(TagFixShakePostForce -int FixShakeKokkos::dof(int igroup) +bigint FixShakeKokkos::dof(int igroup) { d_mask = atomKK->k_mask.view(); d_tag = atomKK->k_tag.view(); @@ -538,7 +538,7 @@ int FixShakeKokkos::dof(int igroup) // count dof in a cluster if and only if // the central atom is in group and atom i is the central atom - int n = 0; + bigint n = 0; { // local variables for lambda capture @@ -549,7 +549,7 @@ int FixShakeKokkos::dof(int igroup) auto groupbit = group->bitmask[igroup]; Kokkos::parallel_reduce(Kokkos::RangePolicy(0,nlocal), - LAMMPS_LAMBDA(const int& i, int& n) { + LAMMPS_LAMBDA(const int& i, bigint& n) { if (!(mask[i] & groupbit)) return; if (d_shake_flag[i] == 0) return; if (d_shake_atom(i,0) != tag[i]) return; @@ -560,8 +560,8 @@ int FixShakeKokkos::dof(int igroup) },n); } - int nall; - MPI_Allreduce(&n,&nall,1,MPI_INT,MPI_SUM,world); + bigint nall; + MPI_Allreduce(&n,&nall,1,MPI_LMP_BIGINT,MPI_SUM,world); return nall; } diff --git a/src/KOKKOS/fix_shake_kokkos.h b/src/KOKKOS/fix_shake_kokkos.h index 185e69ce86..7c830e94d8 100644 --- a/src/KOKKOS/fix_shake_kokkos.h +++ b/src/KOKKOS/fix_shake_kokkos.h @@ -44,8 +44,6 @@ struct TagFixShakeUnpackExchange{}; template class FixShakeKokkos : public FixShake, public KokkosBase { - //friend class FixEHEX; - public: typedef DeviceType device_type; typedef EV_FLOAT value_type; @@ -77,7 +75,7 @@ class FixShakeKokkos : public FixShake, public KokkosBase { void shake_end_of_step(int vflag) override; void correct_coordinates(int vflag) override; - int dof(int) override; + bigint dof(int) override; void unconstrained_update() override; diff --git a/src/LATBOLTZ/fix_lb_fluid.cpp b/src/LATBOLTZ/fix_lb_fluid.cpp index f692d28084..f3d8f45142 100644 --- a/src/LATBOLTZ/fix_lb_fluid.cpp +++ b/src/LATBOLTZ/fix_lb_fluid.cpp @@ -4430,9 +4430,9 @@ void FixLbFluid::calc_MPT(double &totalmass, double totalmomentum[3], double &Ta ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */ -int FixLbFluid::adjust_dof_fix() /* Based on same private method in compute class */ -{ /* altered to return fix_dof */ - int fix_dof = 0; +bigint FixLbFluid::adjust_dof_fix() /* Based on same private method in compute class */ +{ /* altered to return fix_dof */ + bigint fix_dof = 0; for (auto &ifix : modify->get_fix_list()) if (ifix->dof_flag) fix_dof += ifix->dof(igroup); return fix_dof; diff --git a/src/LATBOLTZ/fix_lb_fluid.h b/src/LATBOLTZ/fix_lb_fluid.h index 19cd2c6dc3..f134b50901 100644 --- a/src/LATBOLTZ/fix_lb_fluid.h +++ b/src/LATBOLTZ/fix_lb_fluid.h @@ -182,7 +182,7 @@ class FixLbFluid : public Fix { void calc_fluidforceII(void); void calc_fluidforceweight(void); - int adjust_dof_fix(); + bigint adjust_dof_fix(); double dof_compute(); /* nanopit parameters */ diff --git a/src/MANIFOLD/fix_nve_manifold_rattle.cpp b/src/MANIFOLD/fix_nve_manifold_rattle.cpp index b1efea951f..dc0492dbe9 100644 --- a/src/MANIFOLD/fix_nve_manifold_rattle.cpp +++ b/src/MANIFOLD/fix_nve_manifold_rattle.cpp @@ -287,21 +287,21 @@ void FixNVEManifoldRattle::update_var_params() /* ----------------------------------------------------------------------------- ---------------------------------------------------------------------------*/ -int FixNVEManifoldRattle::dof(int /*igroup*/) +bigint FixNVEManifoldRattle::dof(int /*igroup*/) { int *mask = atom->mask; int nlocal = atom->nlocal; - int natoms = 0; + bigint natoms = 0; for (int i = 0; i < nlocal; ++i) { if (mask[i] & groupbit) ++natoms; } - int dofs; - MPI_Allreduce( &natoms, &dofs, 1, MPI_INT, MPI_SUM, world ); + bigint dofs; + MPI_Allreduce( &natoms, &dofs, 1, MPI_LMP_BIGINT, MPI_SUM, world ); // Make sure that, if there is just no or one atom, no dofs are subtracted, // since for the first atom already 3 dofs are subtracted because of the - // centre of mass corrections: + // center of mass corrections: if (dofs <= 1) dofs = 0; stats.dofs_removed = dofs; diff --git a/src/MANIFOLD/fix_nve_manifold_rattle.h b/src/MANIFOLD/fix_nve_manifold_rattle.h index 3eae9c4bc3..7c9e302094 100644 --- a/src/MANIFOLD/fix_nve_manifold_rattle.h +++ b/src/MANIFOLD/fix_nve_manifold_rattle.h @@ -75,7 +75,7 @@ class FixNVEManifoldRattle : public Fix { void init() override; void reset_dt() override; void end_of_step() override; - int dof(int) override; + bigint dof(int) override; void setup(int) override {} // Not needed for fixNVE but is for fixNVT double memory_usage() override; diff --git a/src/POEMS/fix_poems.cpp b/src/POEMS/fix_poems.cpp index f289a939e6..55199a7191 100644 --- a/src/POEMS/fix_poems.cpp +++ b/src/POEMS/fix_poems.cpp @@ -855,7 +855,7 @@ void FixPOEMS::pre_neighbor() {} count # of degrees-of-freedom removed by fix_poems for atoms in igroup ------------------------------------------------------------------------- */ -int FixPOEMS::dof(int igroup) +bigint FixPOEMS::dof(int igroup) { int groupbit = group->bitmask[igroup]; @@ -877,17 +877,17 @@ int FixPOEMS::dof(int igroup) // remove 3N - 6 dof for each rigid body if at least 2 atoms are in igroup - int n = 0; + bigint n = 0; for (int ibody = 0; ibody < nbody; ibody++) if (nall[ibody] > 2) n += 3 * nall[ibody] - 6; // subtract 3 additional dof for each joint if atom is also in igroup - int m = 0; + bigint m = 0; for (int i = 0; i < nlocal; i++) if (natom2body[i] > 1 && (mask[i] & groupbit)) m += 3 * (natom2body[i] - 1); - int mall; - MPI_Allreduce(&m, &mall, 1, MPI_INT, MPI_SUM, world); + bigint mall; + MPI_Allreduce(&m, &mall, 1, MPI_LMP_BIGINT, MPI_SUM, world); n += mall; // delete local memory diff --git a/src/POEMS/fix_poems.h b/src/POEMS/fix_poems.h index 99af171636..6aac4abd8a 100644 --- a/src/POEMS/fix_poems.h +++ b/src/POEMS/fix_poems.h @@ -47,7 +47,7 @@ class FixPOEMS : public Fix { double memory_usage() override; void pre_neighbor() override; - int dof(int) override; + bigint dof(int) override; void deform(int) override; int modify_param(int, char **) override; void reset_dt() override; diff --git a/src/RIGID/fix_rigid.cpp b/src/RIGID/fix_rigid.cpp index 628abb240e..bd3c53e3ec 100644 --- a/src/RIGID/fix_rigid.cpp +++ b/src/RIGID/fix_rigid.cpp @@ -1247,7 +1247,7 @@ void FixRigid::enforce2d() return total count of DOF ------------------------------------------------------------------------- */ -int FixRigid::dof(int tgroup) +bigint FixRigid::dof(int tgroup) { // cannot count DOF correctly unless setup_bodies_static() has been called @@ -1306,7 +1306,7 @@ int FixRigid::dof(int tgroup) // 3d body with any finite-size M should have 6 dof, remove (3N+6M) - 6 // 2d body with any finite-size M should have 3 dof, remove (2N+3M) - 3 - int n = 0; + bigint n = 0; nlinear = 0; if (domain->dimension == 3) { for (int ibody = 0; ibody < nbody; ibody++) diff --git a/src/RIGID/fix_rigid.h b/src/RIGID/fix_rigid.h index 361ddd2720..c2f04ecf1a 100644 --- a/src/RIGID/fix_rigid.h +++ b/src/RIGID/fix_rigid.h @@ -48,7 +48,7 @@ class FixRigid : public Fix { void setup_pre_neighbor() override; void pre_neighbor() override; - int dof(int) override; + bigint dof(int) override; void deform(int) override; void reset_dt() override; void zero_momentum() override; diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index bd49834f15..5905e44595 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -1123,7 +1123,7 @@ void FixRigidSmall::enforce2d() return total count of DOF ------------------------------------------------------------------------- */ -int FixRigidSmall::dof(int tgroup) +bigint FixRigidSmall::dof(int tgroup) { int i,j; @@ -1195,7 +1195,7 @@ int FixRigidSmall::dof(int tgroup) double *inertia; - int n = 0; + bigint n = 0; nlinear = 0; if (domain->dimension == 3) { for (int ibody = 0; ibody < nlocal_body; ibody++) { @@ -1216,8 +1216,8 @@ int FixRigidSmall::dof(int tgroup) memory->destroy(counts); - int nall; - MPI_Allreduce(&n,&nall,1,MPI_INT,MPI_SUM,world); + bigint nall; + MPI_Allreduce(&n,&nall,1,MPI_LMP_BIGINT,MPI_SUM,world); return nall; } diff --git a/src/RIGID/fix_rigid_small.h b/src/RIGID/fix_rigid_small.h index 0070d976df..0508063f05 100644 --- a/src/RIGID/fix_rigid_small.h +++ b/src/RIGID/fix_rigid_small.h @@ -54,7 +54,7 @@ class FixRigidSmall : public Fix { void setup_pre_neighbor() override; void pre_neighbor() override; - int dof(int) override; + bigint dof(int) override; void deform(int) override; void reset_dt() override; void zero_momentum() override; diff --git a/src/RIGID/fix_shake.cpp b/src/RIGID/fix_shake.cpp index b2c65220bc..540ad35a26 100644 --- a/src/RIGID/fix_shake.cpp +++ b/src/RIGID/fix_shake.cpp @@ -755,7 +755,7 @@ void FixShake::min_post_force(int vflag) count # of degrees-of-freedom removed by SHAKE for atoms in igroup ------------------------------------------------------------------------- */ -int FixShake::dof(int igroup) +bigint FixShake::dof(int igroup) { int groupbit = group->bitmask[igroup]; @@ -766,7 +766,7 @@ int FixShake::dof(int igroup) // count dof in a cluster if and only if // the central atom is in group and atom i is the central atom - int n = 0; + bigint n = 0; for (int i = 0; i < nlocal; i++) { if (!(mask[i] & groupbit)) continue; if (shake_flag[i] == 0) continue; @@ -777,8 +777,8 @@ int FixShake::dof(int igroup) else if (shake_flag[i] == 4) n += 3; } - int nall; - MPI_Allreduce(&n,&nall,1,MPI_INT,MPI_SUM,world); + bigint nall; + MPI_Allreduce(&n,&nall,1,MPI_LMP_BIGINT,MPI_SUM,world); return nall; } diff --git a/src/RIGID/fix_shake.h b/src/RIGID/fix_shake.h index 3b04560f09..b728c9d6a5 100644 --- a/src/RIGID/fix_shake.h +++ b/src/RIGID/fix_shake.h @@ -59,7 +59,7 @@ class FixShake : public Fix { virtual void correct_coordinates(int vflag); virtual void correct_velocities(); - int dof(int) override; + bigint dof(int) override; void reset_dt() override; void *extract(const char *, int &) override; double compute_scalar() override; diff --git a/src/compute.cpp b/src/compute.cpp index 2bd1544fd7..d47d1d5292 100644 --- a/src/compute.cpp +++ b/src/compute.cpp @@ -83,7 +83,7 @@ Compute::Compute(LAMMPS *lmp, int narg, char **arg) : extra_dof = domain->dimension; dynamic_user = 0; - fix_dof = 0; + fix_dof = 0.0; // setup list of timesteps diff --git a/src/fix.h b/src/fix.h index 9b595f0c60..5fde4fd8e2 100644 --- a/src/fix.h +++ b/src/fix.h @@ -236,7 +236,7 @@ class Fix : protected Pointers { virtual double compute_vector(int) { return 0.0; } virtual double compute_array(int, int) { return 0.0; } - virtual int dof(int) { return 0; } + virtual bigint dof(int) { return 0; } virtual void deform(int) {} virtual void reset_target(double) {} virtual void reset_dt() {}