Beispiel #1
0
 double PetscVector<double>::get(unsigned int idx) const
 {
   double y = 0;
   PetscScalar py;
   VecGetValues(vec, 1, (PetscInt*)&idx, &py);
   y = py.real();
   return y;
 }
Beispiel #2
0
 double PetscMatrix<double>::get(unsigned int m, unsigned int n) const
 {
   double v = 0.0;
   PetscScalar pv;
   MatGetValues(matrix, 1, (PetscInt*)&m, 1, (PetscInt*)&n, &pv);
   v = pv.real();
   return v;
 }
void linearSystemPETSc<scalar>::getFromSolution(int row, scalar &val) const
{
#if defined(PETSC_USE_COMPLEX)
  PetscScalar *tmp;
  _try(VecGetArray(_x, &tmp));
  PetscScalar s = tmp[row];
  _try(VecRestoreArray(_x, &tmp));
  val = s.real();
#else
  _try(VecGetValues(_x, 1, &row, &val));
#endif
}
void linearSystemPETSc<scalar>::getFromRightHandSide(int row, scalar &val) const
{
#if defined(PETSC_USE_COMPLEX)
  PetscScalar *tmp;
  _try(VecGetArray(_b, &tmp));
  PetscScalar s = tmp[row];
  _try(VecRestoreArray(_b, &tmp));
  // FIXME specialize this routine
  val = s.real();
#else
  _try(VecGetValues(_b, 1, &row, &val));
#endif
}
Beispiel #5
0
void linearSystemPETSc<fullMatrix<double> >::getFromSolution(int row, fullMatrix<double> &val) const
{
  int blockSize;
  _try(MatGetBlockSize(_a, &blockSize));
  for (int i = 0; i < blockSize; i++) {
    int ii = row*blockSize +i;
    #ifdef PETSC_USE_COMPLEX
    PetscScalar s;
    VecGetValues ( _x, 1, &ii, &s);
    val(i,0) = s.real();
    #else
    VecGetValues ( _x, 1, &ii, &val(i,0));
    #endif
  }
}