Skip to content
Snippets Groups Projects
Select Git revision
  • 16dc7bcf8cba9729ffc787e4d676defee8a7c39a
  • develop default protected
  • feature/gmsh-reader
  • origin/stage/bouguettaia
  • feature/kinetic-schemes
  • feature/reconstruction
  • feature/local-dt-fsi
  • feature/composite-scheme-sources
  • feature/composite-scheme-other-fluxes
  • feature/serraille
  • feature/variational-hydro
  • feature/composite-scheme
  • hyperplastic
  • feature/polynomials
  • feature/gks
  • feature/implicit-solver-o2
  • feature/coupling_module
  • feature/implicit-solver
  • feature/merge-local-dt-fsi
  • master protected
  • feature/escobar-smoother
  • v0.5.0 protected
  • v0.4.1 protected
  • v0.4.0 protected
  • v0.3.0 protected
  • v0.2.0 protected
  • v0.1.0 protected
  • Kidder
  • v0.0.4 protected
  • v0.0.3 protected
  • v0.0.2 protected
  • v0 protected
  • v0.0.1 protected
33 results

main.cpp

Blame
    • Stéphane Del Pino's avatar
      16dc7bcf
      Add plugin loading mechanism · 16dc7bcf
      Stéphane Del Pino authored
      Plugins are loaded through environment variables. Two environment
      variables are read: PUGS_PLUGIN and PUGS_PLUGIN_DIR
      
      - PUGS_PLUGIN is a string literal that contains the filename of the
      dynamic library that contains plugins. One can provide multiple
      filename using semicolumn separators.
        ex. PUGS_PLUGIN="/path/to/my/libplugin1.so;/anotherpath/to/another/libplugin2.so"
      
      - PUGS_PLUGIN_DIR is a string literal that contains directory path
      where plugins (dynamic libraries) are.  One can provide multiple path
      using semicolumn separators. All the dynamic libraries present at the
      locations are loaded!
        ex. PUGS_PLUGIN="/path/to/a/plugin/list/;/anotherpath/to/another/plugin/list/"
      16dc7bcf
      History
      Add plugin loading mechanism
      Stéphane Del Pino authored
      Plugins are loaded through environment variables. Two environment
      variables are read: PUGS_PLUGIN and PUGS_PLUGIN_DIR
      
      - PUGS_PLUGIN is a string literal that contains the filename of the
      dynamic library that contains plugins. One can provide multiple
      filename using semicolumn separators.
        ex. PUGS_PLUGIN="/path/to/my/libplugin1.so;/anotherpath/to/another/libplugin2.so"
      
      - PUGS_PLUGIN_DIR is a string literal that contains directory path
      where plugins (dynamic libraries) are.  One can provide multiple path
      using semicolumn separators. All the dynamic libraries present at the
      locations are loaded!
        ex. PUGS_PLUGIN="/path/to/a/plugin/list/;/anotherpath/to/another/plugin/list/"
    test_EigenvalueSolver.cpp 4.62 KiB
    #include <catch2/catch_test_macros.hpp>
    #include <catch2/matchers/catch_matchers_all.hpp>
    
    #include <algebra/CRSMatrix.hpp>
    #include <algebra/CRSMatrixDescriptor.hpp>
    #include <algebra/EigenvalueSolver.hpp>
    #include <algebra/SmallMatrix.hpp>
    
    #include <utils/pugs_config.hpp>
    
    // clazy:excludeall=non-pod-global-static
    
    TEST_CASE("EigenvalueSolver", "[algebra]")
    {
      SECTION("Sparse Matrices")
      {
        SECTION("symmetric system")
        {
          Array<int> non_zeros(3);
          non_zeros.fill(3);
          CRSMatrixDescriptor<double> S{3, 3, non_zeros};
    
          S(0, 0) = 3;
          S(0, 1) = 2;
          S(0, 2) = 4;
    
          S(1, 0) = 2;
          S(1, 1) = 0;
          S(1, 2) = 2;
    
          S(2, 0) = 4;
          S(2, 1) = 2;
          S(2, 2) = 3;
    
          CRSMatrix A{S.getCRSMatrix()};
    
          SECTION("eigenvalues")
          {
            SmallArray<double> eigenvalues;
    
    #ifdef PUGS_HAS_SLEPC
            EigenvalueSolver{}.computeForSymmetricMatrix(A, eigenvalues);
            REQUIRE(eigenvalues[0] == Catch::Approx(-1));
            REQUIRE(eigenvalues[1] == Catch::Approx(-1));
            REQUIRE(eigenvalues[2] == Catch::Approx(8));
    #else    //  PUGS_HAS_SLEPC
            REQUIRE_THROWS_WITH(EigenvalueSolver{}.computeForSymmetricMatrix(A, eigenvalues),
                                "not implemented yet: SLEPc is required to solve eigenvalue problems");
    #endif   // PUGS_HAS_SLEPC
          }
    
          SECTION("eigenvalues and eigenvectors")
          {
            SmallArray<double> eigenvalue_list;
            std::vector<SmallVector<double>> eigenvector_list;
    
    #ifdef PUGS_HAS_SLEPC
            EigenvalueSolver{}.computeForSymmetricMatrix(A, eigenvalue_list, eigenvector_list);
    
            REQUIRE(eigenvalue_list[0] == Catch::Approx(-1));
            REQUIRE(eigenvalue_list[1] == Catch::Approx(-1));
            REQUIRE(eigenvalue_list[2] == Catch::Approx(8));
    
            SmallMatrix<double> P{3};
            SmallMatrix<double> PT{3};
            SmallMatrix<double> D{3};
            D = zero;
    
            for (size_t i = 0; i < 3; ++i) {
              for (size_t j = 0; j < 3; ++j) {
                P(i, j)  = eigenvector_list[j][i];
                PT(i, j) = eigenvector_list[i][j];
              }
              D(i, i) = eigenvalue_list[i];
            }
    
            SmallMatrix PDPT = P * D * PT;
            for (size_t i = 0; i < 3; ++i) {
              for (size_t j = 0; j < 3; ++j) {
                REQUIRE(PDPT(i, j) - S(i, j) == Catch::Approx(0).margin(1E-13));
              }
            }
    #else    //  PUGS_HAS_SLEPC
            REQUIRE_THROWS_WITH(EigenvalueSolver{}.computeForSymmetricMatrix(A, eigenvalue_list, eigenvector_list),
                                "not implemented yet: SLEPc is required to solve eigenvalue problems");
    #endif   // PUGS_HAS_SLEPC
          }
    
          SECTION("eigenvalues and passage matrix")
          {
            SmallArray<double> eigenvalue_list;
            SmallMatrix<double> P{};
    
    #ifdef PUGS_HAS_SLEPC
            EigenvalueSolver{}.computeForSymmetricMatrix(A, eigenvalue_list, P);
    
            REQUIRE(eigenvalue_list[0] == Catch::Approx(-1));
            REQUIRE(eigenvalue_list[1] == Catch::Approx(-1));
            REQUIRE(eigenvalue_list[2] == Catch::Approx(8));
    
            SmallMatrix<double> D{3};
            D = zero;
            for (size_t i = 0; i < 3; ++i) {
              D(i, i) = eigenvalue_list[i];
            }
            SmallMatrix PT = transpose(P);
    
            SmallMatrix PDPT = P * D * PT;
            for (size_t i = 0; i < 3; ++i) {
              for (size_t j = 0; j < 3; ++j) {
                REQUIRE(PDPT(i, j) - S(i, j) == Catch::Approx(0).margin(1E-13));
              }
            }
    #else    //  PUGS_HAS_SLEPC
            REQUIRE_THROWS_WITH(EigenvalueSolver{}.computeForSymmetricMatrix(A, eigenvalue_list, P),
                                "not implemented yet: SLEPc is required to solve eigenvalue problems");
    #endif   // PUGS_HAS_SLEPC
          }
          SECTION("exponential of a matrix")
          {
            SmallMatrix<double> expA{};
            SmallMatrix<double> expS{3};
    
            expS(0, 0) = 1325.074593930307812;
            expS(0, 1) = 662.353357244568285;
            expS(0, 2) = 1324.70671448913637;
            expS(1, 0) = expS(0, 1);
            expS(1, 1) = 331.544558063455535;
            expS(1, 2) = 662.353357244568185;
            expS(2, 0) = expS(0, 2);
            expS(2, 1) = expS(1, 2);
            expS(2, 2) = expS(0, 0);
    
    #ifdef PUGS_HAS_SLEPC
            EigenvalueSolver{}.computeExpForSymmetricMatrix(A, expA);
    
            for (size_t i = 0; i < 3; ++i) {
              for (size_t j = 0; j < 3; ++j) {
                REQUIRE(expA(i, j) - expS(i, j) == Catch::Approx(0).margin(1E-12));
              }
            }
    #else    //  PUGS_HAS_SLEPC
            REQUIRE_THROWS_WITH(EigenvalueSolver{}.computeExpForSymmetricMatrix(A, expP),
                                "not implemented yet: SLEPc is required to solve eigenvalue problems");
    #endif   // PUGS_HAS_SLEPC
          }
        }
      }
    }