void PETScMGSolver_DestructLevels( PETScMGSolver* self ) { unsigned l_i; assert( self && Stg_CheckType( self, PETScMGSolver ) ); for( l_i = 0; l_i < self->nLevels; l_i++ ) { PETScMGSolver_Level* level = self->levels + l_i; if(level->R == level->P){ if( level->R != PETSC_NULL ){ Stg_MatDestroy(&level->R ); level->P = PETSC_NULL; } }else{/* not same so test individually */ if( level->R != PETSC_NULL ) Stg_MatDestroy(&level->R ); if( level->P != PETSC_NULL ) Stg_MatDestroy(&level->P ); } if( level->workRes ) Stg_VecDestroy(&level->workRes ); if( level->workSol ) Stg_VecDestroy(&level->workSol ); if( level->workRHS ) Stg_VecDestroy(&level->workRHS ); } KillArray( self->levels ); self->nLevels = 0; self->solversChanged = True; self->opsChanged = True; }
void MultigridSolver_DestructLevels( MultigridSolver* self ) { unsigned l_i; assert( self && Stg_CheckType( self, MultigridSolver ) ); for( l_i = 0; l_i < self->nLevels; l_i++ ) { MultigridSolver_Level* level = self->levels + l_i; if( level->downSolver ) { //Stg_Class_RemoveRef( MatrixSolver_GetMatrix( level->downSolver ) ); //Stg_Class_RemoveRef( level->downSolver ); if( level->downSolver->ksp != PETSC_NULL ) Stg_KSPDestroy(&level->downSolver->ksp ); if( level->downSolver->matrix != PETSC_NULL ) Stg_MatDestroy(&level->downSolver->matrix ); if( level->downSolver->inversion != PETSC_NULL ) Stg_MatDestroy(&level->downSolver->inversion ); if( level->downSolver->residual != PETSC_NULL ) Stg_VecDestroy(&level->downSolver->residual ); if( level->downSolver->curRHS != PETSC_NULL ) Stg_VecDestroy(&level->downSolver->curRHS ); if( level->downSolver->curSolution != PETSC_NULL ) Stg_VecDestroy(&level->downSolver->curSolution ); free( level->downSolver ); } if( level->upSolver ) { //Stg_Class_RemoveRef( MatrixSolver_GetMatrix( level->upSolver ) ); //Stg_Class_RemoveRef( level->upSolver ); if( level->upSolver->ksp != PETSC_NULL ) Stg_KSPDestroy(&level->upSolver->ksp ); if( level->upSolver->matrix != PETSC_NULL ) Stg_MatDestroy(&level->upSolver->matrix ); if( level->upSolver->inversion != PETSC_NULL ) Stg_MatDestroy(&level->upSolver->inversion ); if( level->upSolver->residual != PETSC_NULL ) Stg_VecDestroy(&level->upSolver->residual ); if( level->upSolver->curRHS != PETSC_NULL ) Stg_VecDestroy(&level->upSolver->curRHS ); if( level->upSolver->curSolution != PETSC_NULL ) Stg_VecDestroy(&level->upSolver->curSolution ); free( level->upSolver ); } if( level->R != PETSC_NULL ) //Stg_Class_RemoveRef( level->R ); Stg_MatDestroy(&level->R ); if( level->P != PETSC_NULL ) //Stg_Class_RemoveRef( level->P ); Stg_MatDestroy(&level->P ); if( level->workRHS != PETSC_NULL ) //Stg_Class_RemoveRef( level->workRHS ); Stg_VecDestroy(&level->workRHS ); if( level->workSol != PETSC_NULL ) //Stg_Class_RemoveRef( level->workSol ); Stg_VecDestroy(&level->workSol ); } KillArray( self->levels ); self->nLevels = 0; self->solversChanged = True; self->opsChanged = True; /* Temporary. */ //KillObject( self->outerSolver ); if( self->outerSolver->ksp ) Stg_KSPDestroy(&self->outerSolver->ksp ); if( self->outerSolver->matrix ) Stg_MatDestroy(&self->outerSolver->matrix ); if( self->outerSolver->inversion ) Stg_MatDestroy(&self->outerSolver->inversion ); if( self->outerSolver->residual ) Stg_VecDestroy(&self->outerSolver->residual ); if( self->outerSolver->curRHS ) Stg_VecDestroy(&self->outerSolver->curRHS ); if( self->outerSolver->curSolution ) Stg_VecDestroy(&self->outerSolver->curSolution ); free( self->outerSolver ); }
void _SnacRemesher_DeleteExtensions( void* _context, void* data ) { Snac_Context* context = (Snac_Context*)_context; Mesh* mesh = context->mesh; SnacRemesher_Mesh* meshExt = ExtensionManager_Get( context->meshExtensionMgr, mesh, SnacRemesher_MeshHandle ); Journal_Printf( context->debug, "In: %s\n", __func__ ); /* ** Probably will not need to do this. */ if( meshExt->newNodes ) { ExtensionManager_Free( mesh->nodeExtensionMgr, meshExt->newNodes ); } #if 0 if( meshExt->newElements ) { ExtensionManager_Free( mesh->nodeExtensionMgr, meshExt->newElements ); } #endif /* ** Kill the mesh extension. */ KillArray( meshExt->newNodeCoords ); KillArray( meshExt->externalNodes ); KillArray( meshExt->externalElements ); KillArray( meshExt->topInternToLocal ); KillArray( meshExt->botInternToLocal ); KillArray( meshExt->topTriToDomain ); KillArray( meshExt->botTriToDomain ); KillArray( meshExt->yLineLTerm ); KillArray( meshExt->yLineUTerm ); KillArray( meshExt->yLineNYInds ); KillArray2D( meshExt->nYLines, meshExt->yLineYInds ); KillArray2D( meshExt->nYLines, meshExt->yLineLocalInds ); }
void Mesh_Destruct( Mesh* self ) { unsigned et_i/*, v_i*/; for( et_i = 0; et_i < self->nElTypes; et_i++ ) Stg_Class_Delete( self->elTypes[et_i] ); KillArray( self->elTypes ); KillArray( self->elTypeMap ); self->nElTypes = 0; KillArray( self->vertices ); Stg_Component_Destroy(self->verticesVariable, NULL, False); self->verticesVariable = NULL; KillArray( self->verticesgid ); Stg_Component_Destroy(self->vGlobalIdsVar, NULL, False); self->vGlobalIdsVar = NULL; KillArray( self->e_n ); Stg_Component_Destroy(self->enMapVar, NULL, False); self->enMapVar = NULL; KillArray( self->elgid ); Stg_Component_Destroy(self->eGlobalIdsVar, NULL, False); self->eGlobalIdsVar = NULL; self->generator = NULL; self->emReg = NULL; /* for( v_i = 0; v_i < List_GetSize( self->vars ); v_i++ ) { MeshVariable* var; var = *(MeshVariable**)List_GetItem( self->vars, v_i ); MeshVariable_SetMesh( var, NULL ); } List_Clear( self->vars ); */ }
void TestSuite_Destruct( TestSuite* self ) { assert( self ); self->nTests = 0; KillArray( self->tests ); }