avoid copies of C++ strings

This commit is contained in:
Axel Kohlmeyer
2025-06-16 20:19:53 -04:00
parent 53fec5563c
commit 515ccac51c

View File

@ -18,7 +18,6 @@
#define LAMMPS_LIB_MPI 1
#include "library.h"
#include <mpi.h>
#include <algorithm>
#include "accelerator_kokkos.h"
#include "atom.h"
@ -60,7 +59,10 @@
#include "variable.h"
#include "version.h"
#include <algorithm>
#include <cstring>
#include <utility>
#if defined(LMP_PYTHON)
#include <Python.h>
@ -125,11 +127,11 @@ static void ptr_argument_warning()
error->set_last_error(e.what(), ERROR_NORMAL); \
}
#define STORE_ERROR_MESSAGE(handle, message) \
if (handle && handle->error) { \
handle->error->set_last_error(message); \
} else { \
lammps_last_global_errormessage = message; \
#define STORE_ERROR_MESSAGE(handle, message) \
if (handle && handle->error) { \
handle->error->set_last_error(message); \
} else { \
lammps_last_global_errormessage = std::move(message); \
}
// ----------------------------------------------------------------------
@ -312,7 +314,7 @@ void lammps_close(void *handle)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->comm) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -500,7 +502,7 @@ void lammps_error(void *handle, int error_type, const char *error_text)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -587,7 +589,7 @@ char *lammps_expand(void *handle, const char *line)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return nullptr;
}
@ -637,7 +639,7 @@ void lammps_file(void *handle, const char *filename)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->update || !lmp->input) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -679,7 +681,7 @@ char *lammps_command(void *handle, const char *cmd)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->update || !lmp->input) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return nullptr;
}
@ -755,7 +757,7 @@ void lammps_commands_string(void *handle, const char *str)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->update || !lmp->output || !lmp->comm || !lmp->input) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -883,7 +885,7 @@ double lammps_get_natoms(void *handle)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->atom) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return -1.0;
}
@ -916,7 +918,7 @@ double lammps_get_thermo(void *handle, const char *keyword)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->output || !lmp->output->thermo) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return 0.0;
}
@ -1017,7 +1019,7 @@ void *lammps_last_thermo(void *handle, const char *what, int index)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->update || !lmp->output || !lmp->output->thermo) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return nullptr;
}
@ -1108,7 +1110,7 @@ void lammps_extract_box(void *handle, double *boxlo, double *boxhi,
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->domain || !lmp->comm) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -1175,7 +1177,7 @@ void lammps_reset_box(void *handle, double *boxlo, double *boxhi,
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->domain || !lmp->comm) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -1242,7 +1244,7 @@ void lammps_memory_usage(void *handle, double *meminfo)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -1278,14 +1280,14 @@ int lammps_get_mpi_comm(void *handle)
{
#ifdef MPI_STUBS
LAMMPS *lmp = nullptr;
const auto mesg = fmt::format("ERROR: {}(): No MPI communicator conversion possible "
const auto &mesg = fmt::format("ERROR: {}(): No MPI communicator conversion possible "
"with MPI STUBS\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return -1;
#else
LAMMPS *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return -1;
}
@ -1538,7 +1540,7 @@ int lammps_extract_setting(void *handle, const char *keyword)
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->domain || !lmp->force || !lmp->comm || !lmp->universe || !lmp->atom) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return -1;
}
@ -2209,7 +2211,7 @@ void *lammps_extract_global(void *handle, const char *name)
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->update || !lmp->atom || !lmp->force || !lmp->domain || !lmp->domain->lattice
|| !lmp->update->integrate) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return nullptr;
}
@ -2351,7 +2353,7 @@ int lammps_extract_pair_dimension(void * handle, const char *name)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->force || !lmp->force->pair) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return -1;
}
@ -2385,7 +2387,7 @@ void *lammps_extract_pair(void * handle, const char *name)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->force || !lmp->force->pair) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return nullptr;
}
@ -2420,7 +2422,7 @@ int lammps_map_atom(void *handle, const void *id)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->atom) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return -1;
}
@ -2461,7 +2463,7 @@ int lammps_extract_atom_datatype(void *handle, const char *name)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->atom) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return -1;
}
@ -2499,7 +2501,7 @@ int lammps_extract_atom_size(void *handle, const char *name, int type)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->atom) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return -1;
}
@ -2540,7 +2542,7 @@ void *lammps_extract_atom(void *handle, const char *name)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->atom) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return nullptr;
}
@ -2663,7 +2665,7 @@ void *lammps_extract_compute(void *handle, const char *id, int style, int type)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->modify) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return nullptr;
}
@ -2896,7 +2898,7 @@ void *lammps_extract_fix(void *handle, const char *id, int style, int type, int
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->modify) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return nullptr;
}
@ -3095,7 +3097,7 @@ void *lammps_extract_variable(void *handle, const char *name, const char *group)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->input || !lmp->input->variable || !lmp->group) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return nullptr;
}
@ -3161,7 +3163,7 @@ int lammps_extract_variable_datatype(void *handle, const char *name)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->input || !lmp->input->variable) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return -1;
}
@ -3252,7 +3254,7 @@ int lammps_set_string_variable(void *handle, const char *name, const char *str)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->input || !lmp->input->variable) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return -1;
}
@ -3295,7 +3297,7 @@ int lammps_set_internal_variable(void *handle, const char *name, double value)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->input || !lmp->input->variable) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return -1;
}
@ -3343,7 +3345,7 @@ string, otherwise 1.
int lammps_variable_info(void *handle, int idx, char *buffer, int buf_size) {
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->input || !lmp->input->variable) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return -1;
}
@ -3384,7 +3386,7 @@ double lammps_eval(void *handle, const char *expr)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->input || !lmp->input->variable) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return 0.0;
}
@ -3423,7 +3425,7 @@ double lammps_eval(void *handle, const char *expr)
void lammps_clearstep_compute(void *handle) {
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->modify) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -3455,7 +3457,7 @@ void lammps_clearstep_compute(void *handle) {
void lammps_addstep_compute_all(void *handle, void *newstep) {
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->modify) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -3486,7 +3488,7 @@ void lammps_addstep_compute_all(void *handle, void *newstep) {
void lammps_addstep_compute(void *handle, void *newstep) {
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->modify) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -3549,7 +3551,7 @@ void lammps_gather_atoms(void *handle, const char *name, int dtype, int count, v
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->atom || !lmp->memory) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -3711,7 +3713,7 @@ void lammps_gather_atoms_concat(void *handle, const char *name, int dtype,
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->atom || !lmp->comm || !lmp->memory) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -3878,7 +3880,7 @@ void lammps_gather_atoms_subset(void *handle, const char *name, int dtype,
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->atom || !lmp->memory) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -4041,7 +4043,7 @@ void lammps_scatter_atoms(void *handle, const char *name, int dtype, int count,
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->atom || !lmp->memory) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -4195,7 +4197,7 @@ void lammps_scatter_atoms_subset(void *handle, const char *name, int dtype,
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->atom || !lmp->memory) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -4370,7 +4372,7 @@ void lammps_gather_bonds(void *handle, void *data)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->atom || !lmp->atom->avec || !lmp->comm || !lmp->memory) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -4488,7 +4490,7 @@ void lammps_gather_angles(void *handle, void *data)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->atom || !lmp->atom->avec || !lmp->comm || !lmp->memory) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -4607,7 +4609,7 @@ void lammps_gather_dihedrals(void *handle, void *data)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->atom || !lmp->atom->avec || !lmp->comm || !lmp->memory) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -4726,7 +4728,7 @@ void lammps_gather_impropers(void *handle, void *data)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->atom || !lmp->atom->avec || !lmp->comm || !lmp->memory) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -4839,7 +4841,7 @@ void lammps_gather(void *handle, const char *name, int dtype, int count, void *d
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->atom || !lmp->memory || !lmp->modify) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -5099,7 +5101,7 @@ void lammps_gather_concat(void *handle, const char *name, int dtype, int count,
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->atom || !lmp->memory || !lmp->modify || !lmp->comm) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -5369,7 +5371,7 @@ void lammps_gather_subset(void *handle, const char *name, int dtype, int count,
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->atom || !lmp->memory || !lmp->modify || !lmp->comm) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -5637,7 +5639,7 @@ void lammps_scatter(void *handle, const char *name, int dtype, int count, void *
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->atom || !lmp->memory || !lmp->modify || !lmp->comm) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -5880,7 +5882,7 @@ void lammps_scatter_subset(void *handle, const char *name, int dtype, int count,
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->atom || !lmp->memory || !lmp->modify || !lmp->comm) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -6118,7 +6120,7 @@ int lammps_create_atoms(void *handle, int n, const tagint *id, const int *type,
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->domain || !lmp->atom) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return -1;
}
@ -6225,12 +6227,12 @@ void lammps_create_molecule(void *handle, const char *id, const char *jsonstr)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->atom || !lmp->comm || !lmp->domain || !lmp->error) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
if (!id || !jsonstr) {
const auto mesg = fmt::format("ERROR: {}(): Non-NULL arguments required\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Non-NULL arguments required\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -6280,7 +6282,7 @@ void lammps_create_molecule(void *handle, const char *id, const char *jsonstr)
int lammps_find_pair_neighlist(void *handle, const char *style, int exact, int nsub, int reqid) {
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->neighbor || !lmp->force) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return -1;
}
@ -6321,7 +6323,7 @@ int lammps_find_pair_neighlist(void *handle, const char *style, int exact, int n
int lammps_find_fix_neighlist(void *handle, const char *id, int reqid) {
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->neighbor || !lmp->modify) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return -1;
}
@ -6362,7 +6364,7 @@ int lammps_find_fix_neighlist(void *handle, const char *id, int reqid) {
int lammps_find_compute_neighlist(void *handle, const char *id, int reqid) {
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->neighbor || !lmp->modify) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return -1;
}
@ -6459,7 +6461,7 @@ int lammps_request_single_neighlist(void *handle, const char *id, int flags, dou
auto lmp = (LAMMPS *)handle;
int idx = -1;
if (!lmp || !lmp->error || !lmp->neighbor) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return -1;
}
@ -6490,7 +6492,7 @@ int lammps_request_single_neighlist(void *handle, const char *id, int flags, dou
int lammps_neighlist_num_elements(void *handle, int idx) {
auto lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->neighbor) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return 0;
}
@ -6521,7 +6523,7 @@ void lammps_neighlist_element_neighbors(void *handle, int idx, int element, int
int *numneigh, int **neighbors) {
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->neighbor) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -6572,7 +6574,7 @@ int lammps_version(void *handle)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return 0;
}
@ -6922,7 +6924,7 @@ Valid categories are: *atom*\ , *integrate*\ , *minimize*\ ,
int lammps_has_style(void *handle, const char *category, const char *name) {
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return 0;
}
@ -6950,7 +6952,7 @@ categories.
int lammps_style_count(void *handle, const char *category) {
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return 0;
}
@ -6982,7 +6984,7 @@ int lammps_style_count(void *handle, const char *category) {
int lammps_style_name(void *handle, const char *category, int idx, char *buffer, int buf_size) {
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return 0;
}
@ -7023,7 +7025,7 @@ int lammps_has_id(void *handle, const char *category, const char *name) {
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->modify || !lmp->output || !lmp->group || !lmp->atom
|| !lmp->domain || !lmp->input || !lmp->input->variable) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return 0;
}
@ -7070,7 +7072,7 @@ int lammps_id_count(void *handle, const char *category) {
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->modify || !lmp->output || !lmp->group || !lmp->atom
|| !lmp->domain || !lmp->input || !lmp->input->variable) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return 0;
}
@ -7122,7 +7124,7 @@ int lammps_id_name(void *handle, const char *category, int idx, char *buffer, in
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->modify || !lmp->output || !lmp->group || !lmp->atom
|| !lmp->domain || !lmp->input || !lmp->input->variable) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return 0;
}
@ -7351,7 +7353,7 @@ void lammps_set_fix_external_callback(void *handle, const char *id, FixExternalF
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->modify) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -7420,7 +7422,7 @@ double **lammps_fix_external_get_force(void *handle, const char *id)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->modify) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return nullptr;
}
@ -7476,7 +7478,7 @@ void lammps_fix_external_set_energy_global(void *handle, const char *id, double
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->modify) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -7531,7 +7533,7 @@ void lammps_fix_external_set_virial_global(void *handle, const char *id, double
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->modify) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -7586,7 +7588,7 @@ void lammps_fix_external_set_energy_peratom(void *handle, const char *id, double
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->modify) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -7644,7 +7646,7 @@ void lammps_fix_external_set_virial_peratom(void *handle, const char *id, double
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->modify) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -7695,7 +7697,7 @@ void lammps_fix_external_set_vector_length(void *handle, const char *id, int len
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->modify) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -7756,7 +7758,7 @@ void lammps_fix_external_set_vector(void *handle, const char *id, int idx, doubl
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->modify) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}
@ -7826,7 +7828,7 @@ int lammps_is_running(void *handle)
{
auto lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->update) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return 0;
}
@ -7844,7 +7846,7 @@ void lammps_force_timeout(void *handle)
{
auto *lmp = (LAMMPS *) handle;
if (!lmp || !lmp->error || !lmp->timer) {
const auto mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
const auto &mesg = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
STORE_ERROR_MESSAGE(lmp, mesg);
return;
}