Brief description of class still missing. More...
#include <DispersionReader.h>
Public Member Functions | |
| DispersionReader () | |
| bool | setOptions (int &argc, char **argv) |
| ~DispersionReader () | |
Protected Member Functions | |
| virtual bool | parse (QTextStream &s) |
Brief description of class still missing.
Full description of class still missing
Description of constructor still missing
References QGpCoreTools::LogScale, and TRACE.
: ArgumentStdinReader() { TRACE; _nRayleigh=1; _nLove=0; _groupSlowness=false; _samplingType=LogScale; _nSamples=100; _minRange=0.2; _maxRange=20.0; _vNSamples=100; _vMinRange=100.0; _vMaxRange=3000.0; _mode=CurveMode; _oneMode=false; _force=false; _deltaK=false; }
| bool DispersionReader::parse | ( | QTextStream & | s | ) | [protected, virtual] |
Implements QGpCoreTools::ArgumentStdinReader.
References QGpCoreWave::Dispersion::calculate(), QGpCoreWave::Dispersion::deltaK(), QGpCoreWave::Seismic1DModel::fromStream(), QGpCoreTools::IrregularGrid2D::init(), QGpCoreWave::Seismic1DModel::layerCount(), QGpCoreWave::Dispersion::setGroupSlowness(), QGpCoreTools::IrregularGrid2D::setLinear(), QGpCoreTools::IrregularGrid2D::setLog(), QGpCoreWave::Love::setOmega(), QGpCoreWave::RayleighTemplate< RealType >::setOmega(), QGpCoreTools::IrregularGrid2D::setValue(), sOut(), QGpCoreWave::ModalStorage::toStream(), TRACE, QGpCoreTools::IrregularGrid2D::x(), QGpCoreTools::XAxis, QGpCoreWave::Love::y(), QGpCoreWave::RayleighTemplate< RealType >::y(), QGpCoreTools::IrregularGrid2D::y(), and QGpCoreTools::YAxis.
{
TRACE;
QTextStream sOut(stdout);
Seismic1DModel m;
QString comments;
if(!m.fromStream(s, &comments)) {
return false;
}
if(m.layerCount()>0) {
switch(_mode) {
case GridMode: {
IrregularGrid2D grid;
grid.init(_nSamples, _vNSamples, 0.0);
grid.setLinear(YAxis, 1.0/_vMaxRange, 1.0/_vMinRange);
grid.setLog(XAxis, _minRange, _maxRange);
if(_nLove>_nRayleigh) {
Love love(&m);
for(int ix=0; ix<_nSamples; ix++) {
double f=grid.x(ix);
love.setOmega(2.0*M_PI*f);
double factor=1.0/(f*f);
for(int iy=0; iy<_vNSamples; iy++) {
grid.setValue(ix, iy, fabs(love.y(grid.y(iy))*factor));
}
}
} else {
Rayleigh rayleigh(&m);
for(int ix=0; ix<_nSamples; ix++) {
double f=grid.x(ix);
rayleigh.setOmega(2.0*M_PI*f);
double factor=1.0/(f*f);
for(int iy=0; iy<_vNSamples; iy++) {
grid.setValue(ix, iy, fabs(rayleigh.y(grid.y(iy))*factor));
}
}
}
sOut << comments;
sOut << grid;
}
break;
case CurveMode:
if(_nRayleigh>0) {
Rayleigh rayleigh(&m);
QTime t;
t.start();
Dispersion dispersion (_nRayleigh, &_x);
if(dispersion.calculate(&rayleigh, 0)) {
if(_groupSlowness) {
dispersion.setGroupSlowness();
}
int dt=t.elapsed();
sOut << comments;
sOut << QString("# %1 Rayleigh dispersion mode(s)\n").arg(_nRayleigh);
sOut << QString("# CPU Time=%1 ms\n").arg(dt);
if(_deltaK) {
ModalStorage * dk=dispersion.deltaK();
dk->toStream(sOut, _oneMode ? _nRayleigh-2 : -1);
delete dk;
} else {
dispersion.toStream(sOut, _oneMode ? _nRayleigh-1 : -1);
}
} else if(_force) {
int dt=t.elapsed();
sOut << comments;
sOut << QString("# %1 Rayleigh dispersion mode(s)\n").arg(_nRayleigh);
sOut << QString("# CPU Time=%1 ms\n").arg(dt);
sOut << QString("# Failed: cannot compute dispersion curves\n");
} else {
return false;
}
}
if(_nLove>0) {
Love love(&m);
QTime t;
t.start();
Dispersion dispersion (_nLove, &_x);
if(dispersion.calculate(&love)) {
if(_groupSlowness) {
dispersion.setGroupSlowness();
}
int dt=t.elapsed();
sOut << comments;
sOut << QString("# %1 Love dispersion mode(s)\n").arg(_nLove);
sOut << QString("# CPU Time=%1 ms\n").arg(dt);
if(_deltaK) {
ModalStorage * dk=dispersion.deltaK();
dk->toStream(sOut, _oneMode ? _nLove-2 : -1);
delete dk;
} else {
dispersion.toStream(sOut, _oneMode ? _nLove-1 : -1);
}
} else if(_force) {
int dt=t.elapsed();
sOut << comments;
sOut << QString("# %1 Love dispersion mode(s)\n").arg(_nLove);
sOut << QString("# CPU Time=%1 ms\n").arg(dt);
sOut << QString("# Failed: cannot compute dispersion curves\n");
} else {
return false;
}
}
break;
}
}
return true;
}
| bool DispersionReader::setOptions | ( | int & | argc, |
| char ** | argv | ||
| ) |
References QGpCoreTools::endl(), QGpCoreTools::Function, QGpCoreTools::InversedScale, QGpCoreTools::Curve< pointType >::line(), QGpCoreTools::LinearScale, QGpCoreTools::LogScale, QGpCoreTools::Curve< pointType >::resample(), QGpCoreTools::tr(), TRACE, QGpCoreTools::Curve< pointType >::xMultiply(), and QGpCoreTools::Curve< pointType >::xVector().
Referenced by main().
{
TRACE;
// Check arguments
int i, j=1;
for(i=1; i<argc; i++) {
QByteArray arg=argv[i];
if(arg[0]=='-') {
if(arg=="-grid") {
CoreApplication::checkOptionArg(i, argc, argv);
if(argv[i][0]=='R') {
_nLove=0;
_nRayleigh=1;
} else {
_nLove=1;
_nRayleigh=0;
}
_mode=GridMode;
} else if(arg=="-vmin") {
CoreApplication::checkOptionArg(i, argc, argv);
_vMinRange=atof(argv[i]);
if(_vMinRange<=0) {
App::stream() << tr("gpdc: negative or null value for -vmin") << endl;
return false;
}
} else if(arg=="-vmax") {
CoreApplication::checkOptionArg(i, argc, argv);
_vMaxRange=atof(argv[i]);
if(_vMaxRange<=0) {
App::stream() << tr("gpdc: negative or null value for -vmax") << endl;
return false;
}
} else if(arg=="-vn") {
CoreApplication::checkOptionArg(i, argc, argv);
_vNSamples=atoi(argv[i]);
if(_vNSamples<=0) {
App::stream() << tr("gpdc: negative or null number of samples (option -vn)") << endl;
return false;
}
} else if(arg=="-R") {
CoreApplication::checkOptionArg(i, argc, argv);
_nRayleigh=atoi(argv[i]);
} else if(arg=="-L") {
CoreApplication::checkOptionArg(i, argc, argv);
_nLove=atoi(argv[i]);
} else if(arg=="-one-mode") {
_oneMode=true;
} else if(arg=="-delta-k") {
_deltaK=true;
} else if(arg=="-f") {
_force=true;
} else if(arg=="-group") {
_groupSlowness=true;
} else if(arg=="-s") {
CoreApplication::checkOptionArg(i, argc, argv);
if(strcmp(argv[i],"period")==0) {
_samplingType=InversedScale;
} else if(strcmp(argv[i],"frequency")==0) {
_samplingType=LinearScale;
} else {
_samplingType=LogScale;
}
} else if(arg=="-min") {
CoreApplication::checkOptionArg(i, argc, argv);
_minRange=atof(argv[i]);
if(_minRange<=0) {
App::stream() << tr("gpdc: negative or null value for -min") << endl;
return false;
}
} else if(arg=="-max") {
CoreApplication::checkOptionArg(i, argc, argv);
_maxRange=atof(argv[i]);
if(_maxRange<=0) {
App::stream() << tr("gpdc: negative or null value for -max") << endl;
return false;
}
} else if(arg=="-n") {
CoreApplication::checkOptionArg(i, argc, argv);
_nSamples=atoi(argv[i]);
if(_nSamples<=0) {
App::stream() << tr("gpdc: negative or null number of samples (option -n)") << endl;
return false;
}
} else {
App::stream() << tr("gpdc: bad option %1, see -help").arg(argv[i]) << endl;
return false;
}
} else {
argv[j++]=argv[i];
}
}
if(j < argc) {
argv[j]=0;
argc=j;
}
// Compute common sampling scale
Curve<Point1D> c;
c.line(_minRange, _maxRange);
c.resample(_nSamples, _minRange, _maxRange, _samplingType | Function);
c.xMultiply(2*M_PI); // convert to angular frequency
_x=c.xVector();
// Check arguments
if(_deltaK) {
if(_nRayleigh>0) {
if(_nRayleigh<2) {
App::stream() << tr("gpdc: wiht option -delta-k, the minimum number of Rayleigh modes is 2") << endl;
return false;
}
}
if(_nLove>0) {
if(_nLove<2) {
App::stream() << tr("gpdc: wiht option -delta-k, the minimum number of Love modes is 2") << endl;
return false;
}
}
}
return true;
}