QGpCoreWave/RefractionDippingModel.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of QGpCoreWave.
00004 **
00005 **  This library is free software; you can redistribute it and/or
00006 **  modify it under the terms of the GNU Lesser General Public
00007 **  License as published by the Free Software Foundation; either
00008 **  version 2.1 of the License, or (at your option) any later version.
00009 **
00010 **  This file is distributed in the hope that it will be useful, but WITHOUT
00011 **  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 **  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00013 **  License for more details.
00014 **
00015 **  You should have received a copy of the GNU Lesser General Public
00016 **  License along with this library; if not, write to the Free Software
00017 **  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 **
00019 **  See http://www.geopsy.org for more information.
00020 **
00021 **  Created : 2004-09-17
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (ULg, Liège, Belgium)
00025 **    Marc Wathelet (LGIT, Grenoble, France)
00026 **
00027 ***************************************************************************/
00028 
00029 #ifndef REFRACTIONDIPPINGMODEL_H
00030 #define REFRACTIONDIPPINGMODEL_H
00031 
00032 #include <math.h>
00033 #include <QGpCoreTools.h>
00034 #include "Seismic1DModel.h"
00035 #include "QGpCoreWaveDLLExport.h"
00036 
00037 namespace QGpCoreWave {
00038 
00039 class TiltNode;
00040 class TiltPath;
00041 
00042 class QGPCOREWAVE_EXPORT RefractionDippingModel : public GeophysicalModel
00043 {
00044   TRANSLATIONS("RefractionDippingModel");
00045 public:
00046   RefractionDippingModel();
00047   RefractionDippingModel(int nLayers);
00048   RefractionDippingModel(const RefractionDippingModel& o);
00049   ~RefractionDippingModel();
00050 
00051   virtual GeophysicalModel * clone() const {return new RefractionDippingModel(*this);}
00052 
00053   int layerCount() const {return _layerCount;}
00054   virtual bool isEmpty() const {return layerCount()==0;}
00055   double depthLeft(int iLayer) const {return _depthL[iLayer];}
00056   double setDepthLeft(int iLayer, double d) {return _depthL[iLayer]=d;}
00057   double depthRight(int iLayer) const {return _depthR[iLayer];}
00058   double setDepthRight(int iLayer, double d) {return _depthR[iLayer]=d;}
00059   double slowness(int iLayer) const {return _slow[iLayer];}
00060   double setSlowness(int iLayer, double s) {return _slow[iLayer]=s;}
00061 
00062   void setXLeft(double x) {_xL=x;}
00063   double xLeft() const {return _xL;}
00064 
00065   void setXRight(double x) {_xR=x;}
00066   double xRight() const {return _xR;}
00067 
00068   void fromSeismic1DModel(const Seismic1DModel& ref, const QVector<double>& pitch,
00069                          Seismic1DModel::SlownessType slowType);
00070 
00071   enum Direction {LeftToRight, RightToLeft};
00072 
00073   void begin();
00074   inline bool isCriticalLayer(Direction dir, int iLayer) const;
00075   double propagate(Direction dir, int iLayer, int iDeepestLayer, double& x) const;
00076   void end();
00077 
00078   double travelTime(const TiltNode& src, const TiltNode& rec, int& minTimeLayer);
00079   Curve<Point2D> ray(const TiltNode& src, const TiltNode& rec);
00080 
00081   static QString formatHelp();
00082   virtual QString toString() const;
00083   virtual bool fromStream(QTextStream& s, QString * comments=0);
00084   virtual void toStream(QTextStream& s) const;
00085   void fromStream(QDataStream& s);
00086   void toStream(QDataStream& s) const;
00087 
00088   class RefractionContext : public GeophysicalContext
00089   {
00090   public:
00091     RefractionContext();
00092     RefractionDippingModel * model() const {return static_cast<RefractionDippingModel *>(_model);}
00093     virtual QString helpCode() const;
00094   };
00095 
00096   virtual GeophysicalContext * expressionContext() const {return new RefractionContext;}
00097 
00098   class RefractionStorage : public ExpressionStorage
00099   {
00100   public:
00101     RefractionStorage(RefractionContext * context) {_context=context;}
00102     virtual bool isReadOnly() const {return false;}
00103   protected:
00104     RefractionContext * _context;
00105   };
00106 
00107   class VariableN : public RefractionStorage
00108   {
00109   public:
00110     VariableN(RefractionContext * context) : RefractionStorage(context) {}
00111     virtual bool isReadOnly() const {return true;}
00112     virtual QVariant value(const QString&) const;
00113     virtual void setValue(const QString&, const QVariant& ) {}
00114   };
00115 
00116   class VariableDL : public RefractionStorage
00117   {
00118   public:
00119     VariableDL(RefractionContext * context) : RefractionStorage(context) {}
00120     virtual QVariant value(const QString& index) const;
00121     virtual void setValue(const QString&, const QVariant& );
00122   };
00123 
00124   class VariableDR : public RefractionStorage
00125   {
00126   public:
00127     VariableDR(RefractionContext * context) : RefractionStorage(context) {}
00128     virtual QVariant value(const QString& index) const;
00129     virtual void setValue(const QString&, const QVariant& );
00130   };
00131 
00132   class VariableV : public RefractionStorage
00133   {
00134   public:
00135     VariableV(RefractionContext * context) : RefractionStorage(context) {}
00136     virtual QVariant value(const QString& index) const;
00137     virtual void setValue(const QString&, const QVariant& );
00138   };
00139 private:
00140   void initMembers();
00141   void allocateData();
00142   void deleteData();
00143   bool setValue(double& var, const StringSection& field, int iLayer, const QString& varName, bool optional);
00144   double travelTime(const TiltPath *& srcPaths, const TiltPath *& recPaths, int& minTimeLayer);
00145   bool node2paths(const TiltNode& src, const TiltNode& rec,
00146                    const TiltPath *& srcPaths, const TiltPath *& recPaths) const;
00147 
00148   // number of layers including the bottom half space
00149   int _layerCount;
00150   // pointer to depth vector (positive values) counted at profile Left
00151   double * _depthL;
00152   // pointer to depth vector (positive values) counted at profile Right
00153   double * _depthR;
00154   // pointer to slownesses vector
00155   double * _slow;
00156   double _xL, _xR;
00157 
00158   // Min and max x of rays along interfaces
00159   double * _minX;
00160   double * _maxX;
00161 
00162   // Cosine of the angle (to avoid multiple useless computations)
00163   double * _cosangle;
00164   // Sine of the angle (to avoid multiple useless computations)
00165   double * _sinangle;
00166   // ratio of slownesses at the interface
00167   double * _n;
00168   /* Abscissa to substract to abscissae measured from the intercept point
00169       to obtain the abcissa from the reference profile.
00170       The intercept is the projection of the intersection of the reference
00171       profile with the upper interface, made perpendiculary to the upper
00172       interface, and downto the current interface */
00173   double * _shift;
00174   /* Apparent thickness of the layer calculated prependiculary to upper interface
00175       and at reference profile */
00176   double * _h;
00177   /* For each layer a vector of relative angles may be allocated
00178     if the interface is a good candidate for refraction at critical angle */
00179   double ** _critl;
00180   double ** _critr;
00181 };
00182 
00183 inline bool RefractionDippingModel::isCriticalLayer(Direction dir, int iLayer) const
00184 {
00185   TRACE;
00186   switch(dir) {
00187   case LeftToRight:
00188     return _critl[iLayer];
00189     break;
00190   default:
00191     return _critr[iLayer];
00192     break;
00193   }
00194 }
00195 
00196 } // namespace QGpCoreWave
00197 
00198 #endif // REFRACTIONDIPPINGMODEL_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines