3D EM based on Schur decomposition
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

EMSchur3D.cpp 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* This file is part of Lemma, a geophysical modelling and inversion API.
  2. * More information is available at http://lemmasoftware.org
  3. */
  4. /* This Source Code Form is subject to the terms of the Mozilla Public
  5. * License, v. 2.0. If a copy of the MPL was not distributed with this
  6. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  7. */
  8. /**
  9. * @file
  10. * @date 01/04/2018 04:34:54 PM
  11. * @version $Id$
  12. * @author Trevor Irons (ti)
  13. * @email tirons@egi.utah.edu
  14. * @copyright Copyright (c) 2018, University of Utah
  15. * @copyright Copyright (c) 2018, Lemma Software, LLC
  16. */
  17. #include <LemmaCore>
  18. #include "RectilinearGridReader.h"
  19. //#include "AEMSurveyReader.h"
  20. #include "EMSchur3D.h"
  21. //#include "LayeredEarthEMReader.h"
  22. //#include "CSymSimplicialCholesky.h"
  23. using namespace Lemma;
  24. int main( int argc, char** argv ) {
  25. // BiCGSTAB Diagonal preconditioner
  26. auto EM3D = EMSchur3D< Eigen::BiCGSTAB<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();
  27. if (argc < 3) {
  28. std::cout << "EMSchur3D <rgrid> <1dmod> <aemsurvey> " << std::endl;
  29. exit( EXIT_SUCCESS );
  30. }
  31. ///////////////////////////////////////////////////
  32. // Read in Grid
  33. auto GridRead = RectilinearGridReader::NewSP();
  34. try {
  35. GridRead->ReadASCIIGridFile( argv[1] );
  36. } catch (std::exception& e) {
  37. std::cout << "Caught an error opening ASCII Grid file: ";
  38. std::cout << e.what() << std::endl;
  39. std::cout << "enter filename or 0 to exit programme\n";
  40. std::string inp;
  41. std::cin >> inp;
  42. if (inp != "0")
  43. GridRead->ReadASCIIGridFile( inp.c_str() );
  44. else exit(EXIT_FAILURE);
  45. }
  46. //////////////////////////////////////////////////
  47. // Read in Layered earth, for backgound model
  48. auto LayEarthRead = LayeredEarthEMReader::NewSP();
  49. try {
  50. LayEarthRead->ReadASCIIInputFile( argv[2] );
  51. } catch (std::exception& e) {
  52. std::cout << "Caught an error opening ASCII Layered Earth file: ";
  53. std::cout << e.what() << std::endl;
  54. std::cout << "enter filename or 0 to exit programme\n";
  55. std::string inp;
  56. std::cin >> inp;
  57. if (inp != "0")
  58. GridRead->ReadASCIIGridFile( inp.c_str() );
  59. else exit(EXIT_FAILURE);
  60. }
  61. /*
  62. //////////////////////////////////////////////////
  63. // Read in source specification
  64. auto AEMRead = AEMSurveyReader::NewSP();
  65. try{
  66. AEMRead->ReadASCIIAEMFile(argv[4]);
  67. } catch (std::exception& e) {
  68. std::cout << "Caught an error opening ASCII AEM file: ";
  69. std::cout << e.what() << std::endl;
  70. std::cout << "enter filename or 0 to exit programme\n";
  71. std::string inp;
  72. std::cin >> inp;
  73. if (inp != "0")
  74. AEMRead->ReadASCIIAEMFile( inp.c_str() );
  75. else exit(EXIT_FAILURE);
  76. }
  77. */
  78. /*
  79. //////////////////////////////////////////////////
  80. // And solve
  81. EM3D->SetRectilinearGrid(GridRead->GetGrid());
  82. EM3D->SetLayeredEarthEM( LayEarthRead->GetLayeredEarth() );
  83. EM3D->SetAEMSurvey( AEMRead->GetSurvey() );
  84. EM3D->LoadMeshToolsConductivityModel( argv[3] );
  85. EM3D->SetResFileName(argv[5]);
  86. //EM3D->SetCSolver( Lemma::SPARSELU ); // Lemma::BiCGSTAB );
  87. EM3D->Solve();
  88. */
  89. std::cout << *EM3D;
  90. exit(EXIT_SUCCESS);
  91. }