Poisson Equation with Source Term from a array(dataset)

Dear All

This question is related to solve Poisson Equation in which source term is taken from a dataset(array) which I have created through a for loop. I have used the following script in C++

#include <dolfin.h>
#include “Poisson.h”
//#include
#include<stdio.h>
using namespace dolfin;
// Source term (right-hand side)
class Source : public Expression
{
public:
Source(): Expression() {}
void eval(Array& values, const Array& x) const
{
Array vec(1331); /// Dataset for Source term
for (int ii=0; ii<1331;ii++){
values[0]=ii;
}
class DirichletBoundary : public SubDomain
{
bool inside(const Array& x, bool on_boundary) const
{
return on_boundary;
}
};
int main()
{
// Create mesh and function space
UnitCubeMesh mesh(10, 10, 10);// Working upto 323232 after that not converging
Poisson::FunctionSpace V(mesh);
Poisson::FunctionSpace F(mesh);

Constant u0(0.0);
DirichletBoundary boundary;
DirichletBC bc(V, u0, boundary);

// Define variational forms
Poisson::BilinearForm a(V, V);
Poisson::LinearForm L(V);

Source f;
L.f = f;
Function u(V);
solve(a == L, u, bc);
plot(u);
interactive();
return 0;
}

I am able to solve poisson equation but the source term is not ditributed over the mesh , it just taking the final value from the loop and solve the equation.

I am new to Fenics, could you please help me . if I miss something please let me know

Thanks
Waseem