/*
|
/*
|
The ST (spectral transformation) interface routines, callable by users.
|
The ST (spectral transformation) interface routines, callable by users.
|
|
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
SLEPc - Scalable Library for Eigenvalue Problem Computations
|
SLEPc - Scalable Library for Eigenvalue Problem Computations
|
Copyright (c) 2002-2010, Universidad Politecnica de Valencia, Spain
|
Copyright (c) 2002-2010, Universidad 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*/
|
|
|
PetscCookie ST_COOKIE = 0;
|
PetscClassId ST_CLASSID = 0;
|
PetscLogEvent ST_SetUp = 0, ST_Apply = 0, ST_ApplyTranspose = 0;
|
PetscLogEvent ST_SetUp = 0, ST_Apply = 0, ST_ApplyTranspose = 0;
|
static PetscTruth STPackageInitialized = PETSC_FALSE;
|
static PetscTruth STPackageInitialized = PETSC_FALSE;
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STFinalizePackage"
|
#define __FUNCT__ "STFinalizePackage"
|
/*@C
|
/*@C
|
STFinalizePackage - This function destroys everything in the Slepc interface to the ST package. It is
|
STFinalizePackage - This function destroys everything in the Slepc interface to the ST package. It is
|
called from SlepcFinalize().
|
called from SlepcFinalize().
|
|
|
Level: developer
|
Level: developer
|
|
|
.seealso: SlepcFinalize()
|
.seealso: SlepcFinalize()
|
@*/
|
@*/
|
PetscErrorCode STFinalizePackage(void)
|
PetscErrorCode STFinalizePackage(void)
|
{
|
{
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
STPackageInitialized = PETSC_FALSE;
|
STPackageInitialized = PETSC_FALSE;
|
STList = 0;
|
STList = 0;
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STInitializePackage"
|
#define __FUNCT__ "STInitializePackage"
|
/*@C
|
/*@C
|
STInitializePackage - This function initializes everything in the ST package. It is called
|
STInitializePackage - This function initializes everything in the ST package. It is called
|
from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to STCreate()
|
from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to STCreate()
|
when using static libraries.
|
when using static libraries.
|
|
|
Input Parameter:
|
Input Parameter:
|
path - The dynamic library path, or PETSC_NULL
|
path - The dynamic library path, or PETSC_NULL
|
|
|
Level: developer
|
Level: developer
|
|
|
.seealso: SlepcInitialize()
|
.seealso: SlepcInitialize()
|
@*/
|
@*/
|
PetscErrorCode STInitializePackage(const char *path) {
|
PetscErrorCode STInitializePackage(const char *path) {
|
char logList[256];
|
char logList[256];
|
char *className;
|
char *className;
|
PetscTruth opt;
|
PetscTruth opt;
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
if (STPackageInitialized) PetscFunctionReturn(0);
|
if (STPackageInitialized) PetscFunctionReturn(0);
|
STPackageInitialized = PETSC_TRUE;
|
STPackageInitialized = PETSC_TRUE;
|
/* Register Classes */
|
/* Register Classes */
|
ierr = PetscCookieRegister("Spectral Transform",&ST_COOKIE);CHKERRQ(ierr);
|
ierr = PetscClassIdRegister("Spectral Transform",&ST_CLASSID);CHKERRQ(ierr);
|
/* Register Constructors */
|
/* Register Constructors */
|
ierr = STRegisterAll(path);CHKERRQ(ierr);
|
ierr = STRegisterAll(path);CHKERRQ(ierr);
|
/* Register Events */
|
/* Register Events */
|
ierr = PetscLogEventRegister("STSetUp",ST_COOKIE,&ST_SetUp);CHKERRQ(ierr);
|
ierr = PetscLogEventRegister("STSetUp",ST_CLASSID,&ST_SetUp);CHKERRQ(ierr);
|
ierr = PetscLogEventRegister("STApply",ST_COOKIE,&ST_Apply);CHKERRQ(ierr);
|
ierr = PetscLogEventRegister("STApply",ST_CLASSID,&ST_Apply);CHKERRQ(ierr);
|
ierr = PetscLogEventRegister("STApplyTranspose",ST_COOKIE,&ST_ApplyTranspose); CHKERRQ(ierr);
|
ierr = PetscLogEventRegister("STApplyTranspose",ST_CLASSID,&ST_ApplyTranspose); 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, "st", &className);CHKERRQ(ierr);
|
ierr = PetscStrstr(logList, "st", &className);CHKERRQ(ierr);
|
if (className) {
|
if (className) {
|
ierr = PetscInfoDeactivateClass(ST_COOKIE);CHKERRQ(ierr);
|
ierr = PetscInfoDeactivateClass(ST_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, "st", &className);CHKERRQ(ierr);
|
ierr = PetscStrstr(logList, "st", &className);CHKERRQ(ierr);
|
if (className) {
|
if (className) {
|
ierr = PetscLogEventDeactivateClass(ST_COOKIE);CHKERRQ(ierr);
|
ierr = PetscLogEventDeactivateClass(ST_CLASSID);CHKERRQ(ierr);
|
}
|
}
|
}
|
}
|
ierr = PetscRegisterFinalize(STFinalizePackage);CHKERRQ(ierr);
|
ierr = PetscRegisterFinalize(STFinalizePackage);CHKERRQ(ierr);
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STDestroy"
|
#define __FUNCT__ "STDestroy"
|
/*@
|
/*@
|
STDestroy - Destroys ST context that was created with STCreate().
|
STDestroy - Destroys ST context that was created with STCreate().
|
|
|
Collective on ST
|
Collective on ST
|
|
|
Input Parameter:
|
Input Parameter:
|
. st - the spectral transformation context
|
. st - the spectral transformation context
|
|
|
Level: beginner
|
Level: beginner
|
|
|
.seealso: STCreate(), STSetUp()
|
.seealso: STCreate(), STSetUp()
|
@*/
|
@*/
|
PetscErrorCode STDestroy(ST st)
|
PetscErrorCode STDestroy(ST st)
|
{
|
{
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
PetscValidHeaderSpecific(st,ST_COOKIE,1);
|
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
if (--((PetscObject)st)->refct > 0) PetscFunctionReturn(0);
|
if (--((PetscObject)st)->refct > 0) PetscFunctionReturn(0);
|
|
|
/* if memory was published with AMS then destroy it */
|
/* if memory was published with AMS then destroy it */
|
ierr = PetscObjectDepublish(st);CHKERRQ(ierr);
|
ierr = PetscObjectDepublish(st);CHKERRQ(ierr);
|
|
|
if (st->ops->destroy) { ierr = (*st->ops->destroy)(st);CHKERRQ(ierr); }
|
if (st->ops->destroy) { ierr = (*st->ops->destroy)(st);CHKERRQ(ierr); }
|
if (st->A) { ierr = MatDestroy(st->A);CHKERRQ(ierr); }
|
if (st->A) { ierr = MatDestroy(st->A);CHKERRQ(ierr); }
|
if (st->B) { ierr = MatDestroy(st->B);CHKERRQ(ierr); }
|
if (st->B) { ierr = MatDestroy(st->B);CHKERRQ(ierr); }
|
if (st->ksp) { ierr = KSPDestroy(st->ksp);CHKERRQ(ierr); }
|
if (st->ksp) { ierr = KSPDestroy(st->ksp);CHKERRQ(ierr); }
|
if (st->w) { ierr = VecDestroy(st->w);CHKERRQ(ierr); }
|
if (st->w) { ierr = VecDestroy(st->w);CHKERRQ(ierr); }
|
if (st->D) { ierr = VecDestroy(st->D);CHKERRQ(ierr); }
|
if (st->D) { ierr = VecDestroy(st->D);CHKERRQ(ierr); }
|
if (st->wb){ ierr = VecDestroy(st->wb);CHKERRQ(ierr); }
|
if (st->wb){ ierr = VecDestroy(st->wb);CHKERRQ(ierr); }
|
if (st->shift_matrix != ST_MATMODE_INPLACE && st->mat) {
|
if (st->shift_matrix != ST_MATMODE_INPLACE && st->mat) {
|
ierr = MatDestroy(st->mat);CHKERRQ(ierr);
|
ierr = MatDestroy(st->mat);CHKERRQ(ierr);
|
}
|
}
|
|
|
ierr = PetscHeaderDestroy(st);CHKERRQ(ierr);
|
ierr = PetscHeaderDestroy(st);CHKERRQ(ierr);
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STCreate"
|
#define __FUNCT__ "STCreate"
|
/*@C
|
/*@C
|
STCreate - Creates a spectral transformation context.
|
STCreate - Creates a spectral transformation context.
|
|
|
Collective on MPI_Comm
|
Collective on MPI_Comm
|
|
|
Input Parameter:
|
Input Parameter:
|
. comm - MPI communicator
|
. comm - MPI communicator
|
|
|
Output Parameter:
|
Output Parameter:
|
. st - location to put the spectral transformation context
|
. st - location to put the spectral transformation context
|
|
|
Level: beginner
|
Level: beginner
|
|
|
.seealso: STSetUp(), STApply(), STDestroy(), ST
|
.seealso: STSetUp(), STApply(), STDestroy(), ST
|
@*/
|
@*/
|
PetscErrorCode STCreate(MPI_Comm comm,ST *newst)
|
PetscErrorCode STCreate(MPI_Comm comm,ST *newst)
|
{
|
{
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
ST st;
|
ST st;
|
const char *prefix;
|
const char *prefix;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
PetscValidPointer(newst,2);
|
PetscValidPointer(newst,2);
|
*newst = 0;
|
*newst = 0;
|
|
|
ierr = PetscHeaderCreate(st,_p_ST,struct _STOps,ST_COOKIE,-1,"ST",comm,STDestroy,STView);CHKERRQ(ierr);
|
ierr = PetscHeaderCreate(st,_p_ST,struct _STOps,ST_CLASSID,-1,"ST",comm,STDestroy,STView);CHKERRQ(ierr);
|
ierr = PetscMemzero(st->ops,sizeof(struct _STOps));CHKERRQ(ierr);
|
ierr = PetscMemzero(st->ops,sizeof(struct _STOps));CHKERRQ(ierr);
|
|
|
st->A = 0;
|
st->A = 0;
|
st->B = 0;
|
st->B = 0;
|
st->sigma = 0.0;
|
st->sigma = 0.0;
|
st->sigma_set = PETSC_FALSE;
|
st->sigma_set = PETSC_FALSE;
|
st->defsigma = 0.0;
|
st->defsigma = 0.0;
|
st->data = 0;
|
st->data = 0;
|
st->setupcalled = 0;
|
st->setupcalled = 0;
|
st->w = 0;
|
st->w = 0;
|
st->D = 0;
|
st->D = 0;
|
st->wb = 0;
|
st->wb = 0;
|
st->shift_matrix = ST_MATMODE_COPY;
|
st->shift_matrix = ST_MATMODE_COPY;
|
st->str = DIFFERENT_NONZERO_PATTERN;
|
st->str = DIFFERENT_NONZERO_PATTERN;
|
|
|
ierr = KSPCreate(((PetscObject)st)->comm,&st->ksp);CHKERRQ(ierr);
|
ierr = KSPCreate(((PetscObject)st)->comm,&st->ksp);CHKERRQ(ierr);
|
ierr = STGetOptionsPrefix(st,&prefix);CHKERRQ(ierr);
|
ierr = STGetOptionsPrefix(st,&prefix);CHKERRQ(ierr);
|
ierr = KSPSetOptionsPrefix(st->ksp,prefix);CHKERRQ(ierr);
|
ierr = KSPSetOptionsPrefix(st->ksp,prefix);CHKERRQ(ierr);
|
ierr = KSPAppendOptionsPrefix(st->ksp,"st_");CHKERRQ(ierr);
|
ierr = KSPAppendOptionsPrefix(st->ksp,"st_");CHKERRQ(ierr);
|
ierr = PetscObjectIncrementTabLevel((PetscObject)st->ksp,(PetscObject)st,1);CHKERRQ(ierr);
|
ierr = PetscObjectIncrementTabLevel((PetscObject)st->ksp,(PetscObject)st,1);CHKERRQ(ierr);
|
|
|
*newst = st;
|
*newst = st;
|
ierr = PetscPublishAll(st);CHKERRQ(ierr);
|
ierr = PetscPublishAll(st);CHKERRQ(ierr);
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
|
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STSetOperators"
|
#define __FUNCT__ "STSetOperators"
|
/*@
|
/*@
|
STSetOperators - Sets the matrices associated with the eigenvalue problem.
|
STSetOperators - Sets the matrices associated with the eigenvalue problem.
|
|
|
Collective on ST and Mat
|
Collective on ST and Mat
|
|
|
Input Parameters:
|
Input Parameters:
|
+ st - the spectral transformation context
|
+ st - the spectral transformation context
|
. A - the matrix associated with the eigensystem
|
. A - the matrix associated with the eigensystem
|
- B - the second matrix in the case of generalized eigenproblems
|
- B - the second matrix in the case of generalized eigenproblems
|
|
|
Notes:
|
Notes:
|
To specify a standard eigenproblem, use PETSC_NULL for B.
|
To specify a standard eigenproblem, use PETSC_NULL for B.
|
|
|
Level: intermediate
|
Level: intermediate
|
|
|
.seealso: STGetOperators()
|
.seealso: STGetOperators()
|
@*/
|
@*/
|
PetscErrorCode STSetOperators(ST st,Mat A,Mat B)
|
PetscErrorCode STSetOperators(ST st,Mat A,Mat B)
|
{
|
{
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
PetscValidHeaderSpecific(st,ST_COOKIE,1);
|
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
PetscValidHeaderSpecific(A,MAT_COOKIE,2);
|
PetscValidHeaderSpecific(A,MAT_CLASSID,2);
|
if (B) PetscValidHeaderSpecific(B,MAT_COOKIE,3);
|
if (B) PetscValidHeaderSpecific(B,MAT_CLASSID,3);
|
PetscCheckSameComm(st,1,A,2);
|
PetscCheckSameComm(st,1,A,2);
|
if (B) PetscCheckSameComm(st,1,B,3);
|
if (B) PetscCheckSameComm(st,1,B,3);
|
ierr = PetscObjectReference((PetscObject)A);CHKERRQ(ierr);
|
ierr = PetscObjectReference((PetscObject)A);CHKERRQ(ierr);
|
if (st->A) { ierr = MatDestroy(st->A);CHKERRQ(ierr); }
|
if (st->A) { ierr = MatDestroy(st->A);CHKERRQ(ierr); }
|
st->A = A;
|
st->A = A;
|
if (B) { ierr = PetscObjectReference((PetscObject)B);CHKERRQ(ierr); }
|
if (B) { ierr = PetscObjectReference((PetscObject)B);CHKERRQ(ierr); }
|
if (st->B) { ierr = MatDestroy(st->B);CHKERRQ(ierr); }
|
if (st->B) { ierr = MatDestroy(st->B);CHKERRQ(ierr); }
|
st->B = B;
|
st->B = B;
|
st->setupcalled = 0;
|
st->setupcalled = 0;
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STGetOperators"
|
#define __FUNCT__ "STGetOperators"
|
/*@C
|
/*@C
|
STGetOperators - Gets the matrices associated with the eigensystem.
|
STGetOperators - Gets the matrices associated with the eigensystem.
|
|
|
Not collective, though parallel Mats are returned if the ST is parallel
|
Not collective, though parallel Mats are returned if the ST is parallel
|
|
|
Input Parameter:
|
Input Parameter:
|
. st - the spectral transformation context
|
. st - the spectral transformation context
|
|
|
Output Parameters:
|
Output Parameters:
|
. A - the matrix associated with the eigensystem
|
. A - the matrix associated with the eigensystem
|
- B - the second matrix in the case of generalized eigenproblems
|
- B - the second matrix in the case of generalized eigenproblems
|
|
|
Level: intermediate
|
Level: intermediate
|
|
|
.seealso: STSetOperators()
|
.seealso: STSetOperators()
|
@*/
|
@*/
|
PetscErrorCode STGetOperators(ST st,Mat *A,Mat *B)
|
PetscErrorCode STGetOperators(ST st,Mat *A,Mat *B)
|
{
|
{
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
PetscValidHeaderSpecific(st,ST_COOKIE,1);
|
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
if (A) *A = st->A;
|
if (A) *A = st->A;
|
if (B) *B = st->B;
|
if (B) *B = st->B;
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STSetShift"
|
#define __FUNCT__ "STSetShift"
|
/*@
|
/*@
|
STSetShift - Sets the shift associated with the spectral transformation.
|
STSetShift - Sets the shift associated with the spectral transformation.
|
|
|
Collective on ST
|
Collective on ST
|
|
|
Input Parameters:
|
Input Parameters:
|
+ st - the spectral transformation context
|
+ st - the spectral transformation context
|
- shift - the value of the shift
|
- shift - the value of the shift
|
|
|
Note:
|
Note:
|
In some spectral transformations, changing the shift may have associated
|
In some spectral transformations, changing the shift may have associated
|
a lot of work, for example recomputing a factorization.
|
a lot of work, for example recomputing a factorization.
|
|
|
Level: beginner
|
Level: beginner
|
|
|
@*/
|
@*/
|
PetscErrorCode STSetShift(ST st,PetscScalar shift)
|
PetscErrorCode STSetShift(ST st,PetscScalar shift)
|
{
|
{
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
PetscValidHeaderSpecific(st,ST_COOKIE,1);
|
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
if (st->sigma != shift) {
|
if (st->sigma != shift) {
|
if (st->ops->setshift) {
|
if (st->ops->setshift) {
|
ierr = (*st->ops->setshift)(st,shift); CHKERRQ(ierr);
|
ierr = (*st->ops->setshift)(st,shift); CHKERRQ(ierr);
|
}
|
}
|
}
|
}
|
st->sigma = shift;
|
st->sigma = shift;
|
st->sigma_set = PETSC_TRUE;
|
st->sigma_set = PETSC_TRUE;
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STGetShift"
|
#define __FUNCT__ "STGetShift"
|
/*@
|
/*@
|
STGetShift - Gets the shift associated with the spectral transformation.
|
STGetShift - Gets the shift associated with the spectral transformation.
|
|
|
Not collective
|
Not collective
|
|
|
Input Parameter:
|
Input Parameter:
|
. st - the spectral transformation context
|
. st - the spectral transformation context
|
|
|
Output Parameter:
|
Output Parameter:
|
. shift - the value of the shift
|
. shift - the value of the shift
|
|
|
Level: beginner
|
Level: beginner
|
|
|
@*/
|
@*/
|
PetscErrorCode STGetShift(ST st,PetscScalar* shift)
|
PetscErrorCode STGetShift(ST st,PetscScalar* shift)
|
{
|
{
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
PetscValidHeaderSpecific(st,ST_COOKIE,1);
|
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
if (shift) *shift = st->sigma;
|
if (shift) *shift = st->sigma;
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STSetDefaultShift"
|
#define __FUNCT__ "STSetDefaultShift"
|
/*@
|
/*@
|
STSetDefaultShift - Sets the value of the shift that should be employed if
|
STSetDefaultShift - Sets the value of the shift that should be employed if
|
the user did not specify one.
|
the user did not specify one.
|
|
|
Collective on ST
|
Collective on ST
|
|
|
Input Parameters:
|
Input Parameters:
|
+ st - the spectral transformation context
|
+ st - the spectral transformation context
|
- defaultshift - the default value of the shift
|
- defaultshift - the default value of the shift
|
|
|
Level: developer
|
Level: developer
|
|
|
@*/
|
@*/
|
PetscErrorCode STSetDefaultShift(ST st,PetscScalar defaultshift)
|
PetscErrorCode STSetDefaultShift(ST st,PetscScalar defaultshift)
|
{
|
{
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
PetscValidHeaderSpecific(st,ST_COOKIE,1);
|
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
st->defsigma = defaultshift;
|
st->defsigma = defaultshift;
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STSetBalanceMatrix"
|
#define __FUNCT__ "STSetBalanceMatrix"
|
/*@
|
/*@
|
STSetBalanceMatrix - Sets the diagonal matrix to be used for balancing.
|
STSetBalanceMatrix - Sets the diagonal matrix to be used for balancing.
|
|
|
Collective on ST and Vec
|
Collective on ST and Vec
|
|
|
Input Parameters:
|
Input Parameters:
|
+ st - the spectral transformation context
|
+ st - the spectral transformation context
|
- D - the diagonal matrix (represented as a vector)
|
- D - the diagonal matrix (represented as a vector)
|
|
|
Notes:
|
Notes:
|
If this matrix is set, STApply will effectively apply D*OP*D^{-1}.
|
If this matrix is set, STApply will effectively apply D*OP*D^{-1}.
|
|
|
Balancing is usually set via EPSSetBalance, but the advanced user may use
|
Balancing is usually set via EPSSetBalance, but the advanced user may use
|
this function to bypass the usual balancing methods.
|
this function to bypass the usual balancing methods.
|
|
|
Level: developer
|
Level: developer
|
|
|
.seealso: EPSSetBalance(), STApply(), STGetBalanceMatrix()
|
.seealso: EPSSetBalance(), STApply(), STGetBalanceMatrix()
|
@*/
|
@*/
|
PetscErrorCode STSetBalanceMatrix(ST st,Vec D)
|
PetscErrorCode STSetBalanceMatrix(ST st,Vec D)
|
{
|
{
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
PetscValidHeaderSpecific(st,ST_COOKIE,1);
|
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
PetscValidHeaderSpecific(D,VEC_COOKIE,2);
|
PetscValidHeaderSpecific(D,VEC_CLASSID,2);
|
PetscCheckSameComm(st,1,D,2);
|
PetscCheckSameComm(st,1,D,2);
|
ierr = PetscObjectReference((PetscObject)D);CHKERRQ(ierr);
|
ierr = PetscObjectReference((PetscObject)D);CHKERRQ(ierr);
|
if (st->D) {
|
if (st->D) {
|
ierr = VecDestroy(st->D); CHKERRQ(ierr);
|
ierr = VecDestroy(st->D); CHKERRQ(ierr);
|
}
|
}
|
st->D = D;
|
st->D = D;
|
if (!st->wb) {
|
if (!st->wb) {
|
ierr = VecDuplicate(st->D,&st->wb); CHKERRQ(ierr);
|
ierr = VecDuplicate(st->D,&st->wb); CHKERRQ(ierr);
|
}
|
}
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STGetBalanceMatrix"
|
#define __FUNCT__ "STGetBalanceMatrix"
|
/*@
|
/*@
|
STGetBalanceMatrix - Gets the balance matrix used by the spectral transformation.
|
STGetBalanceMatrix - Gets the balance matrix used by the spectral transformation.
|
|
|
Not collective, but vector is shared by all processors that share the ST
|
Not collective, but vector is shared by all processors that share the ST
|
|
|
Input Parameter:
|
Input Parameter:
|
. st - the spectral transformation context
|
. st - the spectral transformation context
|
|
|
Output Parameter:
|
Output Parameter:
|
. D - the diagonal matrix (represented as a vector)
|
. D - the diagonal matrix (represented as a vector)
|
|
|
Note:
|
Note:
|
If the matrix was not set, a null pointer will be returned.
|
If the matrix was not set, a null pointer will be returned.
|
|
|
Level: developer
|
Level: developer
|
|
|
.seealso: STSetBalanceMatrix()
|
.seealso: STSetBalanceMatrix()
|
@*/
|
@*/
|
PetscErrorCode STGetBalanceMatrix(ST st,Vec *D)
|
PetscErrorCode STGetBalanceMatrix(ST st,Vec *D)
|
{
|
{
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
PetscValidHeaderSpecific(st,ST_COOKIE,1);
|
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
PetscValidPointer(D,2);
|
PetscValidPointer(D,2);
|
*D = st->D;
|
*D = st->D;
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STSetOptionsPrefix"
|
#define __FUNCT__ "STSetOptionsPrefix"
|
/*@C
|
/*@C
|
STSetOptionsPrefix - Sets the prefix used for searching for all
|
STSetOptionsPrefix - Sets the prefix used for searching for all
|
ST options in the database.
|
ST options in the database.
|
|
|
Collective on ST
|
Collective on ST
|
|
|
Input Parameters:
|
Input Parameters:
|
+ st - the spectral transformation context
|
+ st - the spectral transformation context
|
- prefix - the prefix string to prepend to all ST option requests
|
- prefix - the prefix string to prepend to all ST option requests
|
|
|
Notes:
|
Notes:
|
A hyphen (-) must NOT be given at the beginning of the prefix name.
|
A hyphen (-) must NOT be given at the beginning of the prefix name.
|
The first character of all runtime options is AUTOMATICALLY the
|
The first character of all runtime options is AUTOMATICALLY the
|
hyphen.
|
hyphen.
|
|
|
Level: advanced
|
Level: advanced
|
|
|
.seealso: STAppendOptionsPrefix(), STGetOptionsPrefix()
|
.seealso: STAppendOptionsPrefix(), STGetOptionsPrefix()
|
@*/
|
@*/
|
PetscErrorCode STSetOptionsPrefix(ST st,const char *prefix)
|
PetscErrorCode STSetOptionsPrefix(ST st,const char *prefix)
|
{
|
{
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
PetscValidHeaderSpecific(st,ST_COOKIE,1);
|
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
ierr = PetscObjectSetOptionsPrefix((PetscObject)st,prefix);CHKERRQ(ierr);
|
ierr = PetscObjectSetOptionsPrefix((PetscObject)st,prefix);CHKERRQ(ierr);
|
ierr = KSPSetOptionsPrefix(st->ksp,prefix);CHKERRQ(ierr);
|
ierr = KSPSetOptionsPrefix(st->ksp,prefix);CHKERRQ(ierr);
|
ierr = KSPAppendOptionsPrefix(st->ksp,"st_");CHKERRQ(ierr);
|
ierr = KSPAppendOptionsPrefix(st->ksp,"st_");CHKERRQ(ierr);
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STAppendOptionsPrefix"
|
#define __FUNCT__ "STAppendOptionsPrefix"
|
/*@C
|
/*@C
|
STAppendOptionsPrefix - Appends to the prefix used for searching for all
|
STAppendOptionsPrefix - Appends to the prefix used for searching for all
|
ST options in the database.
|
ST options in the database.
|
|
|
Collective on ST
|
Collective on ST
|
|
|
Input Parameters:
|
Input Parameters:
|
+ st - the spectral transformation context
|
+ st - the spectral transformation context
|
- prefix - the prefix string to prepend to all ST option requests
|
- prefix - the prefix string to prepend to all ST option requests
|
|
|
Notes:
|
Notes:
|
A hyphen (-) must NOT be given at the beginning of the prefix name.
|
A hyphen (-) must NOT be given at the beginning of the prefix name.
|
The first character of all runtime options is AUTOMATICALLY the
|
The first character of all runtime options is AUTOMATICALLY the
|
hyphen.
|
hyphen.
|
|
|
Level: advanced
|
Level: advanced
|
|
|
.seealso: STSetOptionsPrefix(), STGetOptionsPrefix()
|
.seealso: STSetOptionsPrefix(), STGetOptionsPrefix()
|
@*/
|
@*/
|
PetscErrorCode STAppendOptionsPrefix(ST st,const char *prefix)
|
PetscErrorCode STAppendOptionsPrefix(ST st,const char *prefix)
|
{
|
{
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
PetscValidHeaderSpecific(st,ST_COOKIE,1);
|
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
ierr = PetscObjectAppendOptionsPrefix((PetscObject)st,prefix);CHKERRQ(ierr);
|
ierr = PetscObjectAppendOptionsPrefix((PetscObject)st,prefix);CHKERRQ(ierr);
|
ierr = KSPSetOptionsPrefix(st->ksp,((PetscObject)st)->prefix);CHKERRQ(ierr);
|
ierr = KSPSetOptionsPrefix(st->ksp,((PetscObject)st)->prefix);CHKERRQ(ierr);
|
ierr = KSPAppendOptionsPrefix(st->ksp,"st_");CHKERRQ(ierr);
|
ierr = KSPAppendOptionsPrefix(st->ksp,"st_");CHKERRQ(ierr);
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STGetOptionsPrefix"
|
#define __FUNCT__ "STGetOptionsPrefix"
|
/*@C
|
/*@C
|
STGetOptionsPrefix - Gets the prefix used for searching for all
|
STGetOptionsPrefix - Gets the prefix used for searching for all
|
ST options in the database.
|
ST options in the database.
|
|
|
Not Collective
|
Not Collective
|
|
|
Input Parameters:
|
Input Parameters:
|
. st - the spectral transformation context
|
. st - the spectral transformation context
|
|
|
Output Parameters:
|
Output Parameters:
|
. prefix - pointer to the prefix string used, is returned
|
. prefix - pointer to the prefix string used, is returned
|
|
|
Notes: On the Fortran side, the user should pass in a string 'prefix' of
|
Notes: On the Fortran side, the user should pass in a string 'prefix' of
|
sufficient length to hold the prefix.
|
sufficient length to hold the prefix.
|
|
|
Level: advanced
|
Level: advanced
|
|
|
.seealso: STSetOptionsPrefix(), STAppendOptionsPrefix()
|
.seealso: STSetOptionsPrefix(), STAppendOptionsPrefix()
|
@*/
|
@*/
|
PetscErrorCode STGetOptionsPrefix(ST st,const char *prefix[])
|
PetscErrorCode STGetOptionsPrefix(ST st,const char *prefix[])
|
{
|
{
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
PetscValidHeaderSpecific(st,ST_COOKIE,1);
|
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
ierr = PetscObjectGetOptionsPrefix((PetscObject)st, prefix);CHKERRQ(ierr);
|
ierr = PetscObjectGetOptionsPrefix((PetscObject)st, prefix);CHKERRQ(ierr);
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STView"
|
#define __FUNCT__ "STView"
|
/*@C
|
/*@C
|
STView - Prints the ST data structure.
|
STView - Prints the ST data structure.
|
|
|
Collective on ST
|
Collective on ST
|
|
|
Input Parameters:
|
Input Parameters:
|
+ ST - the ST context
|
+ ST - the ST context
|
- viewer - optional visualization context
|
- viewer - optional visualization context
|
|
|
Note:
|
Note:
|
The available visualization contexts include
|
The available visualization contexts include
|
+ PETSC_VIEWER_STDOUT_SELF - standard output (default)
|
+ PETSC_VIEWER_STDOUT_SELF - standard output (default)
|
- PETSC_VIEWER_STDOUT_WORLD - synchronized standard
|
- PETSC_VIEWER_STDOUT_WORLD - synchronized standard
|
output where only the first processor opens
|
output where only the first processor opens
|
the file. All other processors send their
|
the file. All other processors send their
|
data to the first processor to print.
|
data to the first processor to print.
|
|
|
The user can open an alternative visualization contexts with
|
The user can open an alternative visualization contexts with
|
PetscViewerASCIIOpen() (output to a specified file).
|
PetscViewerASCIIOpen() (output to a specified file).
|
|
|
Level: beginner
|
Level: beginner
|
|
|
.seealso: EPSView(), PetscViewerASCIIOpen()
|
.seealso: EPSView(), PetscViewerASCIIOpen()
|
@*/
|
@*/
|
PetscErrorCode STView(ST st,PetscViewer viewer)
|
PetscErrorCode STView(ST st,PetscViewer viewer)
|
{
|
{
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
const STType cstr;
|
const STType cstr;
|
const char* str;
|
const char* str;
|
PetscTruth isascii,isstring;
|
PetscTruth isascii,isstring;
|
PetscViewerFormat format;
|
PetscViewerFormat format;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
PetscValidHeaderSpecific(st,ST_COOKIE,1);
|
PetscValidHeaderSpecific(st,ST_CLASSID,1);
|
if (!viewer) viewer = PETSC_VIEWER_STDOUT_(((PetscObject)st)->comm);
|
if (!viewer) viewer = PETSC_VIEWER_STDOUT_(((PetscObject)st)->comm);
|
PetscValidHeaderSpecific(viewer,PETSC_VIEWER_COOKIE,2);
|
PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2);
|
PetscCheckSameComm(st,1,viewer,2);
|
PetscCheckSameComm(st,1,viewer,2);
|
|
|
ierr = PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_ASCII,&isascii);CHKERRQ(ierr);
|
ierr = PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_ASCII,&isascii);CHKERRQ(ierr);
|
ierr = PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_STRING,&isstring);CHKERRQ(ierr);
|
ierr = PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_STRING,&isstring);CHKERRQ(ierr);
|
if (isascii) {
|
if (isascii) {
|
ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr);
|
ierr = PetscViewerGetFormat(viewer,&format);CHKERRQ(ierr);
|
ierr = PetscViewerASCIIPrintf(viewer,"ST Object:\n");CHKERRQ(ierr);
|
ierr = PetscViewerASCIIPrintf(viewer,"ST Object:\n");CHKERRQ(ierr);
|
ierr = STGetType(st,&cstr);CHKERRQ(ierr);
|
ierr = STGetType(st,&cstr);CHKERRQ(ierr);
|
if (cstr) {
|
if (cstr) {
|
ierr = PetscViewerASCIIPrintf(viewer," type: %s\n",cstr);CHKERRQ(ierr);
|
ierr = PetscViewerASCIIPrintf(viewer," type: %s\n",cstr);CHKERRQ(ierr);
|
} else {
|
} else {
|
ierr = PetscViewerASCIIPrintf(viewer," type: not yet set\n");CHKERRQ(ierr);
|
ierr = PetscViewerASCIIPrintf(viewer," type: not yet set\n");CHKERRQ(ierr);
|
}
|
}
|
#if !defined(PETSC_USE_COMPLEX)
|
#if !defined(PETSC_USE_COMPLEX)
|
ierr = PetscViewerASCIIPrintf(viewer," shift: %g\n",st->sigma);CHKERRQ(ierr);
|
ierr = PetscViewerASCIIPrintf(viewer," shift: %g\n",st->sigma);CHKERRQ(ierr);
|
#else
|
#else
|
ierr = PetscViewerASCIIPrintf(viewer," shift: %g+%g i\n",PetscRealPart(st->sigma),PetscImaginaryPart(st->sigma));CHKERRQ(ierr);
|
ierr = PetscViewerASCIIPrintf(viewer," shift: %g+%g i\n",PetscRealPart(st->sigma),PetscImaginaryPart(st->sigma));CHKERRQ(ierr);
|
#endif
|
#endif
|
switch (st->shift_matrix) {
|
switch (st->shift_matrix) {
|
case ST_MATMODE_COPY:
|
case ST_MATMODE_COPY:
|
break;
|
break;
|
case ST_MATMODE_INPLACE:
|
case ST_MATMODE_INPLACE:
|
ierr = PetscViewerASCIIPrintf(viewer,"Shifting the matrix and unshifting at exit\n");CHKERRQ(ierr);
|
ierr = PetscViewerASCIIPrintf(viewer,"Shifting the matrix and unshifting at exit\n");CHKERRQ(ierr);
|
break;
|
break;
|
case ST_MATMODE_SHELL:
|
case ST_MATMODE_SHELL:
|
ierr = PetscViewerASCIIPrintf(viewer,"Using a shell matrix\n");CHKERRQ(ierr);
|
ierr = PetscViewerASCIIPrintf(viewer,"Using a shell matrix\n");CHKERRQ(ierr);
|
break;
|
break;
|
}
|
}
|
if (st->B && st->shift_matrix != ST_MATMODE_SHELL) {
|
if (st->B && st->shift_matrix != ST_MATMODE_SHELL) {
|
switch (st->str) {
|
switch (st->str) {
|
case SAME_NONZERO_PATTERN: str = "same nonzero pattern";break;
|
case SAME_NONZERO_PATTERN: str = "same nonzero pattern";break;
|
case DIFFERENT_NONZERO_PATTERN: str = "different nonzero pattern";break;
|
case DIFFERENT_NONZERO_PATTERN: str = "different nonzero pattern";break;
|
case SUBSET_NONZERO_PATTERN: str = "subset nonzero pattern";break;
|
case SUBSET_NONZERO_PATTERN: str = "subset nonzero pattern";break;
|
default: SETERRQ(1,"Wrong structure flag");
|
default: SETERRQ(1,"Wrong structure flag");
|
}
|
}
|
ierr = PetscViewerASCIIPrintf(viewer,"Matrices A and B have %s\n",str);CHKERRQ(ierr);
|
ierr = PetscViewerASCIIPrintf(viewer,"Matrices A and B have %s\n",str);CHKERRQ(ierr);
|
}
|
}
|
if (st->ops->view) {
|
if (st->ops->view) {
|
ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
|
ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
|
ierr = (*st->ops->view)(st,viewer);CHKERRQ(ierr);
|
ierr = (*st->ops->view)(st,viewer);CHKERRQ(ierr);
|
ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
|
ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
|
}
|
}
|
} else if (isstring) {
|
} else if (isstring) {
|
ierr = STGetType(st,&cstr);CHKERRQ(ierr);
|
ierr = STGetType(st,&cstr);CHKERRQ(ierr);
|
ierr = PetscViewerStringSPrintf(viewer," %-7.7s",cstr);CHKERRQ(ierr);
|
ierr = PetscViewerStringSPrintf(viewer," %-7.7s",cstr);CHKERRQ(ierr);
|
if (st->ops->view) {ierr = (*st->ops->view)(st,viewer);CHKERRQ(ierr);}
|
if (st->ops->view) {ierr = (*st->ops->view)(st,viewer);CHKERRQ(ierr);}
|
} else {
|
} else {
|
SETERRQ1(1,"Viewer type %s not supported by ST",((PetscObject)viewer)->type_name);
|
SETERRQ1(1,"Viewer type %s not supported by ST",((PetscObject)viewer)->type_name);
|
}
|
}
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STView_Default"
|
#define __FUNCT__ "STView_Default"
|
PetscErrorCode STView_Default(ST st,PetscViewer viewer)
|
PetscErrorCode STView_Default(ST st,PetscViewer viewer)
|
{
|
{
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
PetscTruth isascii,isstring;
|
PetscTruth isascii,isstring;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
ierr = PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_ASCII,&isascii);CHKERRQ(ierr);
|
ierr = PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_ASCII,&isascii);CHKERRQ(ierr);
|
ierr = PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_STRING,&isstring);CHKERRQ(ierr);
|
ierr = PetscTypeCompare((PetscObject)viewer,PETSC_VIEWER_STRING,&isstring);CHKERRQ(ierr);
|
if (isascii) {
|
if (isascii) {
|
ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
|
ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
|
ierr = PetscViewerASCIIPrintf(viewer,"Associated KSP object\n");CHKERRQ(ierr);
|
ierr = PetscViewerASCIIPrintf(viewer,"Associated KSP object\n");CHKERRQ(ierr);
|
ierr = PetscViewerASCIIPrintf(viewer,"------------------------------\n");CHKERRQ(ierr);
|
ierr = PetscViewerASCIIPrintf(viewer,"------------------------------\n");CHKERRQ(ierr);
|
ierr = KSPView(st->ksp,viewer);CHKERRQ(ierr);
|
ierr = KSPView(st->ksp,viewer);CHKERRQ(ierr);
|
ierr = PetscViewerASCIIPrintf(viewer,"------------------------------\n");CHKERRQ(ierr);
|
ierr = PetscViewerASCIIPrintf(viewer,"------------------------------\n");CHKERRQ(ierr);
|
ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
|
ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
|
} else if (isstring) {
|
} else if (isstring) {
|
ierr = KSPView(st->ksp,viewer);CHKERRQ(ierr);
|
ierr = KSPView(st->ksp,viewer);CHKERRQ(ierr);
|
}
|
}
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
/*MC
|
/*MC
|
STRegisterDynamic - Adds a method to the spectral transformation package.
|
STRegisterDynamic - Adds a method to the spectral transformation package.
|
|
|
Synopsis:
|
Synopsis:
|
STRegisterDynamic(char *name_solver,char *path,char *name_create,PetscErrorCode (*routine_create)(ST))
|
STRegisterDynamic(char *name_solver,char *path,char *name_create,PetscErrorCode (*routine_create)(ST))
|
|
|
Not collective
|
Not collective
|
|
|
Input Parameters:
|
Input Parameters:
|
+ name_solver - name of a new user-defined solver
|
+ name_solver - name of a new user-defined solver
|
. path - path (either absolute or relative) the library containing this solver
|
. path - path (either absolute or relative) the library containing this solver
|
. name_create - name of routine to create method context
|
. name_create - name of routine to create method context
|
- routine_create - routine to create method context
|
- routine_create - routine to create method context
|
|
|
Notes:
|
Notes:
|
STRegisterDynamic() may be called multiple times to add several user-defined spectral transformations.
|
STRegisterDynamic() may be called multiple times to add several user-defined spectral transformations.
|
|
|
If dynamic libraries are used, then the fourth input argument (routine_create)
|
If dynamic libraries are used, then the fourth input argument (routine_create)
|
is ignored.
|
is ignored.
|
|
|
Sample usage:
|
Sample usage:
|
.vb
|
.vb
|
STRegisterDynamic("my_solver","/home/username/my_lib/lib/libO/solaris/mylib.a",
|
STRegisterDynamic("my_solver","/home/username/my_lib/lib/libO/solaris/mylib.a",
|
"MySolverCreate",MySolverCreate);
|
"MySolverCreate",MySolverCreate);
|
.ve
|
.ve
|
|
|
Then, your solver can be chosen with the procedural interface via
|
Then, your solver can be chosen with the procedural interface via
|
$ STSetType(st,"my_solver")
|
$ STSetType(st,"my_solver")
|
or at runtime via the option
|
or at runtime via the option
|
$ -st_type my_solver
|
$ -st_type my_solver
|
|
|
Level: advanced
|
Level: advanced
|
|
|
$PETSC_DIR, $PETSC_ARCH and $PETSC_LIB_DIR occuring in pathname will be replaced with appropriate values.
|
$PETSC_DIR, $PETSC_ARCH and $PETSC_LIB_DIR occuring in pathname will be replaced with appropriate values.
|
|
|
.seealso: STRegisterDestroy(), STRegisterAll()
|
.seealso: STRegisterDestroy(), STRegisterAll()
|
M*/
|
M*/
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STRegister"
|
#define __FUNCT__ "STRegister"
|
/*@C
|
/*@C
|
STRegister - See STRegisterDynamic()
|
STRegister - See STRegisterDynamic()
|
|
|
Level: advanced
|
Level: advanced
|
@*/
|
@*/
|
PetscErrorCode STRegister(const char *sname,const char *path,const char *name,PetscErrorCode (*function)(ST))
|
PetscErrorCode STRegister(const char *sname,const char *path,const char *name,PetscErrorCode (*function)(ST))
|
{
|
{
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
char fullname[256];
|
char fullname[256];
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
ierr = PetscFListConcat(path,name,fullname);CHKERRQ(ierr);
|
ierr = PetscFListConcat(path,name,fullname);CHKERRQ(ierr);
|
ierr = PetscFListAdd(&STList,sname,fullname,(void (*)(void))function);CHKERRQ(ierr);
|
ierr = PetscFListAdd(&STList,sname,fullname,(void (*)(void))function);CHKERRQ(ierr);
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
#undef __FUNCT__
|
#undef __FUNCT__
|
#define __FUNCT__ "STRegisterDestroy"
|
#define __FUNCT__ "STRegisterDestroy"
|
/*@
|
/*@
|
STRegisterDestroy - Frees the list of ST methods that were
|
STRegisterDestroy - Frees the list of ST methods that were
|
registered by STRegisterDynamic().
|
registered by STRegisterDynamic().
|
|
|
Not Collective
|
Not Collective
|
|
|
Level: advanced
|
Level: advanced
|
|
|
.seealso: STRegisterDynamic(), STRegisterAll()
|
.seealso: STRegisterDynamic(), STRegisterAll()
|
@*/
|
@*/
|
PetscErrorCode STRegisterDestroy(void)
|
PetscErrorCode STRegisterDestroy(void)
|
{
|
{
|
PetscErrorCode ierr;
|
PetscErrorCode ierr;
|
|
|
PetscFunctionBegin;
|
PetscFunctionBegin;
|
ierr = PetscFListDestroy(&STList);CHKERRQ(ierr);
|
ierr = PetscFListDestroy(&STList);CHKERRQ(ierr);
|
ierr = STRegisterAll(PETSC_NULL);CHKERRQ(ierr);
|
ierr = STRegisterAll(PETSC_NULL);CHKERRQ(ierr);
|
PetscFunctionReturn(0);
|
PetscFunctionReturn(0);
|
}
|
}
|
|
|
|
|