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 4.0KB

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