Subversion Repositories slepc-dev

Rev

Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2212 Rev 2213
Line 21... Line 21...
   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
*/
 
 
#include "private/ipimpl.h"      /*I "slepcip.h" I*/
#include "private/ipimpl.h"      /*I "slepcip.h" I*/
 
 
PetscCookie IP_COOKIE = 0;
PetscClassId IP_CLASSID = 0;
PetscLogEvent IP_InnerProduct = 0, IP_Orthogonalize = 0, IP_ApplyMatrix = 0;
PetscLogEvent IP_InnerProduct = 0, IP_Orthogonalize = 0, IP_ApplyMatrix = 0;
 
 
#undef __FUNCT__  
#undef __FUNCT__  
#define __FUNCT__ "IPInitializePackage"
#define __FUNCT__ "IPInitializePackage"
/*@C
/*@C
Line 50... Line 50...
 
 
  PetscFunctionBegin;
  PetscFunctionBegin;
  if (initialized) PetscFunctionReturn(0);
  if (initialized) PetscFunctionReturn(0);
  initialized = PETSC_TRUE;
  initialized = PETSC_TRUE;
  /* Register Classes */
  /* Register Classes */
  ierr = PetscCookieRegister("Inner product",&IP_COOKIE);CHKERRQ(ierr);
  ierr = PetscClassIdRegister("Inner product",&IP_CLASSID);CHKERRQ(ierr);
  /* Register Events */
  /* Register Events */
  ierr = PetscLogEventRegister("IPOrthogonalize",IP_COOKIE,&IP_Orthogonalize); CHKERRQ(ierr);
  ierr = PetscLogEventRegister("IPOrthogonalize",IP_CLASSID,&IP_Orthogonalize); CHKERRQ(ierr);
  ierr = PetscLogEventRegister("IPInnerProduct",IP_COOKIE,&IP_InnerProduct); CHKERRQ(ierr);
  ierr = PetscLogEventRegister("IPInnerProduct",IP_CLASSID,&IP_InnerProduct); CHKERRQ(ierr);
  ierr = PetscLogEventRegister("IPApplyMatrix",IP_COOKIE,&IP_ApplyMatrix); CHKERRQ(ierr);
  ierr = PetscLogEventRegister("IPApplyMatrix",IP_CLASSID,&IP_ApplyMatrix); CHKERRQ(ierr);
  /* Process info exclusions */
  /* Process info exclusions */
  ierr = PetscOptionsGetString(PETSC_NULL, "-log_info_exclude", logList, 256, &opt);CHKERRQ(ierr);
  ierr = PetscOptionsGetString(PETSC_NULL, "-info_exclude", logList, 256, &opt);CHKERRQ(ierr);
  if (opt) {
  if (opt) {
    ierr = PetscStrstr(logList, "ip", &className);CHKERRQ(ierr);
    ierr = PetscStrstr(logList, "ip", &className);CHKERRQ(ierr);
    if (className) {
    if (className) {
      ierr = PetscInfoDeactivateClass(IP_COOKIE);CHKERRQ(ierr);
      ierr = PetscInfoDeactivateClass(IP_CLASSID);CHKERRQ(ierr);
    }
    }
  }
  }
  /* Process summary exclusions */
  /* Process summary exclusions */
  ierr = PetscOptionsGetString(PETSC_NULL, "-log_summary_exclude", logList, 256, &opt);CHKERRQ(ierr);
  ierr = PetscOptionsGetString(PETSC_NULL, "-log_summary_exclude", logList, 256, &opt);CHKERRQ(ierr);
  if (opt) {
  if (opt) {
    ierr = PetscStrstr(logList, "ip", &className);CHKERRQ(ierr);
    ierr = PetscStrstr(logList, "ip", &className);CHKERRQ(ierr);
    if (className) {
    if (className) {
      ierr = PetscLogEventDeactivateClass(IP_COOKIE);CHKERRQ(ierr);
      ierr = PetscLogEventDeactivateClass(IP_CLASSID);CHKERRQ(ierr);
    }
    }
  }
  }
  PetscFunctionReturn(0);
  PetscFunctionReturn(0);
}
}
 
 
Line 102... Line 102...
  PetscErrorCode ierr;
  PetscErrorCode ierr;
  IP ip;
  IP ip;
 
 
  PetscFunctionBegin;
  PetscFunctionBegin;
  PetscValidPointer(newip,2);
  PetscValidPointer(newip,2);
  ierr = PetscHeaderCreate(ip,_p_IP,int,IP_COOKIE,-1,"IP",comm,IPDestroy,IPView);CHKERRQ(ierr);
  ierr = PetscHeaderCreate(ip,_p_IP,int,IP_CLASSID,-1,"IP",comm,IPDestroy,IPView);CHKERRQ(ierr);
  *newip            = ip;
  *newip            = ip;
  ip->orthog_type   = IP_ORTH_CGS;
  ip->orthog_type   = IP_ORTH_CGS;
  ip->orthog_ref    = IP_ORTH_REFINE_IFNEEDED;
  ip->orthog_ref    = IP_ORTH_REFINE_IFNEEDED;
  ip->orthog_eta    = 0.7071;
  ip->orthog_eta    = 0.7071;
  ip->bilinear_form = IP_INNER_HERMITIAN;
  ip->bilinear_form = IP_INNER_HERMITIAN;
Line 143... Line 143...
@*/
@*/
PetscErrorCode IPSetOptionsPrefix(IP ip,const char *prefix)
PetscErrorCode IPSetOptionsPrefix(IP ip,const char *prefix)
{
{
  PetscErrorCode ierr;
  PetscErrorCode ierr;
  PetscFunctionBegin;
  PetscFunctionBegin;
  PetscValidHeaderSpecific(ip,IP_COOKIE,1);
  PetscValidHeaderSpecific(ip,IP_CLASSID,1);
  ierr = PetscObjectSetOptionsPrefix((PetscObject)ip,prefix);CHKERRQ(ierr);
  ierr = PetscObjectSetOptionsPrefix((PetscObject)ip,prefix);CHKERRQ(ierr);
  PetscFunctionReturn(0);
  PetscFunctionReturn(0);
}
}
 
 
#undef __FUNCT__  
#undef __FUNCT__  
Line 172... Line 172...
@*/
@*/
PetscErrorCode IPAppendOptionsPrefix(IP ip,const char *prefix)
PetscErrorCode IPAppendOptionsPrefix(IP ip,const char *prefix)
{
{
  PetscErrorCode ierr;
  PetscErrorCode ierr;
  PetscFunctionBegin;
  PetscFunctionBegin;
  PetscValidHeaderSpecific(ip,IP_COOKIE,1);
  PetscValidHeaderSpecific(ip,IP_CLASSID,1);
  ierr = PetscObjectAppendOptionsPrefix((PetscObject)ip,prefix);CHKERRQ(ierr);
  ierr = PetscObjectAppendOptionsPrefix((PetscObject)ip,prefix);CHKERRQ(ierr);
  PetscFunctionReturn(0);
  PetscFunctionReturn(0);
}
}
 
 
#undef __FUNCT__
#undef __FUNCT__
Line 202... Line 202...
@*/
@*/
PetscErrorCode IPGetOptionsPrefix(IP ip,const char *prefix[])
PetscErrorCode IPGetOptionsPrefix(IP ip,const char *prefix[])
{
{
 PetscErrorCode ierr;
 PetscErrorCode ierr;
 PetscFunctionBegin;
 PetscFunctionBegin;
 PetscValidHeaderSpecific(ip,IP_COOKIE,1);
 PetscValidHeaderSpecific(ip,IP_CLASSID,1);
 PetscValidPointer(prefix,2);
 PetscValidPointer(prefix,2);
 ierr = PetscObjectGetOptionsPrefix((PetscObject)ip, prefix);CHKERRQ(ierr);
 ierr = PetscObjectGetOptionsPrefix((PetscObject)ip, prefix);CHKERRQ(ierr);
 PetscFunctionReturn(0);
 PetscFunctionReturn(0);
}
}
 
 
Line 235... Line 235...
  const char     *ref_list[3] = { "never" , "ifneeded", "always" };
  const char     *ref_list[3] = { "never" , "ifneeded", "always" };
  PetscReal      r;
  PetscReal      r;
  PetscInt       i,j;
  PetscInt       i,j;
 
 
  PetscFunctionBegin;
  PetscFunctionBegin;
  PetscValidHeaderSpecific(ip,IP_COOKIE,1);
  PetscValidHeaderSpecific(ip,IP_CLASSID,1);
  ierr = PetscOptionsBegin(((PetscObject)ip)->comm,((PetscObject)ip)->prefix,"Inner Product (IP) Options","IP");CHKERRQ(ierr);
  ierr = PetscOptionsBegin(((PetscObject)ip)->comm,((PetscObject)ip)->prefix,"Inner Product (IP) Options","IP");CHKERRQ(ierr);
  i = ip->orthog_type;
  i = ip->orthog_type;
  ierr = PetscOptionsEList("-orthog_type","Orthogonalization method","IPSetOrthogonalization",orth_list,2,orth_list[i],&i,PETSC_NULL);CHKERRQ(ierr);
  ierr = PetscOptionsEList("-orthog_type","Orthogonalization method","IPSetOrthogonalization",orth_list,2,orth_list[i],&i,PETSC_NULL);CHKERRQ(ierr);
  j = ip->orthog_ref;
  j = ip->orthog_ref;
  ierr = PetscOptionsEList("-orthog_refinement","Iterative refinement mode during orthogonalization","IPSetOrthogonalization",ref_list,3,ref_list[j],&j,PETSC_NULL);CHKERRQ(ierr);
  ierr = PetscOptionsEList("-orthog_refinement","Iterative refinement mode during orthogonalization","IPSetOrthogonalization",ref_list,3,ref_list[j],&j,PETSC_NULL);CHKERRQ(ierr);
Line 286... Line 286...
          IPOrthogonalizationRefinementType
          IPOrthogonalizationRefinementType
@*/
@*/
PetscErrorCode IPSetOrthogonalization(IP ip,IPOrthogonalizationType type, IPOrthogonalizationRefinementType refinement, PetscReal eta)
PetscErrorCode IPSetOrthogonalization(IP ip,IPOrthogonalizationType type, IPOrthogonalizationRefinementType refinement, PetscReal eta)
{
{
  PetscFunctionBegin;
  PetscFunctionBegin;
  PetscValidHeaderSpecific(ip,IP_COOKIE,1);
  PetscValidHeaderSpecific(ip,IP_CLASSID,1);
  switch (type) {
  switch (type) {
    case IP_ORTH_CGS:
    case IP_ORTH_CGS:
    case IP_ORTH_MGS:
    case IP_ORTH_MGS:
      ip->orthog_type = type;
      ip->orthog_type = type;
      break;
      break;
Line 337... Line 337...
          IPOrthogonalizationRefinementType
          IPOrthogonalizationRefinementType
@*/
@*/
PetscErrorCode IPGetOrthogonalization(IP ip,IPOrthogonalizationType *type,IPOrthogonalizationRefinementType *refinement, PetscReal *eta)
PetscErrorCode IPGetOrthogonalization(IP ip,IPOrthogonalizationType *type,IPOrthogonalizationRefinementType *refinement, PetscReal *eta)
{
{
  PetscFunctionBegin;
  PetscFunctionBegin;
  PetscValidHeaderSpecific(ip,IP_COOKIE,1);
  PetscValidHeaderSpecific(ip,IP_CLASSID,1);
  if (type) *type = ip->orthog_type;
  if (type) *type = ip->orthog_type;
  if (refinement) *refinement = ip->orthog_ref;
  if (refinement) *refinement = ip->orthog_ref;
  if (eta) *eta = ip->orthog_eta;
  if (eta) *eta = ip->orthog_eta;
  PetscFunctionReturn(0);
  PetscFunctionReturn(0);
}
}
Line 376... Line 376...
{
{
  PetscErrorCode ierr;
  PetscErrorCode ierr;
  PetscTruth     isascii;
  PetscTruth     isascii;
 
 
  PetscFunctionBegin;
  PetscFunctionBegin;
  PetscValidHeaderSpecific(ip,IP_COOKIE,1);
  PetscValidHeaderSpecific(ip,IP_CLASSID,1);
  if (!viewer) viewer = PETSC_VIEWER_STDOUT_(((PetscObject)ip)->comm);
  if (!viewer) viewer = PETSC_VIEWER_STDOUT_(((PetscObject)ip)->comm);
  PetscValidHeaderSpecific(viewer,PETSC_VIEWER_COOKIE,2);
  PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2);
  PetscCheckSameComm(ip,1,viewer,2);
  PetscCheckSameComm(ip,1,viewer,2);
 
 
  ierr = PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_ASCII,&isascii);CHKERRQ(ierr);
  ierr = PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_ASCII,&isascii);CHKERRQ(ierr);
  if (isascii) {
  if (isascii) {
    ierr = PetscViewerASCIIPrintf(viewer,"IP Object:\n");CHKERRQ(ierr);
    ierr = PetscViewerASCIIPrintf(viewer,"IP Object:\n");CHKERRQ(ierr);
Line 432... Line 432...
PetscErrorCode IPDestroy(IP ip)
PetscErrorCode IPDestroy(IP ip)
{
{
  PetscErrorCode ierr;
  PetscErrorCode ierr;
 
 
  PetscFunctionBegin;
  PetscFunctionBegin;
  PetscValidHeaderSpecific(ip,IP_COOKIE,1);
  PetscValidHeaderSpecific(ip,IP_CLASSID,1);
  if (--((PetscObject)ip)->refct > 0) PetscFunctionReturn(0);
  if (--((PetscObject)ip)->refct > 0) PetscFunctionReturn(0);
 
 
  if (ip->matrix) { ierr = MatDestroy(ip->matrix);CHKERRQ(ierr); }
  if (ip->matrix) { ierr = MatDestroy(ip->matrix);CHKERRQ(ierr); }
  if (ip->Bx) { ierr = VecDestroy(ip->Bx);CHKERRQ(ierr); }
  if (ip->Bx) { ierr = VecDestroy(ip->Bx);CHKERRQ(ierr); }
  ierr = PetscHeaderDestroy(ip);CHKERRQ(ierr);
  ierr = PetscHeaderDestroy(ip);CHKERRQ(ierr);
Line 462... Line 462...
.seealso: IPResetOperationCounters()
.seealso: IPResetOperationCounters()
@*/
@*/
PetscErrorCode IPGetOperationCounters(IP ip,PetscInt *dots)
PetscErrorCode IPGetOperationCounters(IP ip,PetscInt *dots)
{
{
  PetscFunctionBegin;
  PetscFunctionBegin;
  PetscValidHeaderSpecific(ip,IP_COOKIE,1);
  PetscValidHeaderSpecific(ip,IP_CLASSID,1);
  PetscValidPointer(dots,2);
  PetscValidPointer(dots,2);
  *dots = ip->innerproducts;
  *dots = ip->innerproducts;
  PetscFunctionReturn(0);
  PetscFunctionReturn(0);
}
}
 
 
Line 486... Line 486...
.seealso: IPGetOperationCounters()
.seealso: IPGetOperationCounters()
@*/
@*/
PetscErrorCode IPResetOperationCounters(IP ip)
PetscErrorCode IPResetOperationCounters(IP ip)
{
{
  PetscFunctionBegin;
  PetscFunctionBegin;
  PetscValidHeaderSpecific(ip,IP_COOKIE,1);
  PetscValidHeaderSpecific(ip,IP_CLASSID,1);
  ip->innerproducts = 0;
  ip->innerproducts = 0;
  PetscFunctionReturn(0);
  PetscFunctionReturn(0);
}
}