QGpCoreWave/Seismic1DModel.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-04-28
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (ULg, Liège, Belgium)
00025 **    Marc Wathelet (LGIT, Grenoble, France)
00026 **
00027 ***************************************************************************/
00028 
00029 #ifndef SEISMIC1DMODEL_H
00030 #define SEISMIC1DMODEL_H
00031 
00032 #include <QGpCoreTools.h>
00033 
00034 #include "QGpCoreWaveDLLExport.h"
00035 #include "GeophysicalModel.h"
00036 #include "Profile.h"
00037 
00038 namespace QGpCoreWave {
00039 
00040   class QGPCOREWAVE_EXPORT Seismic1DModel: public GeophysicalModel
00041 {
00042   TRANSLATIONS("Seismic1DModel")
00043 public:
00044   Seismic1DModel();
00045   Seismic1DModel(const Seismic1DModel& o);
00046   Seismic1DModel(int layerCount);
00047   ~Seismic1DModel();
00048 
00049   enum SlownessType {P, S};
00050 
00051   virtual GeophysicalModel * clone() const {return new Seismic1DModel(*this);}
00052 
00053   void operator=(const Seismic1DModel& o);
00054 
00055   double maxSlowR() const {return _maxRayleighSlowness;}
00056   double minSlowS() const {return _slowSMin;}
00057   double maxSlowS() const {return _slowSMax;}
00058   bool initCalculation();
00059   virtual bool isValid() {return initCalculation();}
00060   int checkVelocityInversion() const;
00061 
00062   void setH(int iLayer, double v) {_h[iLayer]=v;}
00063   void setSlowP(int iLayer, double v) {_slowP[iLayer]=v;}
00064   void setSlowS(int iLayer, double v) {_slowS[iLayer]=v;}
00065   void setRho(int iLayer, double v) {_rho[iLayer]=v;}
00066   void setQp(int iLayer, double v) {_qp[iLayer]=v;}
00067   void setQs(int iLayer, double v) {_qs[iLayer]=v;}
00068 
00069   int layerCount() const {return _layerCount;}
00070   virtual bool isEmpty() const {return layerCount()==0;}
00071   double h(int iLayer) const {return _h[iLayer];}
00072   double slowP(int iLayer) const {return _slowP[iLayer];}
00073   double slowS(int iLayer) const {return _slowS[iLayer];}
00074   double rho(int iLayer) const {return _rho[iLayer];}
00075   double mu(int iLayer) const {return _mu[iLayer];}
00076   double qp(int iLayer) const {return _qp[iLayer];}
00077   double qs(int iLayer) const {return _qs[iLayer];}
00078   double poisson(int iLayer) const;
00079   double depth(int iLayer) const;
00080   double expGrad(int iLayer) const;
00081   double halfSpaceRayleighSlowness(int iLayer) const;
00082   bool elastic() const;
00083 
00084   double vpAt(double depth) const;
00085   double vsAt(double depth) const;
00086   double rhoAt(double depth) const;
00087   double poissonAt(double depth) const;
00088   double impedanceAt(double depth) const;
00089   double slowPAt(double depth) const;
00090   double slowSAt(double depth) const;
00091   double roughFundamentalFrequency() const;
00092 
00093   Profile slowpProfile() const;
00094   inline Profile vpProfile() const;
00095   Profile slowsProfile() const;
00096   inline Profile vsProfile() const;
00097   Profile rhoProfile() const;
00098   Profile poissonProfile() const;
00099   Profile impedanceProfile() const;
00100 
00101   static QString formatHelp();
00102   virtual QString toString() const;
00103   virtual bool fromStream(QTextStream& s, QString * comments=0);
00104   virtual void toStream(QTextStream& s) const;
00105   void exportHerrmann(QTextStream& s) const;
00106   void toStream(QDataStream& s) const;
00107   void fromStream(QDataStream& s);
00108 
00109   void changeHKeepOtherDepth(int iLayer,double newH);
00110   void changeVpKeepPoisson(int iLayer,double newV);
00111   void changeVsKeepPoisson(int iLayer,double newV);
00112   void setHFrom(const Seismic1DModel& o);
00113   bool interpole(const Point& at, const Point * refPoints, const Seismic1DModel * refModels);
00114 
00115   class SeismicContext : public GeophysicalContext
00116   {
00117   public:
00118     SeismicContext();
00119     Seismic1DModel * model() const {return static_cast<Seismic1DModel *>(_model);}
00120     virtual QString helpCode() const;
00121   };
00122 
00123   virtual GeophysicalContext * expressionContext() const {return new SeismicContext;}
00124 
00125   class SeismicStorage : public ExpressionStorage
00126   {
00127   public:
00128     SeismicStorage(SeismicContext * context) {_context=context;}
00129     virtual bool isReadOnly() const {return false;}
00130   protected:
00131     SeismicContext * _context;
00132   };
00133 
00134   class VariableN : public SeismicStorage
00135   {
00136   public:
00137     VariableN(SeismicContext * context) : SeismicStorage(context) {}
00138     virtual bool isReadOnly() const {return true;}
00139     virtual QVariant value(const QString&) const;
00140     virtual void setValue(const QString&, const QVariant& ) {}
00141   };
00142 
00143   class VariableH : public SeismicStorage
00144   {
00145   public:
00146     VariableH(SeismicContext * context) : SeismicStorage(context) {}
00147     virtual QVariant value(const QString&) const;
00148     virtual void setValue(const QString&, const QVariant& );
00149   };
00150 
00151   class VariableVp : public SeismicStorage
00152   {
00153   public:
00154     VariableVp(SeismicContext * context) : SeismicStorage(context) {}
00155     virtual QVariant value(const QString& index) const;
00156     virtual void setValue(const QString&, const QVariant& );
00157   };
00158 
00159   class VariableVs : public SeismicStorage
00160   {
00161   public:
00162     VariableVs(SeismicContext * context) : SeismicStorage(context) {}
00163     virtual QVariant value(const QString& index) const;
00164     virtual void setValue(const QString&, const QVariant& );
00165   };
00166 
00167   class VariableRho : public SeismicStorage
00168   {
00169   public:
00170     VariableRho(SeismicContext * context) : SeismicStorage(context) {}
00171     virtual QVariant value(const QString& index) const;
00172     virtual void setValue(const QString&, const QVariant& );
00173   };
00174 
00175   class VariableQp : public SeismicStorage
00176   {
00177   public:
00178     VariableQp(SeismicContext * context) : SeismicStorage(context) {}
00179     virtual QVariant value(const QString& index) const;
00180     virtual void setValue(const QString&, const QVariant& );
00181   };
00182 
00183   class VariableQs : public SeismicStorage
00184   {
00185   public:
00186     VariableQs(SeismicContext * context) : SeismicStorage(context) {}
00187     virtual QVariant value(const QString& index) const;
00188     virtual void setValue(const QString&, const QVariant& );
00189   };
00190 protected:
00191   void allocateData();
00192   void deleteData();
00193 private:
00194   int _layerCount;
00195   double *_h;
00196   double *_slowP;
00197   double *_slowS;
00198   double *_rho;
00199   double *_mu;
00200   double *_qp;
00201   double *_qs;
00202   double _maxRayleighSlowness;
00203   double _slowSMin;
00204   double _slowSMax;
00205 
00206   bool setValue(double& var, const StringSection& field, int iLayer, const QString& varName, bool optional);
00207   void initMembers();
00208   int checkPoissonRatio();
00209   void slowMinMax(int& iSlowSMax);
00210 };
00211 
00212 inline Profile Seismic1DModel::vpProfile() const
00213 {
00214   Profile p=slowpProfile();
00215   p.inverse();
00216   return p;
00217 }
00218 
00219 inline Profile Seismic1DModel::vsProfile() const
00220 {
00221   Profile p=slowsProfile();
00222   p.inverse();
00223   return p;
00224 }
00225 
00226 } // namespace QGpCoreWave
00227 
00228 #endif // SEISMIC1DMODEL_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines