git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11036 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2013-11-21 20:47:55 +00:00
parent c223829854
commit 378ab5cce1
10 changed files with 373 additions and 42 deletions

View File

@ -21,6 +21,9 @@
using namespace LAMMPS_NS;
#define ONELINE 128
#define DELTA 1048576
/* ---------------------------------------------------------------------- */
DumpXYZ::DumpXYZ(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg)
@ -29,6 +32,9 @@ DumpXYZ::DumpXYZ(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg)
if (binary || multiproc) error->all(FLERR,"Invalid dump xyz filename");
size_one = 5;
buffer_allow = 1;
buffer_flag = 1;
sort_flag = 1;
sortcol = 0;
@ -83,6 +89,11 @@ void DumpXYZ::init_style()
}
}
// setup function ptr
if (buffer_flag == 1) write_choice = &DumpXYZ::write_string;
else write_choice = &DumpXYZ::write_lines;
// open single file, one time only
if (multifile == 0) openfile();
@ -151,9 +162,49 @@ void DumpXYZ::pack(int *ids)
}
}
/* ----------------------------------------------------------------------
convert mybuf of doubles to one big formatted string in sbuf
return -1 if strlen exceeds an int, since used as arg in MPI calls in Dump
------------------------------------------------------------------------- */
int DumpXYZ::convert_string(int n, double *mybuf)
{
int offset = 0;
int m = 0;
for (int i = 0; i < n; i++) {
if (offset + ONELINE > maxsbuf) {
if ((bigint) maxsbuf + DELTA > MAXSMALLINT) return -1;
maxsbuf += DELTA;
memory->grow(sbuf,maxsbuf,"dump:sbuf");
}
offset += sprintf(&sbuf[offset],format,
typenames[static_cast<int> (mybuf[m+1])],
mybuf[m+2],mybuf[m+3],mybuf[m+4]);
m += size_one;
}
return offset;
}
/* ---------------------------------------------------------------------- */
void DumpXYZ::write_data(int n, double *mybuf)
{
(this->*write_choice)(n,mybuf);
}
/* ---------------------------------------------------------------------- */
void DumpXYZ::write_string(int n, double *mybuf)
{
fwrite(mybuf,sizeof(char),n,fp);
}
/* ---------------------------------------------------------------------- */
void DumpXYZ::write_lines(int n, double *mybuf)
{
int m = 0;
for (int i = 0; i < n; i++) {