Esempio n. 1
0
    void UMFPackLinearMatrixSolver<std::complex<double> >::solve()
    {
      assert(m != nullptr);
      assert(rhs != nullptr);
      assert(m->get_size() == rhs->get_size());

      this->tick();
      if( !setup_factorization() )
        this->warn("LU factorization could not be completed.");

      if(sln)
        delete [] sln;
      sln = new std::complex<double>[m->get_size()];

      memset(sln, 0, m->get_size() * sizeof(std::complex<double>));
      int status = umfpack_complex_solve(UMFPACK_A, m->get_Ap(), m->get_Ai(), (double *)m->get_Ax(), nullptr, (double*) sln, nullptr, (double *)rhs->v, nullptr, numeric, nullptr, nullptr);
      if(status != UMFPACK_OK)
      {
        this->free_factorization_data();
        throw Exceptions::LinearMatrixSolverException(check_status("UMFPACK solution", status));
      }

      this->tick();
      time = this->accumulated();
    }
Esempio n. 2
0
    void UMFPackLinearMatrixSolver<double>::solve()
    {
      assert(m != nullptr);
      assert(rhs != nullptr);
      assert(m->get_size() == rhs->get_size());

      this->tick();

      if( !setup_factorization() )
        throw Exceptions::LinearMatrixSolverException("LU factorization could not be completed.");

      if(sln != nullptr)
        delete [] sln;

      sln = new double[m->get_size()];
      memset(sln, 0, m->get_size() * sizeof(double));
      int status = umfpack_real_solve(UMFPACK_A, m->get_Ap(), m->get_Ai(), m->get_Ax(), sln, rhs->v, numeric, nullptr, nullptr);
      if(status != UMFPACK_OK)
      {
        this->free_factorization_data();
        throw Exceptions::LinearMatrixSolverException(check_status("UMFPACK solution", status));
      }

      this->tick();
    }
Esempio n. 3
0
    bool AmesosSolver<std::complex<double> >::solve()
    {
      _F_;
      assert(m != NULL);
      assert(rhs != NULL);

      assert(m->size == rhs->size);

      Hermes::TimePeriod tmr;  

      error("AmesosSolver<Scalar>::solve() not yet implemented for complex problems");

      if (!setup_factorization())
      {
        warning("AmesosSolver: LU factorization could not be completed");
        return false;
      }

      int status = solver->Solve();
      if (status != 0) 
      {
        error("AmesosSolver: Solution failed.");
        return false;
      }

      tmr.tick();
      this->time = tmr.accumulated();

      delete [] this->sln;
      this->sln = new std::complex<double>[m->size]; MEM_CHECK(this->sln);
      // copy the solution into sln vector
      memset(this->sln, 0, m->size * sizeof(std::complex<double>));

      return true;
    }
Esempio n. 4
0
    bool AmesosSolver<double>::solve()
    {
      _F_;
      assert(m != NULL);
      assert(rhs != NULL);

      assert(m->size == rhs->size);

      Hermes::TimePeriod tmr;  

      problem.SetOperator(m->mat);
      problem.SetRHS(rhs->vec);
      Epetra_Vector x(*rhs->std_map);
      problem.SetLHS(&x);

      if (!setup_factorization())
      {
        warning("AmesosSolver: LU factorization could not be completed");
        return false;
      }

      int status = solver->Solve();
      if (status != 0) 
      {
        error("AmesosSolver: Solution failed.");
        return false;
      }

      tmr.tick();
      this->time = tmr.accumulated();

      delete [] this->sln;
      this->sln = new double[m->size]; MEM_CHECK(this->sln);
      // copy the solution into sln vector
      memset(this->sln, 0, m->size * sizeof(double));

      for (unsigned int i = 0; i < m->size; i++) this->sln[i] = x[i];

      return true;
    }
Esempio n. 5
0
    void UMFPackLinearMatrixSolver<double>::solve()
    {
      assert(m != nullptr);
      assert(rhs != nullptr);
      assert(m->get_size() == rhs->get_size());

      this->tick();

      if (!setup_factorization())
        throw Exceptions::LinearMatrixSolverException("LU factorization could not be completed.");

      free_with_check(sln);

      sln = calloc_with_check<UMFPackLinearMatrixSolver<double>, double>(m->get_size(), this);
      int status = umfpack_real_solve(UMFPACK_A, m->get_Ap(), m->get_Ai(), m->get_Ax(), sln, rhs->v, numeric, nullptr, nullptr);
      if (status != UMFPACK_OK)
      {
        this->free_factorization_data();
        throw Exceptions::LinearMatrixSolverException(check_status("UMFPACK solution", status));
      }

      this->tick();
    }