本文整理汇总了C++中Communicator::Bcast方法的典型用法代码示例。如果您正苦于以下问题:C++ Communicator::Bcast方法的具体用法?C++ Communicator::Bcast怎么用?C++ Communicator::Bcast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Communicator
的用法示例。
在下文中一共展示了Communicator::Bcast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dumpforces
//.........这里部分代码省略.........
charges[index]=pdb.getBeta()[i];
}
}
} else if( checknatoms<0 && noatoms ){
natoms=0;
}
if( checknatoms<0 ){
checknatoms=natoms;
p.cmd("setNatoms",&natoms);
p.cmd("init");
}
if(checknatoms!=natoms){
std::string stepstr; Tools::convert(step,stepstr);
error("number of atoms in frame " + stepstr + " does not match number of atoms in first frame");
}
coordinates.assign(3*natoms,real(0.0));
forces.assign(3*natoms,real(0.0));
cell.assign(9,real(0.0));
virial.assign(9,real(0.0));
if( first_step || rnd.U01()>0.5){
if(debug_pd){
int npe=intracomm.Get_size();
vector<int> loc(npe,0);
vector<int> start(npe,0);
for(int i=0;i<npe-1;i++){
int cc=(natoms*2*rnd.U01())/npe;
if(start[i]+cc>natoms) cc=natoms-start[i];
loc[i]=cc;
start[i+1]=start[i]+loc[i];
}
loc[npe-1]=natoms-start[npe-1];
intracomm.Bcast(loc,0);
intracomm.Bcast(start,0);
pd_nlocal=loc[intracomm.Get_rank()];
pd_start=start[intracomm.Get_rank()];
if(intracomm.Get_rank()==0){
fprintf(out,"\nDRIVER: Reassigning particle decomposition\n");
fprintf(out,"DRIVER: "); for(int i=0;i<npe;i++) fprintf(out,"%d ",loc[i]); printf("\n");
fprintf(out,"DRIVER: "); for(int i=0;i<npe;i++) fprintf(out,"%d ",start[i]); printf("\n");
}
p.cmd("setAtomsNlocal",&pd_nlocal);
p.cmd("setAtomsContiguous",&pd_start);
} else if(debug_dd){
int npe=intracomm.Get_size();
int rank=intracomm.Get_rank();
dd_charges.assign(natoms,0.0);
dd_masses.assign(natoms,0.0);
dd_gatindex.assign(natoms,-1);
dd_g2l.assign(natoms,-1);
dd_coordinates.assign(3*natoms,0.0);
dd_forces.assign(3*natoms,0.0);
dd_nlocal=0;
for(int i=0;i<natoms;++i){
double r=rnd.U01()*npe;
int n; for(n=0;n<npe;n++) if(n+1>r)break;
plumed_assert(n<npe);
if(n==rank){
dd_gatindex[dd_nlocal]=i;
dd_g2l[i]=dd_nlocal;
dd_charges[dd_nlocal]=charges[i];
dd_masses[dd_nlocal]=masses[i];
dd_nlocal++;
}
}