当前位置: 首页>>代码示例>>C++>>正文


C++ CI::centroid方法代码示例

本文整理汇总了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";
}
开发者ID:bska,项目名称:opm-origins,代码行数:25,代码来源:known_answer_test.cpp

示例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();
    }
}
开发者ID:bska,项目名称:opm-origins,代码行数:8,代码来源:known_answer_test.cpp

示例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;
 }
开发者ID:hnil,项目名称:opm-porsol,代码行数:20,代码来源:SimulatorTesterFlexibleBC.hpp


注:本文中的CI::centroid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。