| matops.c (60224bc541fd55b59daf56d957e93315ca03a274) | matops.c (f1c40530bc6f02bc6ca847af718b8b41cc3fd3ca) |
|---|---|
| 1#include "../include/matops.h" 2#include "../include/petscutils.h" 3 4// ----------------------------------------------------------------------------- 5// This function returns the computed diagonal of the operator 6// ----------------------------------------------------------------------------- 7PetscErrorCode MatGetDiag(Mat A, Vec D) { 8 PetscErrorCode ierr; 9 UserO user; 10 11 PetscFunctionBeginUser; 12 13 ierr = MatShellGetContext(A, &user); CHKERRQ(ierr); 14 15 // Compute Diagonal via libCEED | 1#include "../include/matops.h" 2#include "../include/petscutils.h" 3 4// ----------------------------------------------------------------------------- 5// This function returns the computed diagonal of the operator 6// ----------------------------------------------------------------------------- 7PetscErrorCode MatGetDiag(Mat A, Vec D) { 8 PetscErrorCode ierr; 9 UserO user; 10 11 PetscFunctionBeginUser; 12 13 ierr = MatShellGetContext(A, &user); CHKERRQ(ierr); 14 15 // Compute Diagonal via libCEED |
| 16 PetscScalar *x; | 16 PetscScalar *y; |
| 17 PetscMemType mem_type; 18 19 // -- Place PETSc vector in libCEED vector | 17 PetscMemType mem_type; 18 19 // -- Place PETSc vector in libCEED vector |
| 20 ierr = VecGetArrayAndMemType(user->X_loc, &x, &mem_type); CHKERRQ(ierr); 21 CeedVectorSetArray(user->x_ceed, MemTypeP2C(mem_type), CEED_USE_POINTER, x); | 20 ierr = VecGetArrayAndMemType(user->Y_loc, &y, &mem_type); CHKERRQ(ierr); 21 CeedVectorSetArray(user->y_ceed, MemTypeP2C(mem_type), CEED_USE_POINTER, y); |
| 22 23 // -- Compute Diagonal | 22 23 // -- Compute Diagonal |
| 24 CeedOperatorLinearAssembleDiagonal(user->op, user->x_ceed, | 24 CeedOperatorLinearAssembleDiagonal(user->op, user->y_ceed, |
| 25 CEED_REQUEST_IMMEDIATE); 26 27 // -- Local-to-Global | 25 CEED_REQUEST_IMMEDIATE); 26 27 // -- Local-to-Global |
| 28 CeedVectorTakeArray(user->x_ceed, MemTypeP2C(mem_type), NULL); 29 ierr = VecRestoreArrayAndMemType(user->X_loc, &x); CHKERRQ(ierr); | 28 CeedVectorTakeArray(user->y_ceed, MemTypeP2C(mem_type), NULL); 29 ierr = VecRestoreArrayAndMemType(user->Y_loc, &y); CHKERRQ(ierr); |
| 30 ierr = VecZeroEntries(D); CHKERRQ(ierr); | 30 ierr = VecZeroEntries(D); CHKERRQ(ierr); |
| 31 ierr = DMLocalToGlobal(user->dm, user->X_loc, ADD_VALUES, D); CHKERRQ(ierr); | 31 ierr = DMLocalToGlobal(user->dm, user->Y_loc, ADD_VALUES, D); CHKERRQ(ierr); |
| 32 | 32 |
| 33 // Cleanup 34 ierr = VecZeroEntries(user->X_loc); CHKERRQ(ierr); 35 | |
| 36 PetscFunctionReturn(0); 37}; 38 39// ----------------------------------------------------------------------------- 40// This function uses libCEED to compute the action of the Laplacian with 41// Dirichlet boundary conditions 42// ----------------------------------------------------------------------------- 43PetscErrorCode ApplyLocal_Ceed(Vec X, Vec Y, UserO user) { --- 215 unchanged lines hidden --- | 33 PetscFunctionReturn(0); 34}; 35 36// ----------------------------------------------------------------------------- 37// This function uses libCEED to compute the action of the Laplacian with 38// Dirichlet boundary conditions 39// ----------------------------------------------------------------------------- 40PetscErrorCode ApplyLocal_Ceed(Vec X, Vec Y, UserO user) { --- 215 unchanged lines hidden --- |