/*!
 Set up the event recorder by defining the fault boundaries (in terms of block IDs).
 */
void EventRecorder::init(SimFramework *_sim) {
	VCSimulation				*sim = static_cast<VCSimulation*>(_sim);
	std::string					file_name = sim->getEventsFile().c_str();
	BlockList::const_iterator	it;
	
	if (!sim->isRootNode()) return;
	
    eFile.open(file_name.c_str());
    assertThrow(eFile, "Failed to open events file: " + file_name);
    eFile << std::fixed << std::setprecision(2);
	
    // SETTING FID BOUNDS, ID OF THE FIRST AND THE LAST BLOCK
    FaultID prev_fid = UNDEFINED_FAULT_ID;
	BlockID start_block_id = UNDEFINED_BLOCK_ID;
    for(it=sim->begin();it!=sim->end();++it) {
        if(it->getFaultID() != prev_fid) {
			if (start_block_id != UNDEFINED_BLOCK_ID) {
				faultBlockIDs.push_back(std::make_pair(start_block_id, it->getBlockID()-1));
			}
			start_block_id = it->getBlockID();
            prev_fid = it->getFaultID();
        }
    }
	faultBlockIDs.push_back(std::make_pair(start_block_id, sim->numGlobalBlocks()-1));
	assertThrow(start_block_id!=UNDEFINED_BLOCK_ID, "Could not find any blocks in simulation.");
}
Example #2
0
void GreensFuncCalcStandard::InnerCalcStandard(Simulation *sim,
                                               const BlockID &bnum,
                                               GreensValsSparseMatrix &ssh,
                                               GreensValsSparseMatrix &snorm) {
    Block source_block = sim->getBlock(bnum);
    BlockIDList                         target_blocks;
    BlockIDList::const_iterator         bit;
    BlockList::const_iterator           it;
    double                              stress_values[2];

    // Get a list of block IDs we want to calculate the Greens function for
    for (it=sim->begin(); it!=sim->end(); ++it) target_blocks.push_back(it->getBlockID());

    // Convert the strains to Greens values and record them
    for (bit=target_blocks.begin(); bit!=target_blocks.end(); ++bit) {
        Block target_block = sim->getBlock(*bit);

        target_block.get_rake_and_normal_stress_due_to_block(stress_values, sim->getGreensSampleDistance(), source_block);

        ssh[bnum][*bit] = stress_values[0];
        snorm[bnum][*bit] = stress_values[1];
    }
}