From 79bc319ec58a61228282a1f654fb5ea0d42220d1 Mon Sep 17 00:00:00 2001 From: L Laniewski-Wollk Date: Tue, 20 Feb 2024 21:34:28 +1000 Subject: [PATCH 01/13] Make the SolidGrid depth grow persistent --- src/SolidGrid.h | 2 +- src/SolidGrid.hpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/SolidGrid.h b/src/SolidGrid.h index 0ce721077..a614b9fb1 100644 --- a/src/SolidGrid.h +++ b/src/SolidGrid.h @@ -167,7 +167,7 @@ class SolidGrid { public: BALLS* balls; inline SolidGrid() { - depth = 0; + depth = 4; } void Build(); void InitFinder(finder_t&); diff --git a/src/SolidGrid.hpp b/src/SolidGrid.hpp index 301a632c2..585a08fe1 100644 --- a/src/SolidGrid.hpp +++ b/src/SolidGrid.hpp @@ -58,7 +58,6 @@ void SolidGrid::Build () { } size_t grid_size = 1; for (int k=0; k<3; k++) grid_size = grid_size * (maxs[k]-mins[k]+1); - depth = 4; while (TryDepth(grid_size)) { depth = depth*2; output("Too many particles per bin in SolidGrid. Increasing bin size to %d\n", depth); From 9b5129c40a795c8eb0bd0ea1b1fbc81dd76934e1 Mon Sep 17 00:00:00 2001 From: L Laniewski-Wollk Date: Thu, 18 Apr 2024 15:30:27 +1000 Subject: [PATCH 02/13] Addning atom_force mode --- src/lammps.cpp | 499 ++++++++++++++++++++++++++----------------------- 1 file changed, 267 insertions(+), 232 deletions(-) diff --git a/src/lammps.cpp b/src/lammps.cpp index 0b2cdd79d..72972e699 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -1,268 +1,303 @@ -#include "MPMD.hpp" -#include -#include -#include -#include -#include #include +#include #include #include +#include +#include +#include +#include + +#include + #include "Global.h" +#include "MPMD.hpp" #include "RemoteForceInterface.hpp" -#include using namespace LAMMPS_NS; - -typedef rfi::RemoteForceInterface< rfi::ForceIntegrator, rfi::RotParticle, rfi::ArrayOfStructures, real_t > RFI_t; +typedef rfi::RemoteForceInterface RFI_t; struct Info { - MPMDHelper *MPMD; - Memory *memory; - LAMMPS *lmp; - RFI_t * RFI; - std::vector wsize; - std::vector windex; + MPMDHelper* MPMD; + LAMMPS* lmp; + RFI_t* RFI; + std::vector wsize; + std::vector windex; + bool atom_force; + bool first_print; }; - -void tclb_callback(void *, bigint, int, int *, double **, double **); +void tclb_callback(void*, bigint, int, int*, double**, double**); int match_pattern(char* str, char* pattern) { - bool fit = true; - while (fit) { - if (pattern[0] == '\0') break; - if (pattern[0] == ' ') { - if (str[0] == ' ') str++; - else if (str[0] == '\t') str++; - else pattern++; - } else if (pattern[0] == '*') { - if (str[0] == ' ') pattern++; - else if (str[0] == '\t') pattern++; - else str++; - } else if (pattern[0] == str[0]) { - pattern++; str++; - } else fit = false; - } - return fit; + bool fit = true; + while (fit) { + if (pattern[0] == '\0') break; + if (pattern[0] == ' ') { + if (str[0] == ' ') str++; + else if (str[0] == '\t') + str++; + else + pattern++; + } else if (pattern[0] == '*') { + if (str[0] == ' ') pattern++; + else if (str[0] == '\t') + pattern++; + else + str++; + } else if (pattern[0] == str[0]) { + pattern++; + str++; + } else + fit = false; + } + return fit; } +int main(int argc, char* argv[]) { + int ret; + Info info; + MPMDHelper MPMD; + MPI_Init(&argc, &argv); + MPMD.Init(MPI_COMM_WORLD, "LAMMPS"); + DEBUG_SETRANK(MPMD.local_rank); + InitPrint(DEBUG_LEVEL, 6, 8); + MPMD.Identify(); + RFI_t RFI; + RFI.name = "LAMMPS"; -int main(int argc, char *argv[]) -{ - int ret; - Info info; - MPMDHelper MPMD; - MPI_Init(&argc, &argv); - MPMD.Init(MPI_COMM_WORLD, "LAMMPS"); - DEBUG_SETRANK(MPMD.local_rank); - InitPrint(DEBUG_LEVEL, 6, 8); - MPMD.Identify(); - RFI_t RFI; - RFI.name = "LAMMPS"; + if (argc < 2) { + printf("Syntax: lammps in.lammps [args]\n"); + MPI_Abort(MPI_COMM_WORLD, 1); + exit(1); + } + std::vector lammps_args; + char* infile = NULL; + bool logset = false; + for (int i=0; i lammps_args; - char * infile = NULL; - bool logset = false; - for (int i=0; i %s",line); fflush(stdout); - } + int n; + char line[1024]; + while (1) { + if (MPMD.local_rank == 0) { + if (fgets(line, 1024, fp) == NULL) n = 0; + else + n = strlen(line) + 1; + if (n == 0) fclose(fp); + } + MPI_Bcast(&n, 1, MPI_INT, 0, MPMD.local); + if (n == 0) break; + MPI_Bcast(line, n, MPI_CHAR, 0, MPMD.local); + if (MPMD.local_rank == 0) { + fprintf(stdout, "LAMMPS> %s", line); + fflush(stdout); + } - lammps_command(lmp,line); + lammps_command(lmp, line); - if (match_pattern(line, " fix tclb * external")) { - printf("LAMMPS: Added fix tclb external! (%s) Adding callback.\n", line); - MPMDIntercomm inter = MPMD["TCLB"]; - if (!inter) { - fprintf(stderr,"Didn't find TCLB in MPMD\n"); - return -1; - } - ret = RFI.Connect(MPMD.work,inter.work); - if (ret) return ret; - assert(RFI.Connected()); + if (match_pattern(line, " fix tclb * external")) { + printf("LAMMPS: Added fix tclb external! (%s) Adding callback.\n", line); + MPMDIntercomm inter = MPMD["TCLB"]; + if (!inter) { + fprintf(stderr, "Didn't find TCLB in MPMD\n"); + return -1; + } + ret = RFI.Connect(MPMD.work, inter.work); + if (ret) return ret; + assert(RFI.Connected()); - int ifix = lmp->modify->find_fix("tclb"); - printf("ifix: %d\n",ifix); - FixExternal *fix = (FixExternal *) lmp->modify->fix[ifix]; - printf("fix: %p\n",fix); + int ifix = lmp->modify->find_fix("tclb"); + FixExternal* fix = (FixExternal*)lmp->modify->fix[ifix]; - info.MPMD = &MPMD; - info.memory = NULL; - info.lmp = lmp; - info.RFI = &RFI; - info.wsize.resize(RFI.Workers()); - info.windex.resize(RFI.Workers()); + info.MPMD = &MPMD; + info.lmp = lmp; + info.RFI = &RFI; + info.atom_force = true; + info.first_print = true; + info.wsize.resize(RFI.Workers()); + info.windex.resize(RFI.Workers()); - fix->set_callback(tclb_callback,&info); - } - } + fix->set_callback(tclb_callback, &info); + } + } - lammps_close(lmp); - if (RFI.Connected()) { - RFI.Close(); - } - MPI_Finalize(); - return 0; + lammps_close(lmp); + if (RFI.Connected()) { RFI.Close(); } + MPI_Finalize(); + return 0; } +void tclb_callback(void* ptr, bigint ntimestep, int nlocal, int* id, double** x_, double** f_) { + Info* info = (Info*)ptr; + if (!info->RFI->Active()) return; -void tclb_callback(void *ptr, bigint ntimestep, int nlocal, int *id, double **x_, double **f) -{ - Info *info = (Info *) ptr; - if (! info->RFI->Active()) return; - - double ** v = info->lmp->atom->v; - double ** x = info->lmp->atom->x; - double * r = info->lmp->atom->radius; - - for (int phase = 0; phase < 3; phase++) { - if (phase == 0) { - for (int i = 0; i < info->RFI->Workers(); i++) info->wsize[i] = 0; + double** v = info->lmp->atom->v; + double** x = info->lmp->atom->x; + double** omega = info->lmp->atom->omega; + double** f = NULL; + double** torque = NULL; + if (info->atom_force) { + f = info->lmp->atom->f; + torque = info->lmp->atom->torque; } else { - for (int i = 0; i < info->RFI->Workers(); i++) info->windex[i] = 0; + for (size_t k=0; klmp->atom->radius; - for (size_t k = 0; k < nlocal; k++) { - if (phase == 2) { - f[k][0] = 0; - f[k][1] = 0; - f[k][2] = 0; - } - int minper[3], maxper[3], d[3]; - size_t offset = 0; - for (int worker = 0; worker < info->RFI->Workers(); worker++) { - for (int j=0; j<3; j++) { - double prd = info->lmp->domain->prd[j]; - double lower = 0; - double upper = info->lmp->domain->prd[j]; - if (info->RFI->WorkerBox(worker).declared) { - lower = info->RFI->WorkerBox(worker).lower[j]; - upper = info->RFI->WorkerBox(worker).upper[j]; - } - if (info->lmp->domain->periodicity[j]) { - maxper[j] = floor((upper - x[k][j] + r[k]) / prd); - minper[j] = ceil((lower - x[k][j] - r[k]) / prd); - } else { - if ((x[k][j] + r[k] >= lower) && (x[k][j] - r[k] <= upper)) { - minper[j] = 0; maxper[j] = 0; - } else { - minper[j] = 0; maxper[j] = -1; // no balls - } - } -// printf("particle %ld dimenstion %d in %d worker interval [%lg %lg] and periodicity %lg: %lg copied %d:%d\n", k, j, worker, lower, upper, prd, x[k][j], minper[j], maxper[j]); - } - - int copies = (maxper[0]-minper[0]+1)*(maxper[1]-minper[1]+1)*(maxper[2]-minper[2]+1); - // if (copies > 1) printf("particle %ld is copied %d times (%d %d)x(%d %d)x(%d %d)\n", k, copies, minper[0], maxper[0], minper[1], maxper[1], minper[2], maxper[2]); - for (d[0]=minper[0]; d[0]<=maxper[0]; d[0]++) { - for (d[1]=minper[1]; d[1]<=maxper[1]; d[1]++) { - for (d[2]=minper[2]; d[2]<=maxper[2]; d[2]++) { - double px[3]; - for (int j=0; j<3; j++) px[j] = x[k][j] + d[j] * info->lmp->domain->prd[j]; - if (phase == 0) { - info->wsize[worker]++; - } else { - size_t i = offset + info->windex[worker]; - if (phase == 1) { - //printf("particle %ld sent %d at index %ld\n", k, worker, i); - info->RFI->setData(i, RFI_DATA_R, r[k]); - info->RFI->setData(i, RFI_DATA_POS+0, px[0]); - info->RFI->setData(i, RFI_DATA_POS+1, px[1]); - info->RFI->setData(i, RFI_DATA_POS+2, px[2]); - info->RFI->setData(i, RFI_DATA_VEL+0, v[k][0]); - info->RFI->setData(i, RFI_DATA_VEL+1, v[k][1]); - info->RFI->setData(i, RFI_DATA_VEL+2, v[k][2]); - if (info->RFI->Rot()) { - info->RFI->setData(i, RFI_DATA_ANGVEL+0, 0.0); - info->RFI->setData(i, RFI_DATA_ANGVEL+1, 0.0); - info->RFI->setData(i, RFI_DATA_ANGVEL+2, 0.0); - } - } else { - f[k][0] += info->RFI->getData(i, RFI_DATA_FORCE+0); - f[k][1] += info->RFI->getData(i, RFI_DATA_FORCE+1); - f[k][2] += info->RFI->getData(i, RFI_DATA_FORCE+2); - } - info->windex[worker]++; - } - } - } - } - offset += info->wsize[worker]; - } + if (info->first_print) { + printf("LAMMPS: RFI.Rot:%s atom_force:%s f:%s torque:%s\n", + info->RFI->Rot() ? "true" : "false", + info->atom_force ? "true" : "false", + (f != NULL) ? "true" : "false", + (torque != NULL) ? "true" : "false" + ); + info->first_print = false; } - if (phase == 0) { - for (int worker = 0; worker < info->RFI->Workers(); worker++) info->RFI->Size(worker) = info->wsize[worker]; - //printf("sizes:"); for (int worker = 0; worker < info->RFI->Workers(); worker++) printf(" %ld", (size_t) info->wsize[worker]); printf("\n"); - info->RFI->SendSizes(); - info->RFI->Alloc(); - } else if (phase == 1) { - //printf("indexes:"); for (int worker = 0; worker < info->RFI->Workers(); worker++) printf(" %ld", (size_t) info->windex[worker]); printf("\n"); - info->RFI->SendParticles(); - info->RFI->SendForces(); - } else { + + for (int phase=0; phase<3; phase++) { + if (phase == 0) { + for (int i = 0; i < info->RFI->Workers(); i++) info->wsize[i] = 0; + } else { + for (int i = 0; i < info->RFI->Workers(); i++) info->windex[i] = 0; + } + + for (size_t k=0; kRFI->Workers(); worker++) { + for (int j=0; j<3; j++) { + double prd = info->lmp->domain->prd[j]; + double lower = 0; + double upper = info->lmp->domain->prd[j]; + if (info->RFI->WorkerBox(worker).declared) { + lower = info->RFI->WorkerBox(worker).lower[j]; + upper = info->RFI->WorkerBox(worker).upper[j]; + } + if (info->lmp->domain->periodicity[j]) { + maxper[j] = floor((upper - x[k][j] + r[k])/prd); + minper[j] = ceil((lower - x[k][j] - r[k])/prd); + } else { + if ((x[k][j] + r[k] >= lower) && (x[k][j] - r[k] <= upper)) { + minper[j] = 0; + maxper[j] = 0; + } else { + minper[j] = 0; + maxper[j] = -1; // no balls + } + } + // printf("particle %ld dimenstion %d in %d worker interval [%lg %lg] and periodicity %lg: %lg copied %d:%d\n", k, j, worker, lower, upper, prd, x[k][j], minper[j], maxper[j]); + } + + int copies = (maxper[0] - minper[0] + 1)*(maxper[1] - minper[1] + 1)*(maxper[2] - minper[2] + 1); + // if (copies > 1) printf("particle %ld is copied %d times (%d %d)x(%d %d)x(%d %d)\n", k, copies, minper[0], maxper[0], minper[1], maxper[1], minper[2], maxper[2]); + for (d[0] = minper[0]; d[0] <= maxper[0]; d[0]++) { + for (d[1] = minper[1]; d[1] <= maxper[1]; d[1]++) { + for (d[2] = minper[2]; d[2] <= maxper[2]; d[2]++) { + double px[3]; + for (int j=0; j<3; j++) px[j] = x[k][j] + d[j]*info->lmp->domain->prd[j]; + if (phase == 0) { + info->wsize[worker]++; + } else { + size_t i = offset + info->windex[worker]; + if (phase == 1) { + //printf("particle %ld sent %d at index %ld\n", k, worker, i); + info->RFI->setData(i, RFI_DATA_R, r[k]); + info->RFI->setData(i, RFI_DATA_POS + 0, px[0]); + info->RFI->setData(i, RFI_DATA_POS + 1, px[1]); + info->RFI->setData(i, RFI_DATA_POS + 2, px[2]); + info->RFI->setData(i, RFI_DATA_VEL + 0, v[k][0]); + info->RFI->setData(i, RFI_DATA_VEL + 1, v[k][1]); + info->RFI->setData(i, RFI_DATA_VEL + 2, v[k][2]); + if (info->RFI->Rot()) { + if (omega) { + info->RFI->setData(i, RFI_DATA_ANGVEL + 0, omega[k][0]); + info->RFI->setData(i, RFI_DATA_ANGVEL + 1, omega[k][1]); + info->RFI->setData(i, RFI_DATA_ANGVEL + 2, omega[k][2]); + } else { + info->RFI->setData(i, RFI_DATA_ANGVEL + 0, 0.0); + info->RFI->setData(i, RFI_DATA_ANGVEL + 1, 0.0); + info->RFI->setData(i, RFI_DATA_ANGVEL + 2, 0.0); + } + } + } else { + if (f) { + f[k][0] += info->RFI->getData(i, RFI_DATA_FORCE + 0); + f[k][1] += info->RFI->getData(i, RFI_DATA_FORCE + 1); + f[k][2] += info->RFI->getData(i, RFI_DATA_FORCE + 2); + } + if (torque) { + torque[k][0] += info->RFI->getData(i, RFI_DATA_MOMENT + 0); + torque[k][1] += info->RFI->getData(i, RFI_DATA_MOMENT + 1); + torque[k][2] += info->RFI->getData(i, RFI_DATA_MOMENT + 2); + } + } + info->windex[worker]++; + } + } + } + } + offset += info->wsize[worker]; + } + } + if (phase == 0) { + for (int worker = 0; worker < info->RFI->Workers(); worker++) info->RFI->Size(worker) = info->wsize[worker]; + //printf("sizes:"); for (int worker = 0; worker < info->RFI->Workers(); worker++) printf(" %ld", (size_t) info->wsize[worker]); printf("\n"); + info->RFI->SendSizes(); + info->RFI->Alloc(); + } else if (phase == 1) { + //printf("indexes:"); for (int worker = 0; worker < info->RFI->Workers(); worker++) printf(" %ld", (size_t) info->windex[worker]); printf("\n"); + info->RFI->SendParticles(); + info->RFI->SendForces(); + } else { + } } - } } - From 9c4578b5189bd22af397722e94bce9d1b5ed3446 Mon Sep 17 00:00:00 2001 From: L Laniewski-Wollk Date: Thu, 18 Apr 2024 17:05:26 +1000 Subject: [PATCH 03/13] Adding rotation to simplepart --- src/simplepart.cpp | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/src/simplepart.cpp b/src/simplepart.cpp index c9a579f51..e360b8f83 100644 --- a/src/simplepart.cpp +++ b/src/simplepart.cpp @@ -14,6 +14,8 @@ struct Particle { double v[3]; double f[3]; double favg[3]; + double omega[3]; + double torque[3]; size_t n; bool logging; Particle() { @@ -23,6 +25,8 @@ struct Particle { v[i] = 0; f[i] = 0; favg[i] = 0; + omega[i] = 0; + torque[i] = 0; } m = 0; r = 0; @@ -119,18 +123,20 @@ int main(int argc, char *argv[]) { Particle p; for (pugi::xml_attribute attr = node.first_attribute(); attr; attr = attr.next_attribute()) { std::string attr_name = attr.name(); - if (attr_name == "x") { - p.x[0] = attr.as_double(); - } else if (attr_name == "y") { - p.x[1] = attr.as_double(); - } else if (attr_name == "z") { - p.x[2] = attr.as_double(); - } else if (attr_name == "vx") { - p.v[0] = attr.as_double(); - } else if (attr_name == "vy") { - p.v[1] = attr.as_double(); - } else if (attr_name == "vz") { - p.v[2] = attr.as_double(); + bool vec = true; + int d = -1; + auto w = attr_name.back(); + if (w == 'x') { d = 0; } + else if (w == 'y') { d = 1; } + else if (w == 'z') { d = 2; } + else { vec = false; } + if (vec) attr_name.pop_back(); + if (vec && attr_name == "") { + p.x[d] = attr.as_double(); + } else if (vec && attr_name == "v") { + p.v[d] = attr.as_double(); + } else if (vec && attr_name == "omega") { + p.omega[d] = attr.as_double(); } else if (attr_name == "r") { p.r = attr.as_double(); } else if (attr_name == "m") { @@ -276,14 +282,17 @@ int main(int argc, char *argv[]) { RFI.setData(i, RFI_DATA_VEL + 1, p->v[1]); RFI.setData(i, RFI_DATA_VEL + 2, p->v[2]); if (RFI.Rot()) { - RFI.setData(i, RFI_DATA_ANGVEL + 0, 0.0); - RFI.setData(i, RFI_DATA_ANGVEL + 1, 0.0); - RFI.setData(i, RFI_DATA_ANGVEL + 2, 0.0); + RFI.setData(i, RFI_DATA_ANGVEL + 0, p->omega[0]); + RFI.setData(i, RFI_DATA_ANGVEL + 1, p->omega[1]); + RFI.setData(i, RFI_DATA_ANGVEL + 2, p->omega[2]); } } else { p->f[0] += RFI.getData(i, RFI_DATA_FORCE + 0); p->f[1] += RFI.getData(i, RFI_DATA_FORCE + 1); p->f[2] += RFI.getData(i, RFI_DATA_FORCE + 2); + p->torque[0] += RFI.getData(i, RFI_DATA_MOMENT + 0); + p->torque[1] += RFI.getData(i, RFI_DATA_MOMENT + 1); + p->torque[2] += RFI.getData(i, RFI_DATA_MOMENT + 2); } windex[worker]++; } From dd7b2a122aeec2cc006d46331e4a4abe1af72fcf Mon Sep 17 00:00:00 2001 From: L Laniewski-Wollk Date: Thu, 2 May 2024 20:43:26 +1000 Subject: [PATCH 04/13] Correcting moment force --- src/Lattice.cu.Rt | 3 +++ src/simplepart.cpp | 47 ++++++++++++++++++++++++++++++++++------------ 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/src/Lattice.cu.Rt b/src/Lattice.cu.Rt index 67f11d18a..d17408bc3 100644 --- a/src/Lattice.cu.Rt +++ b/src/Lattice.cu.Rt @@ -402,6 +402,9 @@ void Lattice::CopyInParticles() { RFI.RawData(i, RFI_DATA_FORCE+0) = 0; RFI.RawData(i, RFI_DATA_FORCE+1) = 0; RFI.RawData(i, RFI_DATA_FORCE+2) = 0; + RFI.RawData(i, RFI_DATA_MOMENT+0) = 0; + RFI.RawData(i, RFI_DATA_MOMENT+1) = 0; + RFI.RawData(i, RFI_DATA_MOMENT+2) = 0; } if (RFI.mem_size() > 0) { CudaMemcpyAsync(container->particle_data, RFI.Particles(), RFI.mem_size(), CudaMemcpyHostToDevice, kernelStream); diff --git a/src/simplepart.cpp b/src/simplepart.cpp index e360b8f83..151807658 100644 --- a/src/simplepart.cpp +++ b/src/simplepart.cpp @@ -48,7 +48,7 @@ int main(int argc, char *argv[]) { return -1; } MPMD.Identify(); - rfi::RemoteForceInterface RFI; + rfi::RemoteForceInterface RFI; RFI.name = "SIMPLEPART"; MPMDIntercomm inter = MPMD["TCLB"]; @@ -69,6 +69,12 @@ int main(int argc, char *argv[]) { FILE* logging_f = NULL; bool avg = false; + bool log_position = true; + bool log_velocity = true; + bool log_force = true; + bool log_omega = false; + bool log_torque = false; + double periodicity[3]; bool periodic[3]; for (int i = 0; i < 3; i++) { @@ -190,6 +196,10 @@ int main(int argc, char *argv[]) { } else if (attr_name == "average") { avg = attr.as_bool(); if (avg) notice("SIMPLEPART: Particle force averaging is ON"); + } else if (attr_name == "rotation") { + log_omega = attr.as_bool(); + log_torque = log_omega; + if (log_omega) notice("SIMPLEPART: Particle omega and torque is logged"); } else { ERROR("Unknown atribute '%s' in '%s'", attr.name(), node.name()); return -1; @@ -213,7 +223,11 @@ int main(int argc, char *argv[]) { fprintf(logging_f, "Iteration,Time"); for (Particles::iterator p = particles.begin(); p != particles.end(); p++) if (p->logging) { size_t n = p->n; - fprintf(logging_f, ",p%ld_x,p%ld_y,p%ld_z,p%ld_vx,p%ld_vy,p%ld_vz,p%ld_fx,p%ld_fy,p%ld_fz",n,n,n,n,n,n,n,n,n); + if (log_position) fprintf(logging_f, ",p%2$ld_%1$sx,p%2$ld_%1$sy,p%2$ld_%1$sz","",n); + if (log_velocity) fprintf(logging_f, ",p%2$ld_%1$sx,p%2$ld_%1$sy,p%2$ld_%1$sz","v",n); + if (log_force) fprintf(logging_f, ",p%2$ld_%1$sx,p%2$ld_%1$sy,p%2$ld_%1$sz","f",n); + if (log_omega) fprintf(logging_f, ",p%2$ld_%1$sx,p%2$ld_%1$sy,p%2$ld_%1$sz","o",n); + if (log_torque) fprintf(logging_f, ",p%2$ld_%1$sx,p%2$ld_%1$sy,p%2$ld_%1$sz","t",n); } fprintf(logging_f, "\n"); } @@ -236,6 +250,9 @@ int main(int argc, char *argv[]) { p->f[0] = 0; p->f[1] = 0; p->f[2] = 0; + p->torque[0] = 0; + p->torque[1] = 0; + p->torque[2] = 0; } int minper[3], maxper[3], d[3]; size_t offset = 0; @@ -290,9 +307,11 @@ int main(int argc, char *argv[]) { p->f[0] += RFI.getData(i, RFI_DATA_FORCE + 0); p->f[1] += RFI.getData(i, RFI_DATA_FORCE + 1); p->f[2] += RFI.getData(i, RFI_DATA_FORCE + 2); - p->torque[0] += RFI.getData(i, RFI_DATA_MOMENT + 0); - p->torque[1] += RFI.getData(i, RFI_DATA_MOMENT + 1); - p->torque[2] += RFI.getData(i, RFI_DATA_MOMENT + 2); + if (RFI.Rot()) { + p->torque[0] += RFI.getData(i, RFI_DATA_MOMENT + 0); + p->torque[1] += RFI.getData(i, RFI_DATA_MOMENT + 1); + p->torque[2] += RFI.getData(i, RFI_DATA_MOMENT + 2); + } } windex[worker]++; } @@ -316,14 +335,18 @@ int main(int argc, char *argv[]) { if (logging && (iter % logging_iter == 0)) { fprintf(logging_f, "%d,%.15lg", iter, dt*iter); for (Particles::iterator p = particles.begin(); p != particles.end(); p++) if (p->logging) { - for (int i=0; i<3; i++) fprintf(logging_f, ",%.15lg", p->x[i]); - for (int i=0; i<3; i++) fprintf(logging_f, ",%.15lg", p->v[i]); - if (avg) { - for (int i=0; i<3; i++) fprintf(logging_f, ",%.15lg", p->favg[i]/logging_iter); - } else { - for (int i=0; i<3; i++) fprintf(logging_f, ",%.15lg", p->f[i]); + if (log_position) for (int i=0; i<3; i++) fprintf(logging_f, ",%.15lg", p->x[i]); + if (log_velocity) for (int i=0; i<3; i++) fprintf(logging_f, ",%.15lg", p->v[i]); + if (log_force) { + if (avg) { + for (int i=0; i<3; i++) fprintf(logging_f, ",%.15lg", p->favg[i]/logging_iter); + for (int i=0; i<3; i++) p->favg[i] = 0; + } else { + for (int i=0; i<3; i++) fprintf(logging_f, ",%.15lg", p->f[i]); + } } - for (int i=0; i<3; i++) p->favg[i] = 0; + if (log_omega) for (int i=0; i<3; i++) fprintf(logging_f, ",%.15lg", p->omega[i]); + if (log_torque) for (int i=0; i<3; i++) fprintf(logging_f, ",%.15lg", p->torque[i]); } fprintf(logging_f, "\n"); } From 98b2465b9042d913cbfb1f27083ab6b5db0d2427 Mon Sep 17 00:00:00 2001 From: L Laniewski-Wollk Date: Mon, 6 May 2024 23:57:11 +1000 Subject: [PATCH 05/13] Making torque and omega optionally zero --- src/Handlers/acRemoteForceInterface.cpp | 8 +++++++- src/Lattice.cu.Rt | 27 +++++++++++++------------ src/Lattice.h.Rt | 1 + 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/Handlers/acRemoteForceInterface.cpp b/src/Handlers/acRemoteForceInterface.cpp index 63ca861a2..93e3625cf 100644 --- a/src/Handlers/acRemoteForceInterface.cpp +++ b/src/Handlers/acRemoteForceInterface.cpp @@ -55,7 +55,7 @@ int acRemoteForceInterface::ConnectRemoteForceInterface(std::string integrator_) bool use_box = true; attr = node.attribute("use_box"); if (attr) use_box = attr.as_bool(); - + if (use_box) { lbRegion reg = solver->lattice->region; double px = solver->lattice->px; @@ -69,6 +69,12 @@ int acRemoteForceInterface::ConnectRemoteForceInterface(std::string integrator_) pz + reg.dz - PART_MAR_BOX, pz + reg.dz + reg.nz + PART_MAR_BOX); } + + attr = node.attribute("omega"); + if (attr) solver->lattice->RFI_omega = attr.as_bool(); + attr = node.attribute("torque"); + if (attr) solver->lattice->RFI_torque = attr.as_bool(); + MPI_Barrier(MPMD.local); solver->lattice->RFI.Connect(MPMD.work,inter.work); diff --git a/src/Lattice.cu.Rt b/src/Lattice.cu.Rt index d17408bc3..01e4449c5 100644 --- a/src/Lattice.cu.Rt +++ b/src/Lattice.cu.Rt @@ -146,6 +146,8 @@ Lattice::Lattice(lbRegion _region, MPIInfo mpi_, int ns): zSet(ZONESETTINGS, ZON container->particle_data_size = 0; SC.balls = &RFI; RFI.name = "TCLB"; + RFI_omega = true; + RFI_torque = true; } /// Initialization of MPI buffors @@ -398,14 +400,9 @@ void Lattice::CopyInParticles() { CudaMalloc(&container->particle_data, RFI.mem_size()); } container->particle_data_size = RFI.size(); - for (size_t i=0; i 0) { CudaMemcpyAsync(container->particle_data, RFI.Particles(), RFI.mem_size(), CudaMemcpyHostToDevice, kernelStream); } @@ -422,12 +419,16 @@ void Lattice::CopyOutParticles() { CudaStreamSynchronize(kernelStream); DEBUG_PROF_PUSH("Testing particles for NaNs"); int nans = 0; - for (size_t i=0; i 0) notice("%d NANs in particle forces (overwritten with 0.0)\n", nans); diff --git a/src/Lattice.h.Rt b/src/Lattice.h.Rt index 6cdde4882..220b997a5 100644 --- a/src/Lattice.h.Rt +++ b/src/Lattice.h.Rt @@ -74,6 +74,7 @@ public: real_t px, py, pz; MPIInfo mpi; ///< MPI information rfi_t RFI; + bool RFI_omega, RFI_torque; solidcontainer_t SC; size_t particle_data_size_max; char snapFileName[STRING_LEN]; From c0288e4bd52cbbf4cf91b3b1929368c721d1ab53 Mon Sep 17 00:00:00 2001 From: L Laniewski-Wollk Date: Thu, 9 May 2024 22:48:05 +1000 Subject: [PATCH 06/13] Fixing uninitialized force table --- src/lammps.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lammps.cpp b/src/lammps.cpp index 72972e699..4a447f7ff 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -156,7 +156,7 @@ int main(int argc, char* argv[]) { info.MPMD = &MPMD; info.lmp = lmp; info.RFI = &RFI; - info.atom_force = true; + info.atom_force = false; info.first_print = true; info.wsize.resize(RFI.Workers()); info.windex.resize(RFI.Workers()); @@ -180,17 +180,17 @@ void tclb_callback(void* ptr, bigint ntimestep, int nlocal, int* id, double** x_ double** omega = info->lmp->atom->omega; double** f = NULL; double** torque = NULL; + for (size_t k=0; katom_force) { f = info->lmp->atom->f; - torque = info->lmp->atom->torque; } else { - for (size_t k=0; klmp->atom->torque; double* r = info->lmp->atom->radius; if (info->first_print) { From 57ce2d2fc795c8d10a498eaa4112b367bc08130b Mon Sep 17 00:00:00 2001 From: L Laniewski-Wollk Date: Tue, 14 May 2024 14:35:05 +1000 Subject: [PATCH 07/13] nicer vector attributes --- src/simplepart.cpp | 68 ++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 26 deletions(-) diff --git a/src/simplepart.cpp b/src/simplepart.cpp index 151807658..2303796a6 100644 --- a/src/simplepart.cpp +++ b/src/simplepart.cpp @@ -34,6 +34,33 @@ struct Particle { } }; +struct attr_name_t { + std::string vector; + std::string non_vector; + int d; + attr_name_t(const std::string& name) { + bool vec = true; + d = -1; + auto w = name.back(); + if (w == 'x') { d = 0; } + else if (w == 'y') { d = 1; } + else if (w == 'z') { d = 2; } + else { vec = false; } + if (vec) { + vector = name; + vector.pop_back(); + non_vector = "="; + } else { + non_vector = name; + vector = "="; + } + } + attr_name_t(const char* name) : attr_name_t(std::string(name)) {}; + bool operator==(const std::string& name) { + return non_vector == name; + } +}; + typedef std::vector Particles; int main(int argc, char *argv[]) { @@ -75,11 +102,12 @@ int main(int argc, char *argv[]) { bool log_omega = false; bool log_torque = false; - double periodicity[3]; + double periodicity[3], periodic_origin[3]; bool periodic[3]; for (int i = 0; i < 3; i++) { periodic[i] = false; periodicity[i] = 0.0; + periodic_origin[i] = 0.0; } double acc_vec[3]; @@ -128,21 +156,13 @@ int main(int argc, char *argv[]) { if (node_name == "Particle") { Particle p; for (pugi::xml_attribute attr = node.first_attribute(); attr; attr = attr.next_attribute()) { - std::string attr_name = attr.name(); - bool vec = true; - int d = -1; - auto w = attr_name.back(); - if (w == 'x') { d = 0; } - else if (w == 'y') { d = 1; } - else if (w == 'z') { d = 2; } - else { vec = false; } - if (vec) attr_name.pop_back(); - if (vec && attr_name == "") { - p.x[d] = attr.as_double(); - } else if (vec && attr_name == "v") { - p.v[d] = attr.as_double(); - } else if (vec && attr_name == "omega") { - p.omega[d] = attr.as_double(); + attr_name_t attr_name = attr.name(); + if (attr_name.vector == "") { + p.x[attr_name.d] = attr.as_double(); + } else if (attr_name.vector == "v") { + p.v[attr_name.d] = attr.as_double(); + } else if (attr_name.vector == "omega") { + p.omega[attr_name.d] = attr.as_double(); } else if (attr_name == "r") { p.r = attr.as_double(); } else if (attr_name == "m") { @@ -162,16 +182,12 @@ int main(int argc, char *argv[]) { particles.push_back(p); } else if (node_name == "Periodic") { for (pugi::xml_attribute attr = node.first_attribute(); attr; attr = attr.next_attribute()) { - std::string attr_name = attr.name(); - if (attr_name == "x") { - periodic[0] = true; - periodicity[0] = attr.as_double(); - } else if (attr_name == "y") { - periodic[1] = true; - periodicity[1] = attr.as_double(); - } else if (attr_name == "z") { - periodic[2] = true; - periodicity[2] = attr.as_double(); + attr_name_t attr_name = attr.name(); + if (attr_name.vector == "") { + periodic[attr_name.d] = true; + periodicity[attr_name.d] = attr.as_double(); + } else if (attr_name.vector == "p") { + periodic_origin[attr_name.d] = attr.as_double(); } else { ERROR("Unknown atribute '%s' in '%s'", attr.name(), node.name()); return -1; From 326fb48cf46a76fb09604016bcb3b5663c51ec9c Mon Sep 17 00:00:00 2001 From: L Laniewski-Wollk Date: Tue, 14 May 2024 15:21:56 +1000 Subject: [PATCH 08/13] Adding roll example --- example/particle/3d/roll_lb.xml | 22 ++++++++++++++++++++++ example/particle/3d/roll_sp.xml | 5 +++++ 2 files changed, 27 insertions(+) create mode 100644 example/particle/3d/roll_lb.xml create mode 100644 example/particle/3d/roll_sp.xml diff --git a/example/particle/3d/roll_lb.xml b/example/particle/3d/roll_lb.xml new file mode 100644 index 000000000..23009c52a --- /dev/null +++ b/example/particle/3d/roll_lb.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/particle/3d/roll_sp.xml b/example/particle/3d/roll_sp.xml new file mode 100644 index 000000000..3fcb008dc --- /dev/null +++ b/example/particle/3d/roll_sp.xml @@ -0,0 +1,5 @@ + + + + + From 6d575cb6810803ee15767f5e8d582a1bae27128f Mon Sep 17 00:00:00 2001 From: L Laniewski-Wollk Date: Tue, 14 May 2024 21:33:26 +1000 Subject: [PATCH 09/13] Correcting r vector --- src/Particle.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Particle.hpp b/src/Particle.hpp index 8a6b143d9..a91df7f30 100644 --- a/src/Particle.hpp +++ b/src/Particle.hpp @@ -28,9 +28,9 @@ struct ParticleI : Particle { angvel.x = constContainer.particle_data[i*RFI_DATA_SIZE+RFI_DATA_ANGVEL+0]; angvel.y = constContainer.particle_data[i*RFI_DATA_SIZE+RFI_DATA_ANGVEL+1]; angvel.z = constContainer.particle_data[i*RFI_DATA_SIZE+RFI_DATA_ANGVEL+2]; - diff.x = pos.x - node[0]; - diff.y = pos.y - node[1]; - diff.z = pos.z - node[2]; + diff.x = node[0] - pos.x; + diff.y = node[1] - pos.y; + diff.z = node[2] - pos.z; dist = sqrt(diff.x*diff.x + diff.y*diff.y + diff.z*diff.z); cvel.x = vel.x + angvel.y*diff.z - angvel.z*diff.y; cvel.y = vel.y + angvel.z*diff.x - angvel.x*diff.z; From 727009744695819244aeced382b377578fb9323b Mon Sep 17 00:00:00 2001 From: L Laniewski-Wollk Date: Tue, 14 May 2024 21:33:51 +1000 Subject: [PATCH 10/13] Nicer example --- example/particle/3d/roll_lb.xml | 2 +- example/particle/3d/roll_sp.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/example/particle/3d/roll_lb.xml b/example/particle/3d/roll_lb.xml index 23009c52a..748b4c06b 100644 --- a/example/particle/3d/roll_lb.xml +++ b/example/particle/3d/roll_lb.xml @@ -18,5 +18,5 @@ - + diff --git a/example/particle/3d/roll_sp.xml b/example/particle/3d/roll_sp.xml index 3fcb008dc..1e4035306 100644 --- a/example/particle/3d/roll_sp.xml +++ b/example/particle/3d/roll_sp.xml @@ -1,5 +1,5 @@ - + - + From 576e6783b81deacba800559fa021e03de669eb66 Mon Sep 17 00:00:00 2001 From: L Laniewski-Wollk Date: Mon, 20 May 2024 16:38:51 +1000 Subject: [PATCH 11/13] Adding vars to RemoteForceInterface --- src/Handlers/acRemoteForceInterface.cpp | 22 +++++++++++ src/RemoteForceInterface.h | 9 +++++ src/RemoteForceInterface.hpp | 49 ++++++++++++++++++++++++- src/simplepart.cpp | 36 ++++++++++++++---- 4 files changed, 107 insertions(+), 9 deletions(-) diff --git a/src/Handlers/acRemoteForceInterface.cpp b/src/Handlers/acRemoteForceInterface.cpp index 93e3625cf..c11982459 100644 --- a/src/Handlers/acRemoteForceInterface.cpp +++ b/src/Handlers/acRemoteForceInterface.cpp @@ -2,6 +2,8 @@ std::string acRemoteForceInterface::xmlname = "RemoteForceInterface"; #include "../HandlerFactory.h" +#include + int acRemoteForceInterface::Init () { Action::Init(); pugi::xml_attribute attr = node.attribute("integrator"); @@ -22,6 +24,26 @@ int acRemoteForceInterface::ConnectRemoteForceInterface(std::string integrator_) solver->lattice->RFI.setUnits(units[0],units[1],units[2]); solver->lattice->RFI.CanCopeWithUnits(false); + solver->lattice->RFI.setVar("output", solver->info.outpath); + + + std::string element_content; + int node_children = 0; + for (pugi::xml_node par = node.first_child(); par; par = par.next_sibling()) { + node_children ++; + if (node_children > 1) { + ERROR("Only a single element/CDATA allowed inside of a RemoteForceInterface xml element\n"); + return -1; + } + if ((par.type() == pugi::node_pcdata) || (par.type() == pugi::node_cdata)) { + element_content = par.value(); + } else { + std::stringstream ss; + par.print(ss); + element_content = ss.str(); + } + } + if (node_children > 0) solver->lattice->RFI.setVar("content", element_content); bool stats = false; std::string stats_prefix = solver->info.outpath; stats_prefix = stats_prefix + "_RFI"; diff --git a/src/RemoteForceInterface.h b/src/RemoteForceInterface.h index af70e81ce..1dc109122 100644 --- a/src/RemoteForceInterface.h +++ b/src/RemoteForceInterface.h @@ -6,6 +6,7 @@ #include #include #include +#include namespace rfi { @@ -94,6 +95,10 @@ class RemoteForceInterface { std::vector< rfi_real_t > unit; bool non_trivial_units; bool can_cope_with_units; + typedef std::string vars_name_t; + typedef std::string vars_value_t; + typedef std::map< vars_name_t, vars_value_t > vars_t; + vars_t vars; void ISendSizes(); void WSendSizes(); void ISendParticles(); @@ -114,6 +119,7 @@ class RemoteForceInterface { public: int particle_size; std::string name; + rfi_real_t auto_timestep; RemoteForceInterface(); ~RemoteForceInterface(); void MakeTypes(bool,bool); @@ -143,6 +149,9 @@ class RemoteForceInterface { template inline std::vector Exchange(std::vector out); template inline std::basic_string Exchange(std::basic_string out); void setUnits(rfi_real_t meter, rfi_real_t second, rfi_real_t kilogram); + void setVar(const vars_name_t& name, const vars_value_t& value); + bool hasVar(const vars_name_t& name) { return vars.find(name) != vars.end(); }; + const vars_value_t& getVar(const vars_name_t& name) { return vars[name]; }; inline rfi_real_t& RawData(size_t i, int j) { if (STORAGE == ArrayOfStructures) { return tab[i*particle_size + j]; diff --git a/src/RemoteForceInterface.hpp b/src/RemoteForceInterface.hpp index e1553dcf9..7eb3e05f8 100644 --- a/src/RemoteForceInterface.hpp +++ b/src/RemoteForceInterface.hpp @@ -18,7 +18,7 @@ namespace rfi { -const int version = 0x000104; +const int version = 0x000105; #define safe_MPI_Type_free(datatype) { if ((*datatype) != NULL) MPI_Type_free(datatype); } @@ -117,6 +117,7 @@ RemoteForceInterface < TYPE, ROT, STORAGE, rfi_real_t, tab_allocator >::RemoteFo base_units[0] = 1.0; base_units[1] = 1.0; base_units[2] = 1.0; + auto_timestep = 1.0; non_trivial_units = false; can_cope_with_units = true; } @@ -211,6 +212,15 @@ inline void RemoteForceInterface < TYPE, ROT, STORAGE, rfi_real_t, tab_allocator non_trivial_units = true; } +template < rfi_type_t TYPE, rfi_rot_t ROT, rfi_storage_t STORAGE, typename rfi_real_t, typename tab_allocator > +inline void RemoteForceInterface < TYPE, ROT, STORAGE, rfi_real_t, tab_allocator >::setVar(const vars_name_t& name, const vars_value_t& value) { + if (Connected()) { + ERROR("Vars can be set only before connection is established\n"); + exit(-1); + } + vars[name] = value; +} + template < rfi_type_t TYPE, rfi_rot_t ROT, rfi_storage_t STORAGE, typename rfi_real_t, typename tab_allocator > inline void RemoteForceInterface < TYPE, ROT, STORAGE, rfi_real_t, tab_allocator >::CanCopeWithUnits(bool ccwu_) { if (Connected()) { @@ -362,6 +372,43 @@ int RemoteForceInterface < TYPE, ROT, STORAGE, rfi_real_t, tab_allocator >::Nego unit[RFI_DATA_FORCE+i] = kilogram*meter/(second*second); unit[RFI_DATA_MOMENT+i] = kilogram*meter*meter/(second*second); } + auto_timestep = 1.0/second; + } + + typedef std::vector vars_pack_t; + vars_pack_t my_vars, other_vars; + for (vars_t::const_iterator it = vars.begin(); it != vars.end(); it++) { + std::string v; + v = it->first; + for (std::string::const_iterator it2 = v.begin(); it2 != v.end(); it2++) my_vars.push_back(*it2); + my_vars.push_back(0); + v = it->second; + for (std::string::const_iterator it2 = v.begin(); it2 != v.end(); it2++) my_vars.push_back(*it2); + my_vars.push_back(0); + } + other_vars = Exchange(my_vars); + bool is_name = true; + std::string buf; + std::string name_buf; + std::string value_buf; + for (vars_pack_t::const_iterator it = other_vars.begin(); it != other_vars.end(); it++) { + if (*it == 0) { + if (is_name) { + name_buf = buf; + is_name = false; + } else { + value_buf = buf; + is_name = true; + debug1("RFI: %s: Received: %s = %s\n",name.c_str(), name_buf.c_str(), value_buf.c_str()); + if (vars.find(name_buf) != vars.end()) { + debug1("RFI: %s: Variable overwritten.", name.c_str()); + } + vars[name_buf] = value_buf; + } + buf.clear(); + } else { + buf.push_back(*it); + } } } diff --git a/src/simplepart.cpp b/src/simplepart.cpp index 2303796a6..e5f5b5820 100644 --- a/src/simplepart.cpp +++ b/src/simplepart.cpp @@ -88,10 +88,11 @@ int main(int argc, char *argv[]) { wsize.resize(RFI.Workers()); windex.resize(RFI.Workers()); Particles particles; - double dt = 0; + double dt = RFI.auto_timestep; bool logging = false; - std::string logging_filename; + std::string logging_filename = ""; + if (RFI.hasVar("output")) logging_filename = RFI.getVar("output") + "_SP_Log.csv"; int logging_iter = 1; FILE* logging_f = NULL; bool avg = false; @@ -115,14 +116,33 @@ int main(int argc, char *argv[]) { for (int i = 0; i < 3; i++) acc_vec[i] = 0.0; acc_freq = 0.0; - if (argc != 2) { + if (argc < 1 || argc > 2) { printf("Syntax: simplepart config.xml\n"); + printf(" You can omit config.xml if configuration is provided by the force calculator (eg. TCLB xml)\n"); MPI_Abort(MPI_COMM_WORLD,1); exit(1); } - char * filename = argv[1]; + + char * filename = NULL; + if (argc > 1) { + filename = argv[1]; + } pugi::xml_document config; - pugi::xml_parse_result result = config.load_file(filename, pugi::parse_default | pugi::parse_comments); + pugi::xml_parse_result result; + if (filename != NULL) { + if (RFI.hasVar("content")) { + WARNING("Ignoring content (configuration) sent by calculator"); + } + result = config.load_file(filename, pugi::parse_default | pugi::parse_comments); + } else { + if (RFI.hasVar("content")) { + result = config.load_string(RFI.getVar("content").c_str(), pugi::parse_default | pugi::parse_comments); + } else { + printf("No configuration provided (either xml file or content from force calculator\n"); + MPI_Abort(MPI_COMM_WORLD,1); + exit(1); + } + } if (!result) { ERROR("Error while parsing %s: %s\n", filename, result.description()); return -1; @@ -200,8 +220,8 @@ int main(int argc, char *argv[]) { } for (pugi::xml_attribute attr = node.first_attribute(); attr; attr = attr.next_attribute()) { std::string attr_name = attr.name(); + logging = true; if (attr_name == "name") { - logging = true; logging_filename = attr.value(); } else if (attr_name == "Iterations") { logging_iter = attr.as_int(); @@ -221,8 +241,8 @@ int main(int argc, char *argv[]) { return -1; } } - if (!logging) { - ERROR("Name not set in '%s' element", node.name()); + if (logging && logging_filename == "") { + ERROR("Loggin file name not set in '%s' element", node.name()); return -1; } } else { From 28166ad0c62b0d896f5de91d9100ea8a3bc394f6 Mon Sep 17 00:00:00 2001 From: L Laniewski-Wollk Date: Mon, 20 May 2024 16:58:47 +1000 Subject: [PATCH 12/13] Adding a cube with particle example --- example/particle/3d/cube.xml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 example/particle/3d/cube.xml diff --git a/example/particle/3d/cube.xml b/example/particle/3d/cube.xml new file mode 100644 index 000000000..d0739c874 --- /dev/null +++ b/example/particle/3d/cube.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + From d3e8328f3cfd5e73d5b5f5cefb321b1e9b9c05b4 Mon Sep 17 00:00:00 2001 From: L Laniewski-Wollk Date: Mon, 3 Jun 2024 23:34:26 +1000 Subject: [PATCH 13/13] Making lammps wrapper compatibil with content and output variables in RFI --- src/lammps.cpp | 60 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 19 deletions(-) diff --git a/src/lammps.cpp b/src/lammps.cpp index 4a447f7ff..987ec7966 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -66,13 +66,16 @@ int main(int argc, char* argv[]) { RFI_t RFI; RFI.name = "LAMMPS"; - if (argc < 2) { - printf("Syntax: lammps in.lammps [args]\n"); - MPI_Abort(MPI_COMM_WORLD, 1); - exit(1); + MPMDIntercomm inter = MPMD["TCLB"]; + if (inter) { + ret = RFI.Connect(MPMD.work, inter.work); + if (ret) return ret; + } else { + fprintf(stderr, "Didn't find TCLB in MPMD\n"); } + std::vector lammps_args; - char* infile = NULL; + std::string infile = ""; bool logset = false; for (int i=0; imodify->find_fix("tclb");