# Difficulty with PETSc in solving vectorized problem

**URL:** <https://community.freefem.org/t/difficulty-with-petsc-in-solving-vectorized-problem/2770>\
**Category:** General Discussion\
**Created:** [November 1, 2023, 5:06pm UTC](https://community.freefem.org/t/difficulty-with-petsc-in-solving-vectorized-problem/2770 "2023-11-01T17:06:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![m.lbolok](https://avatars.discourse-cdn.com/v4/letter/m/d2c977/32.png) [@m.lbolok](https://community.freefem.org/u/m.lbolok)\
**Post date:** [November 1, 2023, 5:06pm UTC](https://community.freefem.org/t/difficulty-with-petsc-in-solving-vectorized-problem/2770/1 "2023-11-01T17:06:12Z")

</div>

Hi,  
The problem is defined by:  
//===========================Code====================================  
load “PETSc”  
macro dimension() 2//  
include “macro\_ddm.idp”  
mesh omega=square(25,25);

fespace Uh(omega,[P2,P2]);  
fespace S(omega,P2);

Uh [us,vs],[w1,w2],[u,v];  
S US,VS,U,V;  
real[int] xxSt1(Uh.ndof);

varf step1([us,vs],[w1,w2])=  
int2d(omega)(1/0.02\*[w1,w2]'\*[us,vs])+ …  
+on(1,2,4,us=0,vs=0)+on(3,vs=0,us=1);

Mat A;  
real [int] Ar(Uh.ndof); // Right-hand-side vector  
func Pk = [P2, P2];  
createMat(omega,A,Pk);  
A=step1(Uh,Uh);  
Ar=step1(0,Uh);  
xxSt1=A^-1\*Ar;

```
for(int ii=0; ii<(0.5*Uh.ndof); ii++)
{
  US[][ii]=xxSt1[2*ii];
  VS[][ii]=xxSt1[2*ii+1];
 
}

```

//===============================================================  
When I run the code, I got error messages that mostly says “Error line number 434, in file macro: partitionPrivate in C:\Program Files (x86)\FreeFem++\idp\macro\_ddm.idp, before token ;  
Invalid array size for vectorial fespace function”.

Could you possibly help me to figure it out?

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [November 2, 2023, 12:18pm UTC](https://community.freefem.org/t/difficulty-with-petsc-in-solving-vectorized-problem/2770/2 "2023-11-02T12:18:06Z")

</div>

You are missing this macro definition before the call to `createMat()`: [https://github.com/FreeFem/FreeFem-sources/blob/master/examples/hpddm/elasticity-2d-PETSc.edp#L7](https://github.com/FreeFem/FreeFem-sources/blob/master/examples/hpddm/elasticity-2d-PETSc.edp#L7).
