3D EM based on Schur decomposition
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

EMSchur3D.cpp 3.7KB

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