Hello,
Even though there are already some posts on the GenericMatrix.set function, things are still unclear to me...
I'd like to construct a new GenericMatrix as the matrix product of massMatrix.transpose * stiffnessMatrix, and then solve.
The point is I really don't know how to proceed.
Any help would be appreciated :)
The code below is just a minimal example of what I'd like to do
from dolfin import *
import numpy
mesh = UnitInterval(10)
V = FunctionSpace(mesh, 'CG', 1)
# Define boundary conditions for initial guess
def left_boundary(x, on_boundary):
return on_boundary and near(x[0], 0.0)
def right_boundary(x, on_boundary):
return on_boundary and near(x[0], 1)
Gamma_0 = DirichletBC(V, Constant(0.0), left_boundary)
Gamma_1 = DirichletBC(V, Constant(1.0), right_boundary)
bcs = [Gamma_0, Gamma_1]
# Define variational problem ans solve
u = TrialFunction(V)
v = TestFunction(V)
Mass = assemble(u*v*dx)
Stiff = assemble(u.dx(0)*v.dx(0)*dx)
L = assemble(Constant(0.0)*v*dx)
A=assemble(Constant(0.0)*u*v*dx) # define a new GenericMatrix
# I'd like to define
A.set(Mass.array()*Stiff.array())
for _bc in bcs:
_bc.apply(A,L)
_U_ = Function(V)
solve(A, _U_.vector(), L)
plot(_U_, interactive = True)
Thanks in advance,
Nicolas
Edit: just to mention I use Fenics v. 1.0.0