| Line 63... |
Line 63... |
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STBackTransform_Sinvert"
|
#define __FUNCT__ "STBackTransform_Sinvert"
|
PetscErrorCode STBackTransform_Sinvert(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)
|
PetscErrorCode STBackTransform_Sinvert(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)
|
{
|
{
|
PetscInt j;
|
PetscInt j;
|
#ifndef PETSC_USE_COMPLEX
|
#ifndef PETSC_USE_COMPLEX
|
PetscScalar t;
|
PetscScalar t;
|
|
#endif
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
PetscValidPointer(eigr,2);
|
PetscValidPointer(eigr,3);
|
PetscValidPointer(eigi,3);
|
#ifndef PETSC_USE_COMPLEX
|
|
PetscValidPointer(eigi,4);
|
for (j=0;j<n;j++) {
|
for (j=0;j<n;j++) {
|
if (eigi[j] == 0) eigr[j] = 1.0 / eigr[j] + st->sigma;
|
if (eigi[j] == 0) eigr[j] = 1.0 / eigr[j] + st->sigma;
|
else {
|
else {
|
t = eigr[j] * eigr[j] + eigi[j] * eigi[j];
|
t = eigr[j] * eigr[j] + eigi[j] * eigi[j];
|
eigr[j] = eigr[j] / t + st->sigma;
|
eigr[j] = eigr[j] / t + st->sigma;
|
eigi[j] = - eigi[j] / t;
|
eigi[j] = - eigi[j] / t;
|
}
|
}
|
}
|
}
|
#else
|
#else
|
PetscFunctionBegin;
|
|
PetscValidPointer(eigr,2);
|
|
for (j=0;j<n;j++) {
|
for (j=0;j<n;j++) {
|
eigr[j] = 1.0 / eigr[j] + st->sigma;
|
eigr[j] = 1.0 / eigr[j] + st->sigma;
|
}
|
}
|
#endif
|
#endif
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
| Line 160... |
Line 161... |
{
|
{
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
MatStructure flg;
|
MatStructure flg;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
|
|
/* Nothing to be done if STSetUp has not been called yet */
|
/* Nothing to be done if STSetUp has not been called yet */
|
if (!st->setupcalled) PetscFunctionReturn(0);
|
if (!st->setupcalled) PetscFunctionReturn(0);
|
|
|
/* Check if the new KSP matrix has the same zero structure */
|
/* Check if the new KSP matrix has the same zero structure */
|
if (st->B && st->str == DIFFERENT_NONZERO_PATTERN && (st->sigma == 0.0 || newshift == 0.0)) {
|
if (st->B && st->str == DIFFERENT_NONZERO_PATTERN && (st->sigma == 0.0 || newshift == 0.0)) {
|
| Line 224... |
Line 224... |
PC pc;
|
PC pc;
|
const PCType pctype;
|
const PCType pctype;
|
const KSPType ksptype;
|
const KSPType ksptype;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
|
|
ierr = KSPGetPC(st->ksp,&pc);CHKERRQ(ierr);
|
ierr = KSPGetPC(st->ksp,&pc);CHKERRQ(ierr);
|
ierr = KSPGetType(st->ksp,&ksptype);CHKERRQ(ierr);
|
ierr = KSPGetType(st->ksp,&ksptype);CHKERRQ(ierr);
|
ierr = PCGetType(pc,&pctype);CHKERRQ(ierr);
|
ierr = PCGetType(pc,&pctype);CHKERRQ(ierr);
|
if (!pctype && !ksptype) {
|
if (!pctype && !ksptype) {
|
if (st->shift_matrix == ST_MATMODE_SHELL) {
|
if (st->shift_matrix == ST_MATMODE_SHELL) {
|
| Line 239... |
Line 238... |
/* use direct solver as default */
|
/* use direct solver as default */
|
ierr = KSPSetType(st->ksp,KSPPREONLY);CHKERRQ(ierr);
|
ierr = KSPSetType(st->ksp,KSPPREONLY);CHKERRQ(ierr);
|
ierr = PCSetType(pc,PCREDUNDANT);CHKERRQ(ierr);
|
ierr = PCSetType(pc,PCREDUNDANT);CHKERRQ(ierr);
|
}
|
}
|
}
|
}
|
|
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
EXTERN_C_BEGIN
|
EXTERN_C_BEGIN
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STCreate_Sinvert"
|
#define __FUNCT__ "STCreate_Sinvert"
|
PetscErrorCode STCreate_Sinvert(ST st)
|
PetscErrorCode STCreate_Sinvert(ST st)
|
{
|
{
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
st->data = 0;
|
st->data = 0;
|
|
|
st->ops->apply = STApply_Sinvert;
|
st->ops->apply = STApply_Sinvert;
|
st->ops->getbilinearform = STGetBilinearForm_Default;
|
st->ops->getbilinearform = STGetBilinearForm_Default;
|
st->ops->applytrans = STApplyTranspose_Sinvert;
|
st->ops->applytrans = STApplyTranspose_Sinvert;
|
st->ops->postsolve = STPostSolve_Sinvert;
|
st->ops->postsolve = STPostSolve_Sinvert;
|
st->ops->backtr = STBackTransform_Sinvert;
|
st->ops->backtr = STBackTransform_Sinvert;
|
st->ops->setup = STSetUp_Sinvert;
|
st->ops->setup = STSetUp_Sinvert;
|
st->ops->setshift = STSetShift_Sinvert;
|
st->ops->setshift = STSetShift_Sinvert;
|
st->ops->view = STView_Default;
|
st->ops->view = STView_Default;
|
st->ops->setfromoptions = STSetFromOptions_Sinvert;
|
st->ops->setfromoptions = STSetFromOptions_Sinvert;
|
|
|
st->checknullspace = STCheckNullSpace_Default;
|
st->checknullspace = STCheckNullSpace_Default;
|
|
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
EXTERN_C_END
|
EXTERN_C_END
|
|
|
|
|