当前位置: 首页>>代码示例>>C++>>正文


C++ AtomVec::unpack_restart方法代码示例

本文整理汇总了C++中AtomVec::unpack_restart方法的典型用法代码示例。如果您正苦于以下问题:C++ AtomVec::unpack_restart方法的具体用法?C++ AtomVec::unpack_restart怎么用?C++ AtomVec::unpack_restart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AtomVec的用法示例。


在下文中一共展示了AtomVec::unpack_restart方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: command


//.........这里部分代码省略.........
    double *x,lamda[3];
    double *coord,*sublo,*subhi;
    if (triclinic == 0) {
      sublo = domain->sublo;
      subhi = domain->subhi;
    } else {
      sublo = domain->sublo_lamda;
      subhi = domain->subhi_lamda;
    }

    for (int iproc = 0; iproc < nprocs_file; iproc++) {
      if (read_int() != PERPROC) 
        error->all(FLERR,"Invalid flag in peratom section of restart file");

      n = read_int();
      if (n > maxbuf) {
        maxbuf = n;
        memory->destroy(buf);
        memory->create(buf,maxbuf,"read_restart:buf");
      }
      read_double_vec(n,buf);

      m = 0;
      while (m < n) {
        x = &buf[m+1];
        if (triclinic) {
          domain->x2lamda(x,lamda);
          coord = lamda;
        } else coord = x;

        if (coord[0] >= sublo[0] && coord[0] < subhi[0] &&
            coord[1] >= sublo[1] && coord[1] < subhi[1] &&
            coord[2] >= sublo[2] && coord[2] < subhi[2]) {
          m += avec->unpack_restart(&buf[m]);
        }
        else m += static_cast<int> (buf[m]);
      }
    }

    if (me == 0) fclose(fp);
  }

  // input of multiple native files with procs <= files
  // # of files = multiproc_file
  // each proc reads a subset of files, striding by nprocs
  // each proc keeps all atoms in all perproc chunks in its files

  else if (nprocs <= multiproc_file) {

    char *procfile = new char[strlen(file) + 16];
    char *ptr = strchr(file,'%');

    for (int iproc = me; iproc < multiproc_file; iproc += nprocs) {
      *ptr = '\0';
      sprintf(procfile,"%s%d%s",file,iproc,ptr+1);
      *ptr = '%';
      fp = fopen(procfile,"rb");
      if (fp == NULL) {
        char str[128];
        sprintf(str,"Cannot open restart file %s",procfile);
        error->one(FLERR,str);
      }

      fread(&flag,sizeof(int),1,fp);
      if (flag != PROCSPERFILE) 
        error->one(FLERR,"Invalid flag in peratom section of restart file");
开发者ID:dzhou36,项目名称:hrmc,代码行数:67,代码来源:read_restart.cpp

示例2: command


//.........这里部分代码省略.........
    }
    MPI_Bcast(&n,1,MPI_INT,iproc,world);
    MPI_Bcast(buf,n,MPI_DOUBLE,iproc,world);

    for (ix = 0; ix < nx; ix++) {
      for (iy = 0; iy < ny; iy++) {
        for (iz = 0; iz < nz; iz++) {

          // while loop over one proc's atom list

          m = 0;
          while (m < n) {
            image = ((imageint) IMGMAX << IMG2BITS) |
              ((imageint) IMGMAX << IMGBITS) | IMGMAX;
            if (triclinic == 0) {
              x[0] = buf[m+1] + ix*old_xprd;
              x[1] = buf[m+2] + iy*old_yprd;
              x[2] = buf[m+3] + iz*old_zprd;
            } else {
              x[0] = buf[m+1] + ix*old_xprd + iy*old_xy + iz*old_xz;
              x[1] = buf[m+2] + iy*old_yprd + iz*old_yz;
              x[2] = buf[m+3] + iz*old_zprd;
            }
            domain->remap(x,image);
            if (triclinic) {
              domain->x2lamda(x,lamda);
              coord = lamda;
            } else coord = x;

            if (coord[0] >= sublo[0] && coord[0] < subhi[0] &&
                coord[1] >= sublo[1] && coord[1] < subhi[1] &&
                coord[2] >= sublo[2] && coord[2] < subhi[2]) {

              m += avec->unpack_restart(&buf[m]);

              i = atom->nlocal - 1;
              if (tag_enable)
                atom_offset = iz*ny*nx*maxtag + iy*nx*maxtag + ix*maxtag;
              else atom_offset = 0;
              mol_offset = iz*ny*nx*maxmol + iy*nx*maxmol + ix*maxmol;

              atom->x[i][0] = x[0];
              atom->x[i][1] = x[1];
              atom->x[i][2] = x[2];

              atom->tag[i] += atom_offset;
              atom->image[i] = image;

              if (atom->molecular) {
                if (atom->molecule[i] > 0)
                  atom->molecule[i] += mol_offset;
                if (atom->molecular == 1) {
                  if (atom->avec->bonds_allow)
                    for (j = 0; j < atom->num_bond[i]; j++)
                      atom->bond_atom[i][j] += atom_offset;
                  if (atom->avec->angles_allow)
                    for (j = 0; j < atom->num_angle[i]; j++) {
                      atom->angle_atom1[i][j] += atom_offset;
                      atom->angle_atom2[i][j] += atom_offset;
                      atom->angle_atom3[i][j] += atom_offset;
                    }
                  if (atom->avec->dihedrals_allow)
                    for (j = 0; j < atom->num_dihedral[i]; j++) {
                      atom->dihedral_atom1[i][j] += atom_offset;
                      atom->dihedral_atom2[i][j] += atom_offset;
                      atom->dihedral_atom3[i][j] += atom_offset;
开发者ID:Vikramjit21,项目名称:lammps,代码行数:67,代码来源:replicate.cpp

示例3: command


//.........这里部分代码省略.........
    double *coord,*sublo,*subhi;
    if (triclinic == 0) {
      sublo = domain->sublo;
      subhi = domain->subhi;
    } else {
      sublo = domain->sublo_lamda;
      subhi = domain->subhi_lamda;
    }

    for (int iproc = 0; iproc < nprocs_file; iproc++) {
      n = read_int();
      if (n > maxbuf) {
        maxbuf = n;
        memory->destroy(buf);
        memory->create(buf,maxbuf,"read_restart:buf");
      }

      if (n > 0) {
        if (me == 0) nread_double(buf,n,fp);
        MPI_Bcast(buf,n,MPI_DOUBLE,0,world);
      }

      m = 0;
      while (m < n) {
        x = &buf[m+1];
        if (triclinic) {
          domain->x2lamda(x,lamda);
          coord = lamda;
        } else coord = x;

        if (coord[0] >= sublo[0] && coord[0] < subhi[0] &&
            coord[1] >= sublo[1] && coord[1] < subhi[1] &&
            coord[2] >= sublo[2] && coord[2] < subhi[2]) {
          m += avec->unpack_restart(&buf[m]);
        }
        else m += static_cast<int> (buf[m]);
      }
    }

    if (me == 0) fclose(fp);

  // one file per proc:
  // nprocs_file = # of files
  // each proc reads 1/P fraction of files, keeping all atoms in the files
  // perform irregular comm to migrate atoms to correct procs
  // close restart file when done

  } else {
    if (me == 0) fclose(fp);
    char *perproc = new char[strlen(file) + 16];
    char *ptr = strchr(file,'%');

    for (int iproc = me; iproc < nprocs_file; iproc += nprocs) {
      *ptr = '\0';
      sprintf(perproc,"%s%d%s",file,iproc,ptr+1);
      *ptr = '%';
      fp = fopen(perproc,"rb");
      if (fp == NULL) {
        char str[128];
        sprintf(str,"Cannot open restart file %s",perproc);
        error->one(FLERR,str);
      }

      nread_int(&n,1,fp);
      if (n > maxbuf) {
        maxbuf = n;
开发者ID:Nasrollah,项目名称:LIGGGHTS-PUBLIC,代码行数:67,代码来源:read_restart.cpp

示例4: command


//.........这里部分代码省略.........
      for (i = 0; i < old->nlocal; i++) n += old_avec->pack_restart(i,&buf[n]);
    }
    MPI_Bcast(&n,1,MPI_INT,iproc,world);
    MPI_Bcast(buf,n,MPI_DOUBLE,iproc,world);

    for (ix = 0; ix < nx; ix++) {
      for (iy = 0; iy < ny; iy++) {
	for (iz = 0; iz < nz; iz++) {

	  // while loop over one proc's atom list

	  m = 0;
	  while (m < n) {
	    image = (512 << 20) | (512 << 10) | 512;
	    if (triclinic == 0) {
	      x[0] = buf[m+1] + ix*old_xprd;
	      x[1] = buf[m+2] + iy*old_yprd;
	      x[2] = buf[m+3] + iz*old_zprd;
	    } else {
	      x[0] = buf[m+1] + ix*old_xprd + iy*old_xy + iz*old_xz;
	      x[1] = buf[m+2] + iy*old_yprd + iz*old_yz;
	      x[2] = buf[m+3] + iz*old_zprd;
	    }
	    domain->remap(x,image);
	    if (triclinic) {
	      domain->x2lamda(x,lamda);
	      coord = lamda;
	    } else coord = x;

	    if (coord[0] >= sublo[0] && coord[0] < subhi[0] && 
		coord[1] >= sublo[1] && coord[1] < subhi[1] && 
		coord[2] >= sublo[2] && coord[2] < subhi[2]) {

	      m += avec->unpack_restart(&buf[m]);

	      i = atom->nlocal - 1;
	      if (tag_enable)
		atom_offset = iz*ny*nx*maxtag + iy*nx*maxtag + ix*maxtag;
	      else atom_offset = 0;
	      mol_offset = iz*ny*nx*maxmol + iy*nx*maxmol + ix*maxmol;

	      atom->x[i][0] = x[0];
	      atom->x[i][1] = x[1];
	      atom->x[i][2] = x[2];

	      atom->tag[i] += atom_offset;
	      atom->image[i] = image;

	      if (atom->molecular) {
		if (atom->molecule[i] > 0)
		  atom->molecule[i] += mol_offset;
		if (atom->avec->bonds_allow)
		  for (j = 0; j < atom->num_bond[i]; j++)
		    atom->bond_atom[i][j] += atom_offset;
		if (atom->avec->angles_allow)
		  for (j = 0; j < atom->num_angle[i]; j++) {
		    atom->angle_atom1[i][j] += atom_offset;
		    atom->angle_atom2[i][j] += atom_offset;
		    atom->angle_atom3[i][j] += atom_offset;
		  }
		if (atom->avec->dihedrals_allow)
		  for (j = 0; j < atom->num_dihedral[i]; j++) {
		    atom->dihedral_atom1[i][j] += atom_offset;
		    atom->dihedral_atom2[i][j] += atom_offset;
		    atom->dihedral_atom3[i][j] += atom_offset;
		    atom->dihedral_atom4[i][j] += atom_offset;
开发者ID:8cH9azbsFifZ,项目名称:lammps-CSI,代码行数:67,代码来源:replicate.cpp


注:本文中的AtomVec::unpack_restart方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。