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


C++ ThrData::get_rho1d方法代码示例

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


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

示例1: defined

void PPPMTIP4POMP::fieldforce()
{
  // loop over my charges, interpolate electric field from nearby grid points
  // (nx,ny,nz) = global coords of grid pt to "lower left" of charge
  // (dx,dy,dz) = distance to "lower left" grid pt
  // (mx,my,mz) = global coords of moving stencil pt
  // ek = 3 components of E-field on particle

  const double * const q = atom->q;
  const double * const * const x = atom->x;
  const int * const type = atom->type;
  const int nthreads = comm->nthreads;
  const int nlocal = atom->nlocal;
  const double qqrd2e = force->qqrd2e;

#if defined(_OPENMP)
#pragma omp parallel default(none)
#endif
  {  
#if defined(_OPENMP)
    // each thread works on a fixed chunk of atoms.
    const int tid = omp_get_thread_num();
    const int inum = nlocal;
    const int idelta = 1 + inum/nthreads;
    const int ifrom = tid*idelta;
    const int ito = ((ifrom + idelta) > inum) ? inum : ifrom + idelta;
#else
    const int ifrom = 0;
    const int ito = nlocal;
    const int tid = 0;
#endif
    ThrData *thr = fix->get_thr(tid);
    double * const * const f = thr->get_f();
    FFT_SCALAR * const * const r1d =  static_cast<FFT_SCALAR **>(thr->get_rho1d());
    
    int l,m,n,nx,ny,nz,mx,my,mz;
    FFT_SCALAR dx,dy,dz,x0,y0,z0;
    FFT_SCALAR ekx,eky,ekz;
    int iH1,iH2;
    double xM[3], fx,fy,fz;
    double ddotf, rOMx, rOMy, rOMz, f1x, f1y, f1z;

    // this if protects against having more threads than local atoms
    if (ifrom < nlocal) { 
      for (int i = ifrom; i < ito; i++) {

	if (type[i] == typeO) {
	  find_M(i,iH1,iH2,xM);      
	} else {
	  xM[0] = x[i][0];
	  xM[1] = x[i][1];
	  xM[2] = x[i][2];
	}

	nx = part2grid[i][0];
	ny = part2grid[i][1];
	nz = part2grid[i][2];
	dx = nx+shiftone - (xM[0]-boxlo[0])*delxinv;
	dy = ny+shiftone - (xM[1]-boxlo[1])*delyinv;
	dz = nz+shiftone - (xM[2]-boxlo[2])*delzinv;

	compute_rho1d_thr(r1d,dx,dy,dz);

	ekx = eky = ekz = ZEROF;
	for (n = nlower; n <= nupper; n++) {
	  mz = n+nz;
	  z0 = r1d[2][n];
	  for (m = nlower; m <= nupper; m++) {
	    my = m+ny;
	    y0 = z0*r1d[1][m];
	    for (l = nlower; l <= nupper; l++) {
	      mx = l+nx;
	      x0 = y0*r1d[0][l];
	      ekx -= x0*vdx_brick[mz][my][mx];
	      eky -= x0*vdy_brick[mz][my][mx];
	      ekz -= x0*vdz_brick[mz][my][mx];
	    }
	  }
	}

	// convert E-field to force
	const double qfactor = qqrd2e*scale*q[i];

	if (type[i] != typeO) {
	  f[i][0] += qfactor*ekx;
	  f[i][1] += qfactor*eky;
	  f[i][2] += qfactor*ekz;

	} else {
	  fx = qfactor * ekx;
	  fy = qfactor * eky;
	  fz = qfactor * ekz;
	  find_M(i,iH1,iH2,xM);

	  rOMx = xM[0] - x[i][0];
	  rOMy = xM[1] - x[i][1];
	  rOMz = xM[2] - x[i][2];
  
	  ddotf = (rOMx * fx + rOMy * fy + rOMz * fz) / (qdist * qdist);

//.........这里部分代码省略.........
开发者ID:Polyun,项目名称:LIGGGHTS-PUBLIC,代码行数:101,代码来源:pppm_tip4p_omp.cpp


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