Exemple #1
0
bool Stressor::loadXML(const std::string & file) {

    std::vector<Fault> faults;

    std::ifstream in;
    in.open(file.c_str());
    if (!in.is_open()) {
#ifdef NO_ETISS
        std::cout << "Failed open file " << file << std::endl;
#else
        etiss::log(etiss::ERROR,std::string("Failed to open file ")+file);
#endif
        return false;
    }
    if (!etiss::fault::parseXML(faults,in,std::cout)) {
#ifdef NO_ETISS
        std::cout << "Failed parse file " << file << std::endl;
#else
        etiss::log(etiss::ERROR,std::string("Failed to parse file ")+file);
#endif
        return false;
    }
    bool ok = true;
    for (size_t i = 0; i<faults.size(); ++i) {
        if (!addFault(faults[i])) {
#ifdef NO_ETISS
            std::cout << "Failed to add Fault: " << faults[i].name_ << std::endl;
#else
            etiss::log(etiss::ERROR,std::string("Failed to add Fault "),faults[i]);
#endif
            ok = false;
        }
    }
    return ok;
}
Exemple #2
0
    FaultCollection::FaultCollection( std::shared_ptr<const GRIDSection> deck, std::shared_ptr<const EclipseGrid> grid) {
        const auto& faultKeywords = deck->getKeywordList<ParserKeywords::FAULTS>();

        for (auto keyword_iter = faultKeywords.begin(); keyword_iter != faultKeywords.end(); ++keyword_iter) {
            const auto& faultsKeyword = *keyword_iter;
            for (auto iter = faultsKeyword->begin(); iter != faultsKeyword->end(); ++iter) {
                const auto& faultRecord = *iter;
                const std::string& faultName = faultRecord.getItem(0).get< std::string >(0);
                int I1 = faultRecord.getItem(1).get< int >(0) - 1;
                int I2 = faultRecord.getItem(2).get< int >(0) - 1;
                int J1 = faultRecord.getItem(3).get< int >(0) - 1;
                int J2 = faultRecord.getItem(4).get< int >(0) - 1;
                int K1 = faultRecord.getItem(5).get< int >(0) - 1;
                int K2 = faultRecord.getItem(6).get< int >(0) - 1;
                FaceDir::DirEnum faceDir = FaceDir::FromString( faultRecord.getItem(7).get< std::string >(0) );
                std::shared_ptr<const FaultFace> face = std::make_shared<const FaultFace>(grid->getNX() , grid->getNY() , grid->getNZ(),
                                                                                          static_cast<size_t>(I1) , static_cast<size_t>(I2) ,
                                                                                          static_cast<size_t>(J1) , static_cast<size_t>(J2) ,
                                                                                          static_cast<size_t>(K1) , static_cast<size_t>(K2) ,
                                                                                          faceDir);
                if (!hasFault(faultName)) {
                    std::shared_ptr<Fault> fault = std::make_shared<Fault>( faultName );
                    addFault( fault );
                }

                {
                    std::shared_ptr<Fault> fault = getFault( faultName );
                    fault->addFace( face );
                }
            }
        }
    }
Exemple #3
0
bool Stressor::firedTrigger(const Trigger & triggered,int32_t fault_id,Injector * injector,uint64_t time_ps)
{

#if CXX0X_UP_SUPPORTED
    std::lock_guard<std::mutex> lock(faults_sync());
#endif
    std::map<int32_t,Fault>::iterator find = faults().find(fault_id);
    if (find != faults().end()) {
        for (std::vector<etiss::fault::Action>::iterator iter = find->second.actions.begin(); iter != find->second.actions.end(); ++iter) {
            if (iter->getType() == etiss::fault::Action::INJECTION) {
                addFault(iter->getFault());
            } else {
                if (iter->getInjectorAddress().getInjector()) {
#if CXX0X_UP_SUPPORTED
                    if (iter->getInjectorAddress().getInjector().get() != injector)
#else
                    if (iter->getInjectorAddress().getInjector() != injector)
#endif
                    {
#ifndef NO_ETISS
                        etiss::log(etiss::WARNING,"action injector is not the injector that triggered this event. threadsafety must be ensured by user.",find->second,*iter);
#endif
                    }
                    std::string err;
                    if (!iter->getInjectorAddress().getInjector()->applyAction(find->second,*iter,err)) {
#ifdef NO_ETISS
                        std::cout << "Failed to apply action. Fault: " << fault_id  << " [" << err << "]"<< std::endl;
#else
                        etiss::log(etiss::ERROR,std::string("Failed to apply action "),find->second,*iter,err);
#endif
                    }
                    return true;
                } else {
#ifdef NO_ETISS
                    std::cout << "Failed to find action target. Fault: " << fault_id << std::endl;
#else
                    etiss::log(etiss::ERROR,std::string("Failed to find action target"),find->second,*iter);
#endif
                }
            }
        }
    } else {
#ifdef NO_ETISS
        std::cout << "Failed to find triggered Fault: " << fault_id << std::endl;
#else
        etiss::log(etiss::ERROR,std::string("Failed to find triggered Fault: "),fault_id);
#endif
    }

    return true;
}