예제 #1
0
VFPProdTable::ALQ_TYPE getALQType( const DeckItem& item) {
    if (item.defaultApplied(0)) {
        return VFPProdTable::ALQ_UNDEF;
    } else {
        const std::string& alq_string = item.getTrimmedString(0);

        if (alq_string == "GRAT") {
            return VFPProdTable::ALQ_GRAT;
        }
        else if (alq_string == "IGLR") {
            return VFPProdTable::ALQ_IGLR;
        }
        else if (alq_string == "TGLR") {
            return VFPProdTable::ALQ_TGLR;
        }
        else if (alq_string == "PUMP") {
            return VFPProdTable::ALQ_PUMP;
        }
        else if (alq_string == "COMP") {
            return VFPProdTable::ALQ_COMP;
        }
        else if (alq_string == "BEAN") {
            return VFPProdTable::ALQ_BEAN;
        }
        else if (alq_string == "") {
            return VFPProdTable::ALQ_UNDEF;
        }
        else {
            throw std::invalid_argument("Invalid ALQ_DEF string: " + alq_string);
        }

        return VFPProdTable::ALQ_INVALID;
    }
}
예제 #2
0
void DeckRecord::addItem( DeckItem deckItem ) {
    if( this->hasItem( deckItem.name() ) )
        throw std::invalid_argument(
            "Item with name: "
            + deckItem.name()
            + " already exists in DeckRecord");

    m_items.push_back( std::move( deckItem ) );
}
예제 #3
0
    void SimpleTable::init( const DeckItem& deckItem ) {
        this->addColumns();

        if ( (deckItem.size() % numColumns()) != 0)
            throw std::runtime_error("Number of columns in the data file is"
                    "inconsistent with the ones specified");

        size_t rows = deckItem.size() / numColumns();
        for (size_t colIdx = 0; colIdx < numColumns(); ++colIdx) {
            auto& column = getColumn( colIdx );
            for (size_t rowIdx = 0; rowIdx < rows; rowIdx++) {
                size_t deckItemIdx = rowIdx*numColumns() + colIdx;
                if (deckItem.defaultApplied(deckItemIdx))
                    column.addDefault( );
                else
                    column.addValue( deckItem.getSIDouble(deckItemIdx) );
            }
            if (colIdx > 0)
                column.applyDefaults(getColumn( 0 ));
        }
    }
예제 #4
0
VFPProdTable::WFR_TYPE getWFRType( const DeckItem& item) {
    const std::string& wfr_string = item.getTrimmedString(0);
    if (wfr_string == "WOR") {
        return VFPProdTable::WFR_WOR;
    }
    else if (wfr_string == "WCT") {
        return VFPProdTable::WFR_WCT;
    }
    else if (wfr_string == "WGR") {
        return VFPProdTable::WFR_WGR;
    }
    else {
        throw std::invalid_argument("Invalid WFR string");
    }
    return VFPProdTable::WFR_INVALID;
}
예제 #5
0
static VFPProdTable::FLO_TYPE getFloType( const DeckItem& item) {
    const std::string& flo_string = item.getTrimmedString(0);
    if (flo_string == "OIL") {
        return VFPProdTable::FLO_OIL;
    }
    else if (flo_string == "LIQ") {
        return VFPProdTable::FLO_LIQ;
    }
    else if (flo_string == "GAS") {
        return VFPProdTable::FLO_GAS;
    }
    else {
        throw std::invalid_argument("Invalid RATE_TYPE string");
    }
    return VFPProdTable::FLO_INVALID;
}
예제 #6
0
VFPProdTable::GFR_TYPE getGFRType( const DeckItem& item) {
    ;
    const std::string& gfr_string = item.getTrimmedString(0);
    if (gfr_string == "GOR") {
        return VFPProdTable::GFR_GOR;
    }
    else if (gfr_string == "GLR") {
        return VFPProdTable::GFR_GLR;
    }
    else if (gfr_string == "OGR") {
        return VFPProdTable::GFR_OGR;
    }
    else {
        throw std::invalid_argument("Invalid GFR string");
    }
    return VFPProdTable::GFR_INVALID;
}
예제 #7
0
bool DeckItem::equal(const DeckItem& other, bool cmp_default, bool cmp_numeric) const {
    double rel_eps = 1e-4;
    double abs_eps = 1e-4;

    if (this->type != other.type)
        return false;

    if (this->size() != other.size())
        return false;

    if (this->item_name != other.item_name)
        return false;

    if (cmp_default)
        if (this->defaulted != other.defaulted)
            return false;

    switch( this->type ) {
    case type_tag::integer:
        if (this->ival != other.ival)
            return false;
        break;
    case type_tag::string:
        if (this->sval != other.sval)
            return false;
        break;
    case type_tag::fdouble:
        if (cmp_numeric) {
            const std::vector<double>& this_data = this->dval;
            const std::vector<double>& other_data = other.dval;
            for (size_t i=0; i < this_data.size(); i++) {
                if (!double_equal( this_data[i] , other_data[i], rel_eps, abs_eps))
                    return false;
            }
        } else {
            if (this->dval != other.dval)
                return false;
        }
        break;
    default:
        break;
    }

    return true;
}