Subversion Repositories slepc-dev

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed


#include "davidsones.h"


EXTERN_C_BEGIN
#undef __FUNCT__  
#define __FUNCT__ "dvd_schm_basic_preconf"
PetscErrorCode dvd_schm_basic_preconf(dvdDashboard *d, dvdBlackboard *b,
  PetscInt max_size_V, PetscInt min_size_V, PetscInt bs, PetscInt size_initV,
  PetscInt plusk)
{
  PetscErrorCode ierr;
  PetscFunctionBegin;

  ierr = PetscMemzero(b, sizeof(dvdBlackboard)); CHKERRQ(ierr);
  b->state = DVD_STATE_PRECONF;

  /* Setup basic management of V */
  dvd_managementV_basic(d, b, bs, max_size_V, min_size_V, plusk);

  /* Setup random subspace for V */
  dvd_initV_classic(d, b, size_initV);

  /* Keep V orthonormalized */
  dvd_orthV(d, b, 0);

  /* Setup basic testing convergence routines */
  dvd_testconv_basic(d, b);

  /* Setup Raileigh-Ritz for selecting the best eigenpairs in V */
  dvd_calcpairs_rr(d, b);

  /* Setup GD method for improving the eigenvectors */
  //dvd_improvex_gdbasic(d, b, PETSC_NULL, PETSC_NULL);
  dvd_improvex_gdolsen(d, b, PETSC_NULL, PETSC_NULL);

  PetscFunctionReturn(0);
}
EXTERN_C_END

EXTERN_C_BEGIN
#undef __FUNCT__  
#define __FUNCT__ "dvd_schm_basic_conf"
PetscErrorCode dvd_schm_basic_conf(dvdDashboard *d, dvdBlackboard *b,
  PetscInt max_size_V, PetscInt min_size_V, PetscInt bs, PetscInt size_initV,
  PetscInt plusk, PC pc, Vec diagA, IP ip)
{
  PetscErrorCode  ierr;
  PetscInt        check_sum0, check_sum1;
  dvdPrecond      pf;
  dvdPrecondData  pd;
  Vec             *fv;
  PetscScalar     *fs;

  PetscFunctionBegin;

  b->state = DVD_STATE_CONF;
  check_sum0 = b->max_size_V + b->max_size_auxV + b->max_size_auxS +
               b->own_vecs + b->own_scalars + b->max_size_oldX;
  b->own_vecs = 0; b->own_scalars = 0;
  fv = b->free_vecs; fs = b->free_scalars;

  /* Setup basic management of V */
  dvd_managementV_basic(d, b, bs, max_size_V, min_size_V, plusk);

  /* Setup random subspace for V */
  dvd_initV_classic(d, b, size_initV);

  /* Keep V orthonormalized */
  dvd_orthV(d, b, ip);

  /* Setup basic testing convergence routines */
  dvd_testconv_basic(d, b);

  /* Setup Raileigh-Ritz for selecting the best eigenpairs in V */
  dvd_calcpairs_rr(d, b);

  /* Setup GD method for improving the eigenvectors */
  if(pc) {
    ierr = dvd_static_precond_PC(d, pc, &pf, &pd); CHKERRQ(ierr);
  } else if (diagA) {
    ierr =  dvd_jacobi_precond(d, diagA, &pf, &pd); CHKERRQ(ierr);
  }
  //dvd_improvex_gdbasic(d, b, pf, pd);
  dvd_improvex_gdolsen(d, b, pf, pd);

  check_sum1 = b->max_size_V + b->max_size_auxV + b->max_size_auxS +
               b->own_vecs + b->own_scalars + b->max_size_oldX;
  if ((check_sum0 != check_sum1) ||
      (fv + b->own_vecs != b->free_vecs) ||
      (fs + b->own_scalars < b->free_scalars))
    SETERRQ(1, "Something awful happened!");
   
  PetscFunctionReturn(0);
}
EXTERN_C_END