本文整理汇总了C++中Molecule::F方法的典型用法代码示例。如果您正苦于以下问题:C++ Molecule::F方法的具体用法?C++ Molecule::F怎么用?C++ Molecule::F使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Molecule
的用法示例。
在下文中一共展示了Molecule::F方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
ReturnType SnapshotCommand::execute ()
{
#ifdef ENABLE_MPI
int myRank, mySize;
MPI_Comm_size (MPI_COMM_WORLD, &mySize);
MPI_Comm_rank (MPI_COMM_WORLD, &myRank);
#else
logger->debug() << "----------------->Not Parallel snapshot " << std::endl;
//return EXECUTED;
#endif
Domain* dom = sim -> getDomain ();
int numberOfComponents = dom -> getComponents().size();
SteereoStream daStream;
SteereoStream outStream;
int counter = 0;
#ifdef ENABLE_MPI
int* molNumbers = NULL;
int* dataSizes = NULL;
int* displ = NULL;
int baseDispl = 0;
#endif
int factor = 3 + sendForces + sendVelocity + sendV2;
//int offset = sendV2Max;
// at the moment the simulation area extents need 6 floats
int offset = 7;
ParticleContainer* m_molecules = sim -> getMolecules ();
#ifdef ENABLE_MPI
int anzahl_mol = sim -> getDomain () -> getglobalNumMolecules ();
#endif
int local_mol = m_molecules->getNumberOfParticles();
#ifdef ENABLE_MPI
if (myRank == 0)
{
outStream.allocateMemory (factor * anzahl_mol * sizeof(float) + offset * sizeof(float));
}
// The stream will only be used for sending. And we will send maximally 3*sizeof(float) * local_mol at once
daStream.allocateMemory (3 * local_mol * sizeof(float));
#else
daStream.allocateMemory(factor * local_mol * sizeof(float) + offset * sizeof(float));
#endif
//send the extents of the domain
daStream << (float) 0.0 << (float) 0.0 << (float) 0.0;
daStream << (float) dom->getGlobalLength(0) << (float) dom->getGlobalLength(1) << (float) dom->getGlobalLength(2);
daStream << (int) numberOfComponents;
#ifdef ENABLE_MPI
if (myRank == 0)
{
molNumbers = new int [mySize];
dataSizes = new int [mySize];
}
MPI_Gather (&local_mol, 1, MPI_INT, molNumbers, 1, MPI_INT, 0, MPI_COMM_WORLD );
if (myRank == 0)
{
displ = new int[mySize];
displ[0] = 0;
dataSizes[0] = molNumbers[0] * 3 * sizeof(float);
for (int i = 1; i < mySize; i++)
{
displ[i] = displ[i-1] + dataSizes[i-1];
dataSizes[i] = molNumbers[i] * 3 * sizeof(float);
std::cout << "MolNumber ["<< i-1 << "]: " << molNumbers[i-1] << std::endl;
}
std::cout << "MolNumber ["<< mySize-1 << "]: " << molNumbers[mySize-1] << std::endl;
}
#endif
Molecule* pos = NULL;
double crit = 0.0;
for (pos = m_molecules->begin (); pos != m_molecules->end (); pos = m_molecules->next ()) {
//crit = pos->r(0) * pos->r(0) + pos->r(1) * pos->r(1) + pos->r(2) * pos->r(2);
daStream << (float) pos->r(0);
daStream << (float) pos->r(1);
daStream << (float) pos->r(2);
counter++;
}
#ifdef ENABLE_MPI
MPI_Gatherv (daStream.getStream(), local_mol * 3 * sizeof(float), MPI_CHAR, outStream.getStream (), dataSizes, displ, MPI_CHAR, 0, MPI_COMM_WORLD);
daStream.resetActPos();
daStream.resetReadPos();
#endif
float tempF = 0.0;
if (sendForces)
{
for (pos = m_molecules->begin (); pos != m_molecules->end (); pos = m_molecules->next ())
{
tempF = pos->F(0) * pos->F(0) + pos->F(1) * pos->F(1) + pos->F(2) * pos->F(2);
tempF = sqrt(tempF);
/*daStream << (float) pos->F(0);
//.........这里部分代码省略.........
示例2: dummy
void
ForceBoundary::applyBoundary()
{
std::list<Molecule *> mol;
std::list<Molecule *>::iterator mi;
Molecule *m;
double distanceVector[3];
//double cornerA[3];
//double cornerB[3];
double f[3];
f[0] = 0;
/* cornerA[X] = bBoxMin[X];
cornerA[Y] = bBoxMin[Y];
cornerA[Z] = bBoxMin[Z];
cornerB[X] = bBoxMin[X]+_borderSize[X];
cornerB[Y] = bBoxMax[Y];
cornerB[Z] = bBoxMax[Z];
_moleculeContainer->getRegion(cornerA, cornerB,mol);*/
getLower(X, mol);
for (mi = mol.begin(); mi != mol.end(); mi++)
{
m = (*mi);
f[X] = calcFm(m->r(X) - bBoxMin[X]) * fmplus;
f[Y] = 0;
f[Z] = 0;
/* double r =m->r(X)-bBoxMin[X];
if(r<0.5) {
std::cout << m->F(0) << " "<<m->F(1) << " "<<m->F(2) << " X"<< std::endl;
}*/
m->Fadd(f);
/* if(r<0.5) {
std::cout << r << " " <<m->F(0) << " "<<m->F(1) << " "<<m->F(2) << " X2"<< std::endl;
}*/
if (_RBinFB)
{
Molecule dummy(*m);
dummy.move(X, -2 * m->r(X));
double dd = dummy.dist2(*m, distanceVector);
if (dd < 2.0)
{
std::cout << m->F(0) << " " << m->F(1) << " " << m->F(2)
<< " X" << std::endl;
_particlePairsHandler->processPair(*m, dummy,
distanceVector, MOLECULE_HALOMOLECULE, dd, (dd
< _LJCutoffRadiusSquare));
m->calcFM();
std::cout << dd << " " << m->F(0) << " " << m->F(1) << " "
<< m->F(2) << " X2" << std::endl;
}
}
}
mol.clear();
/*cornerA[X] = bBoxMax[X]-_borderSize[X];
cornerB[X] = bBoxMax[X];
_moleculeContainer->getRegion(cornerA, cornerB,mol);*/
getUpper(X, mol);
for (mi = mol.begin(); mi != mol.end(); mi++)
{
m = (*mi);
f[X] = -calcFm(bBoxMax[X] - m->r(X)) * fmplus;
if (_streamOutDir == X)
f[X] *= _fStreamDamping;
if (!_fStream || _streamOutDir != X)
m->Fadd(f);
if (_RBinFB && _streamOutDir != X)
{
Molecule dummy(*m);
dummy.move(X, 2 * (m->r(X) - _domain->getGlobalLength(X)));
double dd = dummy.dist2(*m, distanceVector);
_particlePairsHandler->processPair(*m, dummy, distanceVector,
MOLECULE_HALOMOLECULE, dd, (dd < _LJCutoffRadiusSquare));
//std::cout << dummy.F(0) << " "<<dummy.F(1) << " "<<dummy.F(2) << " -X"<< std::endl;
}
}
mol.clear();
/* cornerA[X] = bBoxMin[X];
cornerB[X] = bBoxMax[X];
cornerB[Y] = bBoxMin[Y]+_borderSize[Y];
_moleculeContainer->getRegion(cornerA, cornerB,mol);*/
getLower(Y, mol);
for (mi = mol.begin(); mi != mol.end(); mi++)
{
m = (*mi);
f[X] = 0;
f[Y] = calcFm(m->r(Y) - bBoxMin[Y]) * fmplus;
//.........这里部分代码省略.........