123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- /* This file is part of Lemma, a geophysical modelling and inversion API.
- * More information is available at http://lemmasoftware.org
- */
-
- /* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
- /**
- * @file
- * @date 01/04/2018 04:34:54 PM
- * @version $Id$
- * @author Trevor Irons (ti)
- * @email tirons@egi.utah.edu
- * @copyright Copyright (c) 2018, University of Utah
- * @copyright Copyright (c) 2018, Lemma Software, LLC
- */
-
- #include <LemmaCore>
- //#include "RectilinearGridReader.h"
- //#include "AEMSurveyReader.h"
- #include "EMSchur3D.h"
- //#include "LayeredEarthEMReader.h"
- //#include "CSymSimplicialCholesky.h"
-
- using namespace Lemma;
-
- int main( int argc, char** argv ) {
-
- // BiCGSTAB Diagonal preconditioner
- //auto EM3D = EMSchur3D< Eigen::BiCGSTAB<Eigen::SparseMatrix<Complex, Eigen::ColMajor>, Eigen::IncompleteLUT<Complex> > >::NewSP();
- //auto EM3D = EMSchur3D< Eigen::BiCGSTAB<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();
-
- // SUPERLU
- //auto EM3D = EMSchur3D< Eigen::SuperLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();
-
- //auto EM3D = EMSchur3D< Eigen::PardisoLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();
- //auto EM3D = EMSchur3D< Eigen::PardisoLDLT<Eigen::SparseMatrix<Complex, Eigen::ColMajor>, Eigen::Symmetric&Eigen::Lower > >::NewSP();
-
- // Eigen built-in
- auto EM3D = EMSchur3D< Eigen::SparseLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();
-
- // UmfPack
- //auto EM3D = EMSchur3D< Eigen::UmfPackLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor> > >::NewSP();
-
- // PaStiX
- //auto EM3D = EMSchur3D< Eigen::PastixLU<Eigen::SparseMatrix<Complex, Eigen::ColMajor>, true > >::NewSP();
-
-
- if (argc < 3) {
- std::cout << "EMSchur3D <rgrid> <1dmod> <3dmod> <aemsurvey> " << std::endl;
- exit( EXIT_SUCCESS );
- }
-
- #ifdef LEMMAUSEOMP
- std::cout << "Eigen is using OpenMP!!!\n";
- Eigen::initParallel();
- #endif
-
- ///////////////////////////////////////////////////
- // Read in Grid
- auto GridRead = RectilinearGridReader::NewSP();
- try {
- GridRead->ReadASCIIGridFile( argv[1] );
- } catch (std::exception& e) {
- std::cout << "Caught an error opening ASCII Grid file: ";
- std::cout << e.what() << std::endl;
- std::cout << "enter filename or 0 to exit programme\n";
- std::string inp;
- std::cin >> inp;
- if (inp != "0")
- GridRead->ReadASCIIGridFile( inp.c_str() );
- else exit(EXIT_FAILURE);
- }
-
- //////////////////////////////////////////////////
- // Read in Layered earth, for backgound model
- auto LayEarthRead = LayeredEarthEMReader::NewSP();
- try {
- LayEarthRead->ReadASCIIInputFile( argv[2] );
- } catch (std::exception& e) {
- std::cout << "Caught an error opening ASCII Layered Earth file: ";
- std::cout << e.what() << std::endl;
- std::cout << "enter filename or 0 to exit programme\n";
- std::string inp;
- std::cin >> inp;
- if (inp != "0")
- GridRead->ReadASCIIGridFile( inp.c_str() );
- else exit(EXIT_FAILURE);
- }
-
- //////////////////////////////////////////////////
- // Read in source specification
- auto AEMRead = AEMSurveyReader::NewSP();
- try{
- AEMRead->ReadASCIIAEMFile(argv[4]);
- } catch (std::exception& e) {
- std::cout << "Caught an error opening ASCII AEM file: ";
- std::cout << e.what() << std::endl;
- std::cout << "enter filename or 0 to exit programme\n";
- std::string inp;
- std::cin >> inp;
- if (inp != "0")
- AEMRead->ReadASCIIAEMFile( inp.c_str() );
- else exit(EXIT_FAILURE);
- }
-
- //////////////////////////////////////////////////
- // And solve
- EM3D->SetRectilinearGrid( std::static_pointer_cast<RectilinearGrid>( GridRead->GetGrid() ) ); // UGLY!
- EM3D->SetLayeredEarthEM( LayEarthRead->GetLayeredEarth() );
- EM3D->SetAEMSurvey( AEMRead->GetSurvey() );
- EM3D->LoadMeshToolsConductivityModel( argv[3] );
- EM3D->SetResFileName(argv[5]);
- //EM3D->SetCSolver( Lemma::SPARSELU ); // Lemma::BiCGSTAB );
- EM3D->Solve();
-
- exit(EXIT_SUCCESS);
- }
|