I changed .array() to .M :
aa = assemble((div(sigma)+f)*(div(sigma)+f)*dx).M
But again, I got the following error :
AttributeError: 'numpy.float64' object has no attribute 'M'

Any help would be appreciated.


 

----- Original Message -----

 From: Homolya, Miklós (m.homolya14@imperial.ac.uk)
Date: 10/05/97 21:46
To: firedrake (firedrake@imperial.ac.uk)
Subject: Re: [firedrake] .array()
 
Dear Amireh,

For "assembled" matrices, please use .M instead of .array()

.M.values gives you a dense (!) numpy array, while .M.handle gives you a petsc4py object handle.

Miklos
From: firedrake-bounces@imperial.ac.uk <firedrake-bounces@imperial.ac.uk> on behalf of Amireh Mousavi <amireh.mousavi@math.iut.ac.ir>
Sent: 01 August 2018 18:41:52
To: firedrake
Subject: Re: [firedrake] .array()
 
In the following, I put more clear code with more detail,

mesh = UnitSquareMesh(16, 16)
BDM = FunctionSpace(mesh, "BDM", 1)
DG = FunctionSpace(mesh, "DG", 0)
W = BDM * DG
sigma, u = TrialFunctions(W)
tau, v = TestFunctions(W)
x, y = SpatialCoordinate(mesh)
f = Function(DG).interpolate(
    10*exp(-(pow(x - 0.5, 2) + pow(y - 0.5, 2)) / 0.02))
a = (dot(sigma, tau) + div(tau)*u + div(sigma)*v)*dx
L = - f*v*dx
bc0 = DirichletBC(W.sub(0), as_vector([0.0, -sin(5*x)]), 1)
bc1 = DirichletBC(W.sub(0), as_vector([0.0, sin(5*y)]), 2)
w = Function(W)
solve(a == L, w, bcs=[bc0, bc1])
sigma, u = w.split()
Re = assemble((div(sigma)+f)*(div(sigma)+f)*dx).array()

and I got the error:
AttributeError: 'numpy.float64' object has no attribute 'array'

How can I compute "Re" on each element?

 

----- Original Message -----

 From: Colin Cotter (colin.cotter@imperial.ac.uk)
Date: 10/05/97 16:03
To: firedrake@imperial.ac.uk
Subject: Re: [firedrake] .array()
 
Dear Amireh,
What are the types of u and v? I suspect you have Function for both when you need TestFunction and TrialFunction?

All the best
Cjc

On Wednesday, 1 August 2018, Amireh Mousavi <amireh.mousavi@math.iut.ac.ir> wrote:
Dear Firedrake team,
i'm trying to get u*v*dx as a array which each component is amount of the integral on each element. I want to do that in order to compute error indicator.
In dolfin implementation it be done like:
assemble(u*v*dx).array()
Is there a way to do this in Firedrake?
Runing the above code in Firedrake gives:
AttributeError: 'numpy.float64' object has no attribute 'array'
Thank you in advance.

Best,
Amireh




 

--
Colin Cotter
Department of Mathematics
Imperial College London

I don't expect a reply to this email from you outside of your normal working hours.

 

_______________________________________________
firedrake mailing list
firedrake@imperial.ac.uk
https://mailman.ic.ac.uk/mailman/listinfo/firedrake

_______________________________________________
firedrake mailing list
firedrake@imperial.ac.uk
https://mailman.ic.ac.uk/mailman/listinfo/firedrake