fix whitespace and apply clang-format

This commit is contained in:
Axel Kohlmeyer
2022-09-08 23:40:37 -04:00
parent dbbb858e3b
commit 6ec5ca37b7
5 changed files with 46 additions and 49 deletions

View File

@ -255,7 +255,7 @@ void FixMDIQM::init()
ierr = MDI_Send(&n, 1, MDI_INT, mdicomm);
if (ierr) error->all(FLERR, "MDI: >NATOMS data");
} else {
} else {
ierr = MDI_Send_command("<NATOMS", mdicomm);
if (ierr) error->all(FLERR, "MDI: <NATOMS command");
int n;

View File

@ -44,7 +44,7 @@ void MDICommand::command(int narg, char **arg)
} else if (strcmp(arg[0], "connect") == 0) {
if (lmp->mdicomm != nullptr)
error->all(FLERR,"MDI cannot connect to already connected engine");
error->all(FLERR, "MDI cannot connect to already connected engine");
MDI_Comm mdicomm;
MDI_Get_communicator(&mdicomm, 0);
@ -53,23 +53,23 @@ void MDICommand::command(int narg, char **arg)
MDI_Accept_communicator(&mdicomm);
if (mdicomm == MDI_COMM_NULL)
error->all(FLERR, "MDI unable to connect to stand-alone engine");
} else error->all(FLERR, "Cannot use mdi connect with plugin engine");
} else
error->all(FLERR, "Cannot use mdi connect with plugin engine");
int nbytes = sizeof(MDI_Comm);
char *ptrcomm = (char *) memory->smalloc(nbytes,"mdi:mdicomm");
memcpy(ptrcomm,&mdicomm,nbytes);
char *ptrcomm = (char *) memory->smalloc(nbytes, "mdi:mdicomm");
memcpy(ptrcomm, &mdicomm, nbytes);
lmp->mdicomm = (void *) ptrcomm;
} else if (strcmp(arg[0], "exit") == 0) {
if (lmp->mdicomm == nullptr)
error->all(FLERR,"MDI cannot send exit to unconnected engine");
if (lmp->mdicomm == nullptr) error->all(FLERR, "MDI cannot send exit to unconnected engine");
MDI_Comm mdicomm;
int nbytes = sizeof(MDI_Comm);
char *ptrcomm = (char *) lmp->mdicomm;
memcpy(&mdicomm,ptrcomm,nbytes);
memcpy(&mdicomm, ptrcomm, nbytes);
int ierr = MDI_Send_command("EXIT", mdicomm);
if (ierr) error->all(FLERR, "MDI: EXIT command");
@ -77,5 +77,6 @@ void MDICommand::command(int narg, char **arg)
memory->sfree(ptrcomm);
lmp->mdicomm = nullptr;
} else error->all(FLERR, "Illegal mdi command");
} else
error->all(FLERR, "Illegal mdi command");
}

View File

@ -54,7 +54,7 @@ enum { DEFAULT, MD, OPT }; // top-level MDI engine modes
enum { TYPE, CHARGE, MASS, COORD, VELOCITY, FORCE, ADDFORCE };
#define MAXELEMENT 103 // used elsewhere in MDI package
#define MAXELEMENT 103 // used elsewhere in MDI package
/* ----------------------------------------------------------------------
trigger LAMMPS to start acting as an MDI engine
@ -65,7 +65,7 @@ enum { TYPE, CHARGE, MASS, COORD, VELOCITY, FORCE, ADDFORCE };
when EXIT command is received, mdi engine command exits
---------------------------------------------------------------------- */
MDIEngine::MDIEngine(LAMMPS *_lmp, int narg, char ** arg) : Pointers(_lmp)
MDIEngine::MDIEngine(LAMMPS *_lmp, int narg, char **arg) : Pointers(_lmp)
{
// check requirements for LAMMPS to work with MDI as an engine
@ -80,18 +80,19 @@ MDIEngine::MDIEngine(LAMMPS *_lmp, int narg, char ** arg) : Pointers(_lmp)
int iarg = 0;
while (iarg < narg) {
if (strcmp(arg[iarg],"elements") == 0) {
if (strcmp(arg[iarg], "elements") == 0) {
int ntypes = atom->ntypes;
delete [] elements;
elements = new int[ntypes+1];
if (iarg+ntypes+1 > narg) error->all(FLERR,"Illegal mdi engine command");
delete[] elements;
elements = new int[ntypes + 1];
if (iarg + ntypes + 1 > narg) error->all(FLERR, "Illegal mdi engine command");
for (int i = 1; i <= ntypes; i++) {
elements[i] = utils::inumeric(FLERR,arg[iarg+i],false,lmp);
elements[i] = utils::inumeric(FLERR, arg[iarg + i], false, lmp);
if (elements[i] < 0 || elements[i] > MAXELEMENT)
error->all(FLERR,"Illegal mdi engine command");
error->all(FLERR, "Illegal mdi engine command");
}
iarg += ntypes+1;
} else error->all(FLERR,"Illegal mdi engine command");
iarg += ntypes + 1;
} else
error->all(FLERR, "Illegal mdi engine command");
}
// error check an MDI element does not map to multiple atom types
@ -99,10 +100,10 @@ MDIEngine::MDIEngine(LAMMPS *_lmp, int narg, char ** arg) : Pointers(_lmp)
if (elements) {
int ntypes = atom->ntypes;
for (int i = 1; i < ntypes; i++)
for (int j = i+1; j <= ntypes; j++) {
for (int j = i + 1; j <= ntypes; j++) {
if (elements[i] == 0 || elements[j] == 0) continue;
if (elements[i] == elements[j])
error->all(FLERR,"MDI engine element cannot map to multiple types");
error->all(FLERR, "MDI engine element cannot map to multiple types");
}
}
@ -167,7 +168,7 @@ MDIEngine::MDIEngine(LAMMPS *_lmp, int narg, char ** arg) : Pointers(_lmp)
ibuf1 = ibuf1all = nullptr;
maxatom = 0;
sys_natoms = static_cast<int> (atom->natoms);
sys_natoms = static_cast<int>(atom->natoms);
reallocate();
nsteps = 0;
@ -297,8 +298,7 @@ void MDIEngine::engine_node(const char *node)
this is a static method in mdi_engine.h
---------------------------------------------------------------------- */
int MDIEngine::execute_command_plugin_wrapper(const char *command,
MDI_Comm comm, void *class_obj)
int MDIEngine::execute_command_plugin_wrapper(const char *command, MDI_Comm comm, void *class_obj)
{
auto mdi_engine = (MDIEngine *) class_obj;
return mdi_engine->execute_command(command, comm);
@ -346,8 +346,7 @@ int MDIEngine::execute_command(const char *command, MDI_Comm mdicomm)
receive_coords();
} else if (strcmp(command, ">ELEMENTS") == 0) {
if (!elements)
error->all(FLERR,"MDI engine command did not define element list");
if (!elements) error->all(FLERR, "MDI engine command did not define element list");
receive_elements();
} else if (strcmp(command, ">FORCES") == 0) {
@ -374,7 +373,7 @@ int MDIEngine::execute_command(const char *command, MDI_Comm mdicomm)
else
receive_double3(VELOCITY);
// -----------------------------------------------
// -----------------------------------------------
} else if (strcmp(command, "<@") == 0) {
ierr = MDI_Send(node_engine, MDI_NAME_LENGTH, MDI_CHAR, mdicomm);
@ -423,9 +422,9 @@ int MDIEngine::execute_command(const char *command, MDI_Comm mdicomm)
} else if (strcmp(command, "<VELOCITIES") == 0) {
send_double3(VELOCITY);
// -----------------------------------------------
// -----------------------------------------------
// MDI action commands at @DEFAULT node
// MDI action commands at @DEFAULT node
} else if (strcmp(command, "MD") == 0) {
md();
@ -433,9 +432,9 @@ int MDIEngine::execute_command(const char *command, MDI_Comm mdicomm)
} else if (strcmp(command, "OPTG") == 0) {
optg();
// -----------------------------------------------
// -----------------------------------------------
// MDI node commands
// MDI node commands
} else if (strcmp(command, "@INIT_MD") == 0) {
if (mode != DEFAULT) error->all(FLERR, "MDI: MDI engine is already performing a simulation");
@ -470,14 +469,14 @@ int MDIEngine::execute_command(const char *command, MDI_Comm mdicomm)
strncpy(node_driver, command, MDI_COMMAND_LENGTH);
node_match = false;
// exit command
// exit command
} else if (strcmp(command, "EXIT") == 0) {
exit_command = true;
// -------------------------------------------------------
// custom LAMMPS commands
// -------------------------------------------------------
// -------------------------------------------------------
// custom LAMMPS commands
// -------------------------------------------------------
} else if (strcmp(command, "NBYTES") == 0) {
nbytes_command();
@ -490,9 +489,9 @@ int MDIEngine::execute_command(const char *command, MDI_Comm mdicomm)
} else if (strcmp(command, "<KE") == 0) {
send_ke();
// -------------------------------------------------------
// unknown command
// -------------------------------------------------------
// -------------------------------------------------------
// unknown command
// -------------------------------------------------------
} else {
error->all(FLERR, "MDI: Unknown command {} received from driver", command);
@ -1010,9 +1009,9 @@ void MDIEngine::create_system()
// create list of 1 to sys_natoms IDs
// optionally set charges if specified by ">CHARGES"
tagint* sys_ids;
tagint *sys_ids;
memory->create(sys_ids, sys_natoms, "mdi:sys_ids");
for (int i = 0; i < sys_natoms; i++) sys_ids[i] = i+1;
for (int i = 0; i < sys_natoms; i++) sys_ids[i] = i + 1;
if (flag_velocities)
lammps_create_atoms(lmp, sys_natoms, sys_ids, sys_types, sys_coords, sys_velocities, nullptr,
@ -1163,13 +1162,12 @@ void MDIEngine::receive_cell()
// 3,7,6 = xy, yz, xz tilt factors
if (sys_cell[1] != 0.0 || sys_cell[2] != 0.0 || sys_cell[5] != 0.0)
error->all(FLERR,
"MDI: Received cell edges are not an upper triangular matrix");
error->all(FLERR, "MDI: Received cell edges are not an upper triangular matrix");
if (sys_cell[3] != 0.0 || sys_cell[7] != 0.0 || sys_cell[6] != 0.0)
if (!domain->triclinic)
error->all(FLERR,
"MDI: Received cell edges are for a triclinic box, "
error->all(FLERR,
"MDI: Received cell edges are for a triclinic box, "
"but LAMMPS is using an orthogonal box");
}
@ -1247,8 +1245,7 @@ void MDIEngine::receive_elements()
break;
}
}
if (itype > ntypes)
error->all(FLERR,"MDI element not found in element list");
if (itype > ntypes) error->all(FLERR, "MDI element not found in element list");
}
}

View File

@ -101,8 +101,7 @@ MDIPlugin::MDIPlugin(LAMMPS *_lmp, int narg, char **arg) : Pointers(_lmp)
// this calls back to plugin_wrapper(), which issues MDI EXIT at end & returns
// plugin_wrapper() must be a static method
MDI_Launch_plugin(plugin_name, plugin_args, &world, plugin_wrapper,
(void *) this);
MDI_Launch_plugin(plugin_name, plugin_args, &world, plugin_wrapper, (void *) this);
delete[] plugin_args;
}