matrix.c (db13be8e8476db5e8478a6e2fdf53728fbe0409e) matrix.c (d02c7345ebed081476ce6bcdfd784b34c024d6ef)
1/*
2 This is where the abstract matrix operations are defined
3 Portions of this code are under:
4 Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
5*/
6
7#include <petsc/private/matimpl.h> /*I "petscmat.h" I*/
8#include <petsc/private/isimpl.h>

--- 7724 unchanged lines hidden (view full) ---

7733 `MatComputeVariableBlockEnvelope()`, `PCVPBJACOBI`
7734@*/
7735PetscErrorCode MatSetVariableBlockSizes(Mat mat, PetscInt nblocks, PetscInt *bsizes)
7736{
7737 PetscInt i, ncnt = 0, nlocal;
7738
7739 PetscFunctionBegin;
7740 PetscValidHeaderSpecific(mat, MAT_CLASSID, 1);
1/*
2 This is where the abstract matrix operations are defined
3 Portions of this code are under:
4 Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
5*/
6
7#include <petsc/private/matimpl.h> /*I "petscmat.h" I*/
8#include <petsc/private/isimpl.h>

--- 7724 unchanged lines hidden (view full) ---

7733 `MatComputeVariableBlockEnvelope()`, `PCVPBJACOBI`
7734@*/
7735PetscErrorCode MatSetVariableBlockSizes(Mat mat, PetscInt nblocks, PetscInt *bsizes)
7736{
7737 PetscInt i, ncnt = 0, nlocal;
7738
7739 PetscFunctionBegin;
7740 PetscValidHeaderSpecific(mat, MAT_CLASSID, 1);
7741 PetscCheck(nblocks >= 0, PETSC_COMM_SELF, PETSC_ERR_ARG_SIZ, "Number of local blocks must be great than or equal to zero");
7742 PetscCall(MatGetLocalSize(mat, &nlocal, NULL));
7741 PetscCall(MatGetLocalSize(mat, &nlocal, NULL));
7742 PetscCheck(nblocks >= 0 && nblocks <= nlocal, PETSC_COMM_SELF, PETSC_ERR_ARG_SIZ, "Number of local blocks %" PetscInt_FMT " is not in [0, %" PetscInt_FMT "]", nblocks, nlocal);
7743 for (i = 0; i < nblocks; i++) ncnt += bsizes[i];
7744 PetscCheck(ncnt == nlocal, PETSC_COMM_SELF, PETSC_ERR_ARG_SIZ, "Sum of local block sizes %" PetscInt_FMT " does not equal local size of matrix %" PetscInt_FMT, ncnt, nlocal);
7745 PetscCall(PetscFree(mat->bsizes));
7746 mat->nblocks = nblocks;
7747 PetscCall(PetscMalloc1(nblocks, &mat->bsizes));
7748 PetscCall(PetscArraycpy(mat->bsizes, bsizes, nblocks));
7749 PetscFunctionReturn(PETSC_SUCCESS);
7750}

--- 3494 unchanged lines hidden ---
7743 for (i = 0; i < nblocks; i++) ncnt += bsizes[i];
7744 PetscCheck(ncnt == nlocal, PETSC_COMM_SELF, PETSC_ERR_ARG_SIZ, "Sum of local block sizes %" PetscInt_FMT " does not equal local size of matrix %" PetscInt_FMT, ncnt, nlocal);
7745 PetscCall(PetscFree(mat->bsizes));
7746 mat->nblocks = nblocks;
7747 PetscCall(PetscMalloc1(nblocks, &mat->bsizes));
7748 PetscCall(PetscArraycpy(mat->bsizes, bsizes, nblocks));
7749 PetscFunctionReturn(PETSC_SUCCESS);
7750}

--- 3494 unchanged lines hidden ---