6 #include "GmshConfig.h"
9 #if defined(HAVE_PETSC)
19 #ifdef PETSC_USE_COMPLEX
28 _check(VecGetArray(_b, &tmp));
29 PetscScalar s = tmp[row];
30 _check(VecRestoreArray(_b, &tmp));
40 _check(VecGetArray(_x, &tmp));
41 PetscScalar s = tmp[row];
42 _check(VecRestoreArray(_x, &tmp));
50 if(_parameters.find(
"blockSize") == _parameters.end())
51 Msg::Error(
"'blockSize' parameters must be set for linearSystemPETScBlock");
53 strtol(_parameters.find(
"blockSize")->second.c_str(),
nullptr, 10);
61 if(!_entriesPreAllocated) preAllocateEntries();
62 PetscInt i = row, j = col;
63 #ifdef PETSC_USE_COMPLEX
65 for(
int ii = 0; ii < val.
size1(); ii++) {
66 for(
int jj = 0; jj < val.
size1(); jj++) {
67 modval(ii, jj) = val(ii, jj);
70 MatSetValuesBlocked(_a, 1, &i, 1, &j, modval.getDataPtr(), ADD_VALUES);
72 MatSetValuesBlocked(_a, 1, &i, 1, &j, val.
getDataPtr(), ADD_VALUES);
75 _valuesNotAssembled =
true;
82 if(!_entriesPreAllocated) preAllocateEntries();
84 _check(MatGetBlockSize(_a, &blockSize));
85 for(
int ii = 0; ii < blockSize; ii++) {
86 PetscInt i = row * blockSize + ii;
87 PetscScalar v = val(ii, 0);
88 VecSetValues(_b, 1, &i, &v, ADD_VALUES);
97 _check(MatGetBlockSize(_a, &blockSize));
98 for(
int i = 0; i < blockSize; i++) {
99 int ii = row * blockSize + i;
100 #ifdef PETSC_USE_COMPLEX
102 VecGetValues(_b, 1, &ii, &s);
103 val(i, 0) = s.real();
105 VecGetValues(_b, 1, &ii, &val(i, 0));
115 _check(MatGetBlockSize(_a, &blockSize));
116 for(
int ii = 0; ii < blockSize; ii++) {
117 PetscInt i = row * blockSize + ii;
118 PetscScalar v = val(ii, 0);
119 VecSetValues(_x, 1, &i, &v, ADD_VALUES);
128 _check(MatGetBlockSize(_a, &blockSize));
129 for(
int i = 0; i < blockSize; i++) {
130 int ii = row * blockSize + i;
131 #ifdef PETSC_USE_COMPLEX
133 VecGetValues(_x, 1, &ii, &s);
134 val(i, 0) = s.real();
136 VecGetValues(_x, 1, &ii, &val(i, 0));