本文整理汇总了C++中ISDestroy函数的典型用法代码示例。如果您正苦于以下问题:C++ ISDestroy函数的具体用法?C++ ISDestroy怎么用?C++ ISDestroy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ISDestroy函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: PCISDestroy
PetscErrorCode PCISDestroy(PC pc)
{
PC_IS *pcis = (PC_IS*)(pc->data);
PetscErrorCode ierr;
PetscFunctionBegin;
ierr = ISDestroy(&pcis->is_B_local);CHKERRQ(ierr);
ierr = ISDestroy(&pcis->is_I_local);CHKERRQ(ierr);
ierr = ISDestroy(&pcis->is_B_global);CHKERRQ(ierr);
ierr = ISDestroy(&pcis->is_I_global);CHKERRQ(ierr);
ierr = MatDestroy(&pcis->A_II);CHKERRQ(ierr);
ierr = MatDestroy(&pcis->A_IB);CHKERRQ(ierr);
ierr = MatDestroy(&pcis->A_BI);CHKERRQ(ierr);
ierr = MatDestroy(&pcis->A_BB);CHKERRQ(ierr);
ierr = VecDestroy(&pcis->D);CHKERRQ(ierr);
ierr = KSPDestroy(&pcis->ksp_N);CHKERRQ(ierr);
ierr = KSPDestroy(&pcis->ksp_D);CHKERRQ(ierr);
ierr = VecDestroy(&pcis->vec1_N);CHKERRQ(ierr);
ierr = VecDestroy(&pcis->vec2_N);CHKERRQ(ierr);
ierr = VecDestroy(&pcis->vec1_D);CHKERRQ(ierr);
ierr = VecDestroy(&pcis->vec2_D);CHKERRQ(ierr);
ierr = VecDestroy(&pcis->vec3_D);CHKERRQ(ierr);
ierr = VecDestroy(&pcis->vec1_B);CHKERRQ(ierr);
ierr = VecDestroy(&pcis->vec2_B);CHKERRQ(ierr);
ierr = VecDestroy(&pcis->vec3_B);CHKERRQ(ierr);
ierr = VecDestroy(&pcis->vec1_global);CHKERRQ(ierr);
ierr = VecScatterDestroy(&pcis->global_to_D);CHKERRQ(ierr);
ierr = VecScatterDestroy(&pcis->N_to_B);CHKERRQ(ierr);
ierr = VecScatterDestroy(&pcis->global_to_B);CHKERRQ(ierr);
ierr = PetscFree(pcis->work_N);CHKERRQ(ierr);
if (pcis->ISLocalToGlobalMappingGetInfoWasCalled) {
ierr = ISLocalToGlobalMappingRestoreInfo((ISLocalToGlobalMapping)0,&(pcis->n_neigh),&(pcis->neigh),&(pcis->n_shared),&(pcis->shared));CHKERRQ(ierr);
}
ierr = PetscObjectComposeFunction((PetscObject)pc,"PCISSetUseStiffnessScaling_C",NULL);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)pc,"PCISSetSubdomainScalingFactor_C",NULL);CHKERRQ(ierr);
ierr = PetscObjectComposeFunction((PetscObject)pc,"PCISSetSubdomainDiagonalScaling_C",NULL);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
开发者ID:hsahasra,项目名称:petsc-magma-dense-mat,代码行数:38,代码来源:pcis.c
示例2: main
int main(int argc,char **argv)
{
PetscErrorCode ierr;
PetscInt i,n,first,step;
IS set;
const PetscInt *indices;
ierr = PetscInitialize(&argc,&argv,(char*)0,help);
CHKERRQ(ierr);
n = 10;
first = 3;
step = 2;
/*
Create stride index set, starting at 3 with a stride of 2
Note each processor is generating its own index set
(in this case they are all identical)
*/
ierr = ISCreateStride(PETSC_COMM_SELF,n,first,step,&set);
CHKERRQ(ierr);
ierr = ISView(set,PETSC_VIEWER_STDOUT_SELF);
CHKERRQ(ierr);
/*
Extract indices from set.
*/
ierr = ISGetIndices(set,&indices);
CHKERRQ(ierr);
ierr = PetscPrintf(PETSC_COMM_WORLD,"Printing indices directly\n");
CHKERRQ(ierr);
for (i=0; i<n; i++) {
ierr = PetscPrintf(PETSC_COMM_WORLD,"%D\n",indices[i]);
CHKERRQ(ierr);
}
ierr = ISRestoreIndices(set,&indices);
CHKERRQ(ierr);
/*
Determine information on stride
*/
ierr = ISStrideGetInfo(set,&first,&step);
CHKERRQ(ierr);
if (first != 3 || step != 2) SETERRQ(PETSC_COMM_SELF,1,"Stride info not correct!\n");
ierr = ISDestroy(&set);
CHKERRQ(ierr);
ierr = PetscFinalize();
return 0;
}
开发者ID:00liujj,项目名称:petsc,代码行数:50,代码来源:ex2.c
示例3: main
int main(int argc,char **argv)
{
PetscInt n = 5;
PetscErrorCode ierr;
PetscMPIInt rank,size;
IS ispetsc,isapp;
AO ao;
ierr = PetscInitialize(&argc,&argv,(char*)0,help);CHKERRQ(ierr);
ierr = PetscOptionsGetInt(NULL,"-n",&n,NULL);CHKERRQ(ierr);
ierr = MPI_Comm_rank(PETSC_COMM_WORLD,&rank);CHKERRQ(ierr);
ierr = MPI_Comm_size(PETSC_COMM_WORLD,&size);CHKERRQ(ierr);
/* create the index sets */
ierr = ISCreateStride(PETSC_COMM_WORLD,n,rank,size,&ispetsc);CHKERRQ(ierr);
ierr = ISCreateStride(PETSC_COMM_WORLD,n,n*rank,1,&isapp);CHKERRQ(ierr);
/* create the application ordering */
ierr = AOCreateBasicIS(isapp,ispetsc,&ao);CHKERRQ(ierr);
ierr = AOView(ao,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
ierr = ISView(ispetsc,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
ierr = ISView(isapp,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
ierr = AOPetscToApplicationIS(ao,ispetsc);CHKERRQ(ierr);
ierr = ISView(isapp,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
ierr = ISView(ispetsc,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
ierr = ISDestroy(&ispetsc);CHKERRQ(ierr);
ierr = ISDestroy(&isapp);CHKERRQ(ierr);
ierr = AODestroy(&ao);CHKERRQ(ierr);
ierr = PetscFinalize();
return 0;
}
开发者ID:00liujj,项目名称:petsc,代码行数:37,代码来源:ex7.c
示例4: main
int main(int argc,char **args)
{
Mat BAIJ,SBAIJ,*subBAIJ,*subSBAIJ;
PetscViewer viewer;
char file[PETSC_MAX_PATH_LEN];
PetscBool flg;
PetscErrorCode ierr;
PetscInt n = 2,issize;
PetscMPIInt rank;
IS is,iss[2];
PetscInitialize(&argc,&args,(char*)0,help);
ierr = PetscOptionsGetString(NULL,"-f",file,PETSC_MAX_PATH_LEN,&flg);CHKERRQ(ierr);
ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,file,FILE_MODE_READ,&viewer);CHKERRQ(ierr);
ierr = MatCreate(PETSC_COMM_WORLD,&BAIJ);CHKERRQ(ierr);
ierr = MatSetType(BAIJ,MATMPIBAIJ);CHKERRQ(ierr);
ierr = MatLoad(BAIJ,viewer);CHKERRQ(ierr);
ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr);
ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,file,FILE_MODE_READ,&viewer);CHKERRQ(ierr);
ierr = MatCreate(PETSC_COMM_WORLD,&SBAIJ);CHKERRQ(ierr);
ierr = MatSetType(SBAIJ,MATMPISBAIJ);CHKERRQ(ierr);
ierr = MatLoad(SBAIJ,viewer);CHKERRQ(ierr);
ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr);
ierr = MatGetSize(BAIJ,&issize,0);CHKERRQ(ierr);
issize = 9;
ierr = ISCreateStride(PETSC_COMM_SELF,issize,0,1,&is);CHKERRQ(ierr);
iss[0] = is;iss[1] = is;
ierr = MatGetSubMatrices(BAIJ,n,iss,iss,MAT_INITIAL_MATRIX,&subBAIJ);CHKERRQ(ierr);
ierr = MatGetSubMatrices(SBAIJ,n,iss,iss,MAT_INITIAL_MATRIX,&subSBAIJ);CHKERRQ(ierr);
ierr = MPI_Comm_rank(PETSC_COMM_WORLD,&rank);CHKERRQ(ierr);
#if defined(PETSC_USE_SOCKET_VIEWER)
if (!rank) {
ierr = MatView(subBAIJ[0],PETSC_VIEWER_SOCKET_SELF);CHKERRQ(ierr);
ierr = MatView(subSBAIJ[0],PETSC_VIEWER_SOCKET_SELF);CHKERRQ(ierr);
}
#endif
/* Free data structures */
ierr = ISDestroy(&is);CHKERRQ(ierr);
ierr = MatDestroyMatrices(n,&subBAIJ);CHKERRQ(ierr);
ierr = MatDestroyMatrices(n,&subSBAIJ);CHKERRQ(ierr);
ierr = MatDestroy(&BAIJ);CHKERRQ(ierr);
ierr = MatDestroy(&SBAIJ);CHKERRQ(ierr);
ierr = PetscFinalize();
return 0;
}
开发者ID:00liujj,项目名称:petsc,代码行数:49,代码来源:ex87.c
示例5: main
int main(int argc,char **argv)
{
PetscErrorCode ierr;
PetscInt i,n,*indices;
PetscInt rank,size;
IS is,newis;
ierr = PetscInitialize(&argc,&argv,(char*)0,help);CHKERRQ(ierr);
ierr = MPI_Comm_rank(PETSC_COMM_WORLD,&rank);CHKERRQ(ierr);
ierr = MPI_Comm_size(PETSC_COMM_WORLD,&size);CHKERRQ(ierr);
/*
Create IS
*/
n = 4 + rank;
ierr = PetscMalloc(n*sizeof(PetscInt),&indices);CHKERRQ(ierr);
for (i=0; i<n; i++) {
indices[i] = rank + i;
}
ierr = ISCreateGeneral(PETSC_COMM_WORLD,n,indices,PETSC_COPY_VALUES,&is);CHKERRQ(ierr);
ierr = PetscFree(indices);CHKERRQ(ierr);
/*
Stick them together from all processors
*/
ierr = ISAllGather(is,&newis);CHKERRQ(ierr);
if (!rank) {
ierr = ISView(newis,PETSC_VIEWER_STDOUT_SELF);CHKERRQ(ierr);
}
ierr = ISDestroy(&newis);CHKERRQ(ierr);
ierr = ISDestroy(&is);CHKERRQ(ierr);
ierr = PetscFinalize();
return 0;
}
开发者ID:Kun-Qu,项目名称:petsc,代码行数:36,代码来源:ex3.c
示例6: TaoDestroy_ASILS
static PetscErrorCode TaoDestroy_ASILS(Tao tao)
{
TAO_SSLS *ssls = (TAO_SSLS *)tao->data;
PetscErrorCode ierr;
PetscFunctionBegin;
ierr = VecDestroy(&ssls->ff);CHKERRQ(ierr);
ierr = VecDestroy(&ssls->dpsi);CHKERRQ(ierr);
ierr = VecDestroy(&ssls->da);CHKERRQ(ierr);
ierr = VecDestroy(&ssls->db);CHKERRQ(ierr);
ierr = VecDestroy(&ssls->w);CHKERRQ(ierr);
ierr = VecDestroy(&ssls->t1);CHKERRQ(ierr);
ierr = VecDestroy(&ssls->t2);CHKERRQ(ierr);
ierr = VecDestroy(&ssls->r1);CHKERRQ(ierr);
ierr = VecDestroy(&ssls->r2);CHKERRQ(ierr);
ierr = VecDestroy(&ssls->r3);CHKERRQ(ierr);
ierr = VecDestroy(&ssls->dxfree);CHKERRQ(ierr);
ierr = MatDestroy(&ssls->J_sub);CHKERRQ(ierr);
ierr = MatDestroy(&ssls->Jpre_sub);CHKERRQ(ierr);
ierr = ISDestroy(&ssls->fixed);CHKERRQ(ierr);
ierr = ISDestroy(&ssls->free);CHKERRQ(ierr);
ierr = PetscFree(tao->data);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
开发者ID:00liujj,项目名称:petsc,代码行数:24,代码来源:asils.c
示例7: MatPartitioningHierarchical_AssembleSubdomain
PetscErrorCode MatPartitioningHierarchical_AssembleSubdomain(Mat adj,IS destination,Mat *sadj, ISLocalToGlobalMapping *mapping)
{
IS irows,icols;
PetscInt irows_ln;
PetscMPIInt rank;
const PetscInt *irows_indices;
MPI_Comm comm;
PetscErrorCode ierr;
PetscFunctionBegin;
ierr = PetscObjectGetComm((PetscObject)adj,&comm);CHKERRQ(ierr);
ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr);
/* figure out where data comes from */
ierr = ISBuildTwoSided(destination,NULL,&irows);CHKERRQ(ierr);
ierr = ISDuplicate(irows,&icols);CHKERRQ(ierr);
ierr = ISGetLocalSize(irows,&irows_ln);CHKERRQ(ierr);
ierr = ISGetIndices(irows,&irows_indices);CHKERRQ(ierr);
ierr = ISLocalToGlobalMappingCreate(comm,1,irows_ln,irows_indices,PETSC_COPY_VALUES,mapping);CHKERRQ(ierr);
ierr = ISRestoreIndices(irows,&irows_indices);CHKERRQ(ierr);
ierr = MatGetSubMatrices(adj,1,&irows,&icols,MAT_INITIAL_MATRIX,&sadj);CHKERRQ(ierr);
ierr = ISDestroy(&irows);CHKERRQ(ierr);
ierr = ISDestroy(&icols);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
开发者ID:pombredanne,项目名称:petsc,代码行数:24,代码来源:hierarchical.c
示例8: ISView_Block
static PetscErrorCode ISView_Block(IS is, PetscViewer viewer)
{
IS_Block *sub = (IS_Block*)is->data;
PetscErrorCode ierr;
PetscInt i,bs,n,*idx = sub->idx;
PetscBool iascii;
PetscFunctionBegin;
ierr = PetscLayoutGetBlockSize(is->map, &bs);CHKERRQ(ierr);
ierr = PetscLayoutGetLocalSize(is->map, &n);CHKERRQ(ierr);
n /= bs;
ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&iascii);CHKERRQ(ierr);
if (iascii) {
PetscViewerFormat fmt;
ierr = PetscViewerGetFormat(viewer,&fmt);CHKERRQ(ierr);
if (fmt == PETSC_VIEWER_ASCII_MATLAB) {
IS ist;
const char *name;
const PetscInt *idx;
PetscInt n;
ierr = PetscObjectGetName((PetscObject)is,&name);CHKERRQ(ierr);
ierr = ISGetLocalSize(is,&n);CHKERRQ(ierr);
ierr = ISGetIndices(is,&idx);CHKERRQ(ierr);
ierr = ISCreateGeneral(PetscObjectComm((PetscObject)is),n,idx,PETSC_USE_POINTER,&ist);CHKERRQ(ierr);
ierr = PetscObjectSetName((PetscObject)ist,name);CHKERRQ(ierr);
ierr = ISView(ist,viewer);CHKERRQ(ierr);
ierr = ISDestroy(&ist);CHKERRQ(ierr);
ierr = ISRestoreIndices(is,&idx);CHKERRQ(ierr);
} else {
ierr = PetscViewerASCIIPushSynchronized(viewer);CHKERRQ(ierr);
if (is->isperm) {
ierr = PetscViewerASCIISynchronizedPrintf(viewer,"Block Index set is permutation\n");CHKERRQ(ierr);
}
ierr = PetscViewerASCIISynchronizedPrintf(viewer,"Block size %D\n",bs);CHKERRQ(ierr);
ierr = PetscViewerASCIISynchronizedPrintf(viewer,"Number of block indices in set %D\n",n);CHKERRQ(ierr);
ierr = PetscViewerASCIISynchronizedPrintf(viewer,"The first indices of each block are\n");CHKERRQ(ierr);
for (i=0; i<n; i++) {
ierr = PetscViewerASCIISynchronizedPrintf(viewer,"Block %D Index %D\n",i,idx[i]);CHKERRQ(ierr);
}
ierr = PetscViewerFlush(viewer);CHKERRQ(ierr);
ierr = PetscViewerASCIIPopSynchronized(viewer);CHKERRQ(ierr);
}
}
PetscFunctionReturn(0);
}
开发者ID:firedrakeproject,项目名称:petsc,代码行数:47,代码来源:block.c
示例9: DMDestroy_AKKT
PetscErrorCode DMDestroy_AKKT(DM dm) {
DM_AKKT *kkt = (DM_AKKT*)(dm->data);
PetscInt i;
PetscErrorCode ierr;
PetscFunctionBegin;
ierr = MatDestroy(&(kkt->Aff)); CHKERRQ(ierr);
ierr = DMDestroy(&(kkt->dm)); CHKERRQ(ierr);
for(i = 0; i < 2; ++i) {
ierr = DMDestroy(&(kkt->dmf[i])); CHKERRQ(ierr);
ierr = ISDestroy(&(kkt->isf[i])); CHKERRQ(ierr);
ierr = PetscFree(kkt->names[i]); CHKERRQ(ierr);
}
ierr = DMDestroy(&(kkt->cdm)); CHKERRQ(ierr);
ierr = MatDestroy(&(kkt->Pfc)); CHKERRQ(ierr);
ierr = PetscFree(kkt); CHKERRQ(ierr);
PetscFunctionReturn(0);
}
开发者ID:Kun-Qu,项目名称:petsc,代码行数:17,代码来源:dmakkt.c
示例10: PCDestroy_Redistribute
static PetscErrorCode PCDestroy_Redistribute(PC pc)
{
PC_Redistribute *red = (PC_Redistribute*)pc->data;
PetscErrorCode ierr;
PetscFunctionBegin;
ierr = VecScatterDestroy(&red->scatter);CHKERRQ(ierr);
ierr = ISDestroy(&red->is);CHKERRQ(ierr);
ierr = VecDestroy(&red->b);CHKERRQ(ierr);
ierr = VecDestroy(&red->x);CHKERRQ(ierr);
ierr = KSPDestroy(&red->ksp);CHKERRQ(ierr);
ierr = VecDestroy(&red->work);CHKERRQ(ierr);
ierr = PetscFree(red->drows);CHKERRQ(ierr);
ierr = PetscFree(red->diag);CHKERRQ(ierr);
ierr = PetscFree(pc->data);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
开发者ID:erdc-cm,项目名称:petsc-dev,代码行数:17,代码来源:redistribute.c
示例11: DMDestroy_SNESVI
PetscErrorCode DMDestroy_SNESVI(DM_SNESVI *dmsnesvi)
{
PetscErrorCode ierr;
PetscFunctionBegin;
/* reset the base methods in the DM object that were changed when the DM_SNESVI was reset */
dmsnesvi->dm->ops->createinterpolation = dmsnesvi->createinterpolation;
dmsnesvi->dm->ops->coarsen = dmsnesvi->coarsen;
dmsnesvi->dm->ops->createglobalvector = dmsnesvi->createglobalvector;
/* need to clear out this vectors because some of them may not have a reference to the DM
but they are counted as having references to the DM in DMDestroy() */
ierr = DMClearGlobalVectors(dmsnesvi->dm);CHKERRQ(ierr);
ierr = ISDestroy(&dmsnesvi->inactive);CHKERRQ(ierr);
ierr = PetscFree(dmsnesvi);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
开发者ID:erdc-cm,项目名称:petsc-dev,代码行数:17,代码来源:virs.c
示例12: SetupSection
/*
There is a problem here with uninterpolated meshes. The index in numDof[] is not dimension in this case,
but sieve depth.
*/
PetscErrorCode SetupSection(DM dm, AppCtx *user)
{
PetscSection section;
const PetscInt numFields = NUM_FIELDS;
PetscInt dim = user->dim;
PetscInt numBC = 0;
PetscInt bcFields[1] = {0};
IS bcPoints[1] = {NULL};
PetscInt numComp[NUM_FIELDS];
const PetscInt *numFieldDof[NUM_FIELDS];
PetscInt *numDof;
PetscInt f, d;
PetscErrorCode ierr;
PetscFunctionBeginUser;
ierr = PetscFEGetNumComponents(user->fe[0], &numComp[0]);CHKERRQ(ierr);
ierr = PetscFEGetNumComponents(user->fe[1], &numComp[1]);CHKERRQ(ierr);
ierr = PetscFEGetNumDof(user->fe[0], &numFieldDof[0]);CHKERRQ(ierr);
ierr = PetscFEGetNumDof(user->fe[1], &numFieldDof[1]);CHKERRQ(ierr);
ierr = PetscMalloc(NUM_FIELDS*(dim+1) * sizeof(PetscInt), &numDof);CHKERRQ(ierr);
for (f = 0; f < NUM_FIELDS; ++f) {
for (d = 0; d <= dim; ++d) {
numDof[f*(dim+1)+d] = numFieldDof[f][d];
}
}
for (f = 0; f < numFields; ++f) {
for (d = 1; d < dim; ++d) {
if ((numDof[f*(dim+1)+d] > 0) && !user->interpolate) SETERRQ(PetscObjectComm((PetscObject)dm), PETSC_ERR_ARG_WRONG, "Mesh must be interpolated when unknowns are specified on edges or faces.");
}
}
if (user->bcType == DIRICHLET) {
numBC = 1;
ierr = DMPlexGetStratumIS(dm, "marker", 1, &bcPoints[0]);CHKERRQ(ierr);
}
ierr = DMPlexCreateSection(dm, dim, numFields, numComp, numDof, numBC, bcFields, bcPoints, §ion);CHKERRQ(ierr);
ierr = PetscSectionSetFieldName(section, 0, "velocity");CHKERRQ(ierr);
ierr = PetscSectionSetFieldName(section, 1, "pressure");CHKERRQ(ierr);
ierr = DMSetDefaultSection(dm, section);CHKERRQ(ierr);
ierr = PetscSectionDestroy(§ion);CHKERRQ(ierr);
if (user->bcType == DIRICHLET) {
ierr = ISDestroy(&bcPoints[0]);CHKERRQ(ierr);
}
ierr = PetscFree(numDof);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
开发者ID:hsahasra,项目名称:petsc-magma-dense-mat,代码行数:49,代码来源:ex62.c
示例13: DMLabelCreate
/*
DMLabelMakeInvalid_Private - Transfer stratum data from the sorted list format to the hash format
Input parameter:
+ label - The DMLabel
- v - The stratum value
Output parameter:
. label - The DMLabel with stratum in hash format
Level: developer
.seealso: DMLabelCreate()
*/
static PetscErrorCode DMLabelMakeInvalid_Private(DMLabel label, PetscInt v)
{
PETSC_UNUSED PetscHashIIter ret, iter;
PetscInt p;
const PetscInt *points;
PetscErrorCode ierr;
PetscFunctionBegin;
if (!label->validIS[v]) PetscFunctionReturn(0);
if (label->points[v]) {
ierr = ISGetIndices(label->points[v],&points);CHKERRQ(ierr);
for (p = 0; p < label->stratumSizes[v]; ++p) PetscHashIPut(label->ht[v], points[p], ret, iter);
ierr = ISRestoreIndices(label->points[v],&points);CHKERRQ(ierr);
ierr = ISDestroy(&(label->points[v]));CHKERRQ(ierr);
}
label->validIS[v] = PETSC_FALSE;
PetscFunctionReturn(0);
}
开发者ID:ziolai,项目名称:petsc,代码行数:32,代码来源:dmlabel.c
示例14: test5
static PetscErrorCode test5(DM dm, AppCtx *options)
{
IS cells;
Vec locX, locX_t, locA;
PetscScalar *u, *u_t, *a;
PetscErrorCode ierr;
PetscFunctionBegin;
locX_t = NULL;
locA = NULL;
ierr = ISCreateStride(PETSC_COMM_SELF, 0, 0, 1, &cells);CHKERRQ(ierr);
ierr = DMGetLocalVector(dm, &locX);CHKERRQ(ierr);
ierr = DMPlexGetCellFields( dm, cells, locX, locX_t, locA, &u, &u_t, &a);CHKERRQ(ierr);
ierr = DMPlexRestoreCellFields(dm, cells, locX, locX_t, locA, &u, &u_t, &a);CHKERRQ(ierr);
ierr = DMRestoreLocalVector(dm, &locX);CHKERRQ(ierr);
ierr = ISDestroy(&cells);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
开发者ID:firedrakeproject,项目名称:petsc,代码行数:18,代码来源:ex25.c
示例15: main
int main(int argc,char **argv)
{
PetscErrorCode ierr;
PetscInt step = 2;
IS is;
ierr = PetscInitialize(&argc,&argv,(char*)0,help);CHKERRQ(ierr);
ierr = PetscOptionsGetInt(NULL,"-step",&step,NULL);CHKERRQ(ierr);
ierr = ISCreateStride(PETSC_COMM_SELF,10,0,step,&is);CHKERRQ(ierr);
ierr = ISToGeneral(is);CHKERRQ(ierr);
ierr = ISDestroy(&is);CHKERRQ(ierr);
ierr = PetscFinalize();
return 0;
}
开发者ID:00liujj,项目名称:petsc,代码行数:18,代码来源:ex4.c
示例16: GPCGGradProjections
static PetscErrorCode GPCGGradProjections(Tao tao)
{
PetscErrorCode ierr;
TAO_GPCG *gpcg = (TAO_GPCG *)tao->data;
PetscInt i;
PetscReal actred=-1.0,actred_max=0.0, gAg,gtg=gpcg->gnorm,alpha;
PetscReal f_new,gdx,stepsize;
Vec DX=tao->stepdirection,XL=tao->XL,XU=tao->XU,Work=gpcg->Work;
Vec X=tao->solution,G=tao->gradient;
TaoLineSearchConvergedReason lsflag=TAOLINESEARCH_CONTINUE_ITERATING;
/*
The free, active, and binding variables should be already identified
*/
PetscFunctionBegin;
for (i=0;i<gpcg->maxgpits;i++){
if ( -actred <= (gpcg->pg_ftol)*actred_max) break;
ierr = VecBoundGradientProjection(G,X,XL,XU,DX);CHKERRQ(ierr);
ierr = VecScale(DX,-1.0);CHKERRQ(ierr);
ierr = VecDot(DX,G,&gdx);CHKERRQ(ierr);
ierr = MatMult(tao->hessian,DX,Work);CHKERRQ(ierr);
ierr = VecDot(DX,Work,&gAg);CHKERRQ(ierr);
gpcg->gp_iterates++;
gpcg->total_gp_its++;
gtg=-gdx;
alpha = PetscAbsReal(gtg/gAg);
ierr = TaoLineSearchSetInitialStepLength(tao->linesearch,alpha);CHKERRQ(ierr);
f_new=gpcg->f;
ierr = TaoLineSearchApply(tao->linesearch,X,&f_new,G,DX,&stepsize,&lsflag);CHKERRQ(ierr);
/* Update the iterate */
actred = f_new - gpcg->f;
actred_max = PetscMax(actred_max,-(f_new - gpcg->f));
gpcg->f = f_new;
ierr = ISDestroy(&gpcg->Free_Local);CHKERRQ(ierr);
ierr = VecWhichBetween(XL,X,XU,&gpcg->Free_Local);CHKERRQ(ierr);
}
gpcg->gnorm=gtg;
PetscFunctionReturn(0);
} /* End gradient projections */
开发者ID:pombredanne,项目名称:petsc,代码行数:44,代码来源:gpcg.c
示例17: main
int main(int argc,char **args)
{
Mat C;
PetscInt i,j,m = 5,n = 5,Ii,J;
PetscErrorCode ierr;
PetscScalar v,five = 5.0;
IS isrow;
PetscBool keepnonzeropattern;
ierr = PetscInitialize(&argc,&args,(char*)0,help);if (ierr) return ierr;
/* create the matrix for the five point stencil, YET AGAIN*/
ierr = MatCreate(PETSC_COMM_SELF,&C);CHKERRQ(ierr);
ierr = MatSetSizes(C,PETSC_DECIDE,PETSC_DECIDE,m*n,m*n);CHKERRQ(ierr);
ierr = MatSetFromOptions(C);CHKERRQ(ierr);
ierr = MatSetUp(C);CHKERRQ(ierr);
for (i=0; i<m; i++) {
for (j=0; j<n; j++) {
v = -1.0; Ii = j + n*i;
if (i>0) {J = Ii - n; ierr = MatSetValues(C,1,&Ii,1,&J,&v,INSERT_VALUES);CHKERRQ(ierr);}
if (i<m-1) {J = Ii + n; ierr = MatSetValues(C,1,&Ii,1,&J,&v,INSERT_VALUES);CHKERRQ(ierr);}
if (j>0) {J = Ii - 1; ierr = MatSetValues(C,1,&Ii,1,&J,&v,INSERT_VALUES);CHKERRQ(ierr);}
if (j<n-1) {J = Ii + 1; ierr = MatSetValues(C,1,&Ii,1,&J,&v,INSERT_VALUES);CHKERRQ(ierr);}
v = 4.0; ierr = MatSetValues(C,1,&Ii,1,&Ii,&v,INSERT_VALUES);CHKERRQ(ierr);
}
}
ierr = MatAssemblyBegin(C,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
ierr = MatAssemblyEnd(C,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
ierr = ISCreateStride(PETSC_COMM_SELF,(m*n)/2,0,2,&isrow);CHKERRQ(ierr);
ierr = PetscOptionsHasName(NULL,NULL,"-keep_nonzero_pattern",&keepnonzeropattern);CHKERRQ(ierr);
if (keepnonzeropattern) {
ierr = MatSetOption(C,MAT_KEEP_NONZERO_PATTERN,PETSC_TRUE);CHKERRQ(ierr);
}
ierr = MatZeroRowsIS(C,isrow,five,0,0);CHKERRQ(ierr);
ierr = MatView(C,PETSC_VIEWER_STDOUT_SELF);CHKERRQ(ierr);
ierr = ISDestroy(&isrow);CHKERRQ(ierr);
ierr = MatDestroy(&C);CHKERRQ(ierr);
ierr = PetscFinalize();
return ierr;
}
开发者ID:tom-klotz,项目名称:petsc,代码行数:44,代码来源:ex11.c
示例18: TaoDestroy_TRON
static PetscErrorCode TaoDestroy_TRON(Tao tao)
{
TAO_TRON *tron = (TAO_TRON *)tao->data;
PetscErrorCode ierr;
PetscFunctionBegin;
ierr = VecDestroy(&tron->X_New);CHKERRQ(ierr);
ierr = VecDestroy(&tron->G_New);CHKERRQ(ierr);
ierr = VecDestroy(&tron->Work);CHKERRQ(ierr);
ierr = VecDestroy(&tron->DXFree);CHKERRQ(ierr);
ierr = VecDestroy(&tron->R);CHKERRQ(ierr);
ierr = VecDestroy(&tron->diag);CHKERRQ(ierr);
ierr = VecScatterDestroy(&tron->scatter);CHKERRQ(ierr);
ierr = ISDestroy(&tron->Free_Local);CHKERRQ(ierr);
ierr = MatDestroy(&tron->H_sub);CHKERRQ(ierr);
ierr = MatDestroy(&tron->Hpre_sub);CHKERRQ(ierr);
ierr = PetscFree(tao->data);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
开发者ID:plguhur,项目名称:petsc,代码行数:19,代码来源:tron.c
示例19: SNESReset_Multiblock
PetscErrorCode SNESReset_Multiblock(SNES snes)
{
SNES_Multiblock *mb = (SNES_Multiblock *) snes->data;
BlockDesc blocks = mb->blocks, next;
PetscErrorCode ierr;
PetscFunctionBegin;
while (blocks) {
ierr = SNESReset(blocks->snes);CHKERRQ(ierr);
#if 0
ierr = VecDestroy(&blocks->x);CHKERRQ(ierr);
#endif
ierr = VecScatterDestroy(&blocks->sctx);CHKERRQ(ierr);
ierr = ISDestroy(&blocks->is);CHKERRQ(ierr);
next = blocks->next;
blocks = next;
}
PetscFunctionReturn(0);
}
开发者ID:erdc-cm,项目名称:petsc-dev,代码行数:19,代码来源:multiblock.c
示例20: DMLabelFilter
PetscErrorCode DMLabelFilter(DMLabel label, PetscInt start, PetscInt end)
{
PetscInt v;
PetscErrorCode ierr;
PetscFunctionBegin;
ierr = DMLabelMakeAllValid_Private(label);CHKERRQ(ierr);
label->pStart = start;
label->pEnd = end;
if (label->bt) {ierr = PetscBTDestroy(&label->bt);CHKERRQ(ierr);}
/* Could squish offsets, but would only make sense if I reallocate the storage */
for (v = 0; v < label->numStrata; ++v) {
PetscInt off, q;
const PetscInt *points;
PetscInt *pointsNew = NULL;
ierr = ISGetIndices(label->points[v],&points);CHKERRQ(ierr);
for (off = 0, q = 0; q < label->stratumSizes[v]; ++q) {
const PetscInt point = points[q];
if ((point < start) || (point >= end)) {
if (!pointsNew) {
ierr = PetscMalloc1(label->stratumSizes[v],&pointsNew);CHKERRQ(ierr);
ierr = PetscMemcpy(pointsNew,points,(size_t) off * sizeof(PetscInt));CHKERRQ(ierr);
}
continue;
}
if (pointsNew) {
pointsNew[off++] = point;
}
}
ierr = ISRestoreIndices(label->points[v],&points);CHKERRQ(ierr);
if (pointsNew) {
ierr = ISDestroy(&(label->points[v]));CHKERRQ(ierr);
ierr = ISCreateGeneral(PETSC_COMM_SELF,off,pointsNew,PETSC_OWN_POINTER,&(label->points[v]));CHKERRQ(ierr);
ierr = PetscObjectSetName((PetscObject) (label->points[v]), "indices");CHKERRQ(ierr);
}
label->stratumSizes[v] = off;
}
ierr = DMLabelCreateIndex(label, start, end);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
开发者ID:ziolai,项目名称:petsc,代码行数:42,代码来源:dmlabel.c
注:本文中的ISDestroy函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论