本文整理汇总了C++中CI::centroid方法的典型用法代码示例。如果您正苦于以下问题:C++ CI::centroid方法的具体用法?C++ CI::centroid怎么用?C++ CI::centroid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CI
的用法示例。
在下文中一共展示了CI::centroid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compare_pressure
void compare_pressure(const GI& g, const std::vector<double>& p)
{
typedef typename GI::CellIterator CI;
int count = 0;
double l1err = 0.0;
double l2err = 0.0;
double linferr = 0.0;
double totv = 0.0;
for (CI c = g.cellbegin(); c != g.cellend(); ++c, ++count) {
Vec cen = c->centroid();
double uval = u(cen);
double diff = uval - p[count];
double v = c->volume();
l1err += std::fabs(diff*v);
l2err += diff*diff*v;
linferr = std::max(std::fabs(diff), linferr);
totv += v;
// std::cout << cen[0] << ' ' << uval << ' ' << p[count] << std::endl;
}
l2err = std::sqrt(l2err);
std::cout << "\n\n"
<< "\n L1 error density: " << l1err/totv
<< "\n L2 error density: " << l2err/totv
<< "\n Linf error: " << linferr << "\n\n\n";
}
示例2: assign_src
void assign_src(const GI& g, std::vector<double>& src)
{
typedef typename GI::CellIterator CI;
int count = 0;
for (CI c = g.cellbegin(); c != g.cellend(); ++c) {
src[count++] = -Lu(c->centroid())*c->volume();
}
}
示例3: setSourceBlock
double setSourceBlock(const Vector& low, const Vector& high, double density, bool is_injection)
{
typedef typename GI::CellIterator CI;
// Iterate over all cells, if the centroid of a cell is in the
// domain given, set a source term. Accumulate total source terms.
double total_rate = 0.0;
for (CI c = this->ginterf_.cellbegin(); c != this->ginterf_.cellend(); ++c) {
if (isInside(low, high, c->centroid())) {
int index = c->index();
double rate = density*c->volume();
if (!is_injection) {
rate = -rate;
}
total_rate += rate;
this->injection_rates_.addElement(rate, index);
this->injection_rates_psolver_[index] = rate;
}
}
return total_rate;
}