Solving linear system of uBLAS data types
Hi!
The program below crashes when I run it. My question is how I could solve for the unknown vector (x in Ax=b) when I have A and b as uBLASDenseMatrix and uBLASVector? What kind of object should x be? I am now trying to solve it with an uBLASKrylovSolver. The parts of interest for the question are inside the ##### ##### below:
from dolfin import *
from numpy import array, linspace
at=Expression("1") #a(t) in the problem
T=1 #end time
nx=4 #number of interior cells
kn=float(T)/nx #step size
f=Constant("0")
x_0=Constant("1")
#defines time mesh and and normal component of the nodes
mesh=Interval(nx, 0, T)
normal=
#creates a mesh function to represent subdomains of boundary
boundary_parts = MeshFunction(
#defines function spaces
W_h=FunctionSpa
V_h=FunctionSpa
#function to determine wether x=0 or not, where the Dirichlet bc should be applied
"""def Dirichlet_
tol=1E-9 #tolerance for round off errors
return on_boundary and abs(x[0]<tol)"""
#classes for marking different parts of the boundary
class InitialBoundary
def inside(self, x, on_boundary):
return on_boundary and abs(x[0]) < DOLFIN_EPS
#creates instance of the boundary classes
lower_boundary=
lower_boundary.
class EndBoundary(
def inside(self, x, on_boundary):
return on_boundary and abs(x[0]-T) < DOLFIN_EPS
upper_boundary=
upper_boundary.
#sets the Dirichlet boundary conditions on the initial boundary
bc=DirichletBC(W_h, x_0, lower_boundary, "pointwise")
#defines test and trial functions
x=TrialFunction
v=TestFunction(V_h)
#defines the abstract formulation
a=(Dx(x,0) - at*x)*v*dx - jump(x)*avg(v)*dS - x*v*ds(1) + x*v*ds(0)
L=f*v*dx
#assembles system and connects the ds(i) symbols with A and L
A=assemble(a, exterior_
b=assemble(L, exterior_
numRows = A.size(0)
numCols = A.size(1)
#######
newA=uBLASDense
newA.zero()
pos=array(
newA.set(A.array(), pos, pos)
pos2=array(
newA.set(
pos3=array(
pos4=array(
newA.set(
newA.set(
bNew=uBLASVecto
bNew.zero()
bPos=array([0], dtype='I')
bNew.add(
X=uBLASVector(
solver=
solver.solve(newA, X, bNew)
#######
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Anders Pettersson for more information if necessary.