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


C++ Opm::tableIndex方法代码示例

本文整理汇总了C++中Opm::tableIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ Opm::tableIndex方法的具体用法?C++ Opm::tableIndex怎么用?C++ Opm::tableIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Opm的用法示例。


在下文中一共展示了Opm::tableIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: miscible_oil

 double PvtLiveOil::miscible_oil(const double press,
                                 const double* surfvol,
                                 const int pvtTableIdx,
                                 const int item,
                                 const bool deriv) const
 {
     int section;
     double Rval = linearInterpolation(saturated_oil_table_[pvtTableIdx][0],
                                       saturated_oil_table_[pvtTableIdx][3],
                                       press, section);
     double maxR = (surfvol[phase_pos_[Liquid]] == 0.0) ? 0.0 : surfvol[phase_pos_[Vapour]]/surfvol[phase_pos_[Liquid]];
     if (deriv) {
         if (Rval < maxR ) {  // Saturated case
             return linearInterpolationDerivative(saturated_oil_table_[pvtTableIdx][0],
                                                  saturated_oil_table_[pvtTableIdx][item],
                                                  press);
         } else {  // Undersaturated case
             int is = tableIndex(saturated_oil_table_[pvtTableIdx][3], maxR);
             double w = (maxR - saturated_oil_table_[pvtTableIdx][3][is]) /
                 (saturated_oil_table_[pvtTableIdx][3][is+1] - saturated_oil_table_[pvtTableIdx][3][is]);
             assert(undersat_oil_tables_[pvtTableIdx][is][0].size() >= 2);
             assert(undersat_oil_tables_[pvtTableIdx][is+1][0].size() >= 2);
             double val1 =
                 linearInterpolationDerivative(undersat_oil_tables_[pvtTableIdx][is][0],
                                               undersat_oil_tables_[pvtTableIdx][is][item],
                                               press);
             double val2 =
                 linearInterpolationDerivative(undersat_oil_tables_[pvtTableIdx][is+1][0],
                                               undersat_oil_tables_[pvtTableIdx][is+1][item],
                                               press);
             double val = val1 + w*(val2 - val1);
             return val;
         }
     } else {
         if (Rval < maxR ) {  // Saturated case
             return linearInterpolation(saturated_oil_table_[pvtTableIdx][0],
                                        saturated_oil_table_[pvtTableIdx][item],
                                        press);
         } else {  // Undersaturated case
             // Interpolate between table sections
             int is = tableIndex(saturated_oil_table_[pvtTableIdx][3], maxR);
             double w = (maxR - saturated_oil_table_[pvtTableIdx][3][is]) /
                 (saturated_oil_table_[pvtTableIdx][3][is+1] - saturated_oil_table_[pvtTableIdx][3][is]);
             assert(undersat_oil_tables_[pvtTableIdx][is][0].size() >= 2);
             assert(undersat_oil_tables_[pvtTableIdx][is+1][0].size() >= 2);
             double val1 =
                 linearInterpolation(undersat_oil_tables_[pvtTableIdx][is][0],
                                     undersat_oil_tables_[pvtTableIdx][is][item],
                                     press);
             double val2 =
                 linearInterpolation(undersat_oil_tables_[pvtTableIdx][is+1][0],
                                     undersat_oil_tables_[pvtTableIdx][is+1][item],
                                     press);
             double val = val1 + w*(val2 - val1);
             return val;
         }
     }
 }
开发者ID:xavierr,项目名称:opm-core,代码行数:58,代码来源:PvtLiveOil.cpp

示例2: miscible_oil

    double SinglePvtLiveOil::miscible_oil(const double press,
                                          const double r,
                                          const PhasePresence& cond,
                                          const int item,
                                          const int deriv) const
    {
        const bool isSat = cond.hasFreeGas();

        // derivative with respect to frist component (pressure)
        if (deriv == 1) {
            if (isSat) {  // Saturated case
                return linearInterpolationDerivative(saturated_oil_table_[0],
                                                saturated_oil_table_[item],
                                                press);
            } else {  // Undersaturated case
                int is = tableIndex(saturated_oil_table_[3], r);
                double w = (r - saturated_oil_table_[3][is]) /
                    (saturated_oil_table_[3][is+1] - saturated_oil_table_[3][is]);
                assert(undersat_oil_tables_[is][0].size() >= 2);
                assert(undersat_oil_tables_[is+1][0].size() >= 2);
                double val1 =
                    linearInterpolationDerivative(undersat_oil_tables_[is][0],
                                             undersat_oil_tables_[is][item],
                                             press);
                double val2 =
                    linearInterpolationDerivative(undersat_oil_tables_[is+1][0],
                                             undersat_oil_tables_[is+1][item],
                                             press);
                double val = val1 + w*(val2 - val1);
                return val;
            }
            // derivative with respect to second component (r)
        } else if (deriv == 2)  {
            if (isSat) {  // Saturated case
                return 0;
            } else {  // Undersaturated case
                int is = tableIndex(saturated_oil_table_[3], r);
                assert(undersat_oil_tables_[is][0].size() >= 2);
                assert(undersat_oil_tables_[is+1][0].size() >= 2);
                double val1 =
                    linearInterpolation(undersat_oil_tables_[is][0],
                                              undersat_oil_tables_[is][item],
                                              press);
                double val2 =
                    linearInterpolation(undersat_oil_tables_[is+1][0],
                                              undersat_oil_tables_[is+1][item],
                                              press);

                double val = (val2 - val1)/(saturated_oil_table_[3][is+1]-saturated_oil_table_[3][is]);
                return val;
            }


            }    else {
            if (isSat) {  // Saturated case
                return linearInterpolation(saturated_oil_table_[0],
                                                 saturated_oil_table_[item],
                                                 press);
            } else {  // Undersaturated case
                // Interpolate between table sections
                int is = tableIndex(saturated_oil_table_[3], r);
                double w = (r - saturated_oil_table_[3][is]) /
                    (saturated_oil_table_[3][is+1] - saturated_oil_table_[3][is]);
                assert(undersat_oil_tables_[is][0].size() >= 2);
                assert(undersat_oil_tables_[is+1][0].size() >= 2);
                double val1 =
                    linearInterpolation(undersat_oil_tables_[is][0],
                                              undersat_oil_tables_[is][item],
                                              press);
                double val2 =
                    linearInterpolation(undersat_oil_tables_[is+1][0],
                                              undersat_oil_tables_[is+1][item],
                                              press);
                double val = val1 + w*(val2 - val1);
                return val;
            }
        }
    }
开发者ID:karbor,项目名称:opm-core,代码行数:78,代码来源:SinglePvtLiveOil.cpp


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