Lemma is an Electromagnetics API
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

receivercubes.cpp 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* This file is part of Lemma, a geophysical modelling and inversion API */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /**
  6. @file
  7. @author Trevor Irons
  8. @date 06/17/2010
  9. @version $Id: receivercubes.cpp 87 2013-09-05 22:44:05Z tirons $
  10. **/
  11. #include "receivercubes.h"
  12. namespace Lemma{
  13. // ==================== FRIENDS ======================
  14. std::ostream &operator<<(std::ostream &stream,
  15. const ReceiverCubes &ob) {
  16. stream << *(ReceiverPoints*)(&ob);
  17. return stream;
  18. }
  19. // ==================== LIFECYCLE ===================================
  20. ReceiverCubes * ReceiverCubes::New() {
  21. ReceiverCubes* Obj = new ReceiverCubes("ReceiverCubes");
  22. Obj->AttachTo(Obj);
  23. return Obj;
  24. }
  25. void ReceiverCubes::Delete() {
  26. this->DetachFrom(this);
  27. }
  28. void ReceiverCubes::Release() {
  29. delete this;
  30. }
  31. ReceiverCubes::ReceiverCubes(const std::string &name) :
  32. ReceiverPoints(name) {
  33. }
  34. ReceiverCubes::~ReceiverCubes() {
  35. if (this->NumberOfReferences != 0)
  36. throw DeleteObjectWithReferences( this );
  37. }
  38. // ==================== OPERATIONS =======================
  39. void ReceiverCubes::SetNumberOfReceivers(const int &nrec){
  40. ReceiverPoints::SetNumberOfReceivers(nrec);
  41. this->Locations.resize(Eigen::NoChange, nrec);
  42. this->Locations.setZero();
  43. this->Lengths.resize(Eigen::NoChange, nrec);
  44. this->Lengths.setZero();
  45. }
  46. void ReceiverCubes::SetLengthX(const int &ir, const Real& lx) {
  47. this->Lengths.col(ir)[0] = lx;
  48. }
  49. void ReceiverCubes::SetLengthY(const int &ir, const Real& ly) {
  50. this->Lengths.col(ir)[1] = ly;
  51. }
  52. void ReceiverCubes::SetLengthZ(const int &ir, const Real& lz) {
  53. this->Lengths.col(ir)[2] = lz;
  54. }
  55. void ReceiverCubes::SetLength(const int &ir, const Vector3r& l) {
  56. this->Lengths.col(ir) = l;
  57. }
  58. void ReceiverCubes::SetLength(const int &ir,const Real& lx,
  59. const Real& ly, const Real& lz) {
  60. this->Lengths.col(ir) << lx, ly, lz;
  61. }
  62. Real ReceiverCubes::GetLengthX(const int &ir) {
  63. return this->Lengths.col(ir)[0];
  64. }
  65. Real ReceiverCubes::GetLengthY(const int &ir) {
  66. return this->Lengths.col(ir)[1];
  67. }
  68. Real ReceiverCubes::GetLengthZ(const int &ir) {
  69. return this->Lengths.col(ir)[2];
  70. }
  71. Vector3r ReceiverCubes::GetLength(const int& ir) {
  72. return this->Lengths.col(ir);
  73. }
  74. Real ReceiverCubes::GetVolume(const int& ir) {
  75. return this->Lengths.col(ir)[0] *
  76. this->Lengths.col(ir)[1] *
  77. this->Lengths.col(ir)[2] ;
  78. }
  79. Real ReceiverCubes::GetVolumeSum() {
  80. Real Vol = 0.;
  81. for (int i=0; i<NumberOfReceivers; ++i) {
  82. Vol += GetVolume(i);
  83. }
  84. return Vol;
  85. }
  86. } // ----- end of Lemma name -----