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

This commit is contained in:
sjplimp 2016-07-14 19:42:39 +00:00
parent 2020578386
commit 2f09c2755a
2 changed files with 72 additions and 7 deletions

View File

@ -27,6 +27,8 @@
#include "group.h"
#include "force.h"
#include "comm.h"
#include "modify.h"
#include "fix.h"
#include "input.h"
#include "variable.h"
#include "math_const.h"
@ -40,7 +42,7 @@ using namespace MathConst;
#define BIG 1.0e20
enum{NUMERIC,ATOM,TYPE,ELEMENT,ATTRIBUTE};
enum{SPHERE,LINE}; // also in Body child classes
enum{SPHERE,LINE,TRI}; // also in some Body and Fix child classes
enum{STATIC,DYNAMIC};
enum{NO,YES};
@ -108,7 +110,7 @@ DumpImage::DumpImage(LAMMPS *lmp, int narg, char **arg) :
// set defaults for optional args
atomflag = YES;
lineflag = triflag = bodyflag = NO;
lineflag = triflag = bodyflag = fixflag = NO;
if (atom->nbondtypes == 0) bondflag = NO;
else {
bondflag = YES;
@ -116,6 +118,7 @@ DumpImage::DumpImage(LAMMPS *lmp, int narg, char **arg) :
bdiam = NUMERIC;
bdiamvalue = 0.5;
}
char *fixID = NULL;
thetastr = phistr = NULL;
cflag = STATIC;
@ -195,6 +198,16 @@ DumpImage::DumpImage(LAMMPS *lmp, int narg, char **arg) :
bodyflag2 = force->numeric(FLERR,arg[iarg+3]);
iarg += 4;
} else if (strcmp(arg[iarg],"fix") == 0) {
if (iarg+5 > narg) error->all(FLERR,"Illegal dump image command");
fixflag = YES;
fixID = arg[iarg+1];
if (strcmp(arg[iarg+2],"type") == 0) fixcolor = TYPE;
else error->all(FLERR,"Illegal dump image command");
fixflag1 = force->numeric(FLERR,arg[iarg+3]);
fixflag2 = force->numeric(FLERR,arg[iarg+4]);
iarg += 5;
} else if (strcmp(arg[iarg],"size") == 0) {
if (iarg+3 > narg) error->all(FLERR,"Illegal dump image command");
int width = force->inumeric(FLERR,arg[iarg+1]);
@ -354,7 +367,7 @@ DumpImage::DumpImage(LAMMPS *lmp, int narg, char **arg) :
} else error->all(FLERR,"Illegal dump image command");
}
// error checks and setup for lineflag, triflag, bodyflag
// error checks and setup for lineflag, triflag, bodyflag, fixflag
if (lineflag) {
avec_line = (AtomVecLine *) atom->style_match("line");
@ -375,6 +388,12 @@ DumpImage::DumpImage(LAMMPS *lmp, int narg, char **arg) :
extraflag = 0;
if (lineflag || triflag || bodyflag) extraflag = 1;
if (fixflag) {
int ifix = modify->find_fix(fixID);
if (ifix < 0) error->all(FLERR,"Fix ID for dump image does not exist");
fixptr = modify->fix[ifix];
}
// allocate image buffer now that image size is known
image->buffers();
@ -716,9 +735,10 @@ void DumpImage::create_image()
int i,j,k,m,n,itype,atom1,atom2,imol,iatom,btype,ibonus,drawflag;
tagint tagprev;
double diameter,delx,dely,delz;
int *bodyvec;
double **bodyarray;
int *bodyvec,*fixvec;
double **bodyarray,**fixarray;
double *color,*color1,*color2;
double *p1,*p2,*p3;
double xmid[3],pt1[3],pt2[3],pt3[3];
double mat[3][3];
@ -820,7 +840,6 @@ void DumpImage::create_image()
int *tri = atom->tri;
int *type = atom->type;
for (i = 0; i < nchoose; i++) {
j = clist[i];
if (tri[j] < 0) continue;
@ -1014,6 +1033,47 @@ void DumpImage::create_image()
}
}
// render objects provided by a fix
if (fixflag) {
int tridraw,edgedraw;
if (domain->dimension == 3) {
tridraw = 1;
edgedraw = 1;
if ((int) fixflag1 == 2) tridraw = 0;
if ((int) fixflag1 == 1) edgedraw = 0;
}
n = fixptr->image(fixvec,fixarray);
for (i = 0; i < n; i++) {
if (fixvec[i] == SPHERE) {
// no fix draws spheres yet
} else if (fixvec[i] == LINE) {
if (fixcolor == TYPE) {
itype = static_cast<int> (fixarray[i][0]);
color = colortype[itype];
}
image->draw_cylinder(&fixarray[i][1],&fixarray[i][4],
color,fixflag1,3);
} else if (fixvec[i] == TRI) {
if (fixcolor == TYPE) {
itype = static_cast<int> (fixarray[i][0]);
color = colortype[itype];
}
p1 = &fixarray[i][1];
p2 = &fixarray[i][4];
p3 = &fixarray[i][7];
if (tridraw) image->draw_triangle(p1,p2,p3,color);
if (edgedraw) {
image->draw_cylinder(p1,p2,color,fixflag2,3);
image->draw_cylinder(p2,p3,color,fixflag2,3);
image->draw_cylinder(p3,p1,color,fixflag2,3);
}
}
}
}
// render outline of my sub-box, orthogonal or triclinic
if (subboxflag) {

View File

@ -50,7 +50,10 @@ class DumpImage : public DumpCustom {
int bodyflag; // 0/1 for draw atoms as bodies
int bodycolor; // what determines color of bodies
double bodyflag1,bodyflag2; // user-specified params for drawing bodies
int fixflag; // 0/1 to draw what fix provides
int fixcolor; // what determines color of fix objects
double fixflag1,fixflag2; // user-specified params for fix objects
int bondflag; // 0/1 for draw bonds
int bcolor,bdiam; // what determines color/diam of bonds
double bdiamvalue; // bond diameter value
@ -80,6 +83,8 @@ class DumpImage : public DumpCustom {
class AtomVecTri *avec_tri;
class AtomVecBody *avec_body;
class Fix *fixptr; // ptr to Fix that provides image data
class Image *image; // class that renders each image
int *chooseghost; // extended choose array for comm