123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- /* This file is part of Lemma, a geophysical modelling and inversion API */
-
- /* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
- /**
- @file
- @author Trevor Irons
- @date 12/02/2009
- @version $Id: receiverpoints.h 199 2014-12-29 19:25:20Z tirons $
- **/
-
- #ifndef __RECEIVERPOINTS_H
- #define __RECEIVERPOINTS_H
-
- #ifdef LEMMAUSEVTK
- #include "vtkPointData.h"
- #include "vtkFieldData.h"
- #include "vtkGlyph3D.h"
- #include "vtkArrowSource.h"
- #include "vtkActor.h"
- #include "vtkPolyDataMapper.h"
- #include "vtkPoints.h"
- #include "vtkPolyData.h"
- #include "vtkDoubleArray.h"
- #include "vtkDataObject.h"
- #endif
-
- #include "LemmaObject.h"
- #include "dipolesource.h"
-
- #ifdef HAVE_YAMLCPP
- #include "yaml-cpp/yaml.h"
- #endif
-
- namespace Lemma {
-
- // =======================================================================
- // Class: ReceiverPoints
- /// \brief Points in the subsurface to make EM calculations,
- /// more general than the grids.
- // =======================================================================
- class ReceiverPoints : public LemmaObject {
-
- public:
-
- // ==================== FRIENDS ===========================
-
- /** Stream operator printing out information about this class.
- */
- friend std::ostream &operator<<(std::ostream &stream,
- const ReceiverPoints &ob);
-
- friend class EMEarth1D;
- friend class DipoleSource;
-
- // ==================== LIFECYCLE ===========================
-
- /**
- * Returns pointer to new DipoleSource. Location is
- * initialized to (0,0,0) type and polarization are
- * initialized to nonworking values that will throw
- * exceptions if used.
- */
- static ReceiverPoints* New();
-
-
- /**
- * @copybrief LemmaObject::Delete()
- * @copydetails LemmaObject::Delete()
- */
- void Delete();
-
- // ==================== OPERATORS ===========================
-
- // ==================== OPERATIONS ===========================
-
- // ==================== ACCESS ===========================
-
- /// Sets the number of receivers
- virtual void SetNumberOfReceivers(const int &nrec);
-
- /// Returns the location of a single receiver as an Eigen Vector
- void SetLocation(const int& nrec, const Vector3r& loc);
-
- /// Returns the location of a single receiver as an Eigen Vector
- void SetLocation(const int& nrec, const Real& xp, const Real& yp,
- const Real& zp);
-
- // ==================== INQUIRY ===========================
-
- /// Returns the number of receiverpoints.
- int GetNumberOfReceivers();
-
- /// Returns all the receiver locations as a 3 X matrix
- Vector3Xr GetLocations();
-
- /// Returns all the receiver locations as a general matrix, useful for python wrapper
- MatrixXr GetLocationsMat();
-
- /// Returns the E field for all locations
- /// nfreq is the freqency desired
- Vector3Xcr GetEfield(const int &nfreq);
-
- /// Returns the E field for all locations
- /// nfreq is the freqency desired, cast to general dynamic matrix, for python interoperability
- MatrixXcr GetEfieldMat(const int &nfreq);
-
- /// Returns the H field for all locations
- /// nfreq is the freqency desired, cast to general dynamic matrix, for python interoperability
- MatrixXcr GetHfieldMat(const int &nfreq);
-
- /// Returns the H field for all locations
- /// nfreq is the freqency desired
- Vector3Xcr GetHfield(const int &nfreq);
-
- /// Returns all of the computed H fields. Every frequency
- std::vector<Vector3Xcr> GetHfield( );
-
- /// Returns all of the computed E fields. Every frequency
- std::vector<Vector3Xcr> GetEfield( );
-
- /// Returns the E field of a single receiver as an Eigen Vector
- /// nfreq is the freqency desired
- Vector3cr GetEfield(const int &nfreq, const int& loc);
-
- /// Returns the H field of a single receiver as an Eigen Vector
- /// nfreq is the freqency desired
- Vector3cr GetHfield(const int &nfreq, const int& loc);
-
- /// Returns the B field of a single receiver as an Eigen Vector
- /// nfreq is the freqency desired
- Vector3cr GetBfield(const int &nfreq, const int& loc);
-
- #ifdef LEMMAUSEVTK
- /// Returns vtk Glyph actor that can be placed into scenes
- vtkActor* GetVtkGlyphActor(const FIELDTYPE &ftype,
- const Real& clip, const Real &scale,
- const int &nfreq);
-
- /// Returns a vtk Data Object that can easily be plotted
- vtkDataObject * GetVtkDataObject(const FIELDTYPE &ftype,
- const int& nbin,
- const int& start, const int& end,
- const FIELDCOMPONENT& fcomp,
- const SPATIALCOORDINANT& scord);
-
- /// Returns a vtk Data Object that can easily be plotted
- vtkDataObject * GetVtkDataObjectFreq(const FIELDTYPE &ftype,
- const int& nrec,
- const int& fstart, const int& fend,
- const FIELDCOMPONENT& fcomp,
- const VectorXr& Freqs);
- #endif
-
- /// Returns the location of a single receiver as an Eigen Vector
- Vector3r GetLocation(const int& loc);
-
- /// Returns the x component of the location
- Real GetLocationX(const int& loc);
-
- /// Returns the y component of the location
- Real GetLocationY(const int& loc);
-
- /// Returns the z component of the location
- Real GetLocationZ(const int& loc);
-
- /// Resets fields
- void ClearFields();
-
- /// Sets the mask variable to true for this point.
- void MaskPoint(const int& i);
-
- /// Turns the mask off for this point.
- void UnMaskPoint(const int& i);
-
- /// Removes making on all points
- void UnMaskAllPoints();
-
- /// Returns the mask for this point
- int GetMask(const int& i);
-
- #ifdef HAVE_YAMLCPP
- /**
- * Uses YAML to serialize this object.
- * @return a YAML::Node
- */
- YAML::Node Serialize() const;
-
- /**
- * Constructs an object from a YAML::Node.
- */
- static ReceiverPoints* DeSerialize(const YAML::Node& node);
- #endif
-
- protected:
-
- // ==================== LIFECYCLE ===========================
-
- /// Default protected constructor.
- ReceiverPoints (const std::string& name);
-
- #ifdef HAVE_YAMLCPP
- /// Default protected constructor.
- ReceiverPoints (const YAML::Node& node);
- #endif
-
- /// Default protected constructor.
- ~ReceiverPoints ();
-
- /**
- * @copybrief LemmaObject::Release()
- * @copydetails LemmaObject::Release()
- */
- void Release();
-
- // ==================== OPERATIONS ===========================
-
- /// Sets the number of H bins. These bins are often frequencies.
- void SetNumberOfBinsH(const int& nbins);
-
- /// Sets the number of E bins. These bins are often frequencies.
- void SetNumberOfBinsE(const int& nbins);
-
- /** Internal function that resizes the EField data structure */
- void ResizeEField();
-
- /** Internal function that resizes the HField data structure */
- void ResizeHField();
-
- /// Sets the value of the E field
- void SetEfield(const int &nfreq, const int& loc,
- const Complex &ex, const Complex &ey, const Complex &ez);
-
- /// Sets the value of the H field
- void SetHfield(const int &nfreq, const int& loc,
- const Complex &hx, const Complex &hy, const Complex &hz);
-
- /// Appends the value of the E field. This method is not
- /// thread safe.
- void AppendEfield(const int&nfreq, const int& loc,
- const Complex &ex, const Complex &ey, const Complex &ez);
-
- /// Appends the value of the H field. This method is not
- /// thread safe.
- void AppendHfield(const int &nfreq, const int& loc,
- const Complex &hx, const Complex &hy, const Complex &hz);
-
- // ==================== DATA MEMBERS ===========================
-
- /// Number of receivers
- int NumberOfReceivers;
-
- /// Number of fields
- int NumberOfBinsE;
-
- /// Number of fields
- int NumberOfBinsH;
-
- /// Used to mask this point so no computation is made at
- /// this point.
- VectorXi Mask;
-
- /// Locations of receivers
- Vector3Xr Locations;
-
- private:
-
- // NOTE, these are not serialized in output!
-
- /// Electric field at receiver locations
- std::vector<Vector3Xcr> Efield;
-
- /// H field at receiver locations
- std::vector<Vector3Xcr> Hfield;
-
- }; // ----- end of class ReceiverPoints -----
- }
-
- #endif // __RECEIVERPOINTS
|