Hello All,
I am trying to define a material property that varies in space (for my problem I have an inclusion and a matrix, each with its own material property on a unit cube mesh). I tried using the Expression
class as follows:
class materialPoisson(Expression):
def __init__(self, a_NuMatrix, a_NuInclusion):
self.m_NuMatrix = a_NuMatrix
self.m_NuInclusion = a_NuInclusion
def eval(self, value, x):
if myInclusion.inside(x, on_boundary):
Nu0 = self.m_NuInclusion
else:
Nu0 = self.m_NuMatrix
value = Nu0
def value_shape(self):
return (1,)
The function myInclusion.inside()
is just checking whether the point lies inside the inclusion domain or outside of it. I want to now use this in defining the variational form, and try to interpolate it as follows:
Nu = interpolate(Nu, V)
where
V = VectorFunctionSpace(mesh, "CG", 1)
I end up always getting the following error:
*** -------------------------------------------------------------------------
*** Error: Unable to interpolate function into function space.
*** Reason: Dimension 0 of function (1) does not match dimension 0 of function space (3).
*** Where: This error was encountered inside FunctionSpace.cpp.
*** Process: unknown
***
*** DOLFIN version: 1.4.0
*** Git changeset: 3b6582dfb45139c906c13b9ad57395632a2090f4
*** -------------------------------------------------------------------------
How do I interpolate the scalar expression on a vector function space then? Or should I be using a different approach to defining a spatially varying scalar field which I can use for defining material properties (say) in variational forms?
Any tips or pointers will be much appreciated. :)
Thanks