示例#1
0
void AddNoise::init(SimFramework *_sim) {
	VCSimulation						*sim = static_cast<VCSimulation*>(_sim);
	double								stress_noise, stress_res_dist, cur_noise, old_stress_drop;
	std::map<quakelib::Vec<3>, double>	centers_noise;
	quakelib::Vec<3>					mid_pt;
	std::map<quakelib::Vec<3>, double>::iterator	cit;
	BlockList::iterator					it;
	
	stress_noise = sim->getStressNoise();
	stress_res_dist = sim->getStressNoiseResolution();
	
	//! For each block in the simulation, get the midpoint and record the noise added to the block.
	//! Each block within a specified radius of the selected block will have the same level of noise added.
	//! The noise is defined as a modification of the stress drop from x to x +/- stress_noise.
	for (it=sim->begin();it!=sim->end();++it) {
		cur_noise = 1.0e10;
		mid_pt = it->center();
		for (cit=centers_noise.begin();cit!=centers_noise.end();++cit) {
			if (mid_pt.dist(cit->first) <= stress_res_dist) {
				cur_noise = cit->second;
				break;
			}
		}
		if (cur_noise > 1.0e9) {
			cur_noise = (1.0-stress_noise) + 2*stress_noise*sim->randDouble();
			centers_noise.insert(std::make_pair(mid_pt, cur_noise));
		}
		old_stress_drop = it->getStressDrop();
		it->setStressDrop(old_stress_drop*cur_noise);
	}
}
示例#2
0
void GreensFuncCalcBarnesHut::CalculateGreens(Simulation *sim) {
    BlockList::iterator     bit;
    quakelib::Octree<3>     *tree;
    quakelib::RectBound<3>  total_bound;
    unsigned int            n;
    int                     t_num;

    // Get a list of 3D midpoints of all segments
    for (bit=sim->begin(); bit!=sim->end(); ++bit) {
        total_bound.extend_bound(bit->center());
    }

    // Set up an octree of the model space
    tree = new quakelib::Octree<3>(total_bound);

    // Fill the octree with center points of the faults
    for (bit=sim->begin(); bit!=sim->end(); ++bit) {
        tree->add_point(bit->center(), bit->getBlockID());
    }

    // Get the current thread # for OpenMP to avoid printing multiple progress bars.
#ifdef _OPENMP
    t_num = omp_get_thread_num();
#else
    t_num = 0;
#endif

    // TO FIX: Problem with shared global variables (run_bounds)
    //#pragma omp parallel for shared(last_update) schedule(static,1)
    for (n=0; n<sim->numLocalBlocks(); ++n) {
        progressBar(sim, t_num, n);

        bhInnerCalc(sim, tree, sim->getGlobalBID(n));
    }

    // TODO: symmetrize Greens matrix
}