dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #22736
Re: [Question #152565]: Setting up a point source linear form
Question #152565 on DOLFIN changed:
https://answers.launchpad.net/dolfin/+question/152565
Neilen Marais posted a new comment:
Anders,
I don't think the V.sub works for Nedelec elements. I do:
import dolfin as dol
from dolfin import dot, curl, inner, dx, Point, PointSource
class CavityDims(object): pass
cdims = CavityDims()
cdims.a, cdims.b, cdims.c = 29,23,19
# Define mesh
mesh = dol.UnitCube(1,1,1)
mesh.coordinates()[:] *= [cdims.a,cdims.b,cdims.c]
# Define function space
order = 3
V = dol.FunctionSpace(mesh, "Nedelec 1st kind H(curl)", order)
# Define basis and bilinear form
u = dol.TrialFunction(V)
v = dol.TestFunction(V)
source_pt = Point(cdims.a/2, cdims.b/2, cdims.c/2)
m = inner(v, u)*dx # Mass form
M = dol.PETScMatrix()
dol.assemble(m, tensor=M, mesh=mesh)
b = dol.Vector(M.size(0))
b.array()[:] = 0
ps0 = PointSource(V.sub(0), source_pt)
ps1 = PointSource(V.sub(1), source_pt)
ps2 = PointSource(V.sub(2), source_pt)
ps0.apply(b)
ps1.apply(b)
ps2.apply(b)
I get:
/tmp/python-1810_GJ.py in <module>()
32 b.array()[:] = 0
33
---> 34 ps0 = PointSource(V.sub(0), source_pt)
35 ps1 = PointSource(V.sub(1), source_pt)
36 ps2 = PointSource(V.sub(2), source_pt)
/home/nmarais/local/lib/python2.6/site-packages/dolfin/functions/functionspace.pyc in sub(self, i)
98 raise ValueError, "no SubSpaces to extract"
99 if i >= self.num_sub_spaces():
--> 100 raise ValueError, "Can only extract SubSpaces with i = 0..%d"%(self.num_sub_spaces()-1)
101 assert(hasattr(self._ufl_element,"sub_elements"))
102 element = self._ufl_element.sub_elements()[i]
ValueError: Can only extract SubSpaces with i = 0..-1
The error seems to come from the V.sub() call.
also checking
In [25]: V.num_sub_spaces()
Out[25]: 0
Cheers
Neilen
--
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.
References