本文整理汇总了C++中Compute类的典型用法代码示例。如果您正苦于以下问题:C++ Compute类的具体用法?C++ Compute怎么用?C++ Compute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Compute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: e_tally_thr
void ThrOMP::ev_tally_thr(Pair * const pair, const int i, const int j, const int nlocal,
const int newton_pair, const double evdwl, const double ecoul,
const double fpair, const double delx, const double dely,
const double delz, ThrData * const thr)
{
if (pair->eflag_either)
e_tally_thr(pair, i, j, nlocal, newton_pair, evdwl, ecoul, thr);
if (pair->vflag_either) {
double v[6];
v[0] = delx*delx*fpair;
v[1] = dely*dely*fpair;
v[2] = delz*delz*fpair;
v[3] = delx*dely*fpair;
v[4] = delx*delz*fpair;
v[5] = dely*delz*fpair;
v_tally_thr(pair, i, j, nlocal, newton_pair, v, thr);
}
if (pair->num_tally_compute > 0) {
// ev_tally callbacks are not thread safe and thus have to be protected
#if defined(_OPENMP)
#pragma omp critical
#endif
for (int k=0; k < pair->num_tally_compute; ++k) {
Compute *c = pair->list_tally_compute[k];
c->pair_tally_callback(i, j, nlocal, newton_pair,
evdwl, ecoul, fpair, delx, dely, delz);
}
}
}
示例2: if
int FixAveTime::column_length(int dynamic)
{
int m,length,lengthone;
// determine nrows for static values
if (!dynamic) {
length = 0;
for (int i = 0; i < nvalues; i++) {
if (varlen[i]) continue;
if (which[i] == COMPUTE) {
int icompute = modify->find_compute(ids[i]);
if (argindex[i] == 0)
lengthone = modify->compute[icompute]->size_vector;
else lengthone = modify->compute[icompute]->size_array_rows;
} else if (which[i] == FIX) {
int ifix = modify->find_fix(ids[i]);
if (argindex[i] == 0) lengthone = modify->fix[ifix]->size_vector;
else lengthone = modify->fix[ifix]->size_array_rows;
} else if (which[i] == VARIABLE) {
// variables are always varlen = 1, so dynamic
}
if (length == 0) length = lengthone;
else if (lengthone != length)
error->all(FLERR,"Fix ave/time columns are inconsistent lengths");
}
}
// determine new nrows for dynamic values
// either all must be the same
// or must match other static values
// don't need to check if not MODE = VECTOR, just invoke lock_length()
if (dynamic) {
length = 0;
for (int i = 0; i < nvalues; i++) {
if (varlen[i] == 0) continue;
m = value2index[i];
if (which[i] == COMPUTE) {
Compute *compute = modify->compute[m];
lengthone = compute->lock_length();
} else if (which[i] == VARIABLE) {
double *varvec;
lengthone = input->variable->compute_vector(m,&varvec);
}
if (mode == SCALAR) continue;
if (all_variable_length) {
if (length == 0) length = lengthone;
else if (lengthone != length)
error->all(FLERR,"Fix ave/time columns are inconsistent lengths");
} else {
if (lengthone != nrows)
error->all(FLERR,"Fix ave/time columns are inconsistent lengths");
}
}
}
return length;
}
示例3: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
Compute *compute = new Compute("Zad10.txt");
compute->GiveResult();
delete compute;
std::cin.get();
return 0;
}
示例4: extract_one
void ComputeSlice::extract_one(int m, double *vec, int stride)
{
int i,j;
// invoke the appropriate compute if needed
if (which[m] == COMPUTE) {
Compute *compute = modify->compute[value2index[m]];
if (argindex[m] == 0) {
if (!(compute->invoked_flag & INVOKED_VECTOR)) {
compute->compute_vector();
compute->invoked_flag |= INVOKED_VECTOR;
}
double *cvector = compute->vector;
j = 0;
for (i = nstart; i < nstop; i += nskip) {
vec[j] = cvector[i-1];
j += stride;
}
} else {
if (!(compute->invoked_flag & INVOKED_ARRAY)) {
compute->compute_array();
compute->invoked_flag |= INVOKED_ARRAY;
}
double **carray = compute->array;
int icol = argindex[m]-1;
j = 0;
for (i = nstart; i < nstop; i += nskip) {
vec[j] = carray[i-1][icol];
j += stride;
}
}
// access fix fields, check if fix frequency is a match
} else if (which[m] == FIX) {
if (update->ntimestep % modify->fix[value2index[m]]->global_freq)
error->all(FLERR,"Fix used in compute slice not computed at compatible time");
Fix *fix = modify->fix[value2index[m]];
if (argindex[m] == 0) {
j = 0;
for (i = nstart; i < nstop; i += nskip) {
vec[j] = fix->compute_vector(i-1);
j += stride;
}
} else {
int icol = argindex[m]-1;
j = 0;
for (i = nstart; i < nstop; i += nskip) {
vec[j] = fix->compute_array(i-1,icol);
j += stride;
}
}
}
}
示例5: compute_one
void ComputeAtomMolecule::compute_one(int m)
{
int vidx = value2index[m];
int aidx = argindex[m];
// invoke compute if not previously invoked
if (which[m] == COMPUTE) {
Compute *compute = modify->compute[vidx];
if (!(compute->invoked_flag & INVOKED_PERATOM)) {
compute->compute_peratom();
compute->invoked_flag |= INVOKED_PERATOM;
}
if (aidx == 0) {
peratom = compute->vector_atom;
nstride = 1;
} else {
if (compute->array_atom) peratom = &compute->array_atom[0][aidx-1];
else peratom = NULL;
nstride = compute->size_array_cols;
}
// access fix fields, check if fix frequency is a match
} else if (which[m] == FIX) {
if (update->ntimestep % modify->fix[vidx]->peratom_freq)
error->all(FLERR,"Fix used in compute atom/molecule not computed "
"at compatible time");
Fix *fix = modify->fix[vidx];
if (aidx == 0) {
peratom = fix->vector_atom;
nstride = 1;
} else {
peratom = &fix->array_atom[0][aidx-1];
nstride = fix->size_array_cols;
}
// evaluate atom-style variable
} else if (which[m] == VARIABLE) {
if (atom->nlocal > maxatom) {
maxatom = atom->nmax;
memory->destroy(scratch);
memory->create(scratch,maxatom,"atom/molecule:scratch");
peratom = scratch;
}
input->variable->compute_atom(vidx,igroup,peratom,1,0);
nstride = 1;
}
}
示例6:
shared_ptr<LinkedActionList> ProgramHandler::runCompiler(const shared_ptr<LinkedTokenList>& tokenList, const bool printCompiledList)
{
Compute compute;
shared_ptr<LinkedActionList> compiledList = compute.computeCompile(tokenList);
if (printCompiledList)
{
compiledList->printList();
}
return compiledList;
}
示例7: compute
void Compute::sendC() {
int indexY = thisIndex.y;
for(int j=0; j<num_chare_y; j++) {
if(j != indexY) {
// use a local pointer for chares on the same processor
Compute *c = compute(thisIndex.x, j, thisIndex.z).ckLocal();
if(c != NULL)
c->receiveC(&C[j*subBlockDimXy*blockDimZ], subBlockDimXy * blockDimZ, 1);
else
compute(thisIndex.x, j, thisIndex.z).receiveC(&C[j*subBlockDimXy*blockDimZ], subBlockDimXy * blockDimZ, 1);
}
}
}
示例8: return
void *lammps_extract_compute(void *ptr, char *id, int style, int type)
{
LAMMPS *lmp = (LAMMPS *) ptr;
int icompute = lmp->modify->find_compute(id);
if (icompute < 0) return NULL;
Compute *compute = lmp->modify->compute[icompute];
if (style == 0) {
if (type == 0) {
if (!compute->scalar_flag) return NULL;
if (compute->invoked_scalar != lmp->update->ntimestep)
compute->compute_scalar();
return (void *) &compute->scalar;
}
if (type == 1) {
if (!compute->vector_flag) return NULL;
if (compute->invoked_vector != lmp->update->ntimestep)
compute->compute_vector();
return (void *) compute->vector;
}
if (type == 2) {
if (!compute->array_flag) return NULL;
if (compute->invoked_array != lmp->update->ntimestep)
compute->compute_array();
return (void *) compute->array;
}
}
if (style == 1) {
if (!compute->peratom_flag) return NULL;
if (type == 1) {
if (compute->invoked_peratom != lmp->update->ntimestep)
compute->compute_peratom();
return (void *) compute->vector_atom;
}
if (type == 2) {
if (compute->invoked_peratom != lmp->update->ntimestep)
compute->compute_peratom();
return (void *) compute->array_atom;
}
}
if (style == 2) {
if (!compute->local_flag) return NULL;
if (type == 1) {
if (compute->invoked_local != lmp->update->ntimestep)
compute->compute_local();
return (void *) compute->vector_local;
}
if (type == 2) {
if (compute->invoked_local != lmp->update->ntimestep)
compute->compute_local();
return (void *) compute->array_local;
}
}
return NULL;
}
示例9: CkDirect_put
void Compute::sendA() {
int indexZ = thisIndex.z;
for(int k=0; k<num_chare_z; k++)
if(k != indexZ) {
#if USE_CKDIRECT
CkDirect_put(&sHandles[num_chare_x + num_chare_y + k]);
#else
// use a local pointer for chares on the same processor
Compute* c = compute(thisIndex.x, thisIndex.y, k).ckLocal();
if(c != NULL)
c->receiveA(indexZ, &A[indexZ*subBlockDimXz*blockDimY], subBlockDimXz * blockDimY);
else
compute(thisIndex.x, thisIndex.y, k).receiveA(indexZ, &A[indexZ*subBlockDimXz*blockDimY], subBlockDimXz * blockDimY);
#endif
}
}
示例10: BEHAVIAC_ASSERT
EBTStatus ComputeTask::update(Agent* pAgent, EBTStatus childStatus) {
BEHAVIAC_ASSERT(childStatus == BT_RUNNING);
EBTStatus result = BT_SUCCESS;
BEHAVIAC_ASSERT(Compute::DynamicCast(this->GetNode()));
Compute* pComputeNode = (Compute*)(this->GetNode());
//bool bValid = Compute::EvaluteCompute(pAgent, pComputeNode->m_typeName, pComputeNode->m_opl, pComputeNode->m_opr1, pComputeNode->m_opr1_m,
// pComputeNode->m_operator, pComputeNode->m_opr2, pComputeNode->m_opr2_m);
if (pComputeNode->m_opl != NULL) {
pComputeNode->m_opl->Compute(pAgent, pComputeNode->m_opr1, pComputeNode->m_opr2, pComputeNode->m_operator);
} else {
result = pComputeNode->update_impl(pAgent, childStatus);
}
return result;
}
示例11: compute
AllResults compute(Compute& comp) {
comp.compute();
unsigned natoms = comp.get_natoms();
AllResults res;
res.energy = comp.get_energy();
for (unsigned dim = 0; dim < 6; ++dim) {
res.virial(dim) = comp.get_virial()(dim);
res.virial_from_dEdr(dim) = comp.get_virial_from_dEdr()(dim);
}
for (unsigned i = 0; i < natoms; ++i) {
res.particle_energy.push_back(comp.get_energy(i));
for (unsigned dim = 0; dim < 3; ++dim) {
res.force.push_back(comp.get_force(i, dim));
}
res.particle_virial.push_back(comp.get_virial(i));
}
return move(res);
}
示例12: column_length
void FixAveTime::invoke_scalar(bigint ntimestep)
{
int i,m;
double scalar;
// zero if first sample within single Nfreq epoch
// NOTE: doc this
// are not checking for returned length, just initialize it
// check for exceeding length is done below
if (irepeat == 0) {
if (any_variable_length) {
modify->clearstep_compute();
column_length(1);
modify->addstep_compute(ntimestep+nevery);
modify->addstep_compute(ntimestep+nfreq);
}
for (i = 0; i < nvalues; i++) vector[i] = 0.0;
}
// accumulate results of computes,fixes,variables to local copy
// compute/fix/variable may invoke computes so wrap with clear/add
modify->clearstep_compute();
for (i = 0; i < nvalues; i++) {
m = value2index[i];
// invoke compute if not previously invoked
if (which[i] == COMPUTE) {
Compute *compute = modify->compute[m];
if (argindex[i] == 0) {
if (!(compute->invoked_flag & INVOKED_SCALAR)) {
compute->compute_scalar();
compute->invoked_flag |= INVOKED_SCALAR;
}
scalar = compute->scalar;
} else {
if (!(compute->invoked_flag & INVOKED_VECTOR)) {
compute->compute_vector();
compute->invoked_flag |= INVOKED_VECTOR;
}
// insure no out-of-range access to variable-length compute vector
if (varlen[i] && compute->size_vector < argindex[i]) scalar = 0.0;
else scalar = compute->vector[argindex[i]-1];
}
// access fix fields, guaranteed to be ready
} else if (which[i] == FIX) {
if (argindex[i] == 0)
scalar = modify->fix[m]->compute_scalar();
else
scalar = modify->fix[m]->compute_vector(argindex[i]-1);
// evaluate equal-style variable
} else if (which[i] == VARIABLE)
scalar = input->variable->compute_equal(m);
// add value to vector or just set directly if offcol is set
if (offcol[i]) vector[i] = scalar;
else vector[i] += scalar;
}
// done if irepeat < nrepeat
// else reset irepeat and nvalid
irepeat++;
if (irepeat < nrepeat) {
nvalid += nevery;
modify->addstep_compute(nvalid);
return;
}
irepeat = 0;
nvalid = ntimestep + nfreq - (nrepeat-1)*nevery;
modify->addstep_compute(nvalid);
// average the final result for the Nfreq timestep
double repeat = nrepeat;
for (i = 0; i < nvalues; i++)
if (offcol[i] == 0) vector[i] /= repeat;
// if ave = ONE, only single Nfreq timestep value is needed
// if ave = RUNNING, combine with all previous Nfreq timestep values
// if ave = WINDOW, combine with nwindow most recent Nfreq timestep values
if (ave == ONE) {
for (i = 0; i < nvalues; i++) vector_total[i] = vector[i];
norm = 1;
} else if (ave == RUNNING) {
for (i = 0; i < nvalues; i++) vector_total[i] += vector[i];
//.........这里部分代码省略.........
示例13: if
void FixAveAtom::end_of_step()
{
int i,j,m,n;
// skip if not step which requires doing something
bigint ntimestep = update->ntimestep;
if (ntimestep != nvalid) return;
// zero if first step
int nlocal = atom->nlocal;
if (irepeat == 0)
for (i = 0; i < nlocal; i++)
for (m = 0; m < nvalues; m++)
array[i][m] = 0.0;
// accumulate results of attributes,computes,fixes,variables to local copy
// compute/fix/variable may invoke computes so wrap with clear/add
modify->clearstep_compute();
int *mask = atom->mask;
for (m = 0; m < nvalues; m++) {
n = value2index[m];
j = argindex[m];
if (which[m] == X) {
double **x = atom->x;
for (i = 0; i < nlocal; i++)
if (mask[i] & groupbit) array[i][m] += x[i][j];
} else if (which[m] == V) {
double **v = atom->v;
for (i = 0; i < nlocal; i++)
if (mask[i] & groupbit) array[i][m] += v[i][j];
} else if (which[m] == F) {
double **f = atom->f;
for (i = 0; i < nlocal; i++)
if (mask[i] & groupbit) array[i][m] += f[i][j];
// invoke compute if not previously invoked
} else if (which[m] == COMPUTE) {
Compute *compute = modify->compute[n];
if (!(compute->invoked_flag & INVOKED_PERATOM)) {
compute->compute_peratom();
compute->invoked_flag |= INVOKED_PERATOM;
}
if (j == 0) {
double *compute_vector = compute->vector_atom;
for (i = 0; i < nlocal; i++)
if (mask[i] & groupbit) array[i][m] += compute_vector[i];
} else {
int jm1 = j - 1;
double **compute_array = compute->array_atom;
for (i = 0; i < nlocal; i++)
if (mask[i] & groupbit) array[i][m] += compute_array[i][jm1];
}
// access fix fields, guaranteed to be ready
} else if (which[m] == FIX) {
if (j == 0) {
double *fix_vector = modify->fix[n]->vector_atom;
for (i = 0; i < nlocal; i++)
if (mask[i] & groupbit) array[i][m] += fix_vector[i];
} else {
int jm1 = j - 1;
double **fix_array = modify->fix[n]->array_atom;
for (i = 0; i < nlocal; i++)
if (mask[i] & groupbit) array[i][m] += fix_array[i][jm1];
}
// evaluate atom-style variable
// final argument = 1 sums result to array
} else if (which[m] == VARIABLE && array)
input->variable->compute_atom(n,igroup,&array[0][m],nvalues,1);
}
// done if irepeat < nrepeat
// else reset irepeat and nvalid
irepeat++;
if (irepeat < nrepeat) {
nvalid += nevery;
modify->addstep_compute(nvalid);
return;
}
irepeat = 0;
nvalid = ntimestep+peratom_freq - (nrepeat-1)*nevery;
modify->addstep_compute(nvalid);
// average the final result for the Nfreq timestep
//.........这里部分代码省略.........
示例14: bin_atoms
void FixAveHisto::end_of_step()
{
int i,j,m;
// skip if not step which requires doing something
// error check if timestep was reset in an invalid manner
bigint ntimestep = update->ntimestep;
if (ntimestep < nvalid_last || ntimestep > nvalid)
error->all(FLERR,"Invalid timestep reset for fix ave/histo");
if (ntimestep != nvalid) return;
nvalid_last = nvalid;
// zero if first step
if (irepeat == 0) {
stats[0] = stats[1] = 0.0;
stats[2] = BIG;
stats[3] = -BIG;
for (i = 0; i < nbins; i++) bin[i] = 0.0;
}
// accumulate results of computes,fixes,variables to local copy
// compute/fix/variable may invoke computes so wrap with clear/add
modify->clearstep_compute();
for (i = 0; i < nvalues; i++) {
m = value2index[i];
j = argindex[i];
// atom attributes
if (which[i] == X)
bin_atoms(&atom->x[0][j],3);
else if (which[i] == V)
bin_atoms(&atom->v[0][j],3);
else if (which[i] == F)
bin_atoms(&atom->f[0][j],3);
// invoke compute if not previously invoked
if (which[i] == COMPUTE) {
Compute *compute = modify->compute[m];
if (kind == GLOBAL && mode == SCALAR) {
if (j == 0) {
if (!(compute->invoked_flag & INVOKED_SCALAR)) {
compute->compute_scalar();
compute->invoked_flag |= INVOKED_SCALAR;
}
bin_one(compute->scalar);
} else {
if (!(compute->invoked_flag & INVOKED_VECTOR)) {
compute->compute_vector();
compute->invoked_flag |= INVOKED_VECTOR;
}
bin_one(compute->vector[j-1]);
}
} else if (kind == GLOBAL && mode == VECTOR) {
if (j == 0) {
if (!(compute->invoked_flag & INVOKED_VECTOR)) {
compute->compute_vector();
compute->invoked_flag |= INVOKED_VECTOR;
}
bin_vector(compute->size_vector,compute->vector,1);
} else {
if (!(compute->invoked_flag & INVOKED_ARRAY)) {
compute->compute_array();
compute->invoked_flag |= INVOKED_ARRAY;
}
if (compute->array)
bin_vector(compute->size_array_rows,&compute->array[0][j-1],
compute->size_array_cols);
}
} else if (kind == PERATOM) {
if (!(compute->invoked_flag & INVOKED_PERATOM)) {
compute->compute_peratom();
compute->invoked_flag |= INVOKED_PERATOM;
}
if (j == 0)
bin_atoms(compute->vector_atom,1);
else if (compute->array_atom)
bin_atoms(&compute->array_atom[0][j-1],compute->size_peratom_cols);
} else if (kind == LOCAL) {
if (!(compute->invoked_flag & INVOKED_LOCAL)) {
compute->compute_local();
compute->invoked_flag |= INVOKED_LOCAL;
}
if (j == 0)
bin_vector(compute->size_local_rows,compute->vector_local,1);
else if (compute->array_local)
bin_vector(compute->size_local_rows,&compute->array_local[0][j-1],
compute->size_local_cols);
}
// access fix fields, guaranteed to be ready
//.........这里部分代码省略.........
示例15: callBackRcvdC
void Compute::callBackRcvdC(void *arg) {
Compute *obj = (Compute *)arg;
obj->countC++;
if(obj->countC == num_chare_y)
obj->thisProxy(obj->thisIndex.x, obj->thisIndex.y, obj->thisIndex.z).receiveC();
}