3D EM based on Schur decomposition
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

EMSchur3D.cpp 3.5KB

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::RowMajor>, Eigen::IncompleteLUT<Complex> > >::NewSP();
  27. if (argc < 3) {
  28. std::cout << "EMSchur3D <rgrid> <1dmod> <aemsurvey> " << std::endl;
  29. exit( EXIT_SUCCESS );
  30. }
  31. #ifdef LEMMAUSEOMP
  32. std::cout << "Eigen is using OpenMP!!!\n";
  33. Eigen::initParallel();
  34. #endif
  35. ///////////////////////////////////////////////////
  36. // Read in Grid
  37. auto GridRead = RectilinearGridReader::NewSP();
  38. try {
  39. GridRead->ReadASCIIGridFile( argv[1] );
  40. } catch (std::exception& e) {
  41. std::cout << "Caught an error opening ASCII Grid file: ";
  42. std::cout << e.what() << std::endl;
  43. std::cout << "enter filename or 0 to exit programme\n";
  44. std::string inp;
  45. std::cin >> inp;
  46. if (inp != "0")
  47. GridRead->ReadASCIIGridFile( inp.c_str() );
  48. else exit(EXIT_FAILURE);
  49. }
  50. //////////////////////////////////////////////////
  51. // Read in Layered earth, for backgound model
  52. auto LayEarthRead = LayeredEarthEMReader::NewSP();
  53. try {
  54. LayEarthRead->ReadASCIIInputFile( argv[2] );
  55. } catch (std::exception& e) {
  56. std::cout << "Caught an error opening ASCII Layered Earth file: ";
  57. std::cout << e.what() << std::endl;
  58. std::cout << "enter filename or 0 to exit programme\n";
  59. std::string inp;
  60. std::cin >> inp;
  61. if (inp != "0")
  62. GridRead->ReadASCIIGridFile( inp.c_str() );
  63. else exit(EXIT_FAILURE);
  64. }
  65. //////////////////////////////////////////////////
  66. // Read in source specification
  67. auto AEMRead = AEMSurveyReader::NewSP();
  68. try{
  69. AEMRead->ReadASCIIAEMFile(argv[4]);
  70. } catch (std::exception& e) {
  71. std::cout << "Caught an error opening ASCII AEM file: ";
  72. std::cout << e.what() << std::endl;
  73. std::cout << "enter filename or 0 to exit programme\n";
  74. std::string inp;
  75. std::cin >> inp;
  76. if (inp != "0")
  77. AEMRead->ReadASCIIAEMFile( inp.c_str() );
  78. else exit(EXIT_FAILURE);
  79. }
  80. //////////////////////////////////////////////////
  81. // And solve
  82. EM3D->SetRectilinearGrid( std::static_pointer_cast<RectilinearGrid>( GridRead->GetGrid() ) ); // UGLY!
  83. EM3D->SetLayeredEarthEM( LayEarthRead->GetLayeredEarth() );
  84. EM3D->SetAEMSurvey( AEMRead->GetSurvey() );
  85. EM3D->LoadMeshToolsConductivityModel( argv[3] );
  86. EM3D->SetResFileName(argv[5]);
  87. //EM3D->SetCSolver( Lemma::SPARSELU ); // Lemma::BiCGSTAB );
  88. EM3D->Solve();
  89. exit(EXIT_SUCCESS);
  90. }