Hello
I want to define a 2*1 vector inside a class and use the eval function to define the components of this vector, like:
class BodyForce(Expression):
def __init__(self, **kwargs):
self.value = kwargs['value']
def eval(self, value,x):
value[0] = self.value[0]
value[1] = self.value[1]
def value_shape(self):
return (2,)
GG = BodyForce(value=(Constant(A)*(c - 1.), 0.0), degree=1)
The thing is the first component of this vector is with respect to "c" which is an unknown that is needed to be calculated. In addition this vector should be applied in all over the domain. I have to use this vector in my variational problem. The contributing term from this vector in the variational problem is:
inner(GG,v_3) * dx
I get this error:
raceback (most recent call last):
File "/home/hp/Desktop/ert/23.py", line 171, in <module>
solve(F == 0, z, bcs)
File "/home/hp/Desktop/ert/23.py", line 151, in eval
value[0] = self.value[0]
ValueError: setting an array element with a sequence.
Any idea how to fix it?
Thanks!