RelocInfo * FindRelocOffset(long offset, short hunkNo) { RelocInfo *r = RelOffCache; if (r == NULL) r = GetHead(&RelList); while (r && r->ri_SrcOffset >= offset) r = GetPred((Node *)&r->ri_Node); if (r == NULL) r = GetHead(&RelList); while (r && r->ri_SrcOffset < offset) r = GetSucc((Node *)&r->ri_Node); while (r && r->ri_SrcHunk != hunkNo) r = GetSucc((Node *)&r->ri_Node); if (r) RelOffCache = r; return(r); }
void RadPattern::OutputPreds( const std::string& fname, const float norm_dis, const float Q ) const { if( grtM.size() == 0 ) return; std::ofstream fout( fname ); if( ! fout ) throw ErrorRP::BadFile(FuncName, fname); for( auto &grtP : grtM ) { float per = grtP.first; float alpha = M_PI/(per*3.0*Q); auto &grtV = grtP.second; auto &phtV = phtM.at(per); auto &V = ampM.at(per); int iazi; float azi, grt, pht, amp; auto getPreds = norm_dis>0 ? std::function<bool()>([&]() { return GetPred(per, azi, grt, pht, amp, norm_dis, alpha); }) : [&]() { grt=grtV.at(iazi); if(grt==RadPattern::NaN)return false; pht=phtV.at(iazi); amp=ampV.at(iazi); return true; }; for( iazi=0; iazi<nazi; iazi++ ) { azi = iazi*dazi; if( getPreds() ) fout<<azi<<" "<<grt<<" "<<pht<<" "<<amp<<" "<<per<<"\n"; } fout<<"\n\n"; } }
bool RadPattern::GetPred( const float per, const float azi, float& grt, float& pht, float& amp, const float dis, const float alpha, const float recCAmp ) const { if( ! GetPred(per, azi, grt, pht, amp, 1.) ) return false; //if( U==NaN || J==NaN ) { // compute amplitude at the source if( recCAmp == NaN ) { // compute amplitude at the source // M0 = scalar seismic momentum // cAmp = source amp norm term: 1.0/( (phvel*grvel*I0) * sqrt(8 * pi) ) in sec^2/gram auto coefs = cAmp(per); // cAmp and wavenumber //std::cerr<<"amp0 = "<<amp<<" "; amp *= 100. * coefs[0] / sqrt(coefs[1]); // amplitude at 1km distance //std::cerr<<100.<<" "<<M0<<" "<<sqrt(coefs[0]*1.0e15/sqrt(8*M_PI))<<" "<<1.0e-6*sqrt(coefs[0]*1.0e15*sqrt(8*M_PI))/sqrt(coefs[1])*exp(-dis*alpha)<<" amp1 = "<<amp<<" "; } else { // propogate amp to the receiver if extra info is given // recCAmp = 1. / sqrt(J * U * C) in sqrt(sec^2/gram) // J = receiver mode energy integration (from eigen); // U = local group velocity at the receiver location // C = local phase velocity at the receiver location auto coefs = cAmp(per); // cAmp and wavenumber amp *= 100. * sqrt( coefs[0] / (sqrt(8.*M_PI)) ) * recCAmp / sqrt(coefs[1]); // receiver norm term * second part of propogation } if( dis>0 ) { // attenuation and geometric spreading // dis = distance; alpha = average attenuation coeff amp /= sqrt(dis); if( alpha > 0 ) amp *= exp(-dis*alpha); // anelastic propogation //std::cerr<<dis<<" "<<alpha<<" amp2 = "<<amp<<" "; } return true; }
void AddRelocInfo(short srcHunk, short dstHunk, long size, short flags, long offset, Symbol *sym) { RelocInfo *ri = malloc(sizeof(RelocInfo)); RelocInfo *r; if (ri == NULL) cerror(EFATAL, "malloc Failed"); clrmem(ri, sizeof(RelocInfo)); ri->ri_Sym = sym; ri->ri_SrcHunk = srcHunk; ri->ri_DstHunk = dstHunk; ri->ri_RelocSize = size; ri->ri_RelocFlags= flags; ri->ri_SrcOffset = offset; for (r = GetTail(&RelList); r; r = GetPred((Node *)&r->ri_Node)) { if (r->ri_SrcOffset < ri->ri_SrcOffset) break; } Insert(&RelList, (Node *)&ri->ri_Node, (Node *)&r->ri_Node); }