本文整理汇总了C++中MultiFab::color方法的典型用法代码示例。如果您正苦于以下问题:C++ MultiFab::color方法的具体用法?C++ MultiFab::color怎么用?C++ MultiFab::color使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MultiFab
的用法示例。
在下文中一共展示了MultiFab::color方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tmp
static
void
BuildGramMatrix (Real* Gg,
const MultiFab& PR,
const MultiFab& rt,
int sss)
{
BL_ASSERT(rt.nComp() == 1);
BL_ASSERT(PR.nComp() >= 4*sss+1);
const int Nrows = 4*sss+1, Ncols = Nrows + 1;
//
// Gg is dimensioned (Ncols*Nrows).
//
// First fill the upper triangle into tmp
//
#ifdef _OPENMP
const int nthreads = omp_get_max_threads();
#else
const int nthreads = 1;
#endif
const int Ntmp = (Nrows*(Nrows+3))/2;
PArray<Array<Real> > tmp(nthreads, PArrayManage);
#ifdef _OPENMP
#pragma omp parallel
#endif
{
#ifdef _OPENMP
int tid = omp_get_thread_num();
#else
int tid = 0;
#endif
tmp.set(tid, new Array<Real>(Ntmp,0.0));
for (MFIter mfi(PR,true); mfi.isValid(); ++mfi)
{
const Box& bx = mfi.tilebox();
const FArrayBox& rfab = PR[mfi];
const FArrayBox& tfab = rt[mfi];
int cnt = 0;
for (int mm = 0; mm < Nrows; mm++) {
for (int nn = mm; nn < Nrows; nn++) {
tmp[tid][cnt++] = rfab.dot(bx,nn,rfab,bx,mm);
}
tmp[tid][cnt++] = tfab.dot(bx,0,rfab,bx,mm);
}
}
#ifdef _OPENMP
#pragma omp barrier
#pragma omp for
for (int i = 0; i < Ntmp; ++i) {
for (int j = 1; j < nthreads; ++j) {
tmp[0][i] += tmp[j][i];
}
}
#endif
}
ParallelDescriptor::ReduceRealSum(&tmp[0][0], Ntmp, PR.color());
// Now fill upper triangle with "tmp".
int cnt = 0;
for (int mm = 0; mm < Nrows; mm++) {
for (int nn = mm; nn < Nrows; nn++) {
Gg[mm*Ncols + nn] = tmp[0][cnt++];
}
Gg[mm*Ncols + Nrows] = tmp[0][cnt++];
}
// Then fill in strict lower triangle using symmetry.
for (int mm = 0; mm < Nrows; mm++) {
for (int nn = 0; nn < mm; nn++) {
Gg[mm*Ncols + nn] = Gg[nn*Ncols + mm];
}
}
}