3D EM based on Schur decomposition
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

EMSchur3D.cpp 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. // Read in source specification
  63. auto AEMRead = AEMSurveyReader::NewSP();
  64. try{
  65. AEMRead->ReadASCIIAEMFile(argv[4]);
  66. } catch (std::exception& e) {
  67. std::cout << "Caught an error opening ASCII AEM file: ";
  68. std::cout << e.what() << std::endl;
  69. std::cout << "enter filename or 0 to exit programme\n";
  70. std::string inp;
  71. std::cin >> inp;
  72. if (inp != "0")
  73. AEMRead->ReadASCIIAEMFile( inp.c_str() );
  74. else exit(EXIT_FAILURE);
  75. }
  76. //////////////////////////////////////////////////
  77. // And solve
  78. EM3D->SetRectilinearGrid( std::static_pointer_cast<RectilinearGrid>( GridRead->GetGrid() ) ); // UGLY!
  79. EM3D->SetLayeredEarthEM( LayEarthRead->GetLayeredEarth() );
  80. EM3D->SetAEMSurvey( AEMRead->GetSurvey() );
  81. EM3D->LoadMeshToolsConductivityModel( argv[3] );
  82. EM3D->SetResFileName(argv[5]);
  83. //EM3D->SetCSolver( Lemma::SPARSELU ); // Lemma::BiCGSTAB );
  84. EM3D->Solve();
  85. exit(EXIT_SUCCESS);
  86. }