3D EM based on Schur decomposition
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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