/*
|
/*
|
This provides a simple shell interface for programmers to
|
This provides a simple shell interface for programmers to
|
create their own spectral transformations without writing much
|
create their own spectral transformations without writing much
|
interface code.
|
interface code.
|
|
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
SLEPc - Scalable Library for Eigenvalue Problem Computations
|
SLEPc - Scalable Library for Eigenvalue Problem Computations
|
Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain
|
Copyright (c) 2002-2011, Universitat Politecnica de Valencia, Spain
|
|
|
This file is part of SLEPc.
|
This file is part of SLEPc.
|
|
|
SLEPc is free software: you can redistribute it and/or modify it under the
|
SLEPc is free software: you can redistribute it and/or modify it under the
|
terms of version 3 of the GNU Lesser General Public License as published by
|
terms of version 3 of the GNU Lesser General Public License as published by
|
the Free Software Foundation.
|
the Free Software Foundation.
|
|
|
SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY
|
SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
more details.
|
more details.
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
|
along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
*/
|
*/
|
|
|
#include "private/stimpl.h" /*I "slepcst.h" I*/
|
#include "private/stimpl.h" /*I "slepcst.h" I*/
|
|
|
EXTERN_C_BEGIN
|
EXTERN_C_BEGIN
|
typedef struct {
|
typedef struct {
|
void *ctx; /* user provided context */
|
void *ctx; /* user provided context */
|
PetscErrorCode (*apply)(ST,Vec,Vec);
|
PetscErrorCode (*apply)(ST,Vec,Vec);
|
PetscErrorCode (*applytrans)(ST,Vec,Vec);
|
PetscErrorCode (*applytrans)(ST,Vec,Vec);
|
PetscErrorCode (*backtr)(ST,PetscInt n,PetscScalar*,PetscScalar*);
|
PetscErrorCode (*backtr)(ST,PetscInt n,PetscScalar*,PetscScalar*);
|
} ST_Shell;
|
} ST_Shell;
|
EXTERN_C_END
|
EXTERN_C_END
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STShellGetContext"
|
#define __FUNCT__ "STShellGetContext"
|
/*@C
|
/*@C
|
STShellGetContext - Returns the user-provided context associated with a shell ST
|
STShellGetContext - Returns the user-provided context associated with a shell ST
|
|
|
Not Collective
|
Not Collective
|
|
|
Input Parameter:
|
Input Parameter:
|
. st - spectral transformation context
|
. st - spectral transformation context
|
|
|
Output Parameter:
|
Output Parameter:
|
. ctx - the user provided context
|
. ctx - the user provided context
|
|
|
Level: advanced
|
Level: advanced
|
|
|
Notes:
|
Notes:
|
This routine is intended for use within various shell routines
|
This routine is intended for use within various shell routines
|
|
|
.seealso: STShellSetContext()
|
.seealso: STShellSetContext()
|
@*/
|
@*/
|
PetscErrorCode STShellGetContext(ST st,void **ctx)
|
PetscErrorCode STShellGetContext(ST st,void **ctx)
|
{
|
{
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
PetscBool flg;
|
PetscBool flg;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
PetscValidPointer(ctx,2);
|
PetscValidPointer(ctx,2);
|
ierr = PetscTypeCompare((PetscObject)st,STSHELL,&flg);CHKERRQ(ierr);
|
ierr = PetscTypeCompare((PetscObject)st,STSHELL,&flg);CHKERRQ(ierr);
|
if (!flg) *ctx = 0;
|
if (!flg) *ctx = 0;
|
else *ctx = ((ST_Shell*)(st->data))->ctx;
|
else *ctx = ((ST_Shell*)(st->data))->ctx;
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STShellSetContext"
|
#define __FUNCT__ "STShellSetContext"
|
/*@
|
/*@
|
STShellSetContext - sets the context for a shell ST
|
STShellSetContext - Sets the context for a shell ST
|
|
|
Logically Collective on ST
|
Logically Collective on ST
|
|
|
Input Parameters:
|
Input Parameters:
|
+ st - the shell ST
|
+ st - the shell ST
|
- ctx - the context
|
- ctx - the context
|
|
|
Level: advanced
|
Level: advanced
|
|
|
Fortran Notes: The context can only be an integer or a PetscObject;
|
Fortran Notes: The context can only be an integer or a PetscObject;
|
unfortunately it cannot be a Fortran array or derived type.
|
unfortunately it cannot be a Fortran array or derived type.
|
|
|
.seealso: STShellGetContext()
|
.seealso: STShellGetContext()
|
@*/
|
@*/
|
PetscErrorCode STShellSetContext(ST st,void *ctx)
|
PetscErrorCode STShellSetContext(ST st,void *ctx)
|
{
|
{
|
ST_Shell *shell = (ST_Shell*)st->data;
|
ST_Shell *shell = (ST_Shell*)st->data;
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
PetscBool flg;
|
PetscBool flg;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
ierr = PetscTypeCompare((PetscObject)st,STSHELL,&flg);CHKERRQ(ierr);
|
ierr = PetscTypeCompare((PetscObject)st,STSHELL,&flg);CHKERRQ(ierr);
|
if (flg) {
|
if (flg) {
|
shell->ctx = ctx;
|
shell->ctx = ctx;
|
}
|
}
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STApply_Shell"
|
#define __FUNCT__ "STApply_Shell"
|
PetscErrorCode STApply_Shell(ST st,Vec x,Vec y)
|
PetscErrorCode STApply_Shell(ST st,Vec x,Vec y)
|
{
|
{
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
ST_Shell *shell = (ST_Shell*)st->data;
|
ST_Shell *shell = (ST_Shell*)st->data;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
if (!shell->apply) SETERRQ(((PetscObject)st)->comm,PETSC_ERR_USER,"No apply() routine provided to Shell ST");
|
if (!shell->apply) SETERRQ(((PetscObject)st)->comm,PETSC_ERR_USER,"No apply() routine provided to Shell ST");
|
PetscStackPush("STSHELL apply() user function");
|
PetscStackPush("STSHELL apply() user function");
|
CHKMEMQ;
|
CHKMEMQ;
|
ierr = (*shell->apply)(st,x,y);CHKERRQ(ierr);
|
ierr = (*shell->apply)(st,x,y);CHKERRQ(ierr);
|
CHKMEMQ;
|
CHKMEMQ;
|
PetscStackPop;
|
PetscStackPop;
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STApplyTranspose_Shell"
|
#define __FUNCT__ "STApplyTranspose_Shell"
|
PetscErrorCode STApplyTranspose_Shell(ST st,Vec x,Vec y)
|
PetscErrorCode STApplyTranspose_Shell(ST st,Vec x,Vec y)
|
{
|
{
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
ST_Shell *shell = (ST_Shell*)st->data;
|
ST_Shell *shell = (ST_Shell*)st->data;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
if (!shell->applytrans) SETERRQ(((PetscObject)st)->comm,PETSC_ERR_USER,"No applytranspose() routine provided to Shell ST");
|
if (!shell->applytrans) SETERRQ(((PetscObject)st)->comm,PETSC_ERR_USER,"No applytranspose() routine provided to Shell ST");
|
PetscStackPush("STSHELL applytranspose() user function");
|
PetscStackPush("STSHELL applytranspose() user function");
|
CHKMEMQ;
|
CHKMEMQ;
|
ierr = (*shell->applytrans)(st,x,y);CHKERRQ(ierr);
|
ierr = (*shell->applytrans)(st,x,y);CHKERRQ(ierr);
|
CHKMEMQ;
|
CHKMEMQ;
|
PetscStackPop;
|
PetscStackPop;
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STBackTransform_Shell"
|
#define __FUNCT__ "STBackTransform_Shell"
|
PetscErrorCode STBackTransform_Shell(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)
|
PetscErrorCode STBackTransform_Shell(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi)
|
{
|
{
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
ST_Shell *shell = (ST_Shell*)st->data;
|
ST_Shell *shell = (ST_Shell*)st->data;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
if (shell->backtr) {
|
if (shell->backtr) {
|
PetscStackPush("STSHELL backtransform() user function");
|
PetscStackPush("STSHELL backtransform() user function");
|
CHKMEMQ;
|
CHKMEMQ;
|
ierr = (*shell->backtr)(st,n,eigr,eigi);CHKERRQ(ierr);
|
ierr = (*shell->backtr)(st,n,eigr,eigi);CHKERRQ(ierr);
|
CHKMEMQ;
|
CHKMEMQ;
|
PetscStackPop;
|
PetscStackPop;
|
}
|
}
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STDestroy_Shell"
|
#define __FUNCT__ "STDestroy_Shell"
|
PetscErrorCode STDestroy_Shell(ST st)
|
PetscErrorCode STDestroy_Shell(ST st)
|
{
|
{
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
ierr = PetscFree(st->data);CHKERRQ(ierr);
|
ierr = PetscFree(st->data);CHKERRQ(ierr);
|
ierr = PetscObjectComposeFunctionDynamic((PetscObject)st,"STShellSetApply_C","",PETSC_NULL);CHKERRQ(ierr);
|
ierr = PetscObjectComposeFunctionDynamic((PetscObject)st,"STShellSetApply_C","",PETSC_NULL);CHKERRQ(ierr);
|
ierr = PetscObjectComposeFunctionDynamic((PetscObject)st,"STShellSetApplyTranspose_C","",PETSC_NULL);CHKERRQ(ierr);
|
ierr = PetscObjectComposeFunctionDynamic((PetscObject)st,"STShellSetApplyTranspose_C","",PETSC_NULL);CHKERRQ(ierr);
|
ierr = PetscObjectComposeFunctionDynamic((PetscObject)st,"STShellSetBackTransform_C","",PETSC_NULL);CHKERRQ(ierr);
|
ierr = PetscObjectComposeFunctionDynamic((PetscObject)st,"STShellSetBackTransform_C","",PETSC_NULL);CHKERRQ(ierr);
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
EXTERN_C_BEGIN
|
EXTERN_C_BEGIN
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STShellSetApply_Shell"
|
#define __FUNCT__ "STShellSetApply_Shell"
|
PetscErrorCode STShellSetApply_Shell(ST st,PetscErrorCode (*apply)(ST,Vec,Vec))
|
PetscErrorCode STShellSetApply_Shell(ST st,PetscErrorCode (*apply)(ST,Vec,Vec))
|
{
|
{
|
ST_Shell *shell = (ST_Shell*)st->data;
|
ST_Shell *shell = (ST_Shell*)st->data;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
shell->apply = apply;
|
shell->apply = apply;
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
EXTERN_C_END
|
EXTERN_C_END
|
|
|
EXTERN_C_BEGIN
|
EXTERN_C_BEGIN
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STShellSetApplyTranspose_Shell"
|
#define __FUNCT__ "STShellSetApplyTranspose_Shell"
|
PetscErrorCode STShellSetApplyTranspose_Shell(ST st,PetscErrorCode (*applytrans)(ST,Vec,Vec))
|
PetscErrorCode STShellSetApplyTranspose_Shell(ST st,PetscErrorCode (*applytrans)(ST,Vec,Vec))
|
{
|
{
|
ST_Shell *shell = (ST_Shell*)st->data;
|
ST_Shell *shell = (ST_Shell*)st->data;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
shell->applytrans = applytrans;
|
shell->applytrans = applytrans;
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
EXTERN_C_END
|
EXTERN_C_END
|
|
|
EXTERN_C_BEGIN
|
EXTERN_C_BEGIN
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STShellSetBackTransform_Shell"
|
#define __FUNCT__ "STShellSetBackTransform_Shell"
|
PetscErrorCode STShellSetBackTransform_Shell(ST st,PetscErrorCode (*backtr)(ST,PetscInt,PetscScalar*,PetscScalar*))
|
PetscErrorCode STShellSetBackTransform_Shell(ST st,PetscErrorCode (*backtr)(ST,PetscInt,PetscScalar*,PetscScalar*))
|
{
|
{
|
ST_Shell *shell = (ST_Shell*)st->data;
|
ST_Shell *shell = (ST_Shell*)st->data;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
shell->backtr = backtr;
|
shell->backtr = backtr;
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
EXTERN_C_END
|
EXTERN_C_END
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STShellSetApply"
|
#define __FUNCT__ "STShellSetApply"
|
/*@C
|
/*@C
|
STShellSetApply - Sets routine to use as the application of the
|
STShellSetApply - Sets routine to use as the application of the
|
operator to a vector in the user-defined spectral transformation.
|
operator to a vector in the user-defined spectral transformation.
|
|
|
Logically Collective on ST
|
Logically Collective on ST
|
|
|
Input Parameters:
|
Input Parameters:
|
+ st - the spectral transformation context
|
+ st - the spectral transformation context
|
- apply - the application-provided transformation routine
|
- apply - the application-provided transformation routine
|
|
|
Calling sequence of apply:
|
Calling sequence of apply:
|
.vb
|
.vb
|
PetscErrorCode apply (ST st,Vec xin,Vec xout)
|
PetscErrorCode apply (ST st,Vec xin,Vec xout)
|
.ve
|
.ve
|
|
|
+ st - the spectral transformation context
|
+ st - the spectral transformation context
|
. xin - input vector
|
. xin - input vector
|
- xout - output vector
|
- xout - output vector
|
|
|
Level: developer
|
Level: developer
|
|
|
.seealso: STShellSetBackTransform(), STShellSetApplyTranspose()
|
.seealso: STShellSetBackTransform(), STShellSetApplyTranspose()
|
@*/
|
@*/
|
PetscErrorCode STShellSetApply(ST st,PetscErrorCode (*apply)(ST,Vec,Vec))
|
PetscErrorCode STShellSetApply(ST st,PetscErrorCode (*apply)(ST,Vec,Vec))
|
{
|
{
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
ierr = PetscTryMethod(st,"STShellSetApply_C",(ST,PetscErrorCode (*)(ST,Vec,Vec)),(st,apply));CHKERRQ(ierr);
|
ierr = PetscTryMethod(st,"STShellSetApply_C",(ST,PetscErrorCode (*)(ST,Vec,Vec)),(st,apply));CHKERRQ(ierr);
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STShellSetApplyTranspose"
|
#define __FUNCT__ "STShellSetApplyTranspose"
|
/*@C
|
/*@C
|
STShellSetApplyTranspose - Sets routine to use as the application of the
|
STShellSetApplyTranspose - Sets routine to use as the application of the
|
transposed operator to a vector in the user-defined spectral transformation.
|
transposed operator to a vector in the user-defined spectral transformation.
|
|
|
Logically Collective on ST
|
Logically Collective on ST
|
|
|
Input Parameters:
|
Input Parameters:
|
+ st - the spectral transformation context
|
+ st - the spectral transformation context
|
- applytrans - the application-provided transformation routine
|
- applytrans - the application-provided transformation routine
|
|
|
Calling sequence of apply:
|
Calling sequence of apply:
|
.vb
|
.vb
|
PetscErrorCode applytrans (ST st,Vec xin,Vec xout)
|
PetscErrorCode applytrans (ST st,Vec xin,Vec xout)
|
.ve
|
.ve
|
|
|
+ st - the spectral transformation context
|
+ st - the spectral transformation context
|
. xin - input vector
|
. xin - input vector
|
- xout - output vector
|
- xout - output vector
|
|
|
Level: developer
|
Level: developer
|
|
|
.seealso: STShellSetApply(), STShellSetBackTransform()
|
.seealso: STShellSetApply(), STShellSetBackTransform()
|
@*/
|
@*/
|
PetscErrorCode STShellSetApplyTranspose(ST st,PetscErrorCode (*applytrans)(ST,Vec,Vec))
|
PetscErrorCode STShellSetApplyTranspose(ST st,PetscErrorCode (*applytrans)(ST,Vec,Vec))
|
{
|
{
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
ierr = PetscTryMethod(st,"STShellSetApplyTranspose_C",(ST,PetscErrorCode (*)(ST,Vec,Vec)),(st,applytrans));CHKERRQ(ierr);
|
ierr = PetscTryMethod(st,"STShellSetApplyTranspose_C",(ST,PetscErrorCode (*)(ST,Vec,Vec)),(st,applytrans));CHKERRQ(ierr);
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STShellSetBackTransform"
|
#define __FUNCT__ "STShellSetBackTransform"
|
/*@C
|
/*@C
|
STShellSetBackTransform - Sets the routine to be called after the
|
STShellSetBackTransform - Sets the routine to be called after the
|
eigensolution process has finished in order to transform back the
|
eigensolution process has finished in order to transform back the
|
computed eigenvalues.
|
computed eigenvalues.
|
|
|
Logically Collective on ST
|
Logically Collective on ST
|
|
|
Input Parameters:
|
Input Parameters:
|
+ st - the spectral transformation context
|
+ st - the spectral transformation context
|
- backtr - the application-provided backtransform routine
|
- backtr - the application-provided backtransform routine
|
|
|
Calling sequence of backtr:
|
Calling sequence of backtr:
|
.vb
|
.vb
|
PetscErrorCode backtr (ST st,PetscScalar *eigr,PetscScalar *eigi)
|
PetscErrorCode backtr (ST st,PetscScalar *eigr,PetscScalar *eigi)
|
.ve
|
.ve
|
|
|
+ st - the spectral transformation context
|
+ st - the spectral transformation context
|
. eigr - pointer ot the real part of the eigenvalue to transform back
|
. eigr - pointer ot the real part of the eigenvalue to transform back
|
- eigi - pointer ot the imaginary part
|
- eigi - pointer ot the imaginary part
|
|
|
Level: developer
|
Level: developer
|
|
|
.seealso: STShellSetApply(), STShellSetApplyTranspose()
|
.seealso: STShellSetApply(), STShellSetApplyTranspose()
|
@*/
|
@*/
|
PetscErrorCode STShellSetBackTransform(ST st,PetscErrorCode (*backtr)(ST,PetscInt,PetscScalar*,PetscScalar*))
|
PetscErrorCode STShellSetBackTransform(ST st,PetscErrorCode (*backtr)(ST,PetscInt,PetscScalar*,PetscScalar*))
|
{
|
{
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
ierr = PetscTryMethod(st,"STShellSetBackTransform_C",(ST,PetscErrorCode (*)(ST,PetscInt,PetscScalar*,PetscScalar*)),(st,backtr));CHKERRQ(ierr);
|
ierr = PetscTryMethod(st,"STShellSetBackTransform_C",(ST,PetscErrorCode (*)(ST,PetscInt,PetscScalar*,PetscScalar*)),(st,backtr));CHKERRQ(ierr);
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STSetFromOptions_Shell"
|
#define __FUNCT__ "STSetFromOptions_Shell"
|
PetscErrorCode STSetFromOptions_Shell(ST st)
|
PetscErrorCode STSetFromOptions_Shell(ST st)
|
{
|
{
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
PC pc;
|
PC pc;
|
const PCType pctype;
|
const PCType pctype;
|
const KSPType ksptype;
|
const KSPType ksptype;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
if (!st->ksp) { ierr = STGetKSP(st,&st->ksp);CHKERRQ(ierr); }
|
if (!st->ksp) { ierr = STGetKSP(st,&st->ksp);CHKERRQ(ierr); }
|
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) {
|
/* in shell mode use GMRES with Jacobi as the default */
|
/* in shell mode use GMRES with Jacobi as the default */
|
ierr = KSPSetType(st->ksp,KSPGMRES);CHKERRQ(ierr);
|
ierr = KSPSetType(st->ksp,KSPGMRES);CHKERRQ(ierr);
|
ierr = PCSetType(pc,PCJACOBI);CHKERRQ(ierr);
|
ierr = PCSetType(pc,PCJACOBI);CHKERRQ(ierr);
|
} else {
|
} else {
|
/* 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);
|
}
|
}
|
|
|
/*MC
|
/*MC
|
STSHELL - Creates a new spectral transformation class.
|
STSHELL - Creates a new spectral transformation class.
|
This is intended to provide a simple class to use with EPS.
|
This is intended to provide a simple class to use with EPS.
|
You should not use this if you plan to make a complete class.
|
You should not use this if you plan to make a complete class.
|
|
|
Level: advanced
|
Level: advanced
|
|
|
Usage:
|
Usage:
|
$ PetscErrorCode (*apply)(void*,Vec,Vec);
|
$ PetscErrorCode (*apply)(void*,Vec,Vec);
|
$ PetscErrorCode (*applytrans)(void*,Vec,Vec);
|
$ PetscErrorCode (*applytrans)(void*,Vec,Vec);
|
$ PetscErrorCode (*backtr)(void*,PetscScalar*,PetscScalar*);
|
$ PetscErrorCode (*backtr)(void*,PetscScalar*,PetscScalar*);
|
$ STCreate(comm,&st);
|
$ STCreate(comm,&st);
|
$ STSetType(st,STSHELL);
|
$ STSetType(st,STSHELL);
|
$ STShellSetApply(st,apply);
|
$ STShellSetApply(st,apply);
|
$ STShellSetApplyTranspose(st,applytrans);
|
$ STShellSetApplyTranspose(st,applytrans);
|
$ STShellSetBackTransform(st,backtr); (optional)
|
$ STShellSetBackTransform(st,backtr); (optional)
|
|
|
M*/
|
M*/
|
|
|
EXTERN_C_BEGIN
|
EXTERN_C_BEGIN
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STCreate_Shell"
|
#define __FUNCT__ "STCreate_Shell"
|
PetscErrorCode STCreate_Shell(ST st)
|
PetscErrorCode STCreate_Shell(ST st)
|
{
|
{
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
ierr = PetscNewLog(st,ST_Shell,&st->data);CHKERRQ(ierr);
|
ierr = PetscNewLog(st,ST_Shell,&st->data);CHKERRQ(ierr);
|
st->ops->apply = STApply_Shell;
|
st->ops->apply = STApply_Shell;
|
st->ops->applytrans = STApplyTranspose_Shell;
|
st->ops->applytrans = STApplyTranspose_Shell;
|
st->ops->backtr = STBackTransform_Shell;
|
st->ops->backtr = STBackTransform_Shell;
|
st->ops->setfromoptions = STSetFromOptions_Shell;
|
st->ops->setfromoptions = STSetFromOptions_Shell;
|
st->ops->destroy = STDestroy_Shell;
|
st->ops->destroy = STDestroy_Shell;
|
ierr = PetscObjectComposeFunctionDynamic((PetscObject)st,"STShellSetApply_C","STShellSetApply_Shell",STShellSetApply_Shell);CHKERRQ(ierr);
|
ierr = PetscObjectComposeFunctionDynamic((PetscObject)st,"STShellSetApply_C","STShellSetApply_Shell",STShellSetApply_Shell);CHKERRQ(ierr);
|
ierr = PetscObjectComposeFunctionDynamic((PetscObject)st,"STShellSetApplyTranspose_C","STShellSetApplyTranspose_Shell",STShellSetApplyTranspose_Shell);CHKERRQ(ierr);
|
ierr = PetscObjectComposeFunctionDynamic((PetscObject)st,"STShellSetApplyTranspose_C","STShellSetApplyTranspose_Shell",STShellSetApplyTranspose_Shell);CHKERRQ(ierr);
|
ierr = PetscObjectComposeFunctionDynamic((PetscObject)st,"STShellSetBackTransform_C","STShellSetBackTransform_Shell",STShellSetBackTransform_Shell);CHKERRQ(ierr);
|
ierr = PetscObjectComposeFunctionDynamic((PetscObject)st,"STShellSetBackTransform_C","STShellSetBackTransform_Shell",STShellSetBackTransform_Shell);CHKERRQ(ierr);
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
EXTERN_C_END
|
EXTERN_C_END
|
|
|
|
|
|
|