merge with current master

This commit is contained in:
Steve Plimpton
2021-01-11 16:13:33 -07:00
3275 changed files with 181008 additions and 818336 deletions

View File

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
https://lammps.sandia.gov/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
@ -12,21 +12,18 @@
------------------------------------------------------------------------- */
#include "dump_custom.h"
#include <cstdlib>
#include <cstring>
#include <string>
#include "atom.h"
#include "force.h"
#include "domain.h"
#include "region.h"
#include "group.h"
#include "input.h"
#include "modify.h"
#include "compute.h"
#include "domain.h"
#include "error.h"
#include "fix.h"
#include "fix_store.h"
#include "group.h"
#include "input.h"
#include "memory.h"
#include "error.h"
#include "modify.h"
#include "region.h"
#include "update.h"
#include "variable.h"
#include "fmt/format.h"
@ -56,19 +53,22 @@ enum{LT,LE,GT,GE,EQ,NEQ,XOR};
DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) :
Dump(lmp, narg, arg),
idregion(NULL), thresh_array(NULL), thresh_op(NULL), thresh_value(NULL),
thresh_last(NULL), thresh_fix(NULL), thresh_fixID(NULL), thresh_first(NULL),
earg(NULL), vtype(NULL), vformat(NULL), columns(NULL), choose(NULL),
dchoose(NULL), clist(NULL), field2index(NULL), argindex(NULL), id_compute(NULL),
compute(NULL), id_fix(NULL), fix(NULL), id_variable(NULL), variable(NULL),
vbuf(NULL), id_custom(NULL), custom(NULL), custom_flag(NULL), typenames(NULL),
pack_choice(NULL)
idregion(nullptr), thresh_array(nullptr), thresh_op(nullptr), thresh_value(nullptr),
thresh_last(nullptr), thresh_fix(nullptr),
thresh_fixID(nullptr), thresh_first(nullptr),
earg(nullptr), vtype(nullptr), vformat(nullptr), columns(nullptr), choose(nullptr),
dchoose(nullptr), clist(nullptr), field2index(nullptr),
argindex(nullptr), id_compute(nullptr),
compute(nullptr), id_fix(nullptr), fix(nullptr),
id_variable(nullptr), variable(nullptr),
vbuf(nullptr), id_custom(nullptr), custom(nullptr), custom_flag(nullptr),
typenames(nullptr), pack_choice(nullptr)
{
if (narg == 5) error->all(FLERR,"No dump custom arguments specified");
clearstep = 1;
nevery = force->inumeric(FLERR,arg[3]);
nevery = utils::inumeric(FLERR,arg[3],false,lmp);
if (nevery <= 0) error->all(FLERR,"Illegal dump custom command");
// expand args if any have wildcard character "*"
@ -77,7 +77,7 @@ DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) :
// nfield may be shrunk below if extra optional args exist
expand = 0;
nfield = nargnew = input->expand_args(narg-5,&arg[5],1,earg);
nfield = nargnew = utils::expand_args(FLERR,narg-5,&arg[5],1,earg,lmp);
if (earg != &arg[5]) expand = 1;
// allocate field vectors
@ -90,38 +90,38 @@ DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) :
buffer_allow = 1;
buffer_flag = 1;
iregion = -1;
idregion = NULL;
idregion = nullptr;
nthresh = 0;
thresh_array = NULL;
thresh_op = NULL;
thresh_value = NULL;
thresh_last = NULL;
thresh_array = nullptr;
thresh_op = nullptr;
thresh_value = nullptr;
thresh_last = nullptr;
nthreshlast = 0;
thresh_fix = NULL;
thresh_fixID = NULL;
thresh_first = NULL;
thresh_fix = nullptr;
thresh_fixID = nullptr;
thresh_first = nullptr;
// computes, fixes, variables which the dump accesses
ncompute = 0;
id_compute = NULL;
compute = NULL;
id_compute = nullptr;
compute = nullptr;
nfix = 0;
id_fix = NULL;
fix = NULL;
id_fix = nullptr;
fix = nullptr;
nvariable = 0;
id_variable = NULL;
variable = NULL;
vbuf = NULL;
id_variable = nullptr;
variable = nullptr;
vbuf = nullptr;
ncustom = 0;
id_custom = NULL;
custom = NULL;
custom_flag = NULL;
id_custom = nullptr;
custom = nullptr;
custom_flag = nullptr;
// process attributes
// ioptional = start of additional optional args in expanded args
@ -146,9 +146,9 @@ DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) :
// atom selection arrays
maxlocal = 0;
choose = NULL;
dchoose = NULL;
clist = NULL;
choose = nullptr;
dchoose = nullptr;
clist = nullptr;
// default element name for all types = C
@ -161,21 +161,21 @@ DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) :
// setup format strings
vformat = new char*[size_one];
vformat = new char*[nfield];
format_default = new char[4*size_one+1];
format_default = new char[4*nfield+1];
format_default[0] = '\0';
for (int i = 0; i < size_one; i++) {
for (int i = 0; i < nfield; i++) {
if (vtype[i] == Dump::INT) strcat(format_default,"%d ");
else if (vtype[i] == Dump::DOUBLE) strcat(format_default,"%g ");
else if (vtype[i] == Dump::STRING) strcat(format_default,"%s ");
else if (vtype[i] == Dump::BIGINT) strcat(format_default,BIGINT_FORMAT " ");
vformat[i] = NULL;
vformat[i] = nullptr;
}
format_column_user = new char*[size_one];
for (int i = 0; i < size_one; i++) format_column_user[i] = NULL;
format_column_user = new char*[nfield];
for (int i = 0; i < nfield; i++) format_column_user[i] = nullptr;
// setup column string
@ -249,12 +249,12 @@ DumpCustom::~DumpCustom()
delete [] typenames;
if (vformat) {
for (int i = 0; i < size_one; i++) delete [] vformat[i];
for (int i = 0; i < nfield; i++) delete [] vformat[i];
delete [] vformat;
}
if (format_column_user) {
for (int i = 0; i < size_one; i++) delete [] format_column_user[i];
for (int i = 0; i < nfield; i++) delete [] format_column_user[i];
delete [] format_column_user;
}
@ -282,10 +282,10 @@ void DumpCustom::init_style()
// lo priority = line, medium priority = int/float, hi priority = column
char *ptr;
for (int i = 0; i < size_one; i++) {
for (int i = 0; i < nfield; i++) {
if (i == 0) ptr = strtok(format," \0");
else ptr = strtok(NULL," \0");
if (ptr == NULL) error->all(FLERR,"Dump_modify format line is too short");
else ptr = strtok(nullptr," \0");
if (ptr == nullptr) error->all(FLERR,"Dump_modify format line is too short");
delete [] vformat[i];
if (format_column_user[i]) {
@ -305,7 +305,7 @@ void DumpCustom::init_style()
strcpy(vformat[i],ptr);
}
if (i+1 < size_one) vformat[i] = strcat(vformat[i]," ");
if (i+1 < nfield) vformat[i] = strcat(vformat[i]," ");
}
// setup boundary string
@ -477,7 +477,7 @@ void DumpCustom::header_binary(bigint ndump)
fwrite(&boxyhi,sizeof(double),1,fp);
fwrite(&boxzlo,sizeof(double),1,fp);
fwrite(&boxzhi,sizeof(double),1,fp);
fwrite(&size_one,sizeof(int),1,fp);
fwrite(&nfield,sizeof(int),1,fp);
header_unit_style_binary();
header_time_binary();
@ -506,7 +506,7 @@ void DumpCustom::header_binary_triclinic(bigint ndump)
fwrite(&boxxy,sizeof(double),1,fp);
fwrite(&boxxz,sizeof(double),1,fp);
fwrite(&boxyz,sizeof(double),1,fp);
fwrite(&size_one,sizeof(int),1,fp);
fwrite(&nfield,sizeof(int),1,fp);
header_unit_style_binary();
header_time_binary();
@ -1203,13 +1203,13 @@ int DumpCustom::convert_string(int n, double *mybuf)
int offset = 0;
int m = 0;
for (i = 0; i < n; i++) {
if (offset + size_one*ONEFIELD > maxsbuf) {
if (offset + nfield*ONEFIELD > maxsbuf) {
if ((bigint) maxsbuf + DELTA > MAXSMALLINT) return -1;
maxsbuf += DELTA;
memory->grow(sbuf,maxsbuf,"dump:sbuf");
}
for (j = 0; j < size_one; j++) {
for (j = 0; j < nfield; j++) {
if (vtype[j] == Dump::INT)
offset += sprintf(&sbuf[offset],vformat[j],static_cast<int> (mybuf[m]));
else if (vtype[j] == Dump::DOUBLE)
@ -1258,7 +1258,7 @@ void DumpCustom::write_lines(int n, double *mybuf)
int m = 0;
for (i = 0; i < n; i++) {
for (j = 0; j < size_one; j++) {
for (j = 0; j < nfield; j++) {
if (vtype[j] == Dump::INT) fprintf(fp,vformat[j],static_cast<int> (mybuf[m]));
else if (vtype[j] == Dump::DOUBLE) fprintf(fp,vformat[j],mybuf[m]);
else if (vtype[j] == Dump::STRING)
@ -1693,7 +1693,7 @@ int DumpCustom::add_variable(char *id)
variable = new int[nvariable+1];
delete [] vbuf;
vbuf = new double*[nvariable+1];
for (int i = 0; i <= nvariable; i++) vbuf[i] = NULL;
for (int i = 0; i <= nvariable; i++) vbuf[i] = nullptr;
int n = strlen(id) + 1;
id_variable[nvariable] = new char[n];
@ -1755,9 +1755,9 @@ int DumpCustom::modify_param(int narg, char **arg)
if (strcmp(arg[1],"none") == 0) {
// just clear format_column_user allocated by this dump child class
for (int i = 0; i < size_one; i++) {
for (int i = 0; i < nfield; i++) {
delete [] format_column_user[i];
format_column_user[i] = NULL;
format_column_user[i] = nullptr;
}
return 2;
}
@ -1775,7 +1775,7 @@ int DumpCustom::modify_param(int narg, char **arg)
// replace "d" in format_int_user with bigint format specifier
// use of &str[1] removes leading '%' from BIGINT_FORMAT string
char *ptr = strchr(format_int_user,'d');
if (ptr == NULL)
if (ptr == nullptr)
error->all(FLERR,
"Dump_modify int format does not contain d character");
char str[8];
@ -1791,8 +1791,8 @@ int DumpCustom::modify_param(int narg, char **arg)
strcpy(format_float_user,arg[2]);
} else {
int i = force->inumeric(FLERR,arg[1]) - 1;
if (i < 0 || i >= size_one)
int i = utils::inumeric(FLERR,arg[1],false,lmp) - 1;
if (i < 0 || i >= nfield)
error->all(FLERR,"Illegal dump_modify command");
if (format_column_user[i]) delete [] format_column_user[i];
int n = strlen(arg[2]) + 1;
@ -1837,17 +1837,17 @@ int DumpCustom::modify_param(int narg, char **arg)
memory->destroy(thresh_array);
memory->destroy(thresh_op);
memory->destroy(thresh_value);
thresh_array = NULL;
thresh_op = NULL;
thresh_value = NULL;
thresh_last = NULL;
thresh_array = nullptr;
thresh_op = nullptr;
thresh_value = nullptr;
thresh_last = nullptr;
for (int i = 0; i < nthreshlast; i++) {
modify->delete_fix(thresh_fixID[i]);
delete [] thresh_fixID[i];
}
thresh_fix = NULL;
thresh_fixID = NULL;
thresh_first = NULL;
thresh_fix = nullptr;
thresh_fixID = nullptr;
thresh_first = nullptr;
}
nthresh = nthreshlast = 0;
return 2;
@ -2127,7 +2127,7 @@ int DumpCustom::modify_param(int narg, char **arg)
// id = dump-ID + nthreshlast + DUMP_STORE, fix group = dump group
if (strcmp(arg[3],"LAST") != 0) {
thresh_value[nthresh] = force->numeric(FLERR,arg[3]);
thresh_value[nthresh] = utils::numeric(FLERR,arg[3],false,lmp);
thresh_last[nthresh] = -1;
} else {
thresh_fix = (FixStore **)
@ -2161,9 +2161,9 @@ int DumpCustom::modify_param(int narg, char **arg)
return # of bytes of allocated memory in buf, choose, variable arrays
------------------------------------------------------------------------- */
bigint DumpCustom::memory_usage()
double DumpCustom::memory_usage()
{
bigint bytes = Dump::memory_usage();
double bytes = Dump::memory_usage();
bytes += memory->usage(choose,maxlocal);
bytes += memory->usage(dchoose,maxlocal);
bytes += memory->usage(clist,maxlocal);